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
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 // A string-based signature-identifier per leg, may contain duplicated return values for asymmetric chains.
42 const std::vector<std::string> signatures = ChainNameParser::signatures(chain);
43 if (signatures.size() != 1)
44 {
45 ATH_MSG_ERROR("The decoration-based TrigMatchingAlg only supports single-legged triggers. " << chain << " has " << signatures.size() << " legs.");
46 return StatusCode::FAILURE;
47 }
48 const float dR = (signatures.front() == "tau" ? 0.2 : 0.1);
49 m_matchingChains.push_back({chain, dR, SG::Decorator<char>(prefix + sanitizeTriggerChainName(chain))});
50 }
51 for (const std::string &chain : m_trigSingleMatchingListDummy)
52 {
53 m_dummyChains.push_back({chain, SG::Decorator<char>(prefix + sanitizeTriggerChainName(chain))});
54 }
55
57 ANA_CHECK (m_systematicsList.initialize());
58
59 return StatusCode::SUCCESS;
60 }
61
62
63
64 StatusCode TrigMatchingAlg::execute(const EventContext& ctx)
65 {
66 for (const auto & syst : m_systematicsList.systematicsVector())
67 {
68 const xAOD::IParticleContainer* particles(nullptr);
69
70 ANA_CHECK(m_particlesHandle.retrieve(particles, syst, ctx));
71
72 ATH_MSG_DEBUG("Retrieving " << m_particlesHandle.getName(syst));
73
74 for (const xAOD::IParticle *particle : *particles)
75 {
76 ATH_MSG_DEBUG("-- Considering offline eta:" << particle->eta() << " phi:" << particle->phi() << " (pT:" << particle->pt() << ")");
77 for (const MatchingChain &mc : m_matchingChains)
78 {
79 const bool match = m_trigMatchingTool->match(*particle, mc.chain, mc.dR, false);
80 mc.decorator(*particle) = match;
81 ATH_MSG_DEBUG("-- -- Considering for " << mc.chain << ", match = " << match);
82 }
83
84 for (const DummyChain &dc : m_dummyChains)
85 {
86 ATH_MSG_DEBUG("Applying dummy match=0 decoration for " << dc.chain);
87 dc.decorator(*particle) = 0;
88 }
89 }
90 }
91 return StatusCode::SUCCESS;
92 }
93} // namespace CP
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#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
std::vector< DummyChain > m_dummyChains
Gaudi::Property< std::vector< std::string > > m_trigSingleMatchingListDummy
list of triggers for dummy matching decorations
virtual StatusCode initialize() final override
std::vector< MatchingChain > m_matchingChains
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
SysListHandle m_systematicsList
the systematics list we run
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::string sanitizeTriggerChainName(std::string chain)
convert a trigger chain name into a string usable in decoration/branch names (.
std::vector< std::string > signatures(const std::string &chain)
This module defines the arguments passed from the BATCH driver to the BATCH worker.
SG::Decorator< T, ALLOC > Decorator
Helper class to provide type-safe access to aux data, specialized for JaggedVecElt.
Definition AuxElement.h:576
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.
per-chain dummy matching decorations, built in initialize()
per-chain matching configuration, built in initialize()