diff --git a/Configuration/Eras/python/Era_Run3_cff.py b/Configuration/Eras/python/Era_Run3_cff.py index 51f5f2bee57fe..15a53cd1a901f 100644 --- a/Configuration/Eras/python/Era_Run3_cff.py +++ b/Configuration/Eras/python/Era_Run3_cff.py @@ -15,7 +15,8 @@ from Configuration.Eras.Modifier_run2_HLTconditions_2018_cff import run2_HLTconditions_2018 from Configuration.Eras.Modifier_run3_RPC_cff import run3_RPC from Configuration.Eras.Modifier_run3_ecal_cff import run3_ecal +from Configuration.Eras.Modifier_hcalPfCutsFromDB_cff import hcalPfCutsFromDB Run3 = cms.ModifierChain(Run2_2018.copyAndExclude([run2_GEM_2017, ctpps_2018, run2_egamma_2018, run2_HLTconditions_2018]), - run3_common, run3_egamma, run3_GEM, run3_HB, run3_HFSL, stage2L1Trigger_2021, ctpps_2022, dd4hep, run3_RPC, run3_ecal) + run3_common, run3_egamma, run3_GEM, run3_HB, run3_HFSL, stage2L1Trigger_2021, ctpps_2022, dd4hep, run3_RPC, run3_ecal, hcalPfCutsFromDB) diff --git a/Configuration/Eras/python/Modifier_hcalPfCutsFromDB_cff.py b/Configuration/Eras/python/Modifier_hcalPfCutsFromDB_cff.py new file mode 100644 index 0000000000000..80f28e2746469 --- /dev/null +++ b/Configuration/Eras/python/Modifier_hcalPfCutsFromDB_cff.py @@ -0,0 +1,3 @@ +import FWCore.ParameterSet.Config as cms + +hcalPfCutsFromDB = cms.Modifier() diff --git a/HLTrigger/Configuration/python/HLT_75e33/modules/hltParticleFlowClusterECALUncorrectedL1Seeded_cfi.py b/HLTrigger/Configuration/python/HLT_75e33/modules/hltParticleFlowClusterECALUncorrectedL1Seeded_cfi.py index af41e68b30299..739597dd78c67 100644 --- a/HLTrigger/Configuration/python/HLT_75e33/modules/hltParticleFlowClusterECALUncorrectedL1Seeded_cfi.py +++ b/HLTrigger/Configuration/python/HLT_75e33/modules/hltParticleFlowClusterECALUncorrectedL1Seeded_cfi.py @@ -111,6 +111,7 @@ ), recHitCleaners = cms.VPSet(), recHitsSource = cms.InputTag("hltParticleFlowRecHitECALL1Seeded"), + usePFThresholdsFromDB = cms.bool(False), # this needs to be True only for HBHE seedCleaners = cms.VPSet(cms.PSet( RecHitFlagsToBeExcluded = cms.vstring(), algoName = cms.string('FlagsCleanerECAL') diff --git a/HLTrigger/Configuration/python/HLT_75e33/modules/hltParticleFlowClusterECALUncorrectedUnseeded_cfi.py b/HLTrigger/Configuration/python/HLT_75e33/modules/hltParticleFlowClusterECALUncorrectedUnseeded_cfi.py index b297c44b64efb..9c2e460a6caa4 100644 --- a/HLTrigger/Configuration/python/HLT_75e33/modules/hltParticleFlowClusterECALUncorrectedUnseeded_cfi.py +++ b/HLTrigger/Configuration/python/HLT_75e33/modules/hltParticleFlowClusterECALUncorrectedUnseeded_cfi.py @@ -111,6 +111,7 @@ ), recHitCleaners = cms.VPSet(), recHitsSource = cms.InputTag("hltParticleFlowRecHitECALUnseeded"), + usePFThresholdsFromDB = cms.bool(False), # this needs to be True only for HBHE seedCleaners = cms.VPSet(cms.PSet( RecHitFlagsToBeExcluded = cms.vstring(), algoName = cms.string('FlagsCleanerECAL') diff --git a/HLTrigger/Configuration/python/HLT_75e33/modules/hltParticleFlowClusterHBHE_cfi.py b/HLTrigger/Configuration/python/HLT_75e33/modules/hltParticleFlowClusterHBHE_cfi.py index 91193d61ae1fe..ffe210cab03e4 100644 --- a/HLTrigger/Configuration/python/HLT_75e33/modules/hltParticleFlowClusterHBHE_cfi.py +++ b/HLTrigger/Configuration/python/HLT_75e33/modules/hltParticleFlowClusterHBHE_cfi.py @@ -10,7 +10,8 @@ cms.PSet( depths = cms.vint32(1, 2, 3, 4), detector = cms.string('HCAL_BARREL1'), - gatheringThreshold = cms.vdouble(0.8, 1.2, 1.2, 1.2), + #Run3 thresholds. Will be overwritten with valid aging customisation + gatheringThreshold = cms.vdouble(0.1, 0.2, 0.3, 0.3), gatheringThresholdPt = cms.vdouble(0.0, 0.0, 0.0, 0.0) ), cms.PSet( @@ -39,7 +40,8 @@ cms.PSet( depths = cms.vint32(1, 2, 3, 4), detector = cms.string('HCAL_BARREL1'), - logWeightDenominator = cms.vdouble(0.8, 1.2, 1.2, 1.2) + #Run3 thresholds. Will be overwritten with valid aging customisation + logWeightDenominator = cms.vdouble(0.1, 0.2, 0.3, 0.3) ), cms.PSet( depths = cms.vint32( @@ -70,7 +72,8 @@ cms.PSet( depths = cms.vint32(1, 2, 3, 4), detector = cms.string('HCAL_BARREL1'), - logWeightDenominator = cms.vdouble(0.8, 1.2, 1.2, 1.2) + #Run3 thresholds. Will be overwritten with valid aging customisation + logWeightDenominator = cms.vdouble(0.1, 0.2, 0.3, 0.3) ), cms.PSet( depths = cms.vint32( @@ -92,7 +95,8 @@ cms.PSet( depths = cms.vint32(1, 2, 3, 4), detector = cms.string('HCAL_BARREL1'), - recHitEnergyNorm = cms.vdouble(0.8, 1.2, 1.2, 1.2) + #Run3 thresholds. Will be overwritten with valid aging customisation + recHitEnergyNorm = cms.vdouble(0.1, 0.2, 0.3, 0.3) ), cms.PSet( depths = cms.vint32( @@ -134,6 +138,7 @@ ), recHitCleaners = cms.VPSet(), recHitsSource = cms.InputTag("hltParticleFlowRecHitHBHE"), + usePFThresholdsFromDB = cms.bool(True), seedCleaners = cms.VPSet(), seedFinder = cms.PSet( algoName = cms.string('LocalMaximumSeedFinder'), @@ -142,7 +147,8 @@ cms.PSet( depths = cms.vint32(1, 2, 3, 4), detector = cms.string('HCAL_BARREL1'), - seedingThreshold = cms.vdouble(1.0, 1.5, 1.5, 1.5), + #Run3 thresholds. Will be overwritten with valid aging customisation + seedingThreshold = cms.vdouble(0.125, 0.250, 0.350, 0.350), seedingThresholdPt = cms.vdouble(0.0, 0.0, 0.0, 0.0) ), cms.PSet( diff --git a/HLTrigger/Configuration/python/HLT_75e33/modules/hltParticleFlowClusterHCAL_cfi.py b/HLTrigger/Configuration/python/HLT_75e33/modules/hltParticleFlowClusterHCAL_cfi.py index 61d7d427235d4..3b261fec0aa1f 100644 --- a/HLTrigger/Configuration/python/HLT_75e33/modules/hltParticleFlowClusterHCAL_cfi.py +++ b/HLTrigger/Configuration/python/HLT_75e33/modules/hltParticleFlowClusterHCAL_cfi.py @@ -2,6 +2,7 @@ hltParticleFlowClusterHCAL = cms.EDProducer("PFMultiDepthClusterProducer", clustersSource = cms.InputTag("hltParticleFlowClusterHBHE"), + usePFThresholdsFromDB = cms.bool(True), energyCorrector = cms.PSet( ), @@ -13,7 +14,8 @@ cms.PSet( depths = cms.vint32(1, 2, 3, 4), detector = cms.string('HCAL_BARREL1'), - logWeightDenominator = cms.vdouble(0.8, 1.2, 1.2, 1.2) + #Run3 thresholds. Will be overwritten with valid aging customisation + logWeightDenominator = cms.vdouble(0.1, 0.2, 0.3, 0.3) ), cms.PSet( depths = cms.vint32( diff --git a/HLTrigger/Configuration/python/HLT_75e33/modules/hltParticleFlowRecHitHBHE_cfi.py b/HLTrigger/Configuration/python/HLT_75e33/modules/hltParticleFlowRecHitHBHE_cfi.py index 993f50955eb6e..a10af2d6c553e 100644 --- a/HLTrigger/Configuration/python/HLT_75e33/modules/hltParticleFlowRecHitHBHE_cfi.py +++ b/HLTrigger/Configuration/python/HLT_75e33/modules/hltParticleFlowRecHitHBHE_cfi.py @@ -13,7 +13,8 @@ cms.PSet( depth = cms.vint32(1, 2, 3, 4), detectorEnum = cms.int32(1), - threshold = cms.vdouble(0.8, 1.2, 1.2, 1.2) + #Run3 thresholds. Will be overwritten with valid aging customisation + threshold = cms.vdouble(0.1, 0.2, 0.3, 0.3) ), cms.PSet( depth = cms.vint32( @@ -27,7 +28,8 @@ ) ) ), - name = cms.string('PFRecHitQTestHCALThresholdVsDepth') + name = cms.string('PFRecHitQTestHCALThresholdVsDepth'), + usePFThresholdsFromDB = cms.bool(True) ), cms.PSet( cleaningThresholds = cms.vdouble(0.0), diff --git a/HLTrigger/Configuration/python/HLT_75e33/modules/particleFlowClusterECALUncorrected_cfi.py b/HLTrigger/Configuration/python/HLT_75e33/modules/particleFlowClusterECALUncorrected_cfi.py index 3b2c2b713a89f..eb4f27c22d495 100644 --- a/HLTrigger/Configuration/python/HLT_75e33/modules/particleFlowClusterECALUncorrected_cfi.py +++ b/HLTrigger/Configuration/python/HLT_75e33/modules/particleFlowClusterECALUncorrected_cfi.py @@ -111,6 +111,7 @@ ), recHitCleaners = cms.VPSet(), recHitsSource = cms.InputTag("particleFlowRecHitECAL"), + usePFThresholdsFromDB = cms.bool(False), # this needs to be True only for HBHE seedCleaners = cms.VPSet(cms.PSet( RecHitFlagsToBeExcluded = cms.vstring(), algoName = cms.string('FlagsCleanerECAL') diff --git a/HLTrigger/Configuration/python/HLT_75e33/modules/particleFlowClusterHF_cfi.py b/HLTrigger/Configuration/python/HLT_75e33/modules/particleFlowClusterHF_cfi.py index 3c913f0b4d72a..9a5a40cfc7487 100644 --- a/HLTrigger/Configuration/python/HLT_75e33/modules/particleFlowClusterHF_cfi.py +++ b/HLTrigger/Configuration/python/HLT_75e33/modules/particleFlowClusterHF_cfi.py @@ -58,6 +58,7 @@ ), recHitCleaners = cms.VPSet(), recHitsSource = cms.InputTag("particleFlowRecHitHF"), + usePFThresholdsFromDB = cms.bool(False), # this needs to be True only for HBHE seedCleaners = cms.VPSet(), seedFinder = cms.PSet( algoName = cms.string('LocalMaximumSeedFinder'), diff --git a/HLTrigger/Configuration/python/HLT_75e33/modules/particleFlowClusterHGCalFromTICLL1Seeded_cfi.py b/HLTrigger/Configuration/python/HLT_75e33/modules/particleFlowClusterHGCalFromTICLL1Seeded_cfi.py index 76c6417af2693..a632ab5bb4ea4 100644 --- a/HLTrigger/Configuration/python/HLT_75e33/modules/particleFlowClusterHGCalFromTICLL1Seeded_cfi.py +++ b/HLTrigger/Configuration/python/HLT_75e33/modules/particleFlowClusterHGCalFromTICLL1Seeded_cfi.py @@ -25,6 +25,7 @@ ), recHitCleaners = cms.VPSet(), recHitsSource = cms.InputTag("particleFlowRecHitHGCL1Seeded"), + usePFThresholdsFromDB = cms.bool(False), # this needs to be True only for HBHE seedCleaners = cms.VPSet(), seedFinder = cms.PSet( algoName = cms.string('PassThruSeedFinder'), diff --git a/HLTrigger/Configuration/python/HLT_75e33/modules/particleFlowClusterHGCalFromTICLUnseeded_cfi.py b/HLTrigger/Configuration/python/HLT_75e33/modules/particleFlowClusterHGCalFromTICLUnseeded_cfi.py index fc853a254ab95..550d19d7b85d6 100644 --- a/HLTrigger/Configuration/python/HLT_75e33/modules/particleFlowClusterHGCalFromTICLUnseeded_cfi.py +++ b/HLTrigger/Configuration/python/HLT_75e33/modules/particleFlowClusterHGCalFromTICLUnseeded_cfi.py @@ -25,6 +25,7 @@ ), recHitCleaners = cms.VPSet(), recHitsSource = cms.InputTag("particleFlowRecHitHGC"), + usePFThresholdsFromDB = cms.bool(False), # this needs to be True only for HBHE seedCleaners = cms.VPSet(), seedFinder = cms.PSet( algoName = cms.string('PassThruSeedFinder'), diff --git a/HLTrigger/Configuration/python/HLT_75e33/modules/particleFlowClusterHGCal_cfi.py b/HLTrigger/Configuration/python/HLT_75e33/modules/particleFlowClusterHGCal_cfi.py index d917ff411065a..6ea6d4a4bf81d 100644 --- a/HLTrigger/Configuration/python/HLT_75e33/modules/particleFlowClusterHGCal_cfi.py +++ b/HLTrigger/Configuration/python/HLT_75e33/modules/particleFlowClusterHGCal_cfi.py @@ -25,6 +25,7 @@ ), recHitCleaners = cms.VPSet(), recHitsSource = cms.InputTag("particleFlowRecHitHGC"), + usePFThresholdsFromDB = cms.bool(False), # this needs to be True only for HBHE seedCleaners = cms.VPSet(), seedFinder = cms.PSet( algoName = cms.string('PassThruSeedFinder'), diff --git a/HLTrigger/Configuration/python/HLT_75e33/modules/particleFlowClusterHO_cfi.py b/HLTrigger/Configuration/python/HLT_75e33/modules/particleFlowClusterHO_cfi.py index ad8c64558251d..527e12e765a9d 100644 --- a/HLTrigger/Configuration/python/HLT_75e33/modules/particleFlowClusterHO_cfi.py +++ b/HLTrigger/Configuration/python/HLT_75e33/modules/particleFlowClusterHO_cfi.py @@ -58,6 +58,7 @@ ), recHitCleaners = cms.VPSet(), recHitsSource = cms.InputTag("particleFlowRecHitHO"), + usePFThresholdsFromDB = cms.bool(False), # this needs to be True only for HBHE seedCleaners = cms.VPSet(), seedFinder = cms.PSet( algoName = cms.string('LocalMaximumSeedFinder'), diff --git a/HLTrigger/Configuration/python/HLT_75e33/modules/particleFlowRecHitHF_cfi.py b/HLTrigger/Configuration/python/HLT_75e33/modules/particleFlowRecHitHF_cfi.py index 47a4885731fb5..045cc9daf8dfd 100644 --- a/HLTrigger/Configuration/python/HLT_75e33/modules/particleFlowRecHitHF_cfi.py +++ b/HLTrigger/Configuration/python/HLT_75e33/modules/particleFlowRecHitHF_cfi.py @@ -31,7 +31,8 @@ detectorEnum = cms.int32(4), threshold = cms.vdouble(1.2, 1.8) )), - name = cms.string('PFRecHitQTestHCALThresholdVsDepth') + name = cms.string('PFRecHitQTestHCALThresholdVsDepth'), + usePFThresholdsFromDB = cms.bool(False) # this needs to be True only for HBHE ) ), src = cms.InputTag("hfreco"), diff --git a/HLTrigger/Configuration/python/customizeHLTforCMSSW.py b/HLTrigger/Configuration/python/customizeHLTforCMSSW.py index 6f145fb14545c..189277154927c 100644 --- a/HLTrigger/Configuration/python/customizeHLTforCMSSW.py +++ b/HLTrigger/Configuration/python/customizeHLTforCMSSW.py @@ -262,6 +262,22 @@ def customizeHLTfor42943(process): return process +def customizeHLTfor43025(process): + + for producer in producers_by_type(process, "PFClusterProducer"): + producer.usePFThresholdsFromDB = cms.bool(True) + + for producer in producers_by_type(process, "PFMultiDepthClusterProducer"): + producer.usePFThresholdsFromDB = cms.bool(True) + + for producer in producers_by_type(process, "PFRecHitProducer"): + if producer.producers[0].name.value() == 'PFHBHERecHitCreator': + producer.producers[0].qualityTests[0].usePFThresholdsFromDB = cms.bool(True) + if producer.producers[0].name.value() == 'PFHFRecHitCreator': + producer.producers[0].qualityTests[1].usePFThresholdsFromDB = cms.bool(False) + + return process + # CMSSW version specific customizations def customizeHLTforCMSSW(process, menuType="GRun"): @@ -272,5 +288,6 @@ def customizeHLTforCMSSW(process, menuType="GRun"): process = customizeHLTfor42497(process) process = customizeHLTfor42943(process) - + process = customizeHLTfor43025(process) + return process diff --git a/RecoLocalCalo/HcalRecAlgos/plugins/HcalChannelPropertiesEP.cc b/RecoLocalCalo/HcalRecAlgos/plugins/HcalChannelPropertiesEP.cc index dca3eb9b2106d..a246e1e6cf925 100644 --- a/RecoLocalCalo/HcalRecAlgos/plugins/HcalChannelPropertiesEP.cc +++ b/RecoLocalCalo/HcalRecAlgos/plugins/HcalChannelPropertiesEP.cc @@ -11,6 +11,9 @@ #include "CondFormats/HcalObjects/interface/HcalRecoParams.h" #include "CondFormats/DataRecord/interface/HcalRecoParamsRcd.h" +#include "CondFormats/HcalObjects/interface/HcalPFCuts.h" +#include "CondFormats/DataRecord/interface/HcalPFCutsRcd.h" + #include "Geometry/CaloGeometry/interface/CaloGeometry.h" #include "Geometry/Records/interface/CaloGeometryRecord.h" #include "Geometry/CaloTopology/interface/HcalTopology.h" @@ -26,6 +29,7 @@ class HcalChannelPropertiesEP : public edm::ESProducer { public: typedef std::unique_ptr ReturnType1; typedef std::unique_ptr ReturnType2; + typedef std::unique_ptr ReturnType3; inline HcalChannelPropertiesEP(const edm::ParameterSet&) { auto cc1 = setWhatProduced(this, &HcalChannelPropertiesEP::produce1); @@ -39,13 +43,16 @@ class HcalChannelPropertiesEP : public edm::ESProducer { sevToken_ = cc2.consumes(); qualToken_ = cc2.consumes(qTag); geomToken_ = cc2.consumes(); + + edm::es::Label productLabel("withTopo"); + auto cc3 = setWhatProduced(this, &HcalChannelPropertiesEP::produce3, productLabel); + topoToken3_ = cc3.consumes(); + pfcutsToken_ = cc3.consumes(); } inline ~HcalChannelPropertiesEP() override {} ReturnType1 produce1(const HcalChannelPropertiesAuxRecord& rcd) { - using namespace edm; - const HcalTopology& htopo = rcd.getRecord().get(topoToken_); const HcalRecoParams& params = rcd.getRecord().get(paramsToken_); @@ -61,8 +68,7 @@ class HcalChannelPropertiesEP : public edm::ESProducer { // This means that we are sometimes going to rebuild the // whole table on the lumi block boundaries instead of // just updating the list of bad channels. - using namespace edm; - + // // Retrieve various event setup records and data products const HcalDbRecord& dbRecord = rcd.getRecord(); const HcalDbService& cond = dbRecord.get(condToken_); @@ -118,18 +124,28 @@ class HcalChannelPropertiesEP : public edm::ESProducer { return prod; } + ReturnType3 produce3(const HcalPFCutsRcd& rcd) { + const HcalTopology& htopo = rcd.get(topoToken3_); + const HcalPFCuts& cuts = rcd.get(pfcutsToken_); + + ReturnType3 prod = std::make_unique(cuts); + prod->setTopo(&htopo); + return prod; + } + HcalChannelPropertiesEP() = delete; HcalChannelPropertiesEP(const HcalChannelPropertiesEP&) = delete; HcalChannelPropertiesEP& operator=(const HcalChannelPropertiesEP&) = delete; private: edm::ESGetToken condToken_; - edm::ESGetToken topoToken_; + edm::ESGetToken topoToken_, topoToken3_; edm::ESGetToken paramsToken_; edm::ESGetToken sevToken_; edm::ESGetToken qualToken_; edm::ESGetToken geomToken_; edm::ESGetToken myParamsToken_; + edm::ESGetToken pfcutsToken_; }; DEFINE_FWK_EVENTSETUP_MODULE(HcalChannelPropertiesEP); diff --git a/RecoParticleFlow/PFClusterProducer/interface/InitialClusteringStepBase.h b/RecoParticleFlow/PFClusterProducer/interface/InitialClusteringStepBase.h index d1af150090ed7..f70e7b6f35440 100644 --- a/RecoParticleFlow/PFClusterProducer/interface/InitialClusteringStepBase.h +++ b/RecoParticleFlow/PFClusterProducer/interface/InitialClusteringStepBase.h @@ -8,6 +8,8 @@ #include "DataFormats/ParticleFlowReco/interface/PFCluster.h" #include "DataFormats/ParticleFlowReco/interface/PFClusterFwd.h" #include "DataFormats/Common/interface/RefToBaseVector.h" +#include "CondFormats/DataRecord/interface/HcalPFCutsRcd.h" +#include "CondTools/Hcal/interface/HcalPFCutsHandler.h" #include #include @@ -87,9 +89,10 @@ class InitialClusteringStepBase { virtual void updateEvent(const edm::Event&) {} virtual void buildClusters(const edm::Handle&, - const std::vector& mask, // mask flags - const std::vector& seeds, // seed flags - reco::PFClusterCollection&) = 0; //output + const std::vector& mask, // mask flags + const std::vector& seeds, // seed flags + reco::PFClusterCollection&, //output + const HcalPFCuts*) = 0; std::ostream& operator<<(std::ostream& o) const { o << "InitialClusteringStep with algo \"" << _algoName << "\" located " << _nSeeds << " seeds and built " diff --git a/RecoParticleFlow/PFClusterProducer/interface/PFCPositionCalculatorBase.h b/RecoParticleFlow/PFClusterProducer/interface/PFCPositionCalculatorBase.h index ea0e6cea5bac8..35d9adf659615 100644 --- a/RecoParticleFlow/PFClusterProducer/interface/PFCPositionCalculatorBase.h +++ b/RecoParticleFlow/PFClusterProducer/interface/PFCPositionCalculatorBase.h @@ -5,6 +5,8 @@ #include "FWCore/Framework/interface/ConsumesCollector.h" #include "DataFormats/ParticleFlowReco/interface/PFCluster.h" #include "DataFormats/ParticleFlowReco/interface/PFClusterFwd.h" +#include "CondFormats/DataRecord/interface/HcalPFCutsRcd.h" +#include "CondTools/Hcal/interface/HcalPFCutsHandler.h" #include @@ -27,9 +29,9 @@ class PFCPositionCalculatorBase { virtual void update(const edm::EventSetup&) {} // here we transform one PFCluster to use the new position calculation - virtual void calculateAndSetPosition(reco::PFCluster&) = 0; + virtual void calculateAndSetPosition(reco::PFCluster&, const HcalPFCuts*) = 0; // here you call a loop inside to transform the whole vector - virtual void calculateAndSetPositions(reco::PFClusterCollection&) = 0; + virtual void calculateAndSetPositions(reco::PFClusterCollection&, const HcalPFCuts*) = 0; const std::string& name() const { return _algoName; } diff --git a/RecoParticleFlow/PFClusterProducer/interface/PFClusterBuilderBase.h b/RecoParticleFlow/PFClusterProducer/interface/PFClusterBuilderBase.h index 3ce032f8e7c53..2ca93bb66e3bf 100644 --- a/RecoParticleFlow/PFClusterProducer/interface/PFClusterBuilderBase.h +++ b/RecoParticleFlow/PFClusterProducer/interface/PFClusterBuilderBase.h @@ -7,6 +7,8 @@ #include "DataFormats/ParticleFlowReco/interface/PFClusterFwd.h" #include "RecoParticleFlow/PFClusterProducer/interface/PFCPositionCalculatorBase.h" +#include "CondFormats/DataRecord/interface/HcalPFCutsRcd.h" +#include "CondTools/Hcal/interface/HcalPFCutsHandler.h" #include #include @@ -41,7 +43,8 @@ class PFClusterBuilderBase { virtual void buildClusters(const reco::PFClusterCollection& topos, const std::vector& seedable, - reco::PFClusterCollection& outclus) = 0; + reco::PFClusterCollection& outclus, + const HcalPFCuts*) = 0; std::ostream& operator<<(std::ostream& o) const { o << "PFClusterBuilder with algo \"" << _algoName << "\" located " << _nSeeds << " seeds and built " diff --git a/RecoParticleFlow/PFClusterProducer/interface/PFRecHitQTests.h b/RecoParticleFlow/PFClusterProducer/interface/PFRecHitQTests.h index 8858b99054b56..c11d69a2a7289 100644 --- a/RecoParticleFlow/PFClusterProducer/interface/PFRecHitQTests.h +++ b/RecoParticleFlow/PFClusterProducer/interface/PFRecHitQTests.h @@ -10,6 +10,8 @@ #include "Geometry/Records/interface/HcalRecNumberingRecord.h" #include "Geometry/CaloTopology/interface/HcalTopology.h" #include "DataFormats/METReco/interface/HcalPhase1FlagLabels.h" +#include "CondFormats/DataRecord/interface/HcalPFCutsRcd.h" +#include "CondTools/Hcal/interface/HcalPFCutsHandler.h" #include @@ -258,7 +260,12 @@ class PFRecHitQTestHCALThresholdVsDepth : public PFRecHitQTestBase { PFRecHitQTestHCALThresholdVsDepth() {} PFRecHitQTestHCALThresholdVsDepth(const edm::ParameterSet& iConfig, edm::ConsumesCollector& cc) - : PFRecHitQTestBase(iConfig, cc), psets_(iConfig.getParameter>("cuts")) { + : PFRecHitQTestBase(iConfig, cc), + psets_(iConfig.getParameter>("cuts")), + cutsFromDB(iConfig.getParameter("usePFThresholdsFromDB")) { + if (cutsFromDB) { + hcalCutsToken_ = cc.esConsumes(edm::ESInputTag("", "withTopo")); + } for (auto& pset : psets_) { depths_.push_back(pset.getParameter>("depth")); thresholds_.push_back(pset.getParameter>("threshold")); @@ -269,7 +276,11 @@ class PFRecHitQTestHCALThresholdVsDepth : public PFRecHitQTestBase { } } - void beginEvent(const edm::Event& event, const edm::EventSetup& iSetup) override {} + void beginEvent(const edm::Event& event, const edm::EventSetup& iSetup) override { + if (cutsFromDB) { + paramPF = &iSetup.getData(hcalCutsToken_); + } + } bool test(reco::PFRecHit& hit, const EcalRecHit& rh, bool& clean, bool fullReadOut) override { return true; } bool test(reco::PFRecHit& hit, const HBHERecHit& rh, bool& clean) override { @@ -292,16 +303,22 @@ class PFRecHitQTestHCALThresholdVsDepth : public PFRecHitQTestBase { std::vector> depths_; std::vector> thresholds_; std::vector detector_; + HcalPFCuts const* paramPF = nullptr; bool test(unsigned aDETID, double energy, double time, bool& clean) { HcalDetId detid(aDETID); + const HcalPFCut* item = nullptr; + if (cutsFromDB) { + item = paramPF->getValues(detid.rawId()); + } for (unsigned int d = 0; d < detector_.size(); ++d) { if (detid.subdet() != detector_[d]) continue; for (unsigned int i = 0; i < thresholds_[d].size(); ++i) { if (detid.depth() == depths_[d][i]) { - if (energy < thresholds_[d][i]) { + float thres = cutsFromDB ? item->noiseThreshold() : thresholds_[d][i]; + if (energy < thres) { clean = false; return false; } @@ -311,6 +328,11 @@ class PFRecHitQTestHCALThresholdVsDepth : public PFRecHitQTestBase { } return true; } + +private: + edm::ESGetToken htopoToken_; + edm::ESGetToken hcalCutsToken_; + bool cutsFromDB; }; // diff --git a/RecoParticleFlow/PFClusterProducer/interface/SeedFinderBase.h b/RecoParticleFlow/PFClusterProducer/interface/SeedFinderBase.h index 33bfdef088e37..c5c45bfe315c1 100644 --- a/RecoParticleFlow/PFClusterProducer/interface/SeedFinderBase.h +++ b/RecoParticleFlow/PFClusterProducer/interface/SeedFinderBase.h @@ -5,6 +5,8 @@ #include "DataFormats/Common/interface/Handle.h" #include "DataFormats/ParticleFlowReco/interface/PFRecHit.h" #include "DataFormats/ParticleFlowReco/interface/PFRecHitFwd.h" +#include "CondFormats/DataRecord/interface/HcalPFCutsRcd.h" +#include "CondTools/Hcal/interface/HcalPFCutsHandler.h" class SeedFinderBase { public: @@ -15,7 +17,8 @@ class SeedFinderBase { virtual void findSeeds(const edm::Handle& input, const std::vector& mask, - std::vector& seedable) = 0; + std::vector& seedable, + const HcalPFCuts*) = 0; const std::string& name() const { return _algoName; } diff --git a/RecoParticleFlow/PFClusterProducer/plugins/Basic2DClusterForEachSeed.cc b/RecoParticleFlow/PFClusterProducer/plugins/Basic2DClusterForEachSeed.cc index 6942dd97153c4..8734360c34ac6 100644 --- a/RecoParticleFlow/PFClusterProducer/plugins/Basic2DClusterForEachSeed.cc +++ b/RecoParticleFlow/PFClusterProducer/plugins/Basic2DClusterForEachSeed.cc @@ -1,5 +1,7 @@ #include "DataFormats/ParticleFlowReco/interface/PFRecHitFraction.h" #include "RecoParticleFlow/PFClusterProducer/interface/InitialClusteringStepBase.h" +#include "CondFormats/DataRecord/interface/HcalPFCutsRcd.h" +#include "CondTools/Hcal/interface/HcalPFCutsHandler.h" class Basic2DClusterForEachSeed : public InitialClusteringStepBase { public: @@ -10,7 +12,8 @@ class Basic2DClusterForEachSeed : public InitialClusteringStepBase { void buildClusters(const edm::Handle&, const std::vector&, const std::vector&, - reco::PFClusterCollection&) override; + reco::PFClusterCollection&, + const HcalPFCuts*) override; }; DEFINE_EDM_PLUGIN(InitialClusteringStepFactory, Basic2DClusterForEachSeed, "Basic2DClusterForEachSeed"); @@ -18,7 +21,8 @@ DEFINE_EDM_PLUGIN(InitialClusteringStepFactory, Basic2DClusterForEachSeed, "Basi void Basic2DClusterForEachSeed::buildClusters(const edm::Handle& input, const std::vector& rechitMask, const std::vector& seedable, - reco::PFClusterCollection& output) { + reco::PFClusterCollection& output, + const HcalPFCuts*) { auto const& hits = *input; // loop over seeds and make clusters diff --git a/RecoParticleFlow/PFClusterProducer/plugins/Basic2DGenericPFlowClusterizer.cc b/RecoParticleFlow/PFClusterProducer/plugins/Basic2DGenericPFlowClusterizer.cc index 6caf8c629298f..7b6f95d4d5208 100644 --- a/RecoParticleFlow/PFClusterProducer/plugins/Basic2DGenericPFlowClusterizer.cc +++ b/RecoParticleFlow/PFClusterProducer/plugins/Basic2DGenericPFlowClusterizer.cc @@ -4,6 +4,8 @@ #include "FWCore/Framework/interface/ConsumesCollector.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "RecoParticleFlow/PFClusterProducer/interface/PFClusterBuilderBase.h" +#include "CondFormats/DataRecord/interface/HcalPFCutsRcd.h" +#include "CondTools/Hcal/interface/HcalPFCutsHandler.h" #include "Math/GenVector/VectorUtil.h" #include "vdt/vdtMath.h" @@ -31,7 +33,8 @@ class Basic2DGenericPFlowClusterizer : public PFClusterBuilderBase { void buildClusters(const reco::PFClusterCollection&, const std::vector&, - reco::PFClusterCollection& outclus) override; + reco::PFClusterCollection& outclus, + const HcalPFCuts*) override; private: const unsigned _maxIterations; @@ -45,14 +48,18 @@ class Basic2DGenericPFlowClusterizer : public PFClusterBuilderBase { std::unique_ptr _allCellsPosCalc; std::unique_ptr _convergencePosCalc; - void seedPFClustersFromTopo(const reco::PFCluster&, const std::vector&, reco::PFClusterCollection&) const; + void seedPFClustersFromTopo(const reco::PFCluster&, + const std::vector&, + reco::PFClusterCollection&, + const HcalPFCuts*) const; void growPFClusters(const reco::PFCluster&, const std::vector&, const unsigned toleranceScaling, const unsigned iter, double dist, - reco::PFClusterCollection&) const; + reco::PFClusterCollection&, + const HcalPFCuts*) const; void prunePFClusters(reco::PFClusterCollection&) const; }; @@ -133,13 +140,14 @@ Basic2DGenericPFlowClusterizer::Basic2DGenericPFlowClusterizer(const edm::Parame void Basic2DGenericPFlowClusterizer::buildClusters(const reco::PFClusterCollection& input, const std::vector& seedable, - reco::PFClusterCollection& output) { + reco::PFClusterCollection& output, + const HcalPFCuts* hcalCuts) { reco::PFClusterCollection clustersInTopo; for (const auto& topocluster : input) { clustersInTopo.clear(); - seedPFClustersFromTopo(topocluster, seedable, clustersInTopo); + seedPFClustersFromTopo(topocluster, seedable, clustersInTopo, hcalCuts); const unsigned tolScal = std::pow(std::max(1.0, clustersInTopo.size() - 1.0), 2.0); - growPFClusters(topocluster, seedable, tolScal, 0, tolScal, clustersInTopo); + growPFClusters(topocluster, seedable, tolScal, 0, tolScal, clustersInTopo, hcalCuts); // step added by Josh Bendavid, removes low-fraction clusters // did not impact position resolution with fraction cut of 1e-7 // decreases the size of each pf cluster considerably @@ -147,12 +155,12 @@ void Basic2DGenericPFlowClusterizer::buildClusters(const reco::PFClusterCollecti // recalculate the positions of the pruned clusters if (_convergencePosCalc) { // if defined, use the special position calculation for convergence tests - _convergencePosCalc->calculateAndSetPositions(clustersInTopo); + _convergencePosCalc->calculateAndSetPositions(clustersInTopo, hcalCuts); } else { if (clustersInTopo.size() == 1 && _allCellsPosCalc) { - _allCellsPosCalc->calculateAndSetPosition(clustersInTopo.back()); + _allCellsPosCalc->calculateAndSetPosition(clustersInTopo.back(), hcalCuts); } else { - _positionCalc->calculateAndSetPositions(clustersInTopo); + _positionCalc->calculateAndSetPositions(clustersInTopo, hcalCuts); } } for (auto& clusterout : clustersInTopo) { @@ -163,7 +171,8 @@ void Basic2DGenericPFlowClusterizer::buildClusters(const reco::PFClusterCollecti void Basic2DGenericPFlowClusterizer::seedPFClustersFromTopo(const reco::PFCluster& topo, const std::vector& seedable, - reco::PFClusterCollection& initialPFClusters) const { + reco::PFClusterCollection& initialPFClusters, + const HcalPFCuts* hcalCuts) const { const auto& recHitFractions = topo.recHitFractions(); for (const auto& rhf : recHitFractions) { if (!seedable[rhf.recHitRef().key()]) @@ -173,9 +182,9 @@ void Basic2DGenericPFlowClusterizer::seedPFClustersFromTopo(const reco::PFCluste current.addRecHitFraction(rhf); current.setSeed(rhf.recHitRef()->detId()); if (_convergencePosCalc) { - _convergencePosCalc->calculateAndSetPosition(current); + _convergencePosCalc->calculateAndSetPosition(current, hcalCuts); } else { - _positionCalc->calculateAndSetPosition(current); + _positionCalc->calculateAndSetPosition(current, hcalCuts); } } } @@ -185,7 +194,8 @@ void Basic2DGenericPFlowClusterizer::growPFClusters(const reco::PFCluster& topo, const unsigned toleranceScaling, const unsigned iter, double diff, - reco::PFClusterCollection& clusters) const { + reco::PFClusterCollection& clusters, + const HcalPFCuts* hcalCuts) const { if (iter >= _maxIterations) { LOGDRESSED("Basic2DGenericPFlowClusterizer:growAndStabilizePFClusters") << "reached " << _maxIterations << " iterations, terminated position " @@ -200,9 +210,9 @@ void Basic2DGenericPFlowClusterizer::growPFClusters(const reco::PFCluster& topo, clus_prev_pos.emplace_back(repp.rho(), repp.eta(), repp.phi()); if (_convergencePosCalc) { if (clusters.size() == 1 && _allCellsPosCalc) { - _allCellsPosCalc->calculateAndSetPosition(cluster); + _allCellsPosCalc->calculateAndSetPosition(cluster, hcalCuts); } else { - _positionCalc->calculateAndSetPosition(cluster); + _positionCalc->calculateAndSetPosition(cluster, hcalCuts); } } cluster.resetHitsAndFractions(); @@ -225,13 +235,19 @@ void Basic2DGenericPFlowClusterizer::growPFClusters(const reco::PFCluster& topo, double recHitEnergyNorm = 0.; auto const& recHitEnergyNormDepthPair = _recHitEnergyNorms.find(cell_layer)->second; - for (unsigned int j = 0; j < recHitEnergyNormDepthPair.second.size(); ++j) { - int depth = recHitEnergyNormDepthPair.first[j]; - - if ((cell_layer == PFLayer::HCAL_BARREL1 && refhit->depth() == depth) || - (cell_layer == PFLayer::HCAL_ENDCAP && refhit->depth() == depth) || - (cell_layer != PFLayer::HCAL_ENDCAP && cell_layer != PFLayer::HCAL_BARREL1)) - recHitEnergyNorm = recHitEnergyNormDepthPair.second[j]; + if (hcalCuts != nullptr && // this means, cutsFromDB is set to True in PFClusterProducer.cc + (cell_layer == PFLayer::HCAL_BARREL1 || cell_layer == PFLayer::HCAL_ENDCAP)) { + HcalDetId thisId = refhit->detId(); + const HcalPFCut* item = hcalCuts->getValues(thisId.rawId()); + recHitEnergyNorm = item->noiseThreshold(); + } else { + for (unsigned int j = 0; j < recHitEnergyNormDepthPair.second.size(); ++j) { + int depth = recHitEnergyNormDepthPair.first[j]; + if ((cell_layer == PFLayer::HCAL_BARREL1 && refhit->depth() == depth) || + (cell_layer == PFLayer::HCAL_ENDCAP && refhit->depth() == depth) || + (cell_layer != PFLayer::HCAL_ENDCAP && cell_layer != PFLayer::HCAL_BARREL1)) + recHitEnergyNorm = recHitEnergyNormDepthPair.second[j]; + } } // add rechits to clusters, calculating fraction based on distance @@ -283,12 +299,12 @@ void Basic2DGenericPFlowClusterizer::growPFClusters(const reco::PFCluster& topo, double diff2 = 0.0; for (unsigned i = 0; i < clusters.size(); ++i) { if (_convergencePosCalc) { - _convergencePosCalc->calculateAndSetPosition(clusters[i]); + _convergencePosCalc->calculateAndSetPosition(clusters[i], hcalCuts); } else { if (clusters.size() == 1 && _allCellsPosCalc) { - _allCellsPosCalc->calculateAndSetPosition(clusters[i]); + _allCellsPosCalc->calculateAndSetPosition(clusters[i], hcalCuts); } else { - _positionCalc->calculateAndSetPosition(clusters[i]); + _positionCalc->calculateAndSetPosition(clusters[i], hcalCuts); } } const double delta2 = reco::deltaR2(clusters[i].positionREP(), clus_prev_pos[i]); @@ -299,7 +315,7 @@ void Basic2DGenericPFlowClusterizer::growPFClusters(const reco::PFCluster& topo, dist2.clear(); frac.clear(); clus_prev_pos.clear(); // avoid badness - growPFClusters(topo, seedable, toleranceScaling, iter + 1, diff, clusters); + growPFClusters(topo, seedable, toleranceScaling, iter + 1, diff, clusters, hcalCuts); } void Basic2DGenericPFlowClusterizer::prunePFClusters(reco::PFClusterCollection& clusters) const { diff --git a/RecoParticleFlow/PFClusterProducer/plugins/Basic2DGenericPFlowPositionCalc.cc b/RecoParticleFlow/PFClusterProducer/plugins/Basic2DGenericPFlowPositionCalc.cc index e63879e1a189f..177c5f812122f 100644 --- a/RecoParticleFlow/PFClusterProducer/plugins/Basic2DGenericPFlowPositionCalc.cc +++ b/RecoParticleFlow/PFClusterProducer/plugins/Basic2DGenericPFlowPositionCalc.cc @@ -6,6 +6,8 @@ #include "FWCore/Utilities/interface/isFinite.h" #include "RecoParticleFlow/PFClusterProducer/interface/CaloRecHitResolutionProvider.h" #include "RecoParticleFlow/PFClusterProducer/interface/PFCPositionCalculatorBase.h" +#include "CondFormats/DataRecord/interface/HcalPFCutsRcd.h" +#include "CondTools/Hcal/interface/HcalPFCutsHandler.h" #include "vdt/vdtMath.h" @@ -92,8 +94,8 @@ class Basic2DGenericPFlowPositionCalc : public PFCPositionCalculatorBase { Basic2DGenericPFlowPositionCalc(const Basic2DGenericPFlowPositionCalc&) = delete; Basic2DGenericPFlowPositionCalc& operator=(const Basic2DGenericPFlowPositionCalc&) = delete; - void calculateAndSetPosition(reco::PFCluster&) override; - void calculateAndSetPositions(reco::PFClusterCollection&) override; + void calculateAndSetPosition(reco::PFCluster&, const HcalPFCuts*) override; + void calculateAndSetPositions(reco::PFClusterCollection&, const HcalPFCuts*) override; private: const int _posCalcNCrystals; @@ -103,7 +105,7 @@ class Basic2DGenericPFlowPositionCalc : public PFCPositionCalculatorBase { std::unique_ptr _timeResolutionCalcBarrel; std::unique_ptr _timeResolutionCalcEndcap; - void calculateAndSetPositionActual(reco::PFCluster&) const; + void calculateAndSetPositionActual(reco::PFCluster&, const HcalPFCuts*) const; }; DEFINE_EDM_PLUGIN(PFCPositionCalculatorFactory, Basic2DGenericPFlowPositionCalc, "Basic2DGenericPFlowPositionCalc"); @@ -115,17 +117,19 @@ namespace { } } // namespace -void Basic2DGenericPFlowPositionCalc::calculateAndSetPosition(reco::PFCluster& cluster) { - calculateAndSetPositionActual(cluster); +void Basic2DGenericPFlowPositionCalc::calculateAndSetPosition(reco::PFCluster& cluster, const HcalPFCuts* hcalCuts) { + calculateAndSetPositionActual(cluster, hcalCuts); } -void Basic2DGenericPFlowPositionCalc::calculateAndSetPositions(reco::PFClusterCollection& clusters) { +void Basic2DGenericPFlowPositionCalc::calculateAndSetPositions(reco::PFClusterCollection& clusters, + const HcalPFCuts* hcalCuts) { for (reco::PFCluster& cluster : clusters) { - calculateAndSetPositionActual(cluster); + calculateAndSetPositionActual(cluster, hcalCuts); } } -void Basic2DGenericPFlowPositionCalc::calculateAndSetPositionActual(reco::PFCluster& cluster) const { +void Basic2DGenericPFlowPositionCalc::calculateAndSetPositionActual(reco::PFCluster& cluster, + const HcalPFCuts* hcalCuts) const { if (!cluster.seed()) { throw cms::Exception("ClusterWithNoSeed") << " Found a cluster with no seed: " << cluster; } @@ -225,14 +229,23 @@ void Basic2DGenericPFlowPositionCalc::calculateAndSetPositionActual(reco::PFClus int cell_layer = (int)refhit.layer(); float threshold = 0; - for (unsigned int j = 0; j < (std::get<2>(_logWeightDenom)).size(); ++j) { - // barrel is detecor type1 - int detectorEnum = std::get<0>(_logWeightDenom)[j]; - int depth = std::get<1>(_logWeightDenom)[j]; - - if ((cell_layer == PFLayer::HCAL_BARREL1 && detectorEnum == 1 && refhit.depth() == depth) || - (cell_layer == PFLayer::HCAL_ENDCAP && detectorEnum == 2 && refhit.depth() == depth) || detectorEnum == 0) - threshold = std::get<2>(_logWeightDenom)[j]; + if (hcalCuts != nullptr && // this means, cutsFromDB is set to True in the producer code + (cell_layer == PFLayer::HCAL_BARREL1 || cell_layer == PFLayer::HCAL_ENDCAP)) { + HcalDetId thisId = refhit.detId(); + const HcalPFCut* item = hcalCuts->getValues(thisId.rawId()); + threshold = 1. / (item->noiseThreshold()); + + } else { + for (unsigned int j = 0; j < (std::get<2>(_logWeightDenom)).size(); ++j) { + // barrel is detecor type1 + int detectorEnum = std::get<0>(_logWeightDenom)[j]; + int depth = std::get<1>(_logWeightDenom)[j]; + if ((cell_layer == PFLayer::HCAL_BARREL1 && detectorEnum == 1 && refhit.depth() == depth) || + (cell_layer == PFLayer::HCAL_ENDCAP && detectorEnum == 2 && refhit.depth() == depth) || + detectorEnum == 0) { + threshold = std::get<2>(_logWeightDenom)[j]; + } + } } if (ref_depth < 0) diff --git a/RecoParticleFlow/PFClusterProducer/plugins/Basic2DGenericTopoClusterizer.cc b/RecoParticleFlow/PFClusterProducer/plugins/Basic2DGenericTopoClusterizer.cc index 0df322e336460..4635adae0baa1 100644 --- a/RecoParticleFlow/PFClusterProducer/plugins/Basic2DGenericTopoClusterizer.cc +++ b/RecoParticleFlow/PFClusterProducer/plugins/Basic2DGenericTopoClusterizer.cc @@ -1,6 +1,8 @@ #include "DataFormats/ParticleFlowReco/interface/PFRecHitFraction.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "RecoParticleFlow/PFClusterProducer/interface/InitialClusteringStepBase.h" +#include "CondFormats/DataRecord/interface/HcalPFCutsRcd.h" +#include "CondTools/Hcal/interface/HcalPFCutsHandler.h" class Basic2DGenericTopoClusterizer : public InitialClusteringStepBase { typedef Basic2DGenericTopoClusterizer B2DGT; @@ -15,7 +17,8 @@ class Basic2DGenericTopoClusterizer : public InitialClusteringStepBase { void buildClusters(const edm::Handle&, const std::vector&, const std::vector&, - reco::PFClusterCollection&) override; + reco::PFClusterCollection&, + const HcalPFCuts*) override; private: const bool _useCornerCells; @@ -23,7 +26,8 @@ class Basic2DGenericTopoClusterizer : public InitialClusteringStepBase { const std::vector&, // masked rechits unsigned int, //present rechit std::vector&, // hit usage state - reco::PFCluster&); // the topocluster + reco::PFCluster&, // the topocluster + const HcalPFCuts*); }; DEFINE_EDM_PLUGIN(InitialClusteringStepFactory, Basic2DGenericTopoClusterizer, "Basic2DGenericTopoClusterizer"); @@ -43,7 +47,8 @@ DEFINE_EDM_PLUGIN(InitialClusteringStepFactory, Basic2DGenericTopoClusterizer, " void Basic2DGenericTopoClusterizer::buildClusters(const edm::Handle& input, const std::vector& rechitMask, const std::vector& seedable, - reco::PFClusterCollection& output) { + reco::PFClusterCollection& output, + const HcalPFCuts* hcalCuts) { auto const& hits = *input; std::vector used(hits.size(), false); std::vector seeds; @@ -64,7 +69,7 @@ void Basic2DGenericTopoClusterizer::buildClusters(const edm::Handle& rechitMask, unsigned int kcell, std::vector& used, - reco::PFCluster& topocluster) { + reco::PFCluster& topocluster, + const HcalPFCuts* hcalCuts) { auto const& cell = (*input)[kcell]; int cell_layer = (int)cell.layer(); if (cell_layer == PFLayer::HCAL_BARREL2 && std::abs(cell.positionREP().eta()) > 0.34) { @@ -96,6 +102,14 @@ void Basic2DGenericTopoClusterizer::buildTopoCluster(const edm::HandlegetValues(thisId.rawId()); + thresholdE = item->noiseThreshold(); + } + } + if (cell.energy() < thresholdE || cell.pt2() < thresholdPT2) { LOGDRESSED("GenericTopoCluster::buildTopoCluster()") << "RecHit " << cell.detId() << " with enegy " << cell.energy() << " GeV was rejected!." << std::endl; @@ -118,6 +132,6 @@ void Basic2DGenericTopoClusterizer::buildTopoCluster(const edm::Handle(3, "D"); calculateAndSetPositionActual(cluster); } -void Cluster3DPCACalculator::calculateAndSetPositions(reco::PFClusterCollection& clusters) { +void Cluster3DPCACalculator::calculateAndSetPositions(reco::PFClusterCollection& clusters, const HcalPFCuts* cuts) { for (reco::PFCluster& cluster : clusters) { pca_ = std::make_unique(3, "D"); calculateAndSetPositionActual(cluster); diff --git a/RecoParticleFlow/PFClusterProducer/plugins/ECAL2DPositionCalcWithDepthCorr.cc b/RecoParticleFlow/PFClusterProducer/plugins/ECAL2DPositionCalcWithDepthCorr.cc index 1e032c152f445..a8ba116e7e0ba 100644 --- a/RecoParticleFlow/PFClusterProducer/plugins/ECAL2DPositionCalcWithDepthCorr.cc +++ b/RecoParticleFlow/PFClusterProducer/plugins/ECAL2DPositionCalcWithDepthCorr.cc @@ -48,8 +48,8 @@ class ECAL2DPositionCalcWithDepthCorr : public PFCPositionCalculatorBase { void update(const edm::EventSetup& es) override; - void calculateAndSetPosition(reco::PFCluster&) override; - void calculateAndSetPositions(reco::PFClusterCollection&) override; + void calculateAndSetPosition(reco::PFCluster&, const HcalPFCuts*) override; + void calculateAndSetPositions(reco::PFClusterCollection&, const HcalPFCuts*) override; private: const double _param_T0_EB; @@ -92,11 +92,11 @@ void ECAL2DPositionCalcWithDepthCorr::update(const edm::EventSetup& es) { } } -void ECAL2DPositionCalcWithDepthCorr::calculateAndSetPosition(reco::PFCluster& cluster) { +void ECAL2DPositionCalcWithDepthCorr::calculateAndSetPosition(reco::PFCluster& cluster, const HcalPFCuts*) { calculateAndSetPositionActual(cluster); } -void ECAL2DPositionCalcWithDepthCorr::calculateAndSetPositions(reco::PFClusterCollection& clusters) { +void ECAL2DPositionCalcWithDepthCorr::calculateAndSetPositions(reco::PFClusterCollection& clusters, const HcalPFCuts*) { for (reco::PFCluster& cluster : clusters) { calculateAndSetPositionActual(cluster); } diff --git a/RecoParticleFlow/PFClusterProducer/plugins/LocalMaximumSeedFinder.cc b/RecoParticleFlow/PFClusterProducer/plugins/LocalMaximumSeedFinder.cc index f32cb92683d84..86bccb6dbaf7b 100644 --- a/RecoParticleFlow/PFClusterProducer/plugins/LocalMaximumSeedFinder.cc +++ b/RecoParticleFlow/PFClusterProducer/plugins/LocalMaximumSeedFinder.cc @@ -2,6 +2,8 @@ #include "DataFormats/Math/interface/deltaPhi.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "RecoParticleFlow/PFClusterProducer/interface/SeedFinderBase.h" +#include "CondFormats/DataRecord/interface/HcalPFCutsRcd.h" +#include "CondTools/Hcal/interface/HcalPFCutsHandler.h" #include #include @@ -17,7 +19,8 @@ class LocalMaximumSeedFinder final : public SeedFinderBase { void findSeeds(const edm::Handle& input, const std::vector& mask, - std::vector& seedable) override; + std::vector& seedable, + const HcalPFCuts*) override; private: const int _nNeighbours; @@ -57,7 +60,6 @@ LocalMaximumSeedFinder::LocalMaximumSeedFinder(const edm::ParameterSet& conf) const std::vector& thresholds = conf.getParameterSetVector("thresholdsByDetector"); for (const auto& pset : thresholds) { const std::string& det = pset.getParameter("detector"); - std::vector depths; std::vector thresh_E; std::vector thresh_pT; @@ -93,7 +95,8 @@ LocalMaximumSeedFinder::LocalMaximumSeedFinder(const edm::ParameterSet& conf) // the starting state of seedable is all false! void LocalMaximumSeedFinder::findSeeds(const edm::Handle& input, const std::vector& mask, - std::vector& seedable) { + std::vector& seedable, + const HcalPFCuts* hcalCuts) { auto nhits = input->size(); initDynArray(bool, nhits, usable, true); //need to run over energy sorted rechits @@ -126,6 +129,14 @@ void LocalMaximumSeedFinder::findSeeds(const edm::HandlegetValues(thisId.rawId()); + thresholdE = item->seedThreshold(); + } + } + if (maybeseed.energy() < thresholdE || maybeseed.pt2() < thresholdPT2) usable[i] = false; if (!usable[i]) diff --git a/RecoParticleFlow/PFClusterProducer/plugins/PFClusterFromHGCalTrackster.cc b/RecoParticleFlow/PFClusterProducer/plugins/PFClusterFromHGCalTrackster.cc index df7cf738cba7a..6d91ce81d4c1f 100644 --- a/RecoParticleFlow/PFClusterProducer/plugins/PFClusterFromHGCalTrackster.cc +++ b/RecoParticleFlow/PFClusterProducer/plugins/PFClusterFromHGCalTrackster.cc @@ -4,6 +4,8 @@ #include "FWCore/Framework/interface/Event.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "RecoParticleFlow/PFClusterProducer/interface/InitialClusteringStepBase.h" +#include "CondFormats/DataRecord/interface/HcalPFCutsRcd.h" +#include "CondTools/Hcal/interface/HcalPFCutsHandler.h" class PFClusterFromHGCalTrackster : public InitialClusteringStepBase { public: @@ -28,7 +30,8 @@ class PFClusterFromHGCalTrackster : public InitialClusteringStepBase { void buildClusters(const edm::Handle&, const std::vector&, const std::vector&, - reco::PFClusterCollection&) override; + reco::PFClusterCollection&, + const HcalPFCuts*) override; private: bool filterByTracksterPID_; @@ -54,7 +57,8 @@ void PFClusterFromHGCalTrackster::updateEvent(const edm::Event& ev) { void PFClusterFromHGCalTrackster::buildClusters(const edm::Handle& input, const std::vector& rechitMask, const std::vector& seedable, - reco::PFClusterCollection& output) { + reco::PFClusterCollection& output, + const HcalPFCuts*) { auto const& hits = *input; const auto& tracksters = *trackstersH_; diff --git a/RecoParticleFlow/PFClusterProducer/plugins/PFClusterProducer.cc b/RecoParticleFlow/PFClusterProducer/plugins/PFClusterProducer.cc index aa869b0e0a84b..fffd17515e2e9 100644 --- a/RecoParticleFlow/PFClusterProducer/plugins/PFClusterProducer.cc +++ b/RecoParticleFlow/PFClusterProducer/plugins/PFClusterProducer.cc @@ -6,7 +6,8 @@ #include "RecoParticleFlow/PFClusterProducer/interface/PFClusterEnergyCorrectorBase.h" #include "RecoParticleFlow/PFClusterProducer/interface/RecHitTopologicalCleanerBase.h" #include "RecoParticleFlow/PFClusterProducer/interface/SeedFinderBase.h" - +#include "CondFormats/DataRecord/interface/HcalPFCutsRcd.h" +#include "CondTools/Hcal/interface/HcalPFCutsHandler.h" #include class PFClusterProducer : public edm::stream::EDProducer<> { @@ -25,6 +26,10 @@ class PFClusterProducer : public edm::stream::EDProducer<> { private: // inputs edm::EDGetTokenT _rechitsLabel; + edm::ESGetToken hcalCutsToken_; + bool cutsFromDB; + HcalPFCuts const* paramPF = nullptr; + // options const bool _prodInitClusters; // the actual algorithm @@ -55,8 +60,13 @@ DEFINE_FWK_MODULE(PFClusterProducer); PFClusterProducer::PFClusterProducer(const edm::ParameterSet& conf) : _prodInitClusters(conf.getUntrackedParameter("prodInitialClusters", false)) { _rechitsLabel = consumes(conf.getParameter("recHitsSource")); + cutsFromDB = conf.getParameter("usePFThresholdsFromDB"); edm::ConsumesCollector cc = consumesCollector(); + if (cutsFromDB) { + hcalCutsToken_ = esConsumes(edm::ESInputTag("", "withTopo")); + } + //setup rechit cleaners const edm::VParameterSet& cleanerConfs = conf.getParameterSetVector("recHitCleaners"); for (const auto& conf : cleanerConfs) { @@ -107,6 +117,9 @@ PFClusterProducer::PFClusterProducer(const edm::ParameterSet& conf) } void PFClusterProducer::beginRun(const edm::Run& run, const edm::EventSetup& es) { + if (cutsFromDB) { + paramPF = &es.getData(hcalCutsToken_); + } _initialClustering->update(es); if (_pfClusterBuilder) _pfClusterBuilder->update(es); @@ -140,23 +153,23 @@ void PFClusterProducer::produce(edm::Event& e, const edm::EventSetup& es) { } std::vector seedable(rechits->size(), false); - _seedFinder->findSeeds(rechits, seedmask, seedable); + _seedFinder->findSeeds(rechits, seedmask, seedable, paramPF); auto initialClusters = std::make_unique(); - _initialClustering->buildClusters(rechits, mask, seedable, *initialClusters); + _initialClustering->buildClusters(rechits, mask, seedable, *initialClusters, paramPF); LOGVERB("PFClusterProducer::produce()") << *_initialClustering; auto pfClusters = std::make_unique(); pfClusters = std::make_unique(); if (_pfClusterBuilder) { // if we've defined a re-clustering step execute it - _pfClusterBuilder->buildClusters(*initialClusters, seedable, *pfClusters); + _pfClusterBuilder->buildClusters(*initialClusters, seedable, *pfClusters, paramPF); LOGVERB("PFClusterProducer::produce()") << *_pfClusterBuilder; } else { pfClusters->insert(pfClusters->end(), initialClusters->begin(), initialClusters->end()); } if (_positionReCalc) { - _positionReCalc->calculateAndSetPositions(*pfClusters); + _positionReCalc->calculateAndSetPositions(*pfClusters, paramPF); } if (_energyCorrector) { diff --git a/RecoParticleFlow/PFClusterProducer/plugins/PFMultiDepthClusterProducer.cc b/RecoParticleFlow/PFClusterProducer/plugins/PFMultiDepthClusterProducer.cc index be6fd15ad935a..0a8ee49166a5d 100644 --- a/RecoParticleFlow/PFClusterProducer/plugins/PFMultiDepthClusterProducer.cc +++ b/RecoParticleFlow/PFClusterProducer/plugins/PFMultiDepthClusterProducer.cc @@ -9,6 +9,8 @@ #include "RecoParticleFlow/PFClusterProducer/interface/PFClusterEnergyCorrectorBase.h" #include "RecoParticleFlow/PFClusterProducer/interface/RecHitTopologicalCleanerBase.h" #include "RecoParticleFlow/PFClusterProducer/interface/SeedFinderBase.h" +#include "CondFormats/DataRecord/interface/HcalPFCutsRcd.h" +#include "CondTools/Hcal/interface/HcalPFCutsHandler.h" #include @@ -27,10 +29,13 @@ class PFMultiDepthClusterProducer : public edm::stream::EDProducer<> { private: // inputs edm::EDGetTokenT _clustersLabel; + edm::ESGetToken hcalCutsToken_; // options // the actual algorithm std::unique_ptr _pfClusterBuilder; std::unique_ptr _energyCorrector; + bool cutsFromDB; + HcalPFCuts const* paramPF = nullptr; }; DEFINE_FWK_MODULE(PFMultiDepthClusterProducer); @@ -49,9 +54,15 @@ DEFINE_FWK_MODULE(PFMultiDepthClusterProducer); PFMultiDepthClusterProducer::PFMultiDepthClusterProducer(const edm::ParameterSet& conf) { _clustersLabel = consumes(conf.getParameter("clustersSource")); + cutsFromDB = conf.getParameter("usePFThresholdsFromDB"); const edm::ParameterSet& pfcConf = conf.getParameterSet("pfClusterBuilder"); edm::ConsumesCollector&& cc = consumesCollector(); + + if (cutsFromDB) { + hcalCutsToken_ = esConsumes(edm::ESInputTag("", "withTopo")); + } + if (!pfcConf.empty()) { const std::string& pfcName = pfcConf.getParameter("algoName"); _pfClusterBuilder = PFClusterBuilderFactory::get()->create(pfcName, pfcConf, cc); @@ -67,6 +78,9 @@ PFMultiDepthClusterProducer::PFMultiDepthClusterProducer(const edm::ParameterSet } void PFMultiDepthClusterProducer::beginRun(const edm::Run& run, const edm::EventSetup& es) { + if (cutsFromDB) { + paramPF = &es.getData(hcalCutsToken_); + } _pfClusterBuilder->update(es); } @@ -79,7 +93,7 @@ void PFMultiDepthClusterProducer::produce(edm::Event& e, const edm::EventSetup& std::vector seedable; auto pfClusters = std::make_unique(); - _pfClusterBuilder->buildClusters(*inputClusters, seedable, *pfClusters); + _pfClusterBuilder->buildClusters(*inputClusters, seedable, *pfClusters, paramPF); LOGVERB("PFMultiDepthClusterProducer::produce()") << *_pfClusterBuilder; if (_energyCorrector) { diff --git a/RecoParticleFlow/PFClusterProducer/plugins/PFMultiDepthClusterizer.cc b/RecoParticleFlow/PFClusterProducer/plugins/PFMultiDepthClusterizer.cc index 2ca69403b1f4f..520b6ca867375 100644 --- a/RecoParticleFlow/PFClusterProducer/plugins/PFMultiDepthClusterizer.cc +++ b/RecoParticleFlow/PFClusterProducer/plugins/PFMultiDepthClusterizer.cc @@ -6,7 +6,8 @@ #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "Math/GenVector/VectorUtil.h" #include "RecoParticleFlow/PFClusterProducer/interface/PFClusterBuilderBase.h" - +#include "CondFormats/DataRecord/interface/HcalPFCutsRcd.h" +#include "CondTools/Hcal/interface/HcalPFCutsHandler.h" #include "vdt/vdtMath.h" #include @@ -26,7 +27,8 @@ class PFMultiDepthClusterizer final : public PFClusterBuilderBase { void buildClusters(const reco::PFClusterCollection&, const std::vector&, - reco::PFClusterCollection& outclus) override; + reco::PFClusterCollection& outclus, + const HcalPFCuts*) override; private: std::unique_ptr _allCellsPosCalc; @@ -90,7 +92,8 @@ PFMultiDepthClusterizer::PFMultiDepthClusterizer(const edm::ParameterSet& conf, void PFMultiDepthClusterizer::buildClusters(const reco::PFClusterCollection& input, const std::vector& seedable, - reco::PFClusterCollection& output) { + reco::PFClusterCollection& output, + const HcalPFCuts* hcalCuts) { std::vector etaRMS2(input.size(), 0.0); std::vector phiRMS2(input.size(), 0.0); @@ -133,7 +136,7 @@ void PFMultiDepthClusterizer::buildClusters(const reco::PFClusterCollection& inp reco::PFCluster cluster = input[i]; mask[i] = true; expandCluster(cluster, i, mask, input, prunedLinks); - _allCellsPosCalc->calculateAndSetPosition(cluster); + _allCellsPosCalc->calculateAndSetPosition(cluster, hcalCuts); output.push_back(cluster); // printf("Added linked cluster with energy =%f\n",cluster.energy()); } diff --git a/RecoParticleFlow/PFClusterProducer/plugins/PFlow2DClusterizerWithTime.cc b/RecoParticleFlow/PFClusterProducer/plugins/PFlow2DClusterizerWithTime.cc index 35e072177eabf..97d1fa9cd718e 100644 --- a/RecoParticleFlow/PFClusterProducer/plugins/PFlow2DClusterizerWithTime.cc +++ b/RecoParticleFlow/PFClusterProducer/plugins/PFlow2DClusterizerWithTime.cc @@ -5,6 +5,8 @@ #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "RecoParticleFlow/PFClusterProducer/interface/CaloRecHitResolutionProvider.h" #include "RecoParticleFlow/PFClusterProducer/interface/PFClusterBuilderBase.h" +#include "CondFormats/DataRecord/interface/HcalPFCutsRcd.h" +#include "CondTools/Hcal/interface/HcalPFCutsHandler.h" #include "Math/GenVector/VectorUtil.h" #include "TMath.h" @@ -33,7 +35,8 @@ class PFlow2DClusterizerWithTime : public PFClusterBuilderBase { void buildClusters(const reco::PFClusterCollection&, const std::vector&, - reco::PFClusterCollection& outclus) override; + reco::PFClusterCollection& outclus, + const HcalPFCuts*) override; private: const unsigned _maxIterations; @@ -55,14 +58,18 @@ class PFlow2DClusterizerWithTime : public PFClusterBuilderBase { std::unique_ptr _timeResolutionCalcBarrel; std::unique_ptr _timeResolutionCalcEndcap; - void seedPFClustersFromTopo(const reco::PFCluster&, const std::vector&, reco::PFClusterCollection&) const; + void seedPFClustersFromTopo(const reco::PFCluster&, + const std::vector&, + reco::PFClusterCollection&, + const HcalPFCuts*) const; void growPFClusters(const reco::PFCluster&, const std::vector&, const unsigned toleranceScaling, const unsigned iter, double dist, - reco::PFClusterCollection&) const; + reco::PFClusterCollection&, + const HcalPFCuts* hcalCuts) const; void clusterTimeResolution(reco::PFCluster& cluster, double& res) const; void clusterTimeResolutionFromSeed(reco::PFCluster& cluster, double& res) const; double dist2Time(const reco::PFCluster&, const reco::PFRecHitRef&, int cell_layer, double prev_timeres2) const; @@ -146,13 +153,14 @@ PFlow2DClusterizerWithTime::PFlow2DClusterizerWithTime(const edm::ParameterSet& void PFlow2DClusterizerWithTime::buildClusters(const reco::PFClusterCollection& input, const std::vector& seedable, - reco::PFClusterCollection& output) { + reco::PFClusterCollection& output, + const HcalPFCuts* hcalCuts) { reco::PFClusterCollection clustersInTopo; for (const auto& topocluster : input) { clustersInTopo.clear(); - seedPFClustersFromTopo(topocluster, seedable, clustersInTopo); + seedPFClustersFromTopo(topocluster, seedable, clustersInTopo, hcalCuts); const unsigned tolScal = std::pow(std::max(1.0, clustersInTopo.size() - 1.0), 2.0); - growPFClusters(topocluster, seedable, tolScal, 0, tolScal, clustersInTopo); + growPFClusters(topocluster, seedable, tolScal, 0, tolScal, clustersInTopo, hcalCuts); // step added by Josh Bendavid, removes low-fraction clusters // did not impact position resolution with fraction cut of 1e-7 // decreases the size of each pf cluster considerably @@ -160,12 +168,12 @@ void PFlow2DClusterizerWithTime::buildClusters(const reco::PFClusterCollection& // recalculate the positions of the pruned clusters if (_convergencePosCalc) { // if defined, use the special position calculation for convergence tests - _convergencePosCalc->calculateAndSetPositions(clustersInTopo); + _convergencePosCalc->calculateAndSetPositions(clustersInTopo, hcalCuts); } else { if (clustersInTopo.size() == 1 && _allCellsPosCalc) { - _allCellsPosCalc->calculateAndSetPosition(clustersInTopo.back()); + _allCellsPosCalc->calculateAndSetPosition(clustersInTopo.back(), hcalCuts); } else { - _positionCalc->calculateAndSetPositions(clustersInTopo); + _positionCalc->calculateAndSetPositions(clustersInTopo, hcalCuts); } } for (auto& clusterout : clustersInTopo) { @@ -176,7 +184,8 @@ void PFlow2DClusterizerWithTime::buildClusters(const reco::PFClusterCollection& void PFlow2DClusterizerWithTime::seedPFClustersFromTopo(const reco::PFCluster& topo, const std::vector& seedable, - reco::PFClusterCollection& initialPFClusters) const { + reco::PFClusterCollection& initialPFClusters, + const HcalPFCuts* hcalCuts) const { const auto& recHitFractions = topo.recHitFractions(); for (const auto& rhf : recHitFractions) { if (!seedable[rhf.recHitRef().key()]) @@ -186,9 +195,9 @@ void PFlow2DClusterizerWithTime::seedPFClustersFromTopo(const reco::PFCluster& t current.addRecHitFraction(rhf); current.setSeed(rhf.recHitRef()->detId()); if (_convergencePosCalc) { - _convergencePosCalc->calculateAndSetPosition(current); + _convergencePosCalc->calculateAndSetPosition(current, hcalCuts); } else { - _positionCalc->calculateAndSetPosition(current); + _positionCalc->calculateAndSetPosition(current, hcalCuts); } } } @@ -198,7 +207,8 @@ void PFlow2DClusterizerWithTime::growPFClusters(const reco::PFCluster& topo, const unsigned toleranceScaling, const unsigned iter, double diff, - reco::PFClusterCollection& clusters) const { + reco::PFClusterCollection& clusters, + const HcalPFCuts* hcalCuts) const { if (iter >= _maxIterations) { LOGDRESSED("PFlow2DClusterizerWithTime:growAndStabilizePFClusters") << "reached " << _maxIterations << " iterations, terminated position " @@ -216,9 +226,9 @@ void PFlow2DClusterizerWithTime::growPFClusters(const reco::PFCluster& topo, clus_prev_pos.emplace_back(repp.rho(), repp.eta(), repp.phi()); if (_convergencePosCalc) { if (clusters.size() == 1 && _allCellsPosCalc) { - _allCellsPosCalc->calculateAndSetPosition(cluster); + _allCellsPosCalc->calculateAndSetPosition(cluster, hcalCuts); } else { - _positionCalc->calculateAndSetPosition(cluster); + _positionCalc->calculateAndSetPosition(cluster, hcalCuts); } } double resCluster2; @@ -243,7 +253,15 @@ void PFlow2DClusterizerWithTime::growPFClusters(const reco::PFCluster& topo, if (cell_layer == PFLayer::HCAL_BARREL2 && std::abs(refhit->positionREP().eta()) > 0.34) { cell_layer *= 100; } - const double recHitEnergyNorm = _recHitEnergyNorms.find(cell_layer)->second; + double recHitEnergyNorm = _recHitEnergyNorms.find(cell_layer)->second; + if (hcalCuts != nullptr) { // this means, cutsFromDB is set to True in the producer code + if ((cell_layer == PFLayer::HCAL_BARREL1) || (cell_layer == PFLayer::HCAL_ENDCAP)) { + HcalDetId thisId = refhit->detId(); + const HcalPFCut* item = hcalCuts->getValues(thisId.rawId()); + recHitEnergyNorm = item->noiseThreshold(); + } + } + math::XYZPoint topocellpos_xyz(refhit->position()); dist2.clear(); frac.clear(); @@ -307,12 +325,12 @@ void PFlow2DClusterizerWithTime::growPFClusters(const reco::PFCluster& topo, double diff2 = 0.0; for (unsigned i = 0; i < clusters.size(); ++i) { if (_convergencePosCalc) { - _convergencePosCalc->calculateAndSetPosition(clusters[i]); + _convergencePosCalc->calculateAndSetPosition(clusters[i], hcalCuts); } else { if (clusters.size() == 1 && _allCellsPosCalc) { - _allCellsPosCalc->calculateAndSetPosition(clusters[i]); + _allCellsPosCalc->calculateAndSetPosition(clusters[i], hcalCuts); } else { - _positionCalc->calculateAndSetPosition(clusters[i]); + _positionCalc->calculateAndSetPosition(clusters[i], hcalCuts); } } const double delta2 = reco::deltaR2(clusters[i].positionREP(), clus_prev_pos[i]); @@ -326,7 +344,7 @@ void PFlow2DClusterizerWithTime::growPFClusters(const reco::PFCluster& topo, clus_chi2.clear(); clus_chi2_nhits.clear(); clus_prev_timeres2.clear(); - growPFClusters(topo, seedable, toleranceScaling, iter + 1, diff, clusters); + growPFClusters(topo, seedable, toleranceScaling, iter + 1, diff, clusters, hcalCuts); } void PFlow2DClusterizerWithTime::prunePFClusters(reco::PFClusterCollection& clusters) const { diff --git a/RecoParticleFlow/PFClusterProducer/plugins/PassThruSeedFinder.cc b/RecoParticleFlow/PFClusterProducer/plugins/PassThruSeedFinder.cc index a836ea08ed833..230fae2abf94c 100644 --- a/RecoParticleFlow/PFClusterProducer/plugins/PassThruSeedFinder.cc +++ b/RecoParticleFlow/PFClusterProducer/plugins/PassThruSeedFinder.cc @@ -10,7 +10,8 @@ class PassThruSeedFinder : public SeedFinderBase { void findSeeds(const edm::Handle& input, const std::vector& mask, - std::vector& seedable) override; + std::vector& seedable, + const HcalPFCuts*) override; private: }; @@ -22,6 +23,7 @@ PassThruSeedFinder::PassThruSeedFinder(const edm::ParameterSet& conf) : SeedFind // the starting state of seedable is all false! void PassThruSeedFinder::findSeeds(const edm::Handle& input, const std::vector& mask, - std::vector& seedable) { + std::vector& seedable, + const HcalPFCuts*) { seedable = std::vector(input->size(), true); } diff --git a/RecoParticleFlow/PFClusterProducer/plugins/SimMappers/GenericSimClusterMapper.cc b/RecoParticleFlow/PFClusterProducer/plugins/SimMappers/GenericSimClusterMapper.cc index a8c4830cd48e9..f5cfd69ed934d 100644 --- a/RecoParticleFlow/PFClusterProducer/plugins/SimMappers/GenericSimClusterMapper.cc +++ b/RecoParticleFlow/PFClusterProducer/plugins/SimMappers/GenericSimClusterMapper.cc @@ -5,6 +5,8 @@ #include "RecoParticleFlow/PFClusterProducer/interface/InitialClusteringStepBase.h" #include "SimDataFormats/CaloAnalysis/interface/SimCluster.h" #include "SimDataFormats/CaloAnalysis/interface/SimClusterFwd.h" +#include "CondFormats/DataRecord/interface/HcalPFCutsRcd.h" +#include "CondTools/Hcal/interface/HcalPFCutsHandler.h" class GenericSimClusterMapper : public InitialClusteringStepBase { typedef GenericSimClusterMapper B2DGT; @@ -23,7 +25,8 @@ class GenericSimClusterMapper : public InitialClusteringStepBase { void buildClusters(const edm::Handle&, const std::vector&, const std::vector&, - reco::PFClusterCollection&) override; + reco::PFClusterCollection&, + const HcalPFCuts*) override; private: edm::EDGetTokenT _simClusterToken; @@ -49,7 +52,8 @@ void GenericSimClusterMapper::updateEvent(const edm::Event& ev) { ev.getByToken( void GenericSimClusterMapper::buildClusters(const edm::Handle& input, const std::vector& rechitMask, const std::vector& seedable, - reco::PFClusterCollection& output) { + reco::PFClusterCollection& output, + const HcalPFCuts* hcalCuts) { const SimClusterCollection& simClusters = *_simClusterH; auto const& hits = *input; diff --git a/RecoParticleFlow/PFClusterProducer/plugins/SimMappers/RealisticSimClusterMapper.cc b/RecoParticleFlow/PFClusterProducer/plugins/SimMappers/RealisticSimClusterMapper.cc index 5a045705fae40..a9f75a22b3ffd 100644 --- a/RecoParticleFlow/PFClusterProducer/plugins/SimMappers/RealisticSimClusterMapper.cc +++ b/RecoParticleFlow/PFClusterProducer/plugins/SimMappers/RealisticSimClusterMapper.cc @@ -16,6 +16,8 @@ #include "RecoParticleFlow/PFClusterProducer/plugins/SimMappers/RealisticHitToClusterAssociator.h" #include "SimDataFormats/CaloAnalysis/interface/SimCluster.h" #include "SimDataFormats/CaloAnalysis/interface/SimClusterFwd.h" +#include "CondFormats/DataRecord/interface/HcalPFCutsRcd.h" +#include "CondTools/Hcal/interface/HcalPFCutsHandler.h" #include @@ -48,7 +50,8 @@ class RealisticSimClusterMapper : public InitialClusteringStepBase { void buildClusters(const edm::Handle&, const std::vector&, const std::vector&, - reco::PFClusterCollection&) override; + reco::PFClusterCollection&, + const HcalPFCuts*) override; private: hgcal::RecHitTools rhtools_; @@ -107,7 +110,8 @@ void RealisticSimClusterMapper::update(const edm::EventSetup& es) { rhtools_.set void RealisticSimClusterMapper::buildClusters(const edm::Handle& input, const std::vector& rechitMask, const std::vector& seedable, - reco::PFClusterCollection& output) { + reco::PFClusterCollection& output, + const HcalPFCuts* hcalCuts) { const SimClusterCollection& simClusters = *simClusterH_; auto const& hits = *input; RealisticHitToClusterAssociator realisticAssociator; diff --git a/RecoParticleFlow/PFClusterProducer/python/particleFlowClusterECALUncorrected_cfi.py b/RecoParticleFlow/PFClusterProducer/python/particleFlowClusterECALUncorrected_cfi.py index 44a361023141c..e86856d6a048b 100644 --- a/RecoParticleFlow/PFClusterProducer/python/particleFlowClusterECALUncorrected_cfi.py +++ b/RecoParticleFlow/PFClusterProducer/python/particleFlowClusterECALUncorrected_cfi.py @@ -60,7 +60,7 @@ seedingThresholdPt = cms.double(0.0) ) ), - nNeighbours = cms.int32(8) + nNeighbours = cms.int32(8), ) # topo clusterizer @@ -131,6 +131,7 @@ particleFlowClusterECALUncorrected = cms.EDProducer( "PFClusterProducer", recHitsSource = cms.InputTag("particleFlowRecHitECAL"), + usePFThresholdsFromDB = cms.bool(False), recHitCleaners = cms.VPSet(), #seedCleaners = cms.VPSet(_seedsFlagsCleaner_ECAL,_seedCleaner_ECAL), seedCleaners = cms.VPSet(_seedsFlagsCleaner_ECAL), diff --git a/RecoParticleFlow/PFClusterProducer/python/particleFlowClusterHBHE_cfi.py b/RecoParticleFlow/PFClusterProducer/python/particleFlowClusterHBHE_cfi.py index e602f29e15d75..36b780828dbb2 100644 --- a/RecoParticleFlow/PFClusterProducer/python/particleFlowClusterHBHE_cfi.py +++ b/RecoParticleFlow/PFClusterProducer/python/particleFlowClusterHBHE_cfi.py @@ -19,6 +19,7 @@ particleFlowClusterHBHE = cms.EDProducer( "PFClusterProducer", recHitsSource = cms.InputTag("particleFlowRecHitHBHE"), + usePFThresholdsFromDB = cms.bool(False), recHitCleaners = cms.VPSet(), seedCleaners = cms.VPSet(), seedFinder = cms.PSet( @@ -35,7 +36,7 @@ seedingThresholdPt = cms.vdouble(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) ) ), - nNeighbours = cms.int32(4) + nNeighbours = cms.int32(4), ), initialClusteringStep = cms.PSet( algoName = cms.string("Basic2DGenericTopoClusterizer"), @@ -163,3 +164,8 @@ particleFlowClusterHBHEOnly = particleFlowClusterHBHE.clone( recHitsSource = "particleFlowRecHitHBHEOnly" ) + +#--- Use DB conditions for cuts&seeds for Run3 and phase2 +from Configuration.Eras.Modifier_hcalPfCutsFromDB_cff import hcalPfCutsFromDB +hcalPfCutsFromDB.toModify( particleFlowClusterHBHE, + usePFThresholdsFromDB = True) diff --git a/RecoParticleFlow/PFClusterProducer/python/particleFlowClusterHCAL_cfi.py b/RecoParticleFlow/PFClusterProducer/python/particleFlowClusterHCAL_cfi.py index 6245a8dc1847f..ebab00eafee74 100644 --- a/RecoParticleFlow/PFClusterProducer/python/particleFlowClusterHCAL_cfi.py +++ b/RecoParticleFlow/PFClusterProducer/python/particleFlowClusterHCAL_cfi.py @@ -9,6 +9,7 @@ particleFlowClusterHCAL = cms.EDProducer('PFMultiDepthClusterProducer', clustersSource = cms.InputTag("particleFlowClusterHBHE"), + usePFThresholdsFromDB = cms.bool(False), pfClusterBuilder =cms.PSet( algoName = cms.string("PFMultiDepthClusterizer"), nSigmaEta = cms.double(2.), @@ -65,3 +66,8 @@ particleFlowClusterHCALOnly = particleFlowClusterHCAL.clone( clustersSource = "particleFlowClusterHBHEOnly" ) + +#--- Use DB conditions for cuts&seeds for Run3 and Phase2 +from Configuration.Eras.Modifier_hcalPfCutsFromDB_cff import hcalPfCutsFromDB +hcalPfCutsFromDB.toModify( particleFlowClusterHCAL, + usePFThresholdsFromDB = True) diff --git a/RecoParticleFlow/PFClusterProducer/python/particleFlowClusterHF_cfi.py b/RecoParticleFlow/PFClusterProducer/python/particleFlowClusterHF_cfi.py index 2f0ab88f446ab..76aa58c69f062 100644 --- a/RecoParticleFlow/PFClusterProducer/python/particleFlowClusterHF_cfi.py +++ b/RecoParticleFlow/PFClusterProducer/python/particleFlowClusterHF_cfi.py @@ -45,7 +45,7 @@ ) ), - nNeighbours = cms.int32(0) + nNeighbours = cms.int32(0), ) #topo clusters @@ -104,6 +104,7 @@ particleFlowClusterHF = cms.EDProducer( "PFClusterProducer", recHitsSource = cms.InputTag("particleFlowRecHitHF"), + usePFThresholdsFromDB = cms.bool(False), recHitCleaners = cms.VPSet(), seedCleaners = cms.VPSet(), seedFinder = _localMaxSeeds_HF, diff --git a/RecoParticleFlow/PFClusterProducer/python/particleFlowClusterHGC_cfi.py b/RecoParticleFlow/PFClusterProducer/python/particleFlowClusterHGC_cfi.py index 51a367643574e..bd32a4e366a55 100644 --- a/RecoParticleFlow/PFClusterProducer/python/particleFlowClusterHGC_cfi.py +++ b/RecoParticleFlow/PFClusterProducer/python/particleFlowClusterHGC_cfi.py @@ -60,6 +60,7 @@ particleFlowClusterHGCal = cms.EDProducer( "PFClusterProducer", recHitsSource = cms.InputTag("particleFlowRecHitHGC"), + usePFThresholdsFromDB = cms.bool(False), recHitCleaners = cms.VPSet(), seedCleaners = cms.VPSet(), seedFinder = _passThruSeeds_HGCal, diff --git a/RecoParticleFlow/PFClusterProducer/python/particleFlowClusterHO_cfi.py b/RecoParticleFlow/PFClusterProducer/python/particleFlowClusterHO_cfi.py index b04e9ea036057..6d1fbfc4da45d 100644 --- a/RecoParticleFlow/PFClusterProducer/python/particleFlowClusterHO_cfi.py +++ b/RecoParticleFlow/PFClusterProducer/python/particleFlowClusterHO_cfi.py @@ -19,7 +19,7 @@ seedingThresholdPt = cms.double(0.0) ) ), - nNeighbours = cms.int32(4) + nNeighbours = cms.int32(4), ) #topo clusters @@ -77,6 +77,7 @@ particleFlowClusterHO = cms.EDProducer( "PFClusterProducer", recHitsSource = cms.InputTag("particleFlowRecHitHO"), + usePFThresholdsFromDB = cms.bool(False), recHitCleaners = cms.VPSet(), seedCleaners = cms.VPSet(), seedFinder = _localMaxSeeds_HO, diff --git a/RecoParticleFlow/PFClusterProducer/python/particleFlowClusterPS_cfi.py b/RecoParticleFlow/PFClusterProducer/python/particleFlowClusterPS_cfi.py index 9f6c49f0ce2e6..d2b9c8ae2ec08 100644 --- a/RecoParticleFlow/PFClusterProducer/python/particleFlowClusterPS_cfi.py +++ b/RecoParticleFlow/PFClusterProducer/python/particleFlowClusterPS_cfi.py @@ -18,7 +18,7 @@ seedingThresholdPt = cms.double(0.0) ) ), - nNeighbours = cms.int32(4) + nNeighbours = cms.int32(4), ) #topo clusters @@ -71,6 +71,7 @@ particleFlowClusterPS = cms.EDProducer( "PFClusterProducer", recHitsSource = cms.InputTag("particleFlowRecHitPS"), + usePFThresholdsFromDB = cms.bool(False), recHitCleaners = cms.VPSet(), seedCleaners = cms.VPSet(), seedFinder = _localMaxSeeds_PS, diff --git a/RecoParticleFlow/PFClusterProducer/python/particleFlowRecHitHBHE_cfi.py b/RecoParticleFlow/PFClusterProducer/python/particleFlowRecHitHBHE_cfi.py index 272ae984a0876..9d19e38e4409c 100644 --- a/RecoParticleFlow/PFClusterProducer/python/particleFlowRecHitHBHE_cfi.py +++ b/RecoParticleFlow/PFClusterProducer/python/particleFlowRecHitHBHE_cfi.py @@ -19,6 +19,7 @@ qualityTests = cms.VPSet( cms.PSet( name = cms.string("PFRecHitQTestHCALThresholdVsDepth"), + usePFThresholdsFromDB = cms.bool(False), cuts = cms.VPSet( cms.PSet( depth=cms.vint32(1, 2, 3, 4), @@ -61,6 +62,12 @@ producers = {0 : dict(qualityTests = {0 : dict(cuts = {0 : dict(threshold = _thresholdsHBphase1_2023) } ) } ) }, ) +#--- Use DB conditions for cuts&seeds for Run3 and Phase2 +from Configuration.Eras.Modifier_hcalPfCutsFromDB_cff import hcalPfCutsFromDB +hcalPfCutsFromDB.toModify( particleFlowRecHitHBHE, + producers = {0 : dict(qualityTests = {0 : dict(usePFThresholdsFromDB = True) } ) }, +) + # HCALonly WF particleFlowRecHitHBHEOnly = particleFlowRecHitHBHE.clone( producers = { 0: dict(src = "hbheprereco") } diff --git a/RecoParticleFlow/PFClusterProducer/python/particleFlowRecHitHF_cfi.py b/RecoParticleFlow/PFClusterProducer/python/particleFlowRecHitHF_cfi.py index f09437e55ddcc..e056f8f9bed16 100644 --- a/RecoParticleFlow/PFClusterProducer/python/particleFlowRecHitHF_cfi.py +++ b/RecoParticleFlow/PFClusterProducer/python/particleFlowRecHitHF_cfi.py @@ -27,6 +27,7 @@ ), cms.PSet( name = cms.string("PFRecHitQTestHCALThresholdVsDepth"), + usePFThresholdsFromDB = cms.bool(False), cuts = cms.VPSet( cms.PSet( depth = cms.vint32(1,2),