ATLAS Offline Software
Loading...
Searching...
No Matches
TrigMatchingAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
6
11
12
13namespace CP
14{
15
17 ISvcLocator *svcLoc)
18 : EL::AnaAlgorithm(name, svcLoc)
19 {
20 declareProperty("matchingTool", m_trigMatchingTool, "trigger matching tool");
21 }
22
24 {
25 if (m_matchingDecoration.empty())
26 {
27 ATH_MSG_ERROR("The decoration name needs to be defined");
28 return StatusCode::FAILURE;
29 }
30
32 {
33 ATH_MSG_ERROR("At least one trigger needs to be provided in the list");
34 return StatusCode::FAILURE;
35 }
36
37 // retrieve the trigger matching tool
38 ANA_CHECK(m_trigMatchingTool.retrieve());
39
40 for (const std::string &chain : m_trigSingleMatchingList)
41 {
42 m_matchingDecorators.emplace(chain, m_matchingDecoration + "_" + RCU::substitute (chain, "-", "_"));
43 }
44 for (const std::string &chain : m_trigSingleMatchingListDummy)
45 {
46 m_matchingDecorators.emplace(chain, m_matchingDecoration + "_" + RCU::substitute (chain, "-", "_"));
47 }
49
51
52 ANA_CHECK (m_systematicsList.initialize());
53
54 return StatusCode::SUCCESS;
55 }
56
57
58
60 {
61
62 for (const auto & syst : m_systematicsList.systematicsVector())
63 {
64 const xAOD::IParticleContainer* particles(nullptr);
65
66 if (m_particlesHandle) ANA_CHECK(m_particlesHandle.retrieve(particles, syst));
67
68 ATH_MSG_DEBUG("Retrieving " << m_particlesHandle.getName(syst));
69
70 if (particles != nullptr)
71 {
72 for (const xAOD::IParticle *particle : *particles)
73 {
74 ATH_MSG_DEBUG("-- Considering offline eta:" << particle->eta() << " phi:" << particle->phi() << " (pT:" << particle->pt() << ")");
75 for (const std::string &chain : m_trigSingleMatchingList)
76 {
77 // A string-based signature-identifier per leg, may contain duplicated return values for asymmetric chains.
78 const std::vector<std::string> signatures = ChainNameParser::signatures(chain);
79 if (signatures.size() != 1) {
80 ANA_MSG_ERROR("The decoration-based TrigMatchingAlg only supports single-legged triggers." << chain << " has " << signatures.size() << " legs.");
81 return StatusCode::FAILURE;
82 }
83
84 const float dR = (signatures.at(0) == "tau" ? 0.2 : 0.1);
85 const bool match = m_trigMatchingTool->match(*particle, chain, dR, false);
86 (m_matchingDecorators.at(chain))(*particle) = match;
87 ATH_MSG_DEBUG("-- -- Considering for " << chain << ", match = " << match);
88 }
89
90 for (const std::string &chain : m_trigSingleMatchingListDummy)
91 {
92 ATH_MSG_DEBUG("Applying dummy match=0 decoration for " << chain);
93 (m_matchingDecorators.at(chain))(*particle) = 0;
94 }
95 }
96 }
97 }
98 return StatusCode::SUCCESS;
99 }
100} // namespace CP
101
#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
virtual StatusCode execute() 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
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:357
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.
std::string substitute(const std::string &str, const std::string &pattern, const std::string &with)
effects: substitute all occurences of "pattern" with "with" in the string "str" returns: the substitu...
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.