diff --git a/RecoLocalCalo/CaloTowersCreator/python/calotowermaker_cfi.py b/RecoLocalCalo/CaloTowersCreator/python/calotowermaker_cfi.py index e5413cf39701f..df5a243b03f9e 100644 --- a/RecoLocalCalo/CaloTowersCreator/python/calotowermaker_cfi.py +++ b/RecoLocalCalo/CaloTowersCreator/python/calotowermaker_cfi.py @@ -149,8 +149,9 @@ HcalPhase = cms.int32(0), # Read HBHE thresholds from Global Tag - usePFThresholdsFromDB = cms.bool(False) - + usePFThresholdsFromDB = cms.bool(False), +# Read ECAL thresholds from Global Tag + EcalRecHitThresh = cms.bool(False) ) from Configuration.Eras.Modifier_run2_HE_2018_cff import run2_HE_2018 diff --git a/RecoLocalCalo/CaloTowersCreator/src/CaloTowersCreationAlgo.cc b/RecoLocalCalo/CaloTowersCreator/src/CaloTowersCreationAlgo.cc index 81c3bacd56f39..0babbd435bb58 100644 --- a/RecoLocalCalo/CaloTowersCreator/src/CaloTowersCreationAlgo.cc +++ b/RecoLocalCalo/CaloTowersCreator/src/CaloTowersCreationAlgo.cc @@ -353,7 +353,10 @@ CaloTowersCreationAlgo::CaloTowersCreationAlgo(double EBthreshold, // nalgo=N; } -void CaloTowersCreationAlgo::setThresFromDB(const HcalPFCuts* cuts) { hcalCuts = cuts; } +void CaloTowersCreationAlgo::setThresFromDB(const EcalPFRecHitThresholds* EcalCuts, const HcalPFCuts* HcalCuts) { + ecalCuts = EcalCuts; + hcalCuts = HcalCuts; +} void CaloTowersCreationAlgo::setGeometry(const CaloTowerTopology* cttopo, const CaloTowerConstituentsMap* ctmap, @@ -629,7 +632,7 @@ void CaloTowersCreationAlgo::assignHitHcal(const CaloRecHit* recHit) { tower28.E_outer += e28; tower29.E_outer += e29; } // not a "bad" hit - } // end of special case + } // end of special case else { HcalDetId hcalDetId(detId); @@ -1253,14 +1256,22 @@ void CaloTowersCreationAlgo::getThresholdAndWeight(const DetId& detId, double& t EcalSubdetector subdet = (EcalSubdetector)(detId.subdetId()); if (subdet == EcalBarrel) { - threshold = theEBthreshold; + if (ecalCuts == nullptr) { // this means that ecalRecHitThresh_ is false + threshold = theEBthreshold; + } else { + threshold = (*ecalCuts)[detId]; + } weight = theEBweight; if (weight <= 0.) { ROOT::Math::Interpolator my(theEBGrid, theEBWeights, ROOT::Math::Interpolation::kAKIMA); weight = my.Eval(theEBEScale); } } else if (subdet == EcalEndcap) { - threshold = theEEthreshold; + if (ecalCuts == nullptr) { + threshold = theEEthreshold; + } else { + threshold = (*ecalCuts)[detId]; + } weight = theEEweight; if (weight <= 0.) { ROOT::Math::Interpolator my(theEEGrid, theEEWeights, ROOT::Math::Interpolation::kAKIMA); diff --git a/RecoLocalCalo/CaloTowersCreator/src/CaloTowersCreationAlgo.h b/RecoLocalCalo/CaloTowersCreator/src/CaloTowersCreationAlgo.h index 99d4bc75d5f64..97732a82456f8 100644 --- a/RecoLocalCalo/CaloTowersCreator/src/CaloTowersCreationAlgo.h +++ b/RecoLocalCalo/CaloTowersCreator/src/CaloTowersCreationAlgo.h @@ -30,6 +30,8 @@ #include "CondFormats/DataRecord/interface/HcalPFCutsRcd.h" #include "CondTools/Hcal/interface/HcalPFCutsHandler.h" +#include "CondFormats/EcalObjects/interface/EcalPFRecHitThresholds.h" + class CaloTowerTopology; class HcalTopology; class CaloGeometry; @@ -162,7 +164,7 @@ class CaloTowersCreationAlgo { const HcalTopology* htopo, const CaloGeometry* geo); - void setThresFromDB(const HcalPFCuts* cuts); + void setThresFromDB(const EcalPFRecHitThresholds* EcalCuts, const HcalPFCuts* HcalCuts); // pass the containers of channels status from the event record (stored in DB) // these are called in CaloTowersCreator void setHcalChStatusFromDB(const HcalChannelQuality* s) { theHcalChStatus = s; } @@ -322,6 +324,7 @@ class CaloTowersCreationAlgo { double theHOEScale; double theHF1EScale; double theHF2EScale; + const EcalPFRecHitThresholds* ecalCuts; const HcalPFCuts* hcalCuts; const CaloTowerTopology* theTowerTopology; const HcalTopology* theHcalTopology; diff --git a/RecoLocalCalo/CaloTowersCreator/src/CaloTowersCreator.cc b/RecoLocalCalo/CaloTowersCreator/src/CaloTowersCreator.cc index 4503026b5612f..94a3084a36ca6 100644 --- a/RecoLocalCalo/CaloTowersCreator/src/CaloTowersCreator.cc +++ b/RecoLocalCalo/CaloTowersCreator/src/CaloTowersCreator.cc @@ -26,6 +26,8 @@ #include "RecoLocalCalo/EcalRecAlgos/interface/EcalSeverityLevelAlgoRcd.h" #include "CondFormats/DataRecord/interface/HcalPFCutsRcd.h" #include "CondTools/Hcal/interface/HcalPFCutsHandler.h" +#include "CondFormats/EcalObjects/interface/EcalPFRecHitThresholds.h" +#include "CondFormats/DataRecord/interface/EcalPFRecHitThresholdsRcd.h" class CaloTowersCreator : public edm::stream::EDProducer<> { public: @@ -90,6 +92,11 @@ class CaloTowersCreator : public edm::stream::EDProducer<> { edm::ESGetToken hcalCutsToken_; bool cutsFromDB; HcalPFCuts const* paramPF = nullptr; + + // Ecal noise thresholds + edm::ESGetToken ecalPFRechitThresholdsToken_; + bool ecalRecHitThresh_; + EcalPFRecHitThresholds const* ecalThresholds = nullptr; }; #include "FWCore/Framework/interface/MakerMacros.h" @@ -172,9 +179,8 @@ CaloTowersCreator::CaloTowersCreator(const edm::ParameterSet& conf) useRejectedRecoveredHcalHits_(conf.getParameter("UseRejectedRecoveredHcalHits")), useRejectedRecoveredEcalHits_(conf.getParameter("UseRejectedRecoveredEcalHits")), - cutsFromDB(conf.getParameter("usePFThresholdsFromDB")) - -{ + cutsFromDB(conf.getParameter("usePFThresholdsFromDB")), + ecalRecHitThresh_(conf.getParameter("EcalRecHitThresh")) { algo_.setMissingHcalRescaleFactorForEcal(conf.getParameter("missingHcalRescaleFactorForEcal")); // register for data access @@ -193,6 +199,12 @@ CaloTowersCreator::CaloTowersCreator(const edm::ParameterSet& conf) if (cutsFromDB) { hcalCutsToken_ = esConsumes(edm::ESInputTag("", "withTopo")); } + + if (ecalRecHitThresh_) { + ecalPFRechitThresholdsToken_ = + esConsumes(); + } + const unsigned nLabels = ecalLabels_.size(); for (unsigned i = 0; i != nLabels; i++) toks_ecal_.push_back(consumes(ecalLabels_[i])); @@ -231,7 +243,12 @@ void CaloTowersCreator::beginRun(const edm::Run& run, const edm::EventSetup& es) if (cutsFromDB) { paramPF = &es.getData(hcalCutsToken_); } - algo_.setThresFromDB(paramPF); + + if (ecalRecHitThresh_) { + ecalThresholds = &es.getData(ecalPFRechitThresholdsToken_); + } + + algo_.setThresFromDB(ecalThresholds, paramPF); } void CaloTowersCreator::produce(edm::Event& e, const edm::EventSetup& c) { @@ -470,6 +487,6 @@ void CaloTowersCreator::fillDescriptions(edm::ConfigurationDescriptions& descrip desc.add >("EcalSeveritiesToBeUsedInBadTowers", {}); desc.add("HcalPhase", 0); desc.add("usePFThresholdsFromDB", true); - + desc.add("EcalRecHitThresh", false); descriptions.addDefault(desc); }