ATLAS Offline Software
Loading...
Searching...
No Matches
TrigDecisionMakerValidator.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7
8TrigDec::TrigDecisionMakerValidator::TrigDecisionMakerValidator(const std::string &name, ISvcLocator *pSvcLocator)
9 : ::AthReentrantAlgorithm(name, pSvcLocator)
10{}
11
13
14StatusCode
16 ATH_CHECK( m_tdt.retrieve() );
19 return StatusCode::SUCCESS;
20}
21
22StatusCode TrigDec::TrigDecisionMakerValidator::reportError(const std::string& item, const std::string& msg) const {
24 ATH_MSG_ERROR(item << ": " << msg);
25 return StatusCode::FAILURE;
26 }
27 ATH_MSG_WARNING(item << ": " << msg);
28 return StatusCode::SUCCESS;
29}
30
31StatusCode TrigDec::TrigDecisionMakerValidator::execute(const EventContext& context) const {
32
33 if (context.eventID().event_number() % m_samplingFrequence != 0) {
34 return StatusCode::SUCCESS;
35 }
36
37 ATH_MSG_DEBUG("Validator is checking this event.");
38
39 // Need to potentially skip the checks on L1 when using xAOD::CTPResult (see ATR-32736)
40 bool validL1Check = true;
43 ATH_CHECK(ctpResult.isValid());
44 if (!ctpResult->checkForIssues().empty()) { // If not empty then issues have are present for xAOD::CTPResult
45 ATH_MSG_WARNING("Issues seen with L1 information stored in xAOD::CTPResult, skipping L1 checks...");
46 validL1Check = false;
47 }
48 }
49
50 if (m_doL1 && validL1Check) {
51
52 const Trig::ChainGroup* l1group = m_tdt->getChainGroup("L1_.*");
53 const std::vector<std::string> items = l1group->getListOfTriggers();
54 const std::vector<bool> isPassed = l1group->isPassedForEach();
55 const std::vector<unsigned int> bits = l1group->isPassedBitsForEach();
56
57 size_t passL1 = 0;
58 for (size_t i = 0; i<items.size(); i++) {
59
60 const std::string& item = items[i];
61 const bool passedPhysics = isPassed[i];
62 const unsigned passBits = bits[i];
63 const bool l1TBP = (passBits & TrigDefs::L1_isPassedBeforePrescale);
64 const bool l1TAP = (passBits & TrigDefs::L1_isPassedAfterPrescale);
65 const bool l1TAV = (passBits & TrigDefs::L1_isPassedAfterVeto);
66
67 if (passedPhysics) {
68 ++passL1;
69 ATH_MSG_VERBOSE("Passing L1:" << item);
70 }
71
72 if (l1TAP && !l1TBP) {
73 ATH_CHECK( reportError(item, "Cannot pass after L1 prescale if failing before L1 prescale") );
74 }
75
76 if (l1TAV && (!l1TBP || !l1TAP)) {
77 ATH_CHECK( reportError(item, "Cannot pass after L1 veto if failing either before L1 prescale or after L1 prescale") );
78 }
79
80 if (l1TAV && !passedPhysics) {
81 ATH_CHECK( reportError(item, "Inconsistency - L1 pass after veto is true but isPassed is false") );
82 }
83
84 }
85
86 ATH_MSG_DEBUG("Passing L1 Items: " << passL1);
87 if (!passL1) {
88 ATH_CHECK( reportError("L1", "Zero L1 items passed this event.") );
89 }
90
91 }
92
93 if (m_doHLT) {
94
95 const Trig::ChainGroup* hltgroup = m_tdt->getChainGroup("HLT_.*");
96 const std::vector<std::string> items = hltgroup->getListOfTriggers();
97 const std::vector<bool> isPassed = hltgroup->isPassedForEach();
98 const std::vector<unsigned int> bits = hltgroup->isPassedBitsForEach();
99
101 if (m_edmVersion >= 3) {
104 if (!terminusNode) {
105 ATH_CHECK( reportError(m_navigationReadHandleKey.key(), "Terminus Node could not be located from the primary navigation collection.") );
106 }
107 TrigCompositeUtils::decisionIDs(terminusNode, terminusIDs);
108 }
109
110 size_t passHLT = 0;
111 for (size_t i = 0; i<items.size(); i++) {
112
113 const std::string& chain = items[i];
114 const bool passedPhysics = isPassed[i];
115 const unsigned passBits = bits[i];
116 const bool l1TBP = (passBits & TrigDefs::L1_isPassedBeforePrescale);
117 const bool l1TAP = (passBits & TrigDefs::L1_isPassedAfterPrescale);
118 const bool l1TAV = (passBits & TrigDefs::L1_isPassedAfterVeto);
119 const bool isPrescaled = (passBits & TrigDefs::EF_prescaled);
120 const bool isPassedRaw = (passBits & TrigDefs::EF_passedRaw);
121 const bool inTerminusNode = (terminusIDs.count( HLT::Identifier(chain).numeric() ) == 1);
122
123 if (isPassedRaw) {
124 ++passHLT;
125 ATH_MSG_VERBOSE("Passing HLT:" << chain);
126 }
127
128 if (l1TAP && !l1TBP) {
129 ATH_CHECK( reportError(chain, "Cannot pass after L1 prescale if failing before L1 prescale") );
130 }
131
132 if (l1TAV && (!l1TBP || !l1TAP)) {
133 ATH_CHECK( reportError(chain, "Cannot pass after L1 veto if failing either before L1 prescale or after L1 prescale") );
134 }
135
136 if (passedPhysics && !isPassedRaw) {
137 ATH_CHECK( reportError(chain, "Cannot pass for physics if failing at the HLT") );
138 }
139
140 if (passedPhysics && !l1TAV) {
141 ATH_CHECK( reportError(chain, "Cannot pass for physics if failing at L1") );
142 }
143
144 // These check(s) are only valid for the R3 trigger
145 if (m_edmVersion >= 3) {
146 if (isPassedRaw && isPrescaled) { // (possible due to passthrough & rerun in R1, R2)
147 ATH_CHECK( reportError(chain, "Cannot pass if prescaled") );
148 }
149
150 if (passedPhysics && !inTerminusNode) {
151 ATH_CHECK( reportError(chain, "Inconsistency - passing for physics, but not present in the navigation terminus node") );
152 }
153
154 if (inTerminusNode && !isPassedRaw) {
155 ATH_CHECK( reportError(chain, "Inconsistency - in the navigation terminus node, but not passing raw") );
156 }
157 }
158
159 }
160
161 ATH_MSG_DEBUG("Passing HLT Chains: " << passHLT);
162 if (!passHLT) {
163 ATH_CHECK( reportError("HLT", "Zero HLT chains passed this event.") );
164 }
165
166 }
167
168 return StatusCode::SUCCESS;
169}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
An algorithm that can be simultaneously executed in multiple threads.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
TrigDecisionMakerValidator(const std::string &name, ISvcLocator *pSvcLocator)
PublicToolHandle< Trig::TrigDecisionTool > m_tdt
virtual StatusCode execute(const EventContext &context) const override
SG::ReadHandleKey< TrigCompositeUtils::DecisionContainer > m_navigationReadHandleKey
SG::ReadHandleKey< xAOD::CTPResult > m_CTPResultKeyIn
StatusCode reportError(const std::string &item, const std::string &msg) const
std::vector< bool > isPassedForEach(unsigned int condition=TrigDefs::Physics) const
return vector with isPassed decision for each chain
std::vector< unsigned int > isPassedBitsForEach() const
return result of isPassedBits for each chain in the group
std::vector< std::string > getListOfTriggers() const
std::set< DecisionID > DecisionIDContainer
const Decision * getTerminusNode(SG::ReadHandle< DecisionContainer > &container)
void decisionIDs(const Decision *d, DecisionIDContainer &destination)
Extracts DecisionIDs stored in the Decision object.