From 0a647c25e393691d2bcee3334029cf44a1c53a1f Mon Sep 17 00:00:00 2001 From: mmusich Date: Mon, 20 Feb 2023 15:12:51 +0100 Subject: [PATCH 1/3] adjustments to TrackerTrackHitFilter to run the alignment common track refitter and selection sequence in Phase-2. Use std::optional in for SiStripClusterInfo --- .../test/test_all_Phase2_cfg.py | 10 ++++--- .../plugins/TrackerTrackHitFilter.cc | 29 ++++++++++++++----- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/Alignment/OfflineValidation/test/test_all_Phase2_cfg.py b/Alignment/OfflineValidation/test/test_all_Phase2_cfg.py index 9cef9b6919392..e9850f728394b 100644 --- a/Alignment/OfflineValidation/test/test_all_Phase2_cfg.py +++ b/Alignment/OfflineValidation/test/test_all_Phase2_cfg.py @@ -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 @@ -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, @@ -295,6 +295,8 @@ def switchClusterizerParameters(da): TkClusParameters = switchClusterizerParameters(isDA) ) +process.TrackerTrackHitFilter.isPhase2 = cms.untracked.bool(True) + #################################################################### # Path #################################################################### @@ -348,10 +350,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) diff --git a/RecoTracker/FinalTrackSelectors/plugins/TrackerTrackHitFilter.cc b/RecoTracker/FinalTrackSelectors/plugins/TrackerTrackHitFilter.cc index 4b68b72b2649c..0e8eeffe7e672 100644 --- a/RecoTracker/FinalTrackSelectors/plugins/TrackerTrackHitFilter.cc +++ b/RecoTracker/FinalTrackSelectors/plugins/TrackerTrackHitFilter.cc @@ -48,6 +48,7 @@ #include #include +#include //#include /** @@ -124,6 +125,7 @@ namespace reco { bool stripBackInvalidHits_; bool stripAllInvalidHits_; + bool isPhase2_; bool rejectBadStoNHits_; std::string CMNSubtractionMode_; std::vector subdetStoN_; //(6); //,std::bool(false)); @@ -156,7 +158,7 @@ namespace reco { edm::ESGetToken tokenMagField; edm::ESGetToken tokenTrackerTopo; - SiStripClusterInfo siStripClusterInfo_; + std::optional siStripClusterInfo_; bool tagOverlaps_; int nOverlaps; @@ -298,6 +300,7 @@ namespace reco { stripFrontInvalidHits_(iConfig.getParameter("stripFrontInvalidHits")), stripBackInvalidHits_(iConfig.getParameter("stripBackInvalidHits")), stripAllInvalidHits_(iConfig.getParameter("stripAllInvalidHits")), + isPhase2_(iConfig.getUntrackedParameter("isPhase2", false)), rejectBadStoNHits_(iConfig.getParameter("rejectBadStoNHits")), CMNSubtractionMode_(iConfig.getParameter("CMNSubtractionMode")), detsToIgnore_(iConfig.getParameter >("detsToIgnore")), @@ -309,8 +312,13 @@ namespace reco { pxlTPLProbXYQ_(iConfig.getParameter("PxlTemplateProbXYChargeCut")), pxlTPLqBin_(iConfig.getParameter >("PxlTemplateqBinCut")), PXLcorrClusChargeCut_(iConfig.getParameter("PxlCorrClusterChargeCut")), - siStripClusterInfo_(consumesCollector()), tagOverlaps_(iConfig.getParameter("tagOverlaps")) { + // construct the SiStripClusterInfo object only for Phase-0 / Phase-1 + // no Strip modules in Phase-2 + if (!isPhase2_) { + siStripClusterInfo_ = consumesCollector(); + } + tokenGeometry = esConsumes(); tokenMagField = esConsumes(); tokenTrackerTopo = esConsumes(); @@ -399,7 +407,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; @@ -781,6 +790,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 @@ -816,14 +831,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: "<signalOverNoise()< Date: Tue, 21 Feb 2023 12:00:20 +0100 Subject: [PATCH 2/3] add a fillDescriptions method for TrackerTrackHitFilter --- .../plugins/TrackerTrackHitFilter.cc | 39 ++++++++- .../python/TrackerTrackHitFilter_cff.py | 83 ++++++++++--------- 2 files changed, 81 insertions(+), 41 deletions(-) diff --git a/RecoTracker/FinalTrackSelectors/plugins/TrackerTrackHitFilter.cc b/RecoTracker/FinalTrackSelectors/plugins/TrackerTrackHitFilter.cc index 0e8eeffe7e672..1eda7ba7de73b 100644 --- a/RecoTracker/FinalTrackSelectors/plugins/TrackerTrackHitFilter.cc +++ b/RecoTracker/FinalTrackSelectors/plugins/TrackerTrackHitFilter.cc @@ -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" @@ -85,6 +87,8 @@ namespace reco { std::vector &hits); void produceFromTrack(const edm::EventSetup &iSetup, const Track *itt, std::vector &hits); + static void fillDescriptions(edm::ConfigurationDescriptions &descriptions); + private: class Rule { public: @@ -300,7 +304,7 @@ namespace reco { stripFrontInvalidHits_(iConfig.getParameter("stripFrontInvalidHits")), stripBackInvalidHits_(iConfig.getParameter("stripBackInvalidHits")), stripAllInvalidHits_(iConfig.getParameter("stripAllInvalidHits")), - isPhase2_(iConfig.getUntrackedParameter("isPhase2", false)), + isPhase2_(iConfig.getParameter("isPhase2")), rejectBadStoNHits_(iConfig.getParameter("rejectBadStoNHits")), CMNSubtractionMode_(iConfig.getParameter("CMNSubtractionMode")), detsToIgnore_(iConfig.getParameter >("detsToIgnore")), @@ -990,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("src", edm::InputTag("generalTracks")); + desc.add("minimumHits", 3)->setComment("number of hits for refit"); + desc.add("replaceWithInactiveHits", false) + ->setComment( + " instead of removing hits replace them with inactive hits, so you still consider the multiple " + "scattering"); + desc.add("stripFrontInvalidHits", false) + ->setComment("strip invalid & inactive hits from any end of the track"); + desc.add("stripBackInvalidHits", false) + ->setComment("strip invalid & inactive hits from any end of the track"); + desc.add("stripAllInvalidHits", false)->setComment("dangerous to turn on, you might forget about MS"); + desc.add("isPhase2", false); + desc.add("rejectBadStoNHits", false); + desc.add("CMNSubtractionMode", std::string("Median"))->setComment("TT6"); + desc.add >("detsToIgnore", {}); + desc.add("useTrajectories", false); + desc.add("rejectLowAngleHits", false); + desc.add("TrackAngleCut", 0.25)->setComment("rad"); + desc.add("usePixelQualityFlag", false); + desc.add("PxlTemplateProbXYCut", 0.000125); + desc.add("PxlTemplateProbXYChargeCut", -99.); + desc.add >("PxlTemplateqBinCut", {0, 3}); + desc.add("PxlCorrClusterChargeCut", -999.0); + desc.add("tagOverlaps", false); + desc.add >("commands", {})->setComment("layers to remove"); + desc.add >("StoNcommands", {})->setComment("S/N cut per layer"); + descriptions.addWithDefaultLabel(desc); + } + } // namespace modules } // namespace reco diff --git a/RecoTracker/FinalTrackSelectors/python/TrackerTrackHitFilter_cff.py b/RecoTracker/FinalTrackSelectors/python/TrackerTrackHitFilter_cff.py index cce7b97dee595..1fd75c86247b9 100644 --- a/RecoTracker/FinalTrackSelectors/python/TrackerTrackHitFilter_cff.py +++ b/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) From 0a117c645e16f5bb5c9313789e0128931712b5d0 Mon Sep 17 00:00:00 2001 From: mmusich Date: Tue, 21 Feb 2023 12:00:57 +0100 Subject: [PATCH 3/3] make use of full common alignment track selection and fitting sequence for phase-2 --- .../test/testPrimaryVertexRelatedValidations_cfg.py | 5 +---- Alignment/OfflineValidation/test/test_all_Phase2_cfg.py | 7 +++++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Alignment/OfflineValidation/test/testPrimaryVertexRelatedValidations_cfg.py b/Alignment/OfflineValidation/test/testPrimaryVertexRelatedValidations_cfg.py index 7dd29a81fdbda..9b1c4128db275 100644 --- a/Alignment/OfflineValidation/test/testPrimaryVertexRelatedValidations_cfg.py +++ b/Alignment/OfflineValidation/test/testPrimaryVertexRelatedValidations_cfg.py @@ -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 ################################################################### diff --git a/Alignment/OfflineValidation/test/test_all_Phase2_cfg.py b/Alignment/OfflineValidation/test/test_all_Phase2_cfg.py index e9850f728394b..ce80d16c0356c 100644 --- a/Alignment/OfflineValidation/test/test_all_Phase2_cfg.py +++ b/Alignment/OfflineValidation/test/test_all_Phase2_cfg.py @@ -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)), @@ -295,7 +295,10 @@ def switchClusterizerParameters(da): TkClusParameters = switchClusterizerParameters(isDA) ) -process.TrackerTrackHitFilter.isPhase2 = cms.untracked.bool(True) +#################################################################### +# Needed to avoid dependency from Phase-0 strip conditions +#################################################################### +#process.TrackerTrackHitFilter.isPhase2 = cms.bool(True) #################################################################### # Path