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() );
18 return StatusCode::SUCCESS;
19}
20
21StatusCode TrigDec::TrigDecisionMakerValidator::reportError(const std::string& item, const std::string& msg) const {
23 ATH_MSG_ERROR(item << ": " << msg);
24 return StatusCode::FAILURE;
25 }
26 ATH_MSG_WARNING(item << ": " << msg);
27 return StatusCode::SUCCESS;
28}
29
30StatusCode TrigDec::TrigDecisionMakerValidator::execute(const EventContext& context) const {
31
32 if (context.eventID().event_number() % m_samplingFrequence != 0) {
33 return StatusCode::SUCCESS;
34 }
35
36 ATH_MSG_DEBUG("Validator is checking this event.");
37
38 if (m_doL1) {
39
40 const Trig::ChainGroup* l1group = m_tdt->getChainGroup("L1_.*");
41 const std::vector<std::string> items = l1group->getListOfTriggers();
42 const std::vector<bool> isPassed = l1group->isPassedForEach();
43 const std::vector<unsigned int> bits = l1group->isPassedBitsForEach();
44
45 size_t passL1 = 0;
46 for (size_t i = 0; i<items.size(); i++) {
47
48 const std::string& item = items[i];
49 const bool passedPhysics = isPassed[i];
50 const unsigned passBits = bits[i];
51 const bool l1TBP = (passBits & TrigDefs::L1_isPassedBeforePrescale);
52 const bool l1TAP = (passBits & TrigDefs::L1_isPassedAfterPrescale);
53 const bool l1TAV = (passBits & TrigDefs::L1_isPassedAfterVeto);
54
55 if (passedPhysics) {
56 ++passL1;
57 ATH_MSG_VERBOSE("Passing L1:" << item);
58 }
59
60 if (l1TAP && !l1TBP) {
61 ATH_CHECK( reportError(item, "Cannot pass after L1 prescale if failing before L1 prescale") );
62 }
63
64 if (l1TAV && (!l1TBP || !l1TAP)) {
65 ATH_CHECK( reportError(item, "Cannot pass after L1 veto if failing either before L1 prescale or after L1 prescale") );
66 }
67
68 if (l1TAV && !passedPhysics) {
69 ATH_CHECK( reportError(item, "Inconsistency - L1 pass after veto is true but isPassed is false") );
70 }
71
72 }
73
74 ATH_MSG_DEBUG("Passing L1 Items: " << passL1);
75 if (!passL1) {
76 ATH_CHECK( reportError("L1", "Zero L1 items passed this event.") );
77 }
78
79 }
80
81 if (m_doHLT) {
82
83 const Trig::ChainGroup* hltgroup = m_tdt->getChainGroup("HLT_.*");
84 const std::vector<std::string> items = hltgroup->getListOfTriggers();
85 const std::vector<bool> isPassed = hltgroup->isPassedForEach();
86 const std::vector<unsigned int> bits = hltgroup->isPassedBitsForEach();
87
89 if (m_edmVersion >= 3) {
92 if (!terminusNode) {
93 ATH_CHECK( reportError(m_navigationReadHandleKey.key(), "Terminus Node could not be located from the primary navigation collection.") );
94 }
95 TrigCompositeUtils::decisionIDs(terminusNode, terminusIDs);
96 }
97
98 size_t passHLT = 0;
99 for (size_t i = 0; i<items.size(); i++) {
100
101 const std::string& chain = items[i];
102 const bool passedPhysics = isPassed[i];
103 const unsigned passBits = bits[i];
104 const bool l1TBP = (passBits & TrigDefs::L1_isPassedBeforePrescale);
105 const bool l1TAP = (passBits & TrigDefs::L1_isPassedAfterPrescale);
106 const bool l1TAV = (passBits & TrigDefs::L1_isPassedAfterVeto);
107 const bool isPrescaled = (passBits & TrigDefs::EF_prescaled);
108 const bool isPassedRaw = (passBits & TrigDefs::EF_passedRaw);
109 const bool inTerminusNode = (terminusIDs.count( HLT::Identifier(chain).numeric() ) == 1);
110
111 if (isPassedRaw) {
112 ++passHLT;
113 ATH_MSG_VERBOSE("Passing HLT:" << chain);
114 }
115
116 if (l1TAP && !l1TBP) {
117 ATH_CHECK( reportError(chain, "Cannot pass after L1 prescale if failing before L1 prescale") );
118 }
119
120 if (l1TAV && (!l1TBP || !l1TAP)) {
121 ATH_CHECK( reportError(chain, "Cannot pass after L1 veto if failing either before L1 prescale or after L1 prescale") );
122 }
123
124 if (passedPhysics && !isPassedRaw) {
125 ATH_CHECK( reportError(chain, "Cannot pass for physics if failing at the HLT") );
126 }
127
128 if (passedPhysics && !l1TAV) {
129 ATH_CHECK( reportError(chain, "Cannot pass for physics if failing at L1") );
130 }
131
132 // These check(s) are only valid for the R3 trigger
133 if (m_edmVersion >= 3) {
134 if (isPassedRaw && isPrescaled) { // (possible due to passthrough & rerun in R1, R2)
135 ATH_CHECK( reportError(chain, "Cannot pass if prescaled") );
136 }
137
138 if (passedPhysics && !inTerminusNode) {
139 ATH_CHECK( reportError(chain, "Inconsistency - passing for physics, but not present in the navigation terminus node") );
140 }
141
142 if (inTerminusNode && !isPassedRaw) {
143 ATH_CHECK( reportError(chain, "Inconsistency - in the navigation terminus node, but not passing raw") );
144 }
145 }
146
147 }
148
149 ATH_MSG_DEBUG("Passing HLT Chains: " << passHLT);
150 if (!passHLT) {
151 ATH_CHECK( reportError("HLT", "Zero HLT chains passed this event.") );
152 }
153
154 }
155
156 return StatusCode::SUCCESS;
157}
#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.
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
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.