29 static std::atomic<int> s_instances = 0;
36 #ifdef XAOD_ANALYSIS // AthAnalysis or AnalysisBase
38 #else //full Athena env
48 if (m_navigationFormat !=
"TriggerElement" && m_navigationFormat !=
"TrigComposite") {
49 ATH_MSG_ERROR(
"NavigationFormat property must be one of 'TriggerElement' for Run 1, 2 triggered input or 'TrigComposite' for Run 3+ triggered input");
50 return StatusCode::FAILURE;
54 #ifndef XAOD_ANALYSIS // Full Athena only
55 ATH_CHECK(m_oldDecisionKey.initialize( m_useOldAODDecisionInput ) );
56 ATH_CHECK(m_oldEventInfoKey.initialize( m_useOldEventInfoDecisionFormat ) );
59 ATH_CHECK(m_HLTSummaryKeyIn.initialize(m_navigationFormat ==
"TrigComposite"));
60 ATH_CHECK(m_navigationKey.initialize(m_navigationFormat ==
"TriggerElement"));
61 ATH_CHECK(m_decisionKey.initialize( !m_useOldAODDecisionInput ));
64 if ( s_instances > 1) {
66 "This is not efficent from performance perspective. "
67 "Access of the same EDM objects will give warnings." );
68 if (!m_acceptMultipleInstance){
70 "Set 'AcceptMultipleInstance' to overwrite this behavior.");
71 return StatusCode::FAILURE;
75 ATH_MSG_INFO(
"Initializing Trig::TrigDecisionTool (standalone version even for athena)");
77 #ifndef XAOD_STANDALONE // AthAnalysis or full Athena
82 if(m_configSvc.empty()) {
83 ATH_MSG_DEBUG(
"No TrigConfigSvc provided. Using ConfigTool instead...");
84 CHECK( m_configTool.retrieve());
87 m_configTool.disable();
93 if ( m_configSvc->ctpConfig() ) {
94 configurationUpdate( &m_configSvc->chains(), m_configSvc->ctpConfig() );
101 #ifndef XAOD_ANALYSIS // Full athena only
102 if (m_navigationFormat ==
"TriggerElement") {
107 cgm()->navigation(&*m_navigation);
109 cgm()->setStore(&*evtStore());
111 #ifndef XAOD_STANDALONE // AthAnalysis or full Athena
113 if (incSvc.retrieve().isFailure()) {
115 return StatusCode::FAILURE;
119 incSvc->removeListener(
this,
"BeginEvent");
120 incSvc->addListener(
this,
"BeginEvent", pri );
122 incSvc->removeListener(
this, IncidentType::BeginInputFile );
123 incSvc->addListener(
this, IncidentType::BeginInputFile, pri,
true);
128 std::map<std::string, std::string>::const_iterator pIt;
129 for ( pIt = m_publicChainGroups.begin(); pIt != m_publicChainGroups.end(); ++pIt ) {
132 cgm()->createChainGroup(
patterns, pIt->first);
133 ATH_MSG_INFO(
"created Public Chain Group " << pIt->first <<
" with pattern: " << pIt->second );
136 return StatusCode::SUCCESS;
140 return m_configKeysCache.get();
145 if (forceForAllSlots) {
146 for (std::atomic<bool>& ab : m_forceConfigUpdate) {
151 std::atomic<bool>* ab = m_forceConfigUpdate.get();
158 std::atomic<bool>* ab = m_forceConfigUpdate.get();
171 #ifndef XAOD_STANDALONE // AthAnalysis or full Athena
173 slot = Gaudi::Hive::currentContext().slot();
174 #ifndef XAOD_ANALYSIS // Full Athena only
177 #endif // End Full Athena only
178 #endif // End AthAnalysis or Full Athena
185 #ifndef XAOD_STANDALONE
186 if (!m_configSvc.empty())
188 iHLTConfig = m_configSvc.get();
189 iL1Config = m_configSvc.get();
194 iHLTConfig = m_configTool.operator->();
195 iL1Config = m_configTool.operator->();
198 ATH_MSG_DEBUG(
"beginEvent: check if config update is necessary");
199 std::vector<uint32_t> newKeys = {
200 iHLTConfig->masterKey(),
201 iL1Config->lvl1PrescaleKey(),
202 iHLTConfig->hltPrescaleKey(),
203 iL1Config->bunchGroupSetKey()
205 if (*
getKeys() != newKeys or getForceConfigUpdate())
208 <<
" with SMK: " << newKeys[0]
209 <<
" and L1PSK: " << newKeys[1]
210 <<
" and HLTPSK: " << newKeys[2]
211 <<
" and BGSK: " << newKeys[3]
212 <<
" getForceConfigUpdate()=" << getForceConfigUpdate()
213 <<
" HLT Chains: " << iHLTConfig->chains().size());
215 configurationUpdate( &iHLTConfig->chains(), iL1Config->ctpConfig() );
216 setForceConfigUpdate(
false);
219 ATH_MSG_DEBUG(
"Cached trigger configuration keys match for this event in slot " << slot);
221 return StatusCode::SUCCESS;
228 ATH_MSG_VERBOSE(
"Trig::TrigDecisionTool::beginInputFile: setForceConfigUpdate(true, forceForAllSlots=true)");
229 setForceConfigUpdate(
true,
true);
230 return StatusCode::SUCCESS;
236 m_navigation->reset(
true);
241 return StatusCode::SUCCESS;
244 #ifndef XAOD_ANALYSIS // Full Athena only
248 ATH_MSG_DEBUG(
"got incident type:" << inc.type() <<
" source: " << inc.source() );
250 if (inc.type() == IncidentType::BeginEvent) {
251 ATH_MSG_VERBOSE(
"Obtained IncidentType::BeginEvent via Trig::TrigDecisionTool::handle");
252 if (beginEvent().isFailure()) {
253 throw std::runtime_error(
"In Trig::TrigDecisionTool::handle beginEvent() returned StatusCode::FAILURE");
256 else if (inc.type() == IncidentType::BeginInputFile) {
257 ATH_MSG_VERBOSE(
"Obtained IncidentType::BeginInputFile via Trig::TrigDecisionTool::handle");
258 if (beginInputFile().isFailure()) {
259 throw std::runtime_error(
"In Trig::TrigDecisionTool::handle beginInputFile() returned StatusCode::FAILURE");
264 AsgMetadataTool::handle(inc);
288 return m_navigationFormat;