ATLAS Offline Software
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 
9 namespace 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  {
50  if (!m_tdt->isPassed(name, rerun ? TrigDefs::Physics | TrigDefs::allowResurrectedDecision : TrigDefs::Physics))
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
grepfile.info
info
Definition: grepfile.py:38
Trig::R3IParticleRetrievalTool::R3IParticleRetrievalTool
R3IParticleRetrievalTool(const std::string &name)
Standard constructor.
Definition: R3IParticleRetrievalTool.cxx:11
R3IParticleRetrievalTool.h
TrigCompositeUtils::buildCombinations
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.
Definition: TrigCompositeUtilsRoot.cxx:800
runLayerRecalibration.chain
chain
Definition: runLayerRecalibration.py:175
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
Trig::R3IParticleRetrievalTool::~R3IParticleRetrievalTool
virtual ~R3IParticleRetrievalTool() override
Destructor.
Definition: R3IParticleRetrievalTool.cxx:17
Trig
The common trigger namespace for trigger analysis tools.
Definition: LArCellMonAlg.h:33
Trig::R3IParticleRetrievalTool::m_tdt
ToolHandle< Trig::TrigDecisionTool > m_tdt
The TrigDecisionTool that will be used to get the navigation.
Definition: R3IParticleRetrievalTool.h:52
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
TrigCompositeUtils::FilterType::UniqueObjects
@ UniqueObjects
Do not allow any repeated objects.
asg
Definition: DataHandleTestTool.h:28
Trig::R3IParticleRetrievalTool::m_warnedChainsMutex
std::mutex m_warnedChainsMutex
mutex to protect that set
Definition: R3IParticleRetrievalTool.h:56
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
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
IParticleContainer.h
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
Trig::R3IParticleRetrievalTool::retrieveParticles
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.
Definition: R3IParticleRetrievalTool.cxx:26
TrigCompositeUtils::Combinations
Definition: Combinations.h:18
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
Trig::ChainGroup
Definition: ChainGroup.h:51
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
python.combo.combinations
def combinations(items, n)
Definition: combo.py:85
TrigCompositeUtils::LinkInfo< xAOD::IParticleContainer >
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
Trig::ChainGroup::getListOfTriggers
std::vector< std::string > getListOfTriggers() const
Definition: ChainGroup.cxx:467
Combinations.h
Trig::R3IParticleRetrievalTool::initialize
virtual StatusCode initialize() override
Initialise the tool.
Definition: R3IParticleRetrievalTool.cxx:19