ATLAS Offline Software
Loading...
Searching...
No Matches
R3IParticleRetrievalTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
8
9namespace Trig
10{
12 : asg::AsgTool(name)
13 {
14 declareProperty("TrigDecisionTool", m_tdt);
15 }
16
18
20 {
21 ATH_MSG_INFO("Initializing " << name());
22 ATH_CHECK(m_tdt.retrieve());
23 return StatusCode::SUCCESS;
24 }
25
27 std::vector<std::vector<const xAOD::IParticle *>> &combinations,
28 const std::string &chain,
29 bool rerun) const
30 {
32 using VecLinkInfo_t = std::vector<IPartLinkInfo_t>;
33 // Make sure we start from a blank slate
34 combinations.clear();
35
36 // Start by getting the chain group
37 const ChainGroup *cg = m_tdt->getChainGroup(chain);
38 // Make sure that this group actually contains triggers. If it doesn't then
39 // this is very wrong and the job shouldn't be allowed to continue
40 if (cg->getListOfTriggers().size() == 0)
41 {
42 ATH_MSG_ERROR("Chain group " << chain
43 << " is empty! This means that no matching chains were found!");
44 return StatusCode::FAILURE;
45 }
46
47 // Now go chain by chain
48 for (const std::string &name : cg->getListOfTriggers())
49 {
51 {
52 ATH_MSG_DEBUG("Chain " << name << " did not pass");
53 continue;
54 }
55 ATH_MSG_DEBUG("Chain " << name << " passed");
56 const auto &features = m_tdt->features<xAOD::IParticleContainer>(name);
57 ATH_MSG_DEBUG("Found " << features.size() << " features");
58 // Check for dead legs
59 if (std::any_of(
60 features.begin(), features.end(),
61 [] (const TrigCompositeUtils::LinkInfo<xAOD::IParticleContainer>& li) {return !li.link.isValid();}))
62 {
63 // Only warn once per chain per job
64 std::scoped_lock lock(m_warnedChainsMutex);
65 if (m_warnedChains.insert(name).second)
66 ATH_MSG_WARNING("Invalid link found for " << name << "!");
67 continue;
68 }
69 // Build up the full list of trigger combinations
70 // TODO - right now we use a filter that passes everything that isn't pointer-equal.
71 // This will probably need to be fixed to something else later - at least the unique RoI filter
73 name,
74 features,
75 m_tdt->ExperimentalAndExpertMethods().getChainConfigurationDetails(name),
77 // Copy the combinations into the output vector
78 for (const VecLinkInfo_t &combo : trigCombinations)
79 {
80 std::vector<const xAOD::IParticle *> comboOut;
81 comboOut.reserve(combo.size());
82 for (const IPartLinkInfo_t &info : combo)
83 comboOut.push_back(*info.link);
84 combinations.push_back(std::move(comboOut));
85 }
86 }
87 return StatusCode::SUCCESS;
88 }
89} // namespace Trig
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
std::vector< std::string > getListOfTriggers() const
virtual StatusCode initialize() override
Initialise the tool.
ToolHandle< Trig::TrigDecisionTool > m_tdt
The TrigDecisionTool that will be used to get the navigation.
virtual ~R3IParticleRetrievalTool() override
Destructor.
R3IParticleRetrievalTool(const std::string &name)
Standard constructor.
std::mutex m_warnedChainsMutex
mutex to protect that set
virtual StatusCode retrieveParticles(std::vector< std::vector< const xAOD::IParticle * > > &combinations, const std::string &chain, bool rerun=false) const override
Retrieve the particles that caused this trigger to fire.
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition AsgTool.cxx:58
Combinations buildCombinations(const std::string &chainName, const std::vector< LinkInfo< xAOD::IParticleContainer > > &features, const std::vector< std::size_t > &legMultiplicities, const std::function< bool(const std::vector< LinkInfo< xAOD::IParticleContainer > > &)> &filter)
Produce the combinations for a set of features.
@ UniqueObjects
Do not allow any repeated objects.
The common trigger namespace for trigger analysis tools.
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.
Helper to keep a Decision object, ElementLink and ActiveState (with respect to some requested ChainGr...
Definition LinkInfo.h:22