ATLAS Offline Software
Loading...
Searching...
No Matches
TrigEventSelectionAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
6
8#include <algorithm>
11
13 ISvcLocator *svcLoc)
14 : EL::AnaAlgorithm(name, svcLoc),
15 m_trigDecisionTool("Trig::TrigDecisionTool/TrigDecisionTool")
16{
17 declareProperty("tool", m_trigDecisionTool, "trigger decision tool");
18}
19
21{
22 if (m_trigList.empty()) {
23 ATH_MSG_ERROR("A list of triggers needs to be provided");
24 return StatusCode::FAILURE;
25 }
26
27 ANA_CHECK(m_trigDecisionTool.retrieve());
28
29 if (!m_selectionDecoration.empty()) {
30 const std::string prefix{m_selectionDecoration.value() + "_"};
31 for (const std::string &chain : m_trigList) {
32 std::string chainfix = chain;
33 std::replace(chainfix.begin(), chainfix.end(), '.', 'p');
34 std::replace(chainfix.begin(), chainfix.end(), '-', '_');
35 m_selectionAccessors.emplace_back( prefix + chainfix);
36 }
37 }
38
39 ANA_CHECK (m_filterParams.initialize());
40
41 return StatusCode::SUCCESS;
42}
43
44StatusCode CP::TrigEventSelectionAlg::execute(const EventContext& /*ctx*/)
45{
47
48 if (m_trigList.empty()) {
49 filter.setPassed(true);
50 return StatusCode::SUCCESS;
51 }
52
53 const xAOD::EventInfo *evtInfo = 0;
54 ANA_CHECK(evtStore()->retrieve(evtInfo, "EventInfo"));
55
56 for (size_t i = 0; i < m_trigList.size(); i++) {
57 bool trigPassed = m_noL1.value()
59 : m_trigDecisionTool->isPassed(m_trigList[i]);
60 if (!m_selectionDecoration.empty()) {
61 m_selectionAccessors[i](*evtInfo) = trigPassed;
62 }
63 if (trigPassed)
64 filter.setPassed (true);
65 }
66
67 return StatusCode::SUCCESS;
68}
69
71{
72 ANA_MSG_INFO (m_filterParams.summary());
73
74 return StatusCode::SUCCESS;
75}
#define ATH_MSG_ERROR(x)
#define ANA_MSG_INFO(xmsg)
Macro printing info messages.
#define ANA_CHECK(EXP)
check whether the given expression was successful
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
virtual StatusCode initialize() final
ToolHandle< Trig::ITrigDecisionTool > m_trigDecisionTool
trigger decision tool handle
Gaudi::Property< bool > m_noFilter
whether to not apply an event filter
TrigEventSelectionAlg(const std::string &name, ISvcLocator *svcLoc=nullptr)
Gaudi::Property< bool > m_noL1
whether to not require L1 decision
Gaudi::Property< std::string > m_selectionDecoration
the decoration for trigger selection
FilterReporterParams m_filterParams
the filter reporter params
std::vector< SG::Decorator< bool > > m_selectionAccessors
the accessors for m_selectionDecoration and m_trigList combination
virtual StatusCode finalize() final
Gaudi::Property< std::vector< std::string > > m_trigList
list of triggers or trigger chains
AnaAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
constructor with parameters
virtual::StatusCode execute()
execute this algorithm
a guard class for use with ref FilterReporterParams
This module defines the arguments passed from the BATCH driver to the BATCH worker.
EventInfo_v1 EventInfo
Definition of the latest event info version.