Skip to content

Commit

Permalink
Use esConsumes in ConditionDumperInEdm
Browse files Browse the repository at this point in the history
  • Loading branch information
makortel committed Nov 3, 2021
1 parent fc5836f commit e2b5fe6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
Expand Up @@ -33,13 +33,15 @@
#include "FWCore/ParameterSet/interface/ParameterSet.h"

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

#include "FWCore/Utilities/interface/InputTag.h"

#include "DataFormats/Common/interface/ConditionsInEdm.h"
#include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerEvmReadoutRecord.h"

#include "CondFormats/DataRecord/interface/RunSummaryRcd.h"
#include "CondFormats/RunInfo/interface/RunInfo.h"

//
// class declaration
//
Expand All @@ -62,20 +64,14 @@ class ConditionDumperInEdm : public edm::one::EDProducer<edm::RunCache<edm::Cond
void endRunProduce(edm::Run&, const edm::EventSetup&) final;
void produce(edm::Event&, const edm::EventSetup&) final;

template <typename R, typename T>
const T* get(const edm::EventSetup& setup) {
edm::ESHandle<T> handle;
setup.get<R>().get(handle);
return handle.product();
}

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

const edm::InputTag gtEvmDigisLabel_;

edm::ConditionsInEventBlock eventBlock_;

const edm::EDGetTokenT<L1GlobalTriggerEvmReadoutRecord> gtEvmDigisLabelToken_;
const edm::ESGetToken<RunInfo, RunInfoRcd> runInfoToken_;
const edm::EDPutTokenT<edm::ConditionsInLumiBlock> lumiToken_;
const edm::EDPutTokenT<edm::ConditionsInRunBlock> runToken_;
const edm::EDPutTokenT<edm::ConditionsInEventBlock> eventToken_;
Expand Down
13 changes: 5 additions & 8 deletions EventFilter/L1GlobalTriggerRawToDigi/src/ConditionDumperInEdm.cc
Expand Up @@ -6,15 +6,13 @@
#include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerEvmReadoutRecord.h"
#include "DataFormats/L1GlobalTrigger/interface/L1GtfeExtWord.h"

#include "CondFormats/DataRecord/interface/RunSummaryRcd.h"
#include "CondFormats/RunInfo/interface/RunInfo.h"

//
// constructors and destructor
//
ConditionDumperInEdm::ConditionDumperInEdm(const edm::ParameterSet& iConfig)
: gtEvmDigisLabel_{iConfig.getParameter<edm::InputTag>("gtEvmDigisLabel")},
gtEvmDigisLabelToken_{consumes<L1GlobalTriggerEvmReadoutRecord>(gtEvmDigisLabel_)},
runInfoToken_{esConsumes<edm::Transition::EndRun>()},
//per LUMI products
lumiToken_{produces<edm::ConditionsInLumiBlock, edm::Transition::EndLuminosityBlock>()},
//per RUN products
Expand Down Expand Up @@ -45,11 +43,10 @@ void ConditionDumperInEdm::endRunProduce(edm::Run& run, const edm::EventSetup& s
//dump of RunInfo
auto& runBlock = *(runCache(run.index()));
{
edm::ESHandle<RunInfo> sum;
setup.get<RunInfoRcd>().get(sum);
runBlock.BStartCurrent = sum->m_start_current;
runBlock.BStopCurrent = sum->m_stop_current;
runBlock.BAvgCurrent = sum->m_avg_current;
auto const& sum = setup.getData(runInfoToken_);
runBlock.BStartCurrent = sum.m_start_current;
runBlock.BStopCurrent = sum.m_stop_current;
runBlock.BAvgCurrent = sum.m_avg_current;
}

run.emplace(runToken_, runBlock);
Expand Down

0 comments on commit e2b5fe6

Please sign in to comment.