Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-01-24 01:14:43

0001 #include "FWCore/Framework/interface/Event.h"
0002 #include "FWCore/Framework/interface/EventSetup.h"
0003 #include "FWCore/Framework/interface/ESHandle.h"
0004 #include "FWCore/Common/interface/TriggerNames.h"
0005 #include "FWCore/Utilities/interface/Exception.h"
0006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0007 #include "DataFormats/Common/interface/Handle.h"
0008 #include "DataFormats/Common/interface/TriggerResults.h"
0009 #include "DataFormats/L1TGlobal/interface/GlobalAlgBlk.h"
0010 #include "HLTrigger/HLTcore/interface/TriggerExpressionData.h"
0011 
0012 namespace triggerExpression {
0013 
0014   void Data::setPathStatusToken(edm::BranchDescription const& branch, edm::ConsumesCollector&& iC) {
0015     m_pathStatusTokens[branch.moduleLabel()] = iC.consumes<edm::HLTPathStatus>(
0016         edm::InputTag(branch.moduleLabel(), branch.productInstanceName(), branch.processName()));
0017   }
0018 
0019   bool Data::setEvent(const edm::Event& event, const edm::EventSetup& setup) {
0020     // cache the event number
0021     m_eventNumber = event.id().event();
0022 
0023     // access L1 objects only if L1 is used
0024     if (hasL1T()) {
0025       // cache the L1 GT results objects
0026       auto const& l1t = edm::get(event, m_l1tResultsToken);
0027       if (l1t.size() == 0 or l1t.isEmpty(0)) {
0028         m_l1tResults = nullptr;
0029         return false;
0030       }
0031       if (m_l1tIgnoreMaskAndPrescale)
0032         m_l1tResults = &l1t.at(0, 0).getAlgoDecisionInitial();
0033       else
0034         m_l1tResults = &l1t.at(0, 0).getAlgoDecisionFinal();
0035 
0036       // cache the L1 trigger menu
0037       unsigned long long l1tCacheID = setup.get<L1TUtmTriggerMenuRcd>().cacheIdentifier();
0038       if (m_l1tCacheID == l1tCacheID) {
0039         m_l1tUpdated = false;
0040       } else {
0041         m_l1tMenu = &setup.getData(m_l1tUtmTriggerMenuToken);
0042         m_l1tCacheID = l1tCacheID;
0043         m_l1tUpdated = true;
0044       }
0045     }
0046 
0047     // access HLT objects only if HLT is used
0048     if (usePathStatus()) {
0049       m_pathStatus.clear();
0050       std::vector<std::string> triggerNames;
0051       for (auto const& p : m_pathStatusTokens) {
0052         auto const& handle = event.getHandle(p.second);
0053         if (handle.isValid()) {
0054           m_pathStatus.push_back(handle->accept());
0055           triggerNames.push_back(p.first);
0056         }
0057       }
0058       m_hltUpdated = m_triggerNames != triggerNames;
0059       m_triggerNames = triggerNames;
0060     } else if (hasHLT()) {
0061       // cache the HLT TriggerResults
0062       m_hltResults = &edm::get(event, m_hltResultsToken);
0063       if (not m_hltResults)
0064         return false;
0065 
0066       // access the TriggerNames, and check if it has changed
0067       m_hltMenu = &event.triggerNames(*m_hltResults);
0068       if (m_hltMenu->parameterSetID() == m_hltCacheID) {
0069         m_hltUpdated = false;
0070       } else {
0071         m_hltCacheID = m_hltMenu->parameterSetID();
0072         m_hltUpdated = true;
0073       }
0074     }
0075 
0076     return true;
0077   }
0078 
0079 }  // namespace triggerExpression