Skip to content

Commit

Permalink
add era modifier and HcalPFCuts to event record
Browse files Browse the repository at this point in the history
  • Loading branch information
RSalvatico committed Nov 16, 2023
1 parent e4bfeac commit 4fb477e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 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()
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);

0 comments on commit 4fb477e

Please sign in to comment.