ATLAS Offline Software
Loading...
Searching...
No Matches
RunTriggerMatching.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
7#include <vector>
8
9RunTriggerMatching::RunTriggerMatching(const std::string &name, ISvcLocator *pSvcLocator)
10 : AthReentrantAlgorithm(name, pSvcLocator) {
11}
12
14
15 // Initialise the data handles
16 ATH_CHECK(m_containerKey.initialize());
17 // Initialise the tool handles
18 ATH_CHECK(m_trigDec.retrieve());
19 ATH_CHECK(m_matchingTool.retrieve());
20 // Initialise counter
22 return StatusCode::SUCCESS;
23}
24
25StatusCode RunTriggerMatching::execute(const EventContext& ctx) const {
26
27 // Get the particle containers requested
29 if( ! particles.isValid() ) {
30 ATH_MSG_ERROR ("Couldn't retrieve IParticles with key: " << m_containerKey.key() );
31 return StatusCode::FAILURE;
32 }
33
34 // Get the full list of triggers that were available for this event matching the user string
35 const Trig::ChainGroup* chain = m_trigDec->getChainGroup(m_triggerString);
36 const std::vector<std::string> fired_triggers = chain->getListOfTriggers();
37
38 // For triggers that fired, count events where at least one offline object
39 // from the provided container matches that trigger
40 for (const std::string& fired : fired_triggers) {
41 if (m_trigDec->isPassed(fired)) {
42 for ( const xAOD::IParticle* part : *particles) {
43 if (m_matchingTool->match(*part, fired, 0.1, false)) {
45 break;
46 }
47 }
48 }
49 }
50
51 return StatusCode::SUCCESS;
52
53}
54
55// Print the contents of the map
57 ATH_MSG_INFO("=========================");
58 ATH_MSG_INFO("SUMMARY OF TRIGGER COUNTS");
59 ATH_MSG_INFO("=========================");
60 ATH_MSG_INFO("Number of events where a trigger matching the user string");
61 ATH_MSG_INFO("fired and is matched to at least one offline object in " << m_containerKey.key() << " : " << std::to_string(m_matchCounter));
62
63 return StatusCode::SUCCESS;
64}
65
66
67
68
69
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
An algorithm that can be simultaneously executed in multiple threads.
RunTriggerMatching(const std::string &name, ISvcLocator *pSvcLocator)
virtual StatusCode initialize() override
PublicToolHandle< Trig::TrigDecisionTool > m_trigDec
Tool handle for the trigger decision and matching tools.
std::atomic< unsigned int > m_matchCounter
Integer counter for the requested triggers.
Gaudi::Property< std::string > m_triggerString
String to select triggers to use in the matching with offline objects.
PublicToolHandle< Trig::R3MatchingTool > m_matchingTool
SG::ReadHandleKey< xAOD::IParticleContainer > m_containerKey
Read handle for the offline object container - set to muons by default.
virtual StatusCode finalize() override
virtual StatusCode execute(const EventContext &) const override
Class providing the definition of the 4-vector interface.