ATLAS Offline Software
Loading...
Searching...
No Matches
TriggerSelectionAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5// includes
7
8// Tool includes
11
12
13TriggerSelectionAlg::TriggerSelectionAlg( const std::string& name, ISvcLocator* pSvcLocator ):
14 AthFilterAlgorithm( name, pSvcLocator )
15{
16}
17
18
20
21
23{
24 ATH_MSG_DEBUG ("Initializing " << name() << "...");
25
26 // Print the configuration to the log file
27 ATH_MSG_DEBUG( "Using: " << m_trigDecisionTool );
28 ATH_MSG_DEBUG( "Using: " << m_triggerList );
29 ATH_MSG_DEBUG( "Using: " << m_decoEvtInfo );
30 ATH_MSG_DEBUG( "Using: " << m_evtInfoName );
31 ATH_MSG_DEBUG( "Using: " << m_varPrefix );
32 ATH_MSG_DEBUG( "Using: " << m_storePrescaleInfo );
33
34 // Retrieve the TrigDecisionTool
35 ATH_CHECK(m_trigDecisionTool.retrieve());
36
37 // Create the list of decoration variables
38 for ( const std::string& trigName : m_triggerList.value() ){
39 m_varNameList.push_back( m_varPrefix.value() + trigName );
40 }
41
42 return StatusCode::SUCCESS;
43}
44
45
47{
48 ATH_MSG_DEBUG("Finalizing " << name() << "...");
49
50 // Release all tools
51 ATH_CHECK( m_trigDecisionTool.release() );
52
53 return StatusCode::SUCCESS;
54}
55
56
58{
59 ATH_MSG_DEBUG("Executing " << name() << "...");
60
61 // Get the xAOD::EventInfo object, if requested
62 const xAOD::EventInfo* evtInfo = nullptr;
63 if ( m_decoEvtInfo.value() ){
64 ATH_CHECK( evtStore()->retrieve( evtInfo, m_evtInfoName.value() ) );
65 }
66
67 // Create a results Vector
68 std::vector<bool> trigResultsVec( m_triggerList.value().size(), false );
69 std::vector<float> trigPrescalesVec( m_triggerList.value().size(), 0. );
70
71 //Check if event passes trigger selection
72 bool eventPasses = false;
73 if( !(m_triggerList.value().empty()) ) {
74 for( std::size_t i=0; i<m_triggerList.value().size(); ++i ) {
75 if( m_trigDecisionTool->isPassed(m_triggerList.value().at(i)) ) {
76 trigResultsVec[i] = true;
77 eventPasses = true;
78 ATH_MSG_VERBOSE("Name of passed trigger: " << m_triggerList.value().at(i));
79 if ( !(m_decoEvtInfo.value()) ){
80 break; // Found a trigger which we passed, nothing more to do here
81 }
82 }
83 //We sometimes want to keep track of the chain prescale
85 trigPrescalesVec[i] = m_trigDecisionTool->getPrescale(m_triggerList.value().at(i));
86 ATH_MSG_VERBOSE("Retrieved prescale of " << trigPrescalesVec[i] << " for trigger: " << m_triggerList.value().at(i));
87 }
88 }
89 }
90
91 // Decorate the EventInfo, if requested
92 if ( m_decoEvtInfo.value() ){
93 const size_t decoSize = trigResultsVec.size();
94 if ( decoSize != m_varNameList.size() ){
95 ATH_MSG_FATAL("Different number of trigger results and variable names");
96 return StatusCode::FAILURE;
97 }
98 // We also want to decorate the xAOD::EventInfo object with the results
99 for( std::size_t i=0; i<decoSize; ++i ) {
101 decoPassTrig(*evtInfo) = static_cast<char>(trigResultsVec[i]);
102 //We sometimes want to keep track of the chain prescale
104 SG::AuxElement::Decorator<float> decoPrescaleTrig("prescale_"+m_triggerList.value().at(i));
105 decoPrescaleTrig(*evtInfo) = static_cast<float>(trigPrescalesVec[i]);
106 }
107 }
108 }
109
110 // Say if this event should be accepted or not
111 this->setFilterPassed( eventPasses );
112 ATH_MSG_DEBUG("Event passes trigger selection: " << eventPasses );
113
114 return StatusCode::SUCCESS;
115}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
virtual void setFilterPassed(bool state) const
Set the filter passed flag to the specified state.
AthFilterAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
SG::Decorator< T, ALLOC > Decorator
Definition AuxElement.h:575
StringArrayProperty m_triggerList
The list of triggers to cut on.
BooleanProperty m_decoEvtInfo
Decide if we also want to decorate the xAOD::EventInfo object with the pass/fail information.
StringProperty m_evtInfoName
Name of the xAOD::EventInfo object that we want to decorate.
virtual ~TriggerSelectionAlg()
Destructor:
virtual StatusCode finalize() override
Athena algorithm's finalize hook.
StringProperty m_varPrefix
Prefix used for the decoration variables.
virtual StatusCode execute() override
Athena algorithm's execute hook.
TriggerSelectionAlg(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
std::vector< std::string > m_varNameList
The list of all variables names.
BooleanProperty m_storePrescaleInfo
Decide if we also want to decorate the xAOD::EventInfo object with the (full-chain) prescale informat...
virtual StatusCode initialize() override
Athena algorithm's initalize hook.
ToolHandle< Trig::TrigDecisionTool > m_trigDecisionTool
The ToolHandle for the TrigDecisionTool.
EventInfo_v1 EventInfo
Definition of the latest event info version.