ATLAS Offline Software
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 
8 TrigDec::TrigDecisionMakerValidator::TrigDecisionMakerValidator(const std::string &name, ISvcLocator *pSvcLocator)
9  : ::AthReentrantAlgorithm(name, pSvcLocator)
10 {}
11 
13 
16  ATH_CHECK( m_tdt.retrieve() );
17  ATH_CHECK( m_navigationReadHandleKey.initialize(m_doHLT && m_edmVersion >= 3) );
18  return StatusCode::SUCCESS;
19 }
20 
21 StatusCode TrigDec::TrigDecisionMakerValidator::reportError(const std::string& item, const std::string& msg) const {
22  if(m_errorOnFailure) {
23  ATH_MSG_ERROR(item << ": " << msg);
24  return StatusCode::FAILURE;
25  }
26  ATH_MSG_WARNING(item << ": " << msg);
27  return StatusCode::SUCCESS;
28 }
29 
30 StatusCode 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) {
90  SG::ReadHandle<TrigCompositeUtils::DecisionContainer> navRH{m_navigationReadHandleKey, context};
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 }
Trig::ChainGroup::isPassedBitsForEach
std::vector< unsigned int > isPassedBitsForEach() const
return result of isPassedBits for each chain in the group
Definition: Trigger/TrigAnalysis/TrigDecisionTool/Root/ChainGroup.cxx:261
runLayerRecalibration.chain
chain
Definition: runLayerRecalibration.py:175
HLT::Identifier::numeric
TrigCompositeUtils::DecisionID numeric() const
numeric ID
Definition: TrigCompositeUtils/TrigCompositeUtils/HLTIdentifier.h:47
TrigDecisionMakerValidator.h
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
TrigDec::TrigDecisionMakerValidator::initialize
virtual StatusCode initialize() override
Definition: TrigDecisionMakerValidator.cxx:15
xAOD::passBits
passBits
Definition: TrigPassBits_v1.cxx:115
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
TrigCompositeUtils::getTerminusNode
const Decision * getTerminusNode(SG::ReadHandle< DecisionContainer > &container)
Definition: TrigCompositeUtilsRoot.cxx:243
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
TrigDec::TrigDecisionMakerValidator::reportError
StatusCode reportError(const std::string &item, const std::string &msg) const
Definition: TrigDecisionMakerValidator.cxx:21
lumiFormat.i
int i
Definition: lumiFormat.py:92
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
TrigDec::TrigDecisionMakerValidator::~TrigDecisionMakerValidator
~TrigDecisionMakerValidator()
Definition: TrigDecisionMakerValidator.cxx:12
xAOD::TrigComposite_v1
Class used to describe composite objects in the HLT.
Definition: TrigComposite_v1.h:52
HLT::Identifier
Definition: TrigCompositeUtils/TrigCompositeUtils/HLTIdentifier.h:20
Trig::ChainGroup
Definition: Trigger/TrigAnalysis/TrigDecisionTool/TrigDecisionTool/ChainGroup.h:51
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
TrigJetMonitorAlgorithm.items
items
Definition: TrigJetMonitorAlgorithm.py:79
item
Definition: ItemListSvc.h:43
TrigCompositeUtils::DecisionIDContainer
std::set< DecisionID > DecisionIDContainer
Definition: TrigComposite_v1.h:28
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
TrigDec::TrigDecisionMakerValidator::execute
virtual StatusCode execute(const EventContext &context) const override
Definition: TrigDecisionMakerValidator.cxx:30
Trig::ChainGroup::isPassedForEach
std::vector< bool > isPassedForEach(unsigned int condition=TrigDefs::Physics) const
return vector with isPassed decision for each chain
Definition: Trigger/TrigAnalysis/TrigDecisionTool/Root/ChainGroup.cxx:193
TrigCompositeUtils::decisionIDs
void decisionIDs(const Decision *d, DecisionIDContainer &destination)
Extracts DecisionIDs stored in the Decision object.
Definition: TrigCompositeUtilsRoot.cxx:67
Trig::ChainGroup::getListOfTriggers
std::vector< std::string > getListOfTriggers() const
Definition: Trigger/TrigAnalysis/TrigDecisionTool/Root/ChainGroup.cxx:467
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
TrigDec::TrigDecisionMakerValidator::TrigDecisionMakerValidator
TrigDecisionMakerValidator(const std::string &name, ISvcLocator *pSvcLocator)
Definition: TrigDecisionMakerValidator.cxx:8