ATLAS Offline Software
Loading...
Searching...
No Matches
TrigMatchingAlg.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
9#include <algorithm>
10
11
12namespace CP
13{
14
16 ISvcLocator *svcLoc)
17 : EL::AnaAlgorithm(name, svcLoc)
18 {
19 declareProperty("matchingTool", m_trigMatchingTool, "trigger matching tool");
20 }
21
23 {
24 if (m_matchingDecoration.empty())
25 {
26 ATH_MSG_ERROR("The decoration name needs to be defined");
27 return StatusCode::FAILURE;
28 }
29
31 {
32 ATH_MSG_ERROR("At least one trigger needs to be provided in the list");
33 return StatusCode::FAILURE;
34 }
35
36 // retrieve the trigger matching tool
37 ANA_CHECK(m_trigMatchingTool.retrieve());
38 const std::string prefix = m_matchingDecoration + "_";
39 for (const std::string &chain : m_trigSingleMatchingList)
40 {
41 std::string chainfix = chain;
42 std::replace(chainfix.begin(), chainfix.end(), '-', '_');
43 m_matchingDecorators.emplace(chain, prefix + chainfix);
44 }
45 for (const std::string &chain : m_trigSingleMatchingListDummy)
46 {
47 std::string chainfix = chain;
48 std::replace(chainfix.begin(), chainfix.end(), '-', '_');
49 m_matchingDecorators.emplace(chain, prefix + chainfix);
50 }
51
53 {
56 }
57
58 ANA_CHECK (m_systematicsList.initialize());
59
60 return StatusCode::SUCCESS;
61 }
62
63
64
65 StatusCode TrigMatchingAlg::execute(const EventContext& ctx)
66 {
67
68 for (const auto & syst : m_systematicsList.systematicsVector())
69 {
70 const xAOD::IParticleContainer* particles(nullptr);
71
72 if (m_particlesHandle) ANA_CHECK(m_particlesHandle.retrieve(particles, syst, ctx));
73
74 ATH_MSG_DEBUG("Retrieving " << m_particlesHandle.getName(syst));
75
76 if (particles != nullptr)
77 {
78 for (const xAOD::IParticle *particle : *particles)
79 {
80 ATH_MSG_DEBUG("-- Considering offline eta:" << particle->eta() << " phi:" << particle->phi() << " (pT:" << particle->pt() << ")");
81 for (const std::string &chain : m_trigSingleMatchingList)
82 {
83 // A string-based signature-identifier per leg, may contain duplicated return values for asymmetric chains.
84 const std::vector<std::string> signatures = ChainNameParser::signatures(chain);
85 if (signatures.size() != 1) {
86 ANA_MSG_ERROR("The decoration-based TrigMatchingAlg only supports single-legged triggers." << chain << " has " << signatures.size() << " legs.");
87 return StatusCode::FAILURE;
88 }
89
90 const float dR = (signatures.at(0) == "tau" ? 0.2 : 0.1);
91 const bool match = m_trigMatchingTool->match(*particle, chain, dR, false);
92 (m_matchingDecorators.at(chain))(*particle) = match;
93 ATH_MSG_DEBUG("-- -- Considering for " << chain << ", match = " << match);
94 }
95
96 for (const std::string &chain : m_trigSingleMatchingListDummy)
97 {
98 ATH_MSG_DEBUG("Applying dummy match=0 decoration for " << chain);
99 (m_matchingDecorators.at(chain))(*particle) = 0;
100 }
101 }
102 }
103 }
104 return StatusCode::SUCCESS;
105 }
106} // namespace CP
107
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
#define ANA_CHECK(EXP)
check whether the given expression was successful
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
SysReadHandle< xAOD::IParticleContainer > m_particlesHandle
input particle collection
Gaudi::Property< std::vector< std::string > > m_trigSingleMatchingListDummy
list of triggers for dummy matching decorations
virtual StatusCode initialize() final override
TrigMatchingAlg(const std::string &name, ISvcLocator *pSvcLocator)
the standard constructor
ToolHandle< Trig::IMatchingTool > m_trigMatchingTool
trigger decision tool handle
Gaudi::Property< std::string > m_matchingDecoration
the decoration for trigger matching
SysReadSelectionHandle m_particleSelection
input particle selection
SysListHandle m_systematicsList
the systematics list we run
std::unordered_map< std::string, SG::Decorator< char > > m_matchingDecorators
the decorators for m_matchingDecoration and triggers combination
Gaudi::Property< std::vector< std::string > > m_trigSingleMatchingList
list of triggers
AnaAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
constructor with parameters
virtual::StatusCode execute()
execute this algorithm
Class providing the definition of the 4-vector interface.
bool match(std::string s1, std::string s2)
match the individual directories of two strings
Definition hcg.cxx:359
Select isolated Photons, Electrons and Muons.
std::vector< std::string > signatures(const std::string &chain)
This module defines the arguments passed from the BATCH driver to the BATCH worker.
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.