Skip to content

Commit

Permalink
Merge pull request #43025 from swagata87/HcalCutsFromDB_RecoPF
Browse files Browse the repository at this point in the history
Adapt PF code to read Hcal thresholds from GT
  • Loading branch information
cmsbuild authored Nov 20, 2023
2 parents 7122236 + 9990f0d commit 10f466e
Show file tree
Hide file tree
Showing 45 changed files with 366 additions and 131 deletions.
3 changes: 2 additions & 1 deletion Configuration/Eras/python/Era_Run3_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

3 changes: 3 additions & 0 deletions Configuration/Eras/python/Modifier_hcalPfCutsFromDB_cff.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import FWCore.ParameterSet.Config as cms

hcalPfCutsFromDB = cms.Modifier()
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand All @@ -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(
Expand Down Expand Up @@ -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'),
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

hltParticleFlowClusterHCAL = cms.EDProducer("PFMultiDepthClusterProducer",
clustersSource = cms.InputTag("hltParticleFlowClusterHBHE"),
usePFThresholdsFromDB = cms.bool(True),
energyCorrector = cms.PSet(

),
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -27,7 +28,8 @@
)
)
),
name = cms.string('PFRecHitQTestHCALThresholdVsDepth')
name = cms.string('PFRecHitQTestHCALThresholdVsDepth'),
usePFThresholdsFromDB = cms.bool(True)
),
cms.PSet(
cleaningThresholds = cms.vdouble(0.0),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
19 changes: 18 additions & 1 deletion HLTrigger/Configuration/python/customizeHLTforCMSSW.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"):

Expand All @@ -272,5 +288,6 @@ def customizeHLTforCMSSW(process, menuType="GRun"):

process = customizeHLTfor42497(process)
process = customizeHLTfor42943(process)

process = customizeHLTfor43025(process)

return process
26 changes: 21 additions & 5 deletions RecoLocalCalo/HcalRecAlgos/plugins/HcalChannelPropertiesEP.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -26,6 +29,7 @@ class HcalChannelPropertiesEP : public edm::ESProducer {
public:
typedef std::unique_ptr<HcalRecoParams> ReturnType1;
typedef std::unique_ptr<HcalChannelPropertiesVec> ReturnType2;
typedef std::unique_ptr<HcalPFCuts> ReturnType3;

inline HcalChannelPropertiesEP(const edm::ParameterSet&) {
auto cc1 = setWhatProduced(this, &HcalChannelPropertiesEP::produce1);
Expand All @@ -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<HcalRecNumberingRecord>().get(topoToken_);
const HcalRecoParams& params = rcd.getRecord<HcalRecoParamsRcd>().get(paramsToken_);

Expand All @@ -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<HcalDbRecord>();
const HcalDbService& cond = dbRecord.get(condToken_);
Expand Down Expand Up @@ -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<HcalPFCuts>(cuts);
prod->setTopo(&htopo);
return prod;
}

HcalChannelPropertiesEP() = delete;
HcalChannelPropertiesEP(const HcalChannelPropertiesEP&) = delete;
HcalChannelPropertiesEP& operator=(const HcalChannelPropertiesEP&) = delete;

private:
edm::ESGetToken<HcalDbService, HcalDbRecord> condToken_;
edm::ESGetToken<HcalTopology, HcalRecNumberingRecord> topoToken_;
edm::ESGetToken<HcalTopology, HcalRecNumberingRecord> topoToken_, topoToken3_;
edm::ESGetToken<HcalRecoParams, HcalRecoParamsRcd> paramsToken_;
edm::ESGetToken<HcalSeverityLevelComputer, HcalSeverityLevelComputerRcd> sevToken_;
edm::ESGetToken<HcalChannelQuality, HcalChannelQualityRcd> qualToken_;
edm::ESGetToken<CaloGeometry, CaloGeometryRecord> geomToken_;
edm::ESGetToken<HcalRecoParams, HcalChannelPropertiesAuxRecord> myParamsToken_;
edm::ESGetToken<HcalPFCuts, HcalPFCutsRcd> pfcutsToken_;
};

DEFINE_FWK_EVENTSETUP_MODULE(HcalChannelPropertiesEP);
Original file line number Diff line number Diff line change
Expand Up @@ -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 <string>
#include <iostream>
Expand Down Expand Up @@ -87,9 +89,10 @@ class InitialClusteringStepBase {
virtual void updateEvent(const edm::Event&) {}

virtual void buildClusters(const edm::Handle<reco::PFRecHitCollection>&,
const std::vector<bool>& mask, // mask flags
const std::vector<bool>& seeds, // seed flags
reco::PFClusterCollection&) = 0; //output
const std::vector<bool>& mask, // mask flags
const std::vector<bool>& 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 "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <string>

Expand All @@ -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; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <string>
#include <iostream>
Expand Down Expand Up @@ -41,7 +43,8 @@ class PFClusterBuilderBase {

virtual void buildClusters(const reco::PFClusterCollection& topos,
const std::vector<bool>& 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 "
Expand Down
Loading

0 comments on commit 10f466e

Please sign in to comment.