Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-11-09 23:31:50

0001 #include "EventFilter/L1GlobalTriggerRawToDigi/interface/ConditionDumperInEdm.h"
0002 #include <memory>
0003 
0004 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0005 
0006 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerEvmReadoutRecord.h"
0007 #include "DataFormats/L1GlobalTrigger/interface/L1GtfeExtWord.h"
0008 
0009 //
0010 // constructors and destructor
0011 //
0012 ConditionDumperInEdm::ConditionDumperInEdm(const edm::ParameterSet& iConfig)
0013     : gtEvmDigisLabel_{iConfig.getParameter<edm::InputTag>("gtEvmDigisLabel")},
0014       gtEvmDigisLabelToken_{consumes<L1GlobalTriggerEvmReadoutRecord>(gtEvmDigisLabel_)},
0015       runInfoToken_{esConsumes<edm::Transition::EndRun>()},
0016       //per LUMI products
0017       lumiToken_{produces<edm::ConditionsInLumiBlock, edm::Transition::EndLuminosityBlock>()},
0018       //per RUN products
0019       runToken_{produces<edm::ConditionsInRunBlock, edm::Transition::EndRun>()},
0020       //per EVENT products
0021       eventToken_{produces<edm::ConditionsInEventBlock>()} {}
0022 
0023 ConditionDumperInEdm::~ConditionDumperInEdm() {}
0024 
0025 //
0026 // member functions
0027 //
0028 std::shared_ptr<edm::ConditionsInLumiBlock> ConditionDumperInEdm::globalBeginLuminosityBlock(
0029     edm::LuminosityBlock const&, edm::EventSetup const&) const {
0030   return std::make_shared<edm::ConditionsInLumiBlock>();
0031 }
0032 
0033 void ConditionDumperInEdm::endLuminosityBlockProduce(edm::LuminosityBlock& lumi, edm::EventSetup const& setup) {
0034   lumi.emplace(lumiToken_, *luminosityBlockCache(lumi.index()));
0035 }
0036 
0037 std::shared_ptr<edm::ConditionsInRunBlock> ConditionDumperInEdm::globalBeginRun(edm::Run const&,
0038                                                                                 const edm::EventSetup&) const {
0039   return std::make_shared<edm::ConditionsInRunBlock>();
0040 }
0041 
0042 void ConditionDumperInEdm::endRunProduce(edm::Run& run, const edm::EventSetup& setup) {
0043   //dump of RunInfo
0044   auto& runBlock = *(runCache(run.index()));
0045   {
0046     auto const& sum = setup.getData(runInfoToken_);
0047     runBlock.BStartCurrent = sum.m_start_current;
0048     runBlock.BStopCurrent = sum.m_stop_current;
0049     runBlock.BAvgCurrent = sum.m_avg_current;
0050   }
0051 
0052   run.emplace(runToken_, runBlock);
0053 }
0054 
0055 // ------------ method called to produce the data  ------------
0056 void ConditionDumperInEdm::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
0057   //get the L1 object
0058   edm::Handle<L1GlobalTriggerEvmReadoutRecord> gtReadoutRecordData;
0059   iEvent.getByToken(gtEvmDigisLabelToken_, gtReadoutRecordData);
0060 
0061   if (!gtReadoutRecordData.isValid()) {
0062     LogDebug("ConditionDumperInEdm") << "\nWarning: L1GlobalTriggerEvmReadoutRecord with input tag " << gtEvmDigisLabel_
0063                                      << "\nrequested in configuration, but not found in the event."
0064                                      << "\nNo BST quantities retrieved." << std::endl;
0065 
0066     iEvent.emplace(eventToken_, eventBlock_);
0067 
0068     return;
0069   }
0070 
0071   const L1GtfeExtWord& gtfeBlockData = gtReadoutRecordData->gtfeWord();
0072 
0073   //lumi info
0074   auto& lumiBlock = *luminosityBlockCache(iEvent.getLuminosityBlock().index());
0075   lumiBlock.totalIntensityBeam1 = gtfeBlockData.totalIntensityBeam1();
0076   lumiBlock.totalIntensityBeam2 = gtfeBlockData.totalIntensityBeam2();
0077 
0078   //run info
0079   auto& runBlock = *runCache(iEvent.getRun().index());
0080   runBlock.beamMomentum = gtfeBlockData.beamMomentum();
0081   runBlock.beamMode = gtfeBlockData.beamMode();
0082   runBlock.lhcFillNumber = gtfeBlockData.lhcFillNumber();
0083 
0084   //event info
0085   eventBlock_.bstMasterStatus = gtfeBlockData.bstMasterStatus();
0086   eventBlock_.turnCountNumber = gtfeBlockData.turnCountNumber();
0087 
0088   iEvent.emplace(eventToken_, eventBlock_);
0089 }