Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disentangle TrackerTrackHitFilter from phase-0 Strip conditions and activate common alignment track refitter sequence for phase-2 #40835

Merged
merged 3 commits into from Feb 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -30,10 +30,7 @@ class RefitType(Enum):
_allFromGT = True
_applyBows = True
_applyExtraConditions = True
if(options.isPhase2):
_theRefitter = RefitType.STANDARD # FIXME: once the sequence is cleared out
else:
_theRefitter = RefitType.COMMON
_theRefitter = RefitType.COMMON # RefitType.STANDARD (other option not involving filtering)
_theTrackCollection = 'generalTracks' # FIXME: 'ALCARECOTkAlMinBias' once a sample is available

###################################################################
Expand Down
15 changes: 10 additions & 5 deletions Alignment/OfflineValidation/test/test_all_Phase2_cfg.py
Expand Up @@ -12,7 +12,7 @@ class RefitType(Enum):
allFromGT = True
applyBows = True
applyExtraConditions = True
theRefitter = RefitType.STANDARD
theRefitter = RefitType.COMMON
_theTrackCollection = "generalTracks" #"ALCARECOTkAlMinBias" unfortunately not yet

from Configuration.Eras.Era_Phase2C17I13M9_cff import Phase2C17I13M9
Expand Down Expand Up @@ -59,7 +59,7 @@ class RefitType(Enum):
threshold = cms.untracked.string("INFO"),
default = cms.untracked.PSet(limit = cms.untracked.int32(0)),
FwkReport = cms.untracked.PSet(limit = cms.untracked.int32(-1),
reportEvery = cms.untracked.int32(1000)
reportEvery = cms.untracked.int32(1)
),
PrimaryVertexValidation = cms.untracked.PSet( limit = cms.untracked.int32(-1)),
SplitVertexResolution = cms.untracked.PSet( limit = cms.untracked.int32(-1)),
Expand Down Expand Up @@ -193,7 +193,7 @@ class RefitType(Enum):
# Load and Configure Common Track Selection and refitting sequence
####################################################################
import Alignment.CommonAlignment.tools.trackselectionRefitting as trackselRefit
process.seqTrackselRefit = trackselRefit.getSequence(process, 'ALCARECOTkAlMinBias',
process.seqTrackselRefit = trackselRefit.getSequence(process, _theTrackCollection ,
isPVValidation=True,
TTRHBuilder='WithAngleAndTemplate',
usePixelQualityFlag=True,
Expand Down Expand Up @@ -295,6 +295,11 @@ def switchClusterizerParameters(da):
TkClusParameters = switchClusterizerParameters(isDA)
)

####################################################################
# Needed to avoid dependency from Phase-0 strip conditions
####################################################################
#process.TrackerTrackHitFilter.isPhase2 = cms.bool(True)

####################################################################
# Path
####################################################################
Expand Down Expand Up @@ -348,10 +353,10 @@ def switchClusterizerParameters(da):
runControl = cms.untracked.bool(True),
runControlNumber = cms.untracked.vuint32(int(runboundary))
)
#process.Tracer = cms.Service("Tracer")

process.p2 = cms.Path(process.HLTFilter +
process.seqTrackselRefit +
process.offlinePrimaryVerticesFromRefittedTrks +
process.PrimaryVertexResolution +
process.myanalysis
)
process.myanalysis)
66 changes: 59 additions & 7 deletions RecoTracker/FinalTrackSelectors/plugins/TrackerTrackHitFilter.cc
Expand Up @@ -5,6 +5,8 @@

#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "FWCore/Utilities/interface/ESGetToken.h"

Expand Down Expand Up @@ -48,6 +50,7 @@

#include <boost/regex.hpp>
#include <map>
#include <optional>
//#include <math>

