ATLAS Offline Software
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 
5 #include "RunTriggerMatching.h"
7 #include <vector>
8 
9 RunTriggerMatching::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
21  m_matchCounter = 0;
22  return StatusCode::SUCCESS;
23 }
24 
25 StatusCode 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 
LArG4FSStartPointFilter.part
part
Definition: LArG4FSStartPointFilter.py:21
RunTriggerMatching::m_containerKey
SG::ReadHandleKey< xAOD::IParticleContainer > m_containerKey
Read handle for the offline object container - set to muons by default.
Definition: RunTriggerMatching.h:34
runLayerRecalibration.chain
chain
Definition: runLayerRecalibration.py:175
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:40
ChainGroup.h
RunTriggerMatching::m_trigDec
PublicToolHandle< Trig::TrigDecisionTool > m_trigDec
Tool handle for the trigger decision and matching tools.
Definition: RunTriggerMatching.h:36
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
RunTriggerMatching::m_triggerString
Gaudi::Property< std::string > m_triggerString
String to select triggers to use in the matching with offline objects.
Definition: RunTriggerMatching.h:32
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
RunTriggerMatching::initialize
virtual StatusCode initialize() override
Definition: RunTriggerMatching.cxx:13
RunTriggerMatching::execute
virtual StatusCode execute(const EventContext &) const override
Definition: RunTriggerMatching.cxx:25
RunTriggerMatching::RunTriggerMatching
RunTriggerMatching(const std::string &name, ISvcLocator *pSvcLocator)
Definition: RunTriggerMatching.cxx:9
Trig::ChainGroup
Definition: Trigger/TrigAnalysis/TrigDecisionTool/TrigDecisionTool/ChainGroup.h:51
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
RunTriggerMatching::m_matchCounter
std::atomic< unsigned int > m_matchCounter
Integer counter for the requested triggers.
Definition: RunTriggerMatching.h:30
RunTriggerMatching::finalize
virtual StatusCode finalize() override
Definition: RunTriggerMatching.cxx:56
LArG4FSStartPointFilter.particles
list particles
Definition: LArG4FSStartPointFilter.py:84
RunTriggerMatching.h
RunTriggerMatching::m_matchingTool
PublicToolHandle< Trig::R3MatchingTool > m_matchingTool
Definition: RunTriggerMatching.h:37