Skip to content

Commit

Permalink
Use esConsumes with L1TCaloLayer1FetchLUTs
Browse files Browse the repository at this point in the history
  • Loading branch information
Dr15Jones committed Oct 25, 2021
1 parent bba9847 commit 8efff7d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 10 deletions.
7 changes: 6 additions & 1 deletion L1Trigger/L1TCaloLayer1/plugins/L1TCaloLayer1.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class L1TCaloLayer1 : public edm::stream::EDProducer<> {
edm::EDGetTokenT<HcalTrigPrimDigiCollection> hcalTPSource;
edm::EDPutTokenT<CaloTowerBxCollection> towerPutToken;
edm::EDPutTokenT<L1CaloRegionCollection> regionPutToken;
const L1TCaloLayer1FetchLUTsTokens lutsTokens;

std::vector<std::array<std::array<std::array<uint32_t, nEtBins>, nCalSideBins>, nCalEtaBins> > ecalLUT;
std::vector<std::array<std::array<std::array<uint32_t, nEtBins>, nCalSideBins>, nCalEtaBins> > hcalLUT;
Expand Down Expand Up @@ -116,6 +117,9 @@ L1TCaloLayer1::L1TCaloLayer1(const edm::ParameterSet& iConfig)
hcalTPSource(consumes<HcalTrigPrimDigiCollection>(iConfig.getParameter<edm::InputTag>("hcalToken"))),
towerPutToken{produces<CaloTowerBxCollection>()},
regionPutToken{produces<L1CaloRegionCollection>()},
lutsTokens{esConsumes<edm::Transition::BeginRun>(),
esConsumes<edm::Transition::BeginRun>(),
esConsumes<edm::Transition::BeginRun>()},
ePhiMap(72 * 2, 0),
hPhiMap(72 * 2, 0),
hfPhiMap(72 * 2, 0),
Expand Down Expand Up @@ -282,7 +286,8 @@ void L1TCaloLayer1::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {

// ------------ method called when starting to processes a run ------------
void L1TCaloLayer1::beginRun(const edm::Run& iRun, const edm::EventSetup& iSetup) {
if (!L1TCaloLayer1FetchLUTs(iSetup,
if (!L1TCaloLayer1FetchLUTs(lutsTokens,
iSetup,
ecalLUT,
hcalLUT,
hfLUT,
Expand Down
16 changes: 7 additions & 9 deletions L1Trigger/L1TCaloLayer1/src/L1TCaloLayer1FetchLUTs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
using namespace l1tcalo;

bool L1TCaloLayer1FetchLUTs(
const L1TCaloLayer1FetchLUTsTokens &iTokens,
const edm::EventSetup &iSetup,
std::vector<std::array<std::array<std::array<uint32_t, nEtBins>, nCalSideBins>, nCalEtaBins> > &eLUT,
std::vector<std::array<std::array<std::array<uint32_t, nEtBins>, nCalSideBins>, nCalEtaBins> > &hLUT,
Expand All @@ -41,18 +42,16 @@ bool L1TCaloLayer1FetchLUTs(
bool useHFLUT,
int fwVersion) {
int hfValid = 1;
edm::ESHandle<HcalTrigTowerGeometry> pG;
iSetup.get<CaloGeometryRecord>().get(pG);
if (!pG->use1x1()) {
const HcalTrigTowerGeometry &pG = iSetup.getData(iTokens.geom_);
if (!pG.use1x1()) {
edm::LogError("L1TCaloLayer1FetchLUTs")
<< "Using Stage2-Layer1 but HCAL Geometry has use1x1 = 0! HF will be suppressed. Check Global Tag, etc.";
hfValid = 0;
}

// CaloParams contains all persisted parameters for Layer 1
edm::ESHandle<l1t::CaloParams> paramsHandle;
iSetup.get<L1TCaloParamsRcd>().get(paramsHandle);
if (paramsHandle.product() == nullptr) {
edm::ESHandle<l1t::CaloParams> paramsHandle = iSetup.getHandle(iTokens.params_);
if (not paramsHandle.isValid()) {
edm::LogError("L1TCaloLayer1FetchLUTs") << "Missing CaloParams object! Check Global Tag, etc.";
return false;
}
Expand Down Expand Up @@ -133,9 +132,8 @@ bool L1TCaloLayer1FetchLUTs(
const double ecalLSB = 0.5;

// get energy scale to convert input from HCAL
edm::ESHandle<CaloTPGTranscoder> decoder;
iSetup.get<CaloTPGRecord>().get(decoder);
if (decoder.product() == nullptr) {
edm::ESHandle<CaloTPGTranscoder> decoder = iSetup.getHandle(iTokens.decoder_);
if (not decoder.isValid()) {
edm::LogError("L1TCaloLayer1FetchLUTs") << "Missing CaloTPGTranscoder object! Check Global Tag, etc.";
return false;
}
Expand Down
19 changes: 19 additions & 0 deletions L1Trigger/L1TCaloLayer1/src/L1TCaloLayer1FetchLUTs.hh
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,31 @@

#include "UCTGeometry.hh"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Utilities/interface/ESGetToken.h"
#include <vector>
#include <array>

// External function declaration

class HcalTrigTowerGeometry;
class CaloGeometryRecord;
namespace l1t {
class CaloParams;
}
class L1TCaloParamsRcd;
class CaloTPGTranscoder;
class CaloTPGRecord;

struct L1TCaloLayer1FetchLUTsTokens {
template <typename T>
L1TCaloLayer1FetchLUTsTokens(T &&i1, T &&i2, T &&i3) : geom_(i1), params_(i2), decoder_(i3) {}
edm::ESGetToken<HcalTrigTowerGeometry, CaloGeometryRecord> geom_;
edm::ESGetToken<l1t::CaloParams, L1TCaloParamsRcd> params_;
edm::ESGetToken<CaloTPGTranscoder, CaloTPGRecord> decoder_;
};

bool L1TCaloLayer1FetchLUTs(
const L1TCaloLayer1FetchLUTsTokens &iTokens,
const edm::EventSetup &iSetup,
std::vector<std::array<std::array<std::array<uint32_t, l1tcalo::nEtBins>, l1tcalo::nCalSideBins>,
l1tcalo::nCalEtaBins> > &eLUT,
Expand Down

0 comments on commit 8efff7d

Please sign in to comment.