/**
Expand Down Expand Up @@ -84,6 +87,8 @@ namespace reco {
std::vector<TrackingRecHit *> &hits);
void produceFromTrack(const edm::EventSetup &iSetup, const Track *itt, std::vector<TrackingRecHit *> &hits);

static void fillDescriptions(edm::ConfigurationDescriptions &descriptions);

private:
class Rule {
public:
Expand Down Expand Up @@ -124,6 +129,7 @@ namespace reco {
bool stripBackInvalidHits_;
bool stripAllInvalidHits_;

bool isPhase2_;
bool rejectBadStoNHits_;
std::string CMNSubtractionMode_;
std::vector<bool> subdetStoN_; //(6); //,std::bool(false));
Expand Down Expand Up @@ -156,7 +162,7 @@ namespace reco {
edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> tokenMagField;
edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> tokenTrackerTopo;

SiStripClusterInfo siStripClusterInfo_;
std::optional<SiStripClusterInfo> siStripClusterInfo_;

bool tagOverlaps_;
int nOverlaps;
Expand Down Expand Up @@ -298,6 +304,7 @@ namespace reco {
stripFrontInvalidHits_(iConfig.getParameter<bool>("stripFrontInvalidHits")),
stripBackInvalidHits_(iConfig.getParameter<bool>("stripBackInvalidHits")),
stripAllInvalidHits_(iConfig.getParameter<bool>("stripAllInvalidHits")),
isPhase2_(iConfig.getParameter<bool>("isPhase2")),
rejectBadStoNHits_(iConfig.getParameter<bool>("rejectBadStoNHits")),
CMNSubtractionMode_(iConfig.getParameter<std::string>("CMNSubtractionMode")),
detsToIgnore_(iConfig.getParameter<std::vector<uint32_t> >("detsToIgnore")),
Expand All @@ -309,8 +316,13 @@ namespace reco {
pxlTPLProbXYQ_(iConfig.getParameter<double>("PxlTemplateProbXYChargeCut")),
pxlTPLqBin_(iConfig.getParameter<std::vector<int32_t> >("PxlTemplateqBinCut")),
PXLcorrClusChargeCut_(iConfig.getParameter<double>("PxlCorrClusterChargeCut")),
siStripClusterInfo_(consumesCollector()),
tagOverlaps_(iConfig.getParameter<bool>("tagOverlaps")) {
// construct the SiStripClusterInfo object only for Phase-0 / Phase-1
// no Strip modules in Phase-2
if (!isPhase2_) {
siStripClusterInfo_ = consumesCollector();
}

tokenGeometry = esConsumes<TrackerGeometry, TrackerDigiGeometryRecord>();
tokenMagField = esConsumes<MagneticField, IdealMagneticFieldRecord>();
tokenTrackerTopo = esConsumes<TrackerTopology, TrackerTopologyRcd>();
Expand Down Expand Up @@ -399,7 +411,8 @@ namespace reco {
// read from EventSetup
theGeometry = iSetup.getHandle(tokenGeometry);
theMagField = iSetup.getHandle(tokenMagField);
siStripClusterInfo_.initEvent(iSetup);
if (!isPhase2_)
siStripClusterInfo_->initEvent(iSetup);

// prepare output collection
size_t candcollsize;
Expand Down Expand Up @@ -781,6 +794,12 @@ namespace reco {

// if( subdetStoN_[subdet_cnt-1]&& (id.subdetId()==subdet_cnt) ){//check that hit is in a det belonging to a subdet where we decided to apply a S/N cut

// for phase-2 OT placehold, do nothing
if (GeomDetEnumerators::isOuterTracker(theGeometry->geomDetSubDetector(id.subdetId())) &&
!GeomDetEnumerators::isTrackerStrip(theGeometry->geomDetSubDetector(id.subdetId()))) {
return true;
}

if (GeomDetEnumerators::isTrackerStrip(theGeometry->geomDetSubDetector(id.subdetId()))) {
if (subdetStoN_[subdet_cnt - 1]) {
//check that hit is in a det belonging to a subdet where we decided to apply a S/N cut
Expand Down Expand Up @@ -816,14 +835,14 @@ namespace reco {
}

if (keepthishit) {
siStripClusterInfo_.setCluster(*cluster, id.rawId());
siStripClusterInfo_->setCluster(*cluster, id.rawId());
if ((subdetStoNlowcut_[subdet_cnt - 1] > 0) &&
(siStripClusterInfo_.signalOverNoise() < subdetStoNlowcut_[subdet_cnt - 1]))
(siStripClusterInfo_->signalOverNoise() < subdetStoNlowcut_[subdet_cnt - 1]))
keepthishit = false;
if ((subdetStoNhighcut_[subdet_cnt - 1] > 0) &&
(siStripClusterInfo_.signalOverNoise() > subdetStoNhighcut_[subdet_cnt - 1]))
(siStripClusterInfo_->signalOverNoise() > subdetStoNhighcut_[subdet_cnt - 1]))
keepthishit = false;
//if(!keepthishit)std::cout<<"Hit rejected because of bad S/N: "<<siStripClusterInfo_.signalOverNoise()<<std::endl;
//if(!keepthishit)std::cout<<"Hit rejected because of bad S/N: "<<siStripClusterInfo_->signalOverNoise()<<std::endl;
}

} //end if subdetStoN_[subdet_cnt]&&...
Expand Down Expand Up @@ -975,6 +994,39 @@ namespace reco {
return tTopo->side(id);
}

// ------------ method fills 'descriptions' with the allowed parameters for the module ------------
void TrackerTrackHitFilter::fillDescriptions(edm::ConfigurationDescriptions &descriptions) {
edm::ParameterSetDescription desc;
desc.setComment("");
desc.add<edm::InputTag>("src", edm::InputTag("generalTracks"));
desc.add<uint32_t>("minimumHits", 3)->setComment("number of hits for refit");
desc.add<bool>("replaceWithInactiveHits", false)
->setComment(
" instead of removing hits replace them with inactive hits, so you still consider the multiple "
"scattering");
desc.add<bool>("stripFrontInvalidHits", false)
->setComment("strip invalid & inactive hits from any end of the track");
desc.add<bool>("stripBackInvalidHits", false)
->setComment("strip invalid & inactive hits from any end of the track");
desc.add<bool>("stripAllInvalidHits", false)->setComment("dangerous to turn on, you might forget about MS");
desc.add<bool>("isPhase2", false);
desc.add<bool>("rejectBadStoNHits", false);
desc.add<std::string>("CMNSubtractionMode", std::string("Median"))->setComment("TT6");
desc.add<std::vector<uint32_t> >("detsToIgnore", {});
desc.add<bool>("useTrajectories", false);
desc.add<bool>("rejectLowAngleHits", false);
desc.add<double>("TrackAngleCut", 0.25)->setComment("rad");
desc.add<bool>("usePixelQualityFlag", false);
desc.add<double>("PxlTemplateProbXYCut", 0.000125);
desc.add<double>("PxlTemplateProbXYChargeCut", -99.);
desc.add<std::vector<int32_t> >("PxlTemplateqBinCut", {0, 3});
desc.add<double>("PxlCorrClusterChargeCut", -999.0);
desc.add<bool>("tagOverlaps", false);
desc.add<std::vector<std::string> >("commands", {})->setComment("layers to remove");
desc.add<std::vector<std::string> >("StoNcommands", {})->setComment("S/N cut per layer");
descriptions.addWithDefaultLabel(desc);
}

} // namespace modules
} // namespace reco

Expand Down
83 changes: 43 additions & 40 deletions RecoTracker/FinalTrackSelectors/python/TrackerTrackHitFilter_cff.py
@@ -1,43 +1,46 @@
import FWCore.ParameterSet.Config as cms

TrackerTrackHitFilter = cms.EDProducer("TrackerTrackHitFilter",
src = cms.InputTag("generalTracks"),
minimumHits =cms.uint32(3), ##min number of hits for refit
## # layers to remove
commands = cms.vstring(
"drop PXB", "drop PXE" ### same works for TIB, TID, TOB, TEC,
#"drop TIB 3", ## you can also drop specific layers/wheel/disks
#"keep PXB 3", ## you can also 'keep' some layer after
##having dropped the whole structure
),

###list of individual detids to turn off, in addition to the structures above
detsToIgnore = cms.vuint32( ),

### what to do with invalid hits
replaceWithInactiveHits =cms.bool(False), ## instead of removing hits replace
## them with inactive hits, so you still
## consider the multiple scattering
stripFrontInvalidHits =cms.bool(False), ## strip invalid & inactive hits from
stripBackInvalidHits =cms.bool(False), ## any end of the track

stripAllInvalidHits = cms.bool(False), ##not sure if it's better 'true' or 'false'
## might be dangerous to turn on
## as you will forget about MS
from RecoTracker.FinalTrackSelectors.trackerTrackHitFilter_cfi import trackerTrackHitFilter as _trackerTrackHitFilter
TrackerTrackHitFilter = _trackerTrackHitFilter.clone(
src = "generalTracks",
minimumHits = 3, ##min number of hits for refit
## # layers to remove
commands = ["drop PXB", "drop PXE"], ### same works for TIB, TID, TOB, TEC,
# "drop TIB 3", ## you can also drop specific layers/wheel/disks
# "keep PXB 3", ## you can also 'keep' some layer after
# having dropped the whole structure

### hit quality cuts
rejectBadStoNHits = cms.bool(False),
CMNSubtractionMode = cms.string("Median"), ## "TT6"
StoNcommands = cms.vstring(
"TIB 1.0 ", "TOB 1.0 999.0"
),
useTrajectories=cms.bool(False),
rejectLowAngleHits=cms.bool(False),
TrackAngleCut=cms.double(0.25), ## in radians
tagOverlaps=cms.bool(False),
usePixelQualityFlag=cms.bool(False),
PxlTemplateProbXYCut=cms.double(0.000125), #recommended by experts
PxlTemplateProbXYChargeCut=cms.double(-99.), #recommended by experts
PxlTemplateqBinCut =cms.vint32(0, 3), #recommended by experts
PxlCorrClusterChargeCut = cms.double(-999.0)
)####end of module
###list of individual detids to turn off, in addition to the structures above
detsToIgnore = [],

### what to do with invalid hits
replaceWithInactiveHits = False, ## instead of removing hits replace
## them with inactive hits, so you still
## consider the multiple scattering

stripFrontInvalidHits = False, ## strip invalid & inactive hits from
stripBackInvalidHits = False, ## any end of the track

stripAllInvalidHits = False, ## not sure if it's better 'true' or 'false'
## might be dangerous to turn on
## as you will forget about MS

### hit quality cuts
isPhase2 = False,
rejectBadStoNHits = False,
CMNSubtractionMode = "Median", ## "TT6"
StoNcommands = ["TIB 1.0 ", "TOB 1.0 999.0"],
useTrajectories = False,
rejectLowAngleHits = False,
TrackAngleCut = 0.25, ## in radians
tagOverlaps= False,
usePixelQualityFlag = False,
PxlTemplateProbXYCut = 0.000125, # recommended by experts
PxlTemplateProbXYChargeCut = -99., # recommended by experts
PxlTemplateqBinCut = [0, 3], # recommended by experts
PxlCorrClusterChargeCut = -999.0
) #### end of module

from Configuration.Eras.Modifier_phase2_tracker_cff import phase2_tracker
phase2_tracker.toModify(TrackerTrackHitFilter,
isPhase2 = True)