File indexing completed on 2023-03-17 11:09:25
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
0021 m_eventNumber = event.id().event();
0022
0023
0024 if (hasL1T()) {
0025
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
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
0048 if (usePathStatus()) {
0049 m_pathStatus.clear();
0050 std::vector<std::string> triggerNames;
0051 m_pathStatus.reserve(m_pathStatusTokens.size());
0052 triggerNames.reserve(m_pathStatusTokens.size());
0053 for (auto const& p : m_pathStatusTokens) {
0054 auto const& handle = event.getHandle(p.second);
0055 if (handle.isValid()) {
0056 m_pathStatus.push_back(handle->accept());
0057 triggerNames.push_back(p.first);
0058 } else {
0059 edm::LogError("MissingHLTPathStatus")
0060 << "invalid handle for requested edm::HLTPathStatus with label \"" << p.first << "\"";
0061 }
0062 }
0063 m_hltUpdated = m_triggerNames != triggerNames;
0064 m_triggerNames = triggerNames;
0065 } else if (hasHLT()) {
0066
0067 m_hltResults = &edm::get(event, m_hltResultsToken);
0068 if (not m_hltResults)
0069 return false;
0070
0071
0072 m_hltMenu = &event.triggerNames(*m_hltResults);
0073 if (m_hltMenu->parameterSetID() == m_hltCacheID) {
0074 m_hltUpdated = false;
0075 } else {
0076 m_hltCacheID = m_hltMenu->parameterSetID();
0077 m_hltUpdated = true;
0078 }
0079 }
0080
0081 return true;
0082 }
0083
0084 }