Skip to content

Commit

Permalink
Merge pull request #30433 from JamminJones/fixL1TriggerL1TCalorimeter
Browse files Browse the repository at this point in the history
added esConsumes to modules in L1Trigger/L1TCalorimeter
  • Loading branch information
cmsbuild committed Jul 7, 2020
2 parents 6b6aaaa + 461607a commit cca619b
Show file tree
Hide file tree
Showing 11 changed files with 70 additions and 44 deletions.
1 change: 0 additions & 1 deletion L1Trigger/L1TCalorimeter/plugins/L1TCaloParamsWriter.cc
Expand Up @@ -5,7 +5,6 @@
#include "FWCore/ParameterSet/interface/ParameterSet.h"

#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/ESHandle.h"

#include "CondFormats/DataRecord/interface/L1TCaloParamsRcd.h"
#include "CondFormats/L1TObjects/interface/CaloParams.h"
Expand Down
Expand Up @@ -18,7 +18,6 @@
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/global/EDProducer.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
Expand Down
7 changes: 4 additions & 3 deletions L1Trigger/L1TCalorimeter/plugins/L1TCaloStage1LutWriter.cc
Expand Up @@ -7,6 +7,7 @@
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Utilities/interface/ESGetToken.h"

#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "CondFormats/L1TObjects/interface/CaloParams.h"
Expand Down Expand Up @@ -44,7 +45,7 @@ namespace l1t {
std::string m_conditionsLabel;

Stage1TauIsolationLUT* isoTauLut;

edm::ESGetToken<CaloParams, L1TCaloParamsRcd> m_paramsToken;
bool m_writeIsoTauLut;
// output file names
std::string m_isoTauLutName;
Expand All @@ -59,6 +60,7 @@ namespace l1t {
m_writeIsoTauLut = iConfig.getUntrackedParameter<bool>("writeIsoTauLut", false);
m_isoTauLutName = iConfig.getUntrackedParameter<std::string>("isoTauLutName", "isoTauLut.txt");
m_conditionsLabel = iConfig.getParameter<std::string>("conditionsLabel");
m_paramsToken = esConsumes<CaloParams, L1TCaloParamsRcd>(edm::ESInputTag("", m_conditionsLabel));

m_params = new CaloParamsHelper;
isoTauLut = new Stage1TauIsolationLUT(m_params);
Expand All @@ -68,8 +70,7 @@ namespace l1t {

// ------------ method called for each event ------------
void L1TCaloStage1LutWriter::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
edm::ESHandle<CaloParams> paramsHandle;
iSetup.get<L1TCaloParamsRcd>().get(m_conditionsLabel, paramsHandle);
edm::ESHandle<CaloParams> paramsHandle = iSetup.getHandle(m_paramsToken);
m_params = new (m_params) CaloParamsHelper(*paramsHandle.product());
if (!m_params) {
std::cout << "Could not retrieve params from Event Setup" << std::endl;
Expand Down
Expand Up @@ -20,7 +20,6 @@
// user include files
#include "FWCore/Framework/interface/ModuleFactory.h"
#include "FWCore/Framework/interface/ESProducer.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/ESProducts.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

Expand Down
Expand Up @@ -16,7 +16,6 @@
#include "CondFormats/L1TObjects/interface/L1CaloEtScale.h"
#include "CondFormats/DataRecord/interface/L1JetEtScaleRcd.h"
#include "CondFormats/DataRecord/interface/L1EmEtScaleRcd.h"
#include "FWCore/Framework/interface/ESHandle.h"

using namespace std;
using namespace edm;
Expand Down
Expand Up @@ -18,7 +18,6 @@
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/global/EDProducer.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
Expand Down
17 changes: 6 additions & 11 deletions L1Trigger/L1TCalorimeter/plugins/L1TPhysicalEtAdder.cc
@@ -1,11 +1,6 @@
#include "L1Trigger/L1TCalorimeter/plugins/L1TPhysicalEtAdder.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

#include "CondFormats/L1TObjects/interface/L1CaloEtScale.h"
#include "CondFormats/DataRecord/interface/L1JetEtScaleRcd.h"
#include "CondFormats/DataRecord/interface/L1HtMissScaleRcd.h"
#include "CondFormats/DataRecord/interface/L1EmEtScaleRcd.h"

#include "DataFormats/L1CaloTrigger/interface/L1CaloEmCand.h"
#include "DataFormats/L1CaloTrigger/interface/L1CaloRegion.h"
#include "DataFormats/L1CaloTrigger/interface/L1CaloCollections.h"
Expand Down Expand Up @@ -97,6 +92,9 @@ L1TPhysicalEtAdder::L1TPhysicalEtAdder(const edm::ParameterSet& ps) {
EtSumToken_ = consumes<EtSumBxCollection>(ps.getParameter<edm::InputTag>("InputCollection"));
HfSumsToken_ = consumes<CaloSpareBxCollection>(ps.getParameter<edm::InputTag>("InputHFSumsCollection"));
HfCountsToken_ = consumes<CaloSpareBxCollection>(ps.getParameter<edm::InputTag>("InputHFCountsCollection"));
emScaleToken_ = esConsumes<L1CaloEtScale, L1EmEtScaleRcd>();
jetScaleToken_ = esConsumes<L1CaloEtScale, L1JetEtScaleRcd>();
htMissScaleToken_ = esConsumes<L1CaloEtScale, L1HtMissScaleRcd>();
}

L1TPhysicalEtAdder::~L1TPhysicalEtAdder() {}
Expand Down Expand Up @@ -132,14 +130,11 @@ void L1TPhysicalEtAdder::produce(edm::StreamID, edm::Event& iEvent, const edm::E
iEvent.getByToken(HfCountsToken_, old_hfcounts);

//get the proper scales for conversion to physical et
edm::ESHandle<L1CaloEtScale> emScale;
iSetup.get<L1EmEtScaleRcd>().get(emScale);
edm::ESHandle<L1CaloEtScale> emScale = iSetup.getHandle(emScaleToken_);

edm::ESHandle<L1CaloEtScale> jetScale;
iSetup.get<L1JetEtScaleRcd>().get(jetScale);
edm::ESHandle<L1CaloEtScale> jetScale = iSetup.getHandle(jetScaleToken_);

edm::ESHandle<L1CaloEtScale> htMissScale;
iSetup.get<L1HtMissScaleRcd>().get(htMissScale);
edm::ESHandle<L1CaloEtScale> htMissScale = iSetup.getHandle(htMissScaleToken_);

int firstBX = old_egammas->getFirstBX();
int lastBX = old_egammas->getLastBX();
Expand Down
8 changes: 8 additions & 0 deletions L1Trigger/L1TCalorimeter/plugins/L1TPhysicalEtAdder.h
Expand Up @@ -22,12 +22,17 @@
#include "FWCore/Utilities/interface/EDGetToken.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/Utilities/interface/ESGetToken.h"

#include "DataFormats/L1Trigger/interface/EGamma.h"
#include "DataFormats/L1Trigger/interface/Tau.h"
#include "DataFormats/L1Trigger/interface/Jet.h"
#include "DataFormats/L1Trigger/interface/EtSum.h"
#include "DataFormats/L1Trigger/interface/CaloSpare.h"
#include "CondFormats/L1TObjects/interface/L1CaloEtScale.h"
#include "CondFormats/DataRecord/interface/L1JetEtScaleRcd.h"
#include "CondFormats/DataRecord/interface/L1HtMissScaleRcd.h"
#include "CondFormats/DataRecord/interface/L1EmEtScaleRcd.h"

//
// class declaration
Expand All @@ -53,6 +58,9 @@ class L1TPhysicalEtAdder : public edm::global::EDProducer<> {
edm::EDGetToken EtSumToken_;
edm::EDGetToken HfSumsToken_;
edm::EDGetToken HfCountsToken_;
edm::ESGetToken<L1CaloEtScale, L1EmEtScaleRcd> emScaleToken_;
edm::ESGetToken<L1CaloEtScale, L1JetEtScaleRcd> jetScaleToken_;
edm::ESGetToken<L1CaloEtScale, L1HtMissScaleRcd> htMissScaleToken_;
};

#endif
40 changes: 26 additions & 14 deletions L1Trigger/L1TCalorimeter/plugins/L1TStage1Layer2Producer.cc
Expand Up @@ -21,6 +21,7 @@
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Utilities/interface/EDGetToken.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "FWCore/Utilities/interface/ESGetToken.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

#include "CondFormats/L1TObjects/interface/L1CaloEtScale.h"
Expand Down Expand Up @@ -91,6 +92,12 @@ class L1TStage1Layer2Producer : public stream::EDProducer<> {
// to be extended with other "consumes" stuff
EDGetTokenT<BXVector<CaloRegion>> regionToken;
EDGetTokenT<BXVector<CaloEmCand>> candsToken;
edm::ESGetToken<CaloParams, L1TCaloParamsRcd> paramsToken;
edm::ESGetToken<CaloConfig, L1TCaloConfigRcd> configToken;
edm::ESGetToken<L1CaloEtScale, L1EmEtScaleRcd> emScaleToken;
edm::ESGetToken<L1CaloEtScale, L1JetEtScaleRcd> jetScaleToken;
edm::ESGetToken<L1CaloEtScale, L1HtMissScaleRcd> htMissScaleToken;
edm::ESGetToken<L1CaloEtScale, L1HfRingEtScaleRcd> hfRingScaleToken;
};

//
Expand All @@ -116,6 +123,19 @@ L1TStage1Layer2Producer::L1TStage1Layer2Producer(const ParameterSet& iConfig) {

m_params = new CaloParamsHelper;

paramsToken =
esConsumes<CaloParams, L1TCaloParamsRcd, edm::Transition::BeginRun>(edm::ESInputTag("", m_conditionsLabel));
configToken =
esConsumes<CaloConfig, L1TCaloConfigRcd, edm::Transition::BeginRun>(edm::ESInputTag("", m_conditionsLabel));
emScaleToken =
esConsumes<L1CaloEtScale, L1EmEtScaleRcd, edm::Transition::BeginRun>(edm::ESInputTag("", m_conditionsLabel));
jetScaleToken =
esConsumes<L1CaloEtScale, L1JetEtScaleRcd, edm::Transition::BeginRun>(edm::ESInputTag("", m_conditionsLabel));
htMissScaleToken =
esConsumes<L1CaloEtScale, L1HtMissScaleRcd, edm::Transition::BeginRun>(edm::ESInputTag("", m_conditionsLabel));
hfRingScaleToken =
esConsumes<L1CaloEtScale, L1HfRingEtScaleRcd, edm::Transition::BeginRun>(edm::ESInputTag("", m_conditionsLabel));

// set cache id to zero, will be set at first beginRun:
m_paramsCacheId = 0;
m_configCacheId = 0;
Expand Down Expand Up @@ -248,9 +268,7 @@ void L1TStage1Layer2Producer::beginRun(Run const& iR, EventSetup const& iE) {
if (id != m_paramsCacheId) {
m_paramsCacheId = id;

edm::ESHandle<CaloParams> paramsHandle;

iE.get<L1TCaloParamsRcd>().get(m_conditionsLabel, paramsHandle);
edm::ESHandle<CaloParams> paramsHandle = iE.getHandle(paramsToken);

// replace our local copy of the parameters with a new one using placement new
m_params->~CaloParamsHelper();
Expand All @@ -267,9 +285,7 @@ void L1TStage1Layer2Producer::beginRun(Run const& iR, EventSetup const& iE) {
if (id != m_configCacheId) {
m_configCacheId = id;

edm::ESHandle<CaloConfig> configHandle;

iE.get<L1TCaloConfigRcd>().get(m_conditionsLabel, configHandle);
edm::ESHandle<CaloConfig> configHandle = iE.getHandle(configToken);

if (!configHandle.product()) {
edm::LogError("l1t|caloStage1") << "Could not retrieve config from Event Setup" << std::endl;
Expand All @@ -283,21 +299,17 @@ void L1TStage1Layer2Producer::beginRun(Run const& iR, EventSetup const& iE) {
LogDebug("l1t|stage 1 jets") << "L1TStage1Layer2Producer::beginRun function called...\n";

//get the proper scales for conversion to physical et AND gt scales
edm::ESHandle<L1CaloEtScale> emScale;
iE.get<L1EmEtScaleRcd>().get(m_conditionsLabel, emScale);
edm::ESHandle<L1CaloEtScale> emScale = iE.getHandle(emScaleToken);
m_params->setEmScale(*emScale);

edm::ESHandle<L1CaloEtScale> jetScale;
iE.get<L1JetEtScaleRcd>().get(m_conditionsLabel, jetScale);
edm::ESHandle<L1CaloEtScale> jetScale = iE.getHandle(jetScaleToken);
m_params->setJetScale(*jetScale);

edm::ESHandle<L1CaloEtScale> HtMissScale;
iE.get<L1HtMissScaleRcd>().get(m_conditionsLabel, HtMissScale);
edm::ESHandle<L1CaloEtScale> HtMissScale = iE.getHandle(jetScaleToken);
m_params->setHtMissScale(*HtMissScale);

//not sure if I need this one
edm::ESHandle<L1CaloEtScale> HfRingScale;
iE.get<L1HfRingEtScaleRcd>().get(m_conditionsLabel, HfRingScale);
edm::ESHandle<L1CaloEtScale> HfRingScale = iE.getHandle(hfRingScaleToken);
m_params->setHfRingScale(*HfRingScale);

//unsigned long long id = iE.get<CaloParamsRcd>().cacheIdentifier();
Expand Down
22 changes: 16 additions & 6 deletions L1Trigger/L1TCalorimeter/plugins/L1TStage2Layer1Producer.cc
Expand Up @@ -30,6 +30,7 @@
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Utilities/interface/EDGetToken.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "FWCore/Utilities/interface/ESGetToken.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

#include "L1Trigger/L1TCalorimeter/interface/Stage2Layer1FirmwareFactory.h"
Expand Down Expand Up @@ -86,6 +87,10 @@ class L1TStage2Layer1Producer : public edm::EDProducer {
std::vector<edm::EDGetToken> ecalToken_; // this is a crazy way to store multi-BX info
std::vector<edm::EDGetToken> hcalToken_; // should be replaced with a BXVector< > or similar

edm::ESGetToken<L1CaloEcalScale, L1CaloEcalScaleRcd> ecalScaleToken_;
edm::ESGetToken<L1CaloHcalScale, L1CaloHcalScaleRcd> hcalScaleToken_;
edm::ESGetToken<CaloTPGTranscoder, CaloTPGRecord> decoderToken_;
edm::ESGetToken<CaloParams, L1TCaloParamsRcd> paramsToken_;
// parameters
unsigned long long paramsCacheId_;
unsigned fwv_;
Expand Down Expand Up @@ -113,7 +118,13 @@ L1TStage2Layer1Producer::L1TStage2Layer1Producer(const edm::ParameterSet& ps)
ecalToken_[ibx] = consumes<EcalTrigPrimDigiCollection>(ps.getParameter<edm::InputTag>("ecalToken"));
hcalToken_[ibx] = consumes<HcalTrigPrimDigiCollection>(ps.getParameter<edm::InputTag>("hcalToken"));
}

if (rctConditions_) {
ecalScaleToken_ = esConsumes<L1CaloEcalScale, L1CaloEcalScaleRcd>();
hcalScaleToken_ = esConsumes<L1CaloHcalScale, L1CaloHcalScaleRcd>();
} else {
decoderToken_ = esConsumes<CaloTPGTranscoder, CaloTPGRecord>();
}
paramsToken_ = esConsumes<CaloParams, L1TCaloParamsRcd, edm::Transition::BeginRun>();
// placeholder for the parameters
params_ = new CaloParamsHelper;

Expand All @@ -135,10 +146,10 @@ void L1TStage2Layer1Producer::produce(edm::Event& iEvent, const edm::EventSetup&
edm::ESHandle<CaloTPGTranscoder> decoder;

if (rctConditions_) {
iSetup.get<L1CaloEcalScaleRcd>().get(ecalScale);
iSetup.get<L1CaloHcalScaleRcd>().get(hcalScale);
ecalScale = iSetup.getHandle(ecalScaleToken_);
hcalScale = iSetup.getHandle(hcalScaleToken_);
} else {
iSetup.get<CaloTPGRecord>().get(decoder);
decoder = iSetup.getHandle(decoderToken_);
}

LogDebug("L1TDebug") << "First BX=" << bxFirst_ << ", last BX=" << bxLast_ << ", LSB(E)=" << params_->towerLsbE()
Expand Down Expand Up @@ -321,8 +332,7 @@ void L1TStage2Layer1Producer::beginRun(edm::Run const& iRun, edm::EventSetup con
if (id != paramsCacheId_) {
paramsCacheId_ = id;

edm::ESHandle<CaloParams> paramsHandle;
iSetup.get<L1TCaloParamsRcd>().get(paramsHandle);
edm::ESHandle<CaloParams> paramsHandle = iSetup.getHandle(paramsToken_);

// replace our local copy of the parameters with a new one using placement new
params_->~CaloParamsHelper();
Expand Down
15 changes: 10 additions & 5 deletions L1Trigger/L1TCalorimeter/plugins/L1TStage2Layer2Producer.cc
Expand Up @@ -31,6 +31,7 @@
#include "FWCore/Utilities/interface/EDGetToken.h"
#include "FWCore/Utilities/interface/EDPutToken.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "FWCore/Utilities/interface/ESGetToken.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

#include "L1Trigger/L1TCalorimeter/interface/Stage2Layer2FirmwareFactory.h"
Expand Down Expand Up @@ -70,8 +71,10 @@ class L1TStage2Layer2Producer : public edm::stream::EDProducer<> {

// ----------member data ---------------------------

// input token
// input tokens
edm::EDGetTokenT<CaloTowerBxCollection> m_towerToken;
edm::ESGetToken<CaloParams, L1TCaloParamsRcd> m_candidateToken;
edm::ESGetToken<CaloParams, L1TCaloParamsO2ORcd> m_o2oProtoToken;

// put tokens
edm::EDPutTokenT<CaloTowerBxCollection> m_towerMPToken;
Expand Down Expand Up @@ -112,6 +115,7 @@ L1TStage2Layer2Producer::L1TStage2Layer2Producer(const edm::ParameterSet& ps) {

// register what you consume and keep token for later access:
m_towerToken = consumes<CaloTowerBxCollection>(ps.getParameter<edm::InputTag>("towerToken"));
m_candidateToken = esConsumes<CaloParams, L1TCaloParamsRcd, edm::Transition::BeginRun>();

// placeholder for the parameters
m_params = new CaloParamsHelper;
Expand All @@ -121,6 +125,9 @@ L1TStage2Layer2Producer::L1TStage2Layer2Producer(const edm::ParameterSet& ps) {

// get static config flag
m_useStaticConfig = ps.getParameter<bool>("useStaticConfig");
if (!m_useStaticConfig) {
m_o2oProtoToken = esConsumes<CaloParams, L1TCaloParamsO2ORcd, edm::Transition::BeginRun>();
}

//initialize
m_paramsCacheId = 0;
Expand Down Expand Up @@ -253,14 +260,12 @@ void L1TStage2Layer2Producer::beginRun(edm::Run const& iRun, edm::EventSetup con
m_paramsCacheId = id;

// fetch payload corresponding to the current run from the CondDB
edm::ESHandle<CaloParams> candidateHandle;
iSetup.get<L1TCaloParamsRcd>().get(candidateHandle);
edm::ESHandle<CaloParams> candidateHandle = iSetup.getHandle(m_candidateToken);
std::unique_ptr<l1t::CaloParams> candidate(new l1t::CaloParams(*candidateHandle.product()));

if (!m_useStaticConfig) {
// fetch the latest greatest prototype (equivalent of static payload)
edm::ESHandle<CaloParams> o2oProtoHandle;
iSetup.get<L1TCaloParamsO2ORcd>().get(o2oProtoHandle);
edm::ESHandle<CaloParams> o2oProtoHandle = iSetup.getHandle(m_o2oProtoToken);
std::unique_ptr<l1t::CaloParams> prototype(new l1t::CaloParams(*o2oProtoHandle.product()));

// prepare to set the emulator's configuration
Expand Down

0 comments on commit cca619b

Please sign in to comment.