ATLAS Offline Software
Loading...
Searching...
No Matches
AsgClassificationDecorationAlg.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
7
10
11#include <unordered_map>
12
13namespace CP
14{
15
17{
18
21 ANA_CHECK (m_systematicsList.initialize());
22
23 ANA_CHECK (m_tool.retrieve());
24
25 return StatusCode::SUCCESS;
26}
27
28
29
30StatusCode AsgClassificationDecorationAlg::execute(const EventContext& ctx)
31{
32
33 std::unordered_map<const xAOD::IParticle *, unsigned int> classifications;
34
35 for (const auto& sys : m_systematicsList.systematicsVector())
36 {
37 const xAOD::IParticleContainer *particles = nullptr;
38 ANA_CHECK(m_particlesHandle.retrieve(particles, sys, ctx));
39
40 for (const xAOD::IParticle *particle : *particles)
41 {
42 const xAOD::IParticle *key = xAOD::getOriginalObject (*particle);
43 if (key == nullptr)
44 key = particle;
45
46 auto iter = classifications.find (key);
47 if (iter == classifications.end())
48 {
49 unsigned int classification = 0;
50 ANA_CHECK (m_tool->classify (*particle, classification));
51 iter = classifications.emplace (key, classification).first;
52 }
53 m_classificationDecorator.set (*particle, iter->second, sys);
54 }
55 }
56
57 return StatusCode::SUCCESS;
58}
59
60} // namespace CP
#define ANA_CHECK(EXP)
check whether the given expression was successful
CP::SysListHandle m_systematicsList
the systematics list we run
CP::SysWriteDecorHandle< int > m_classificationDecorator
the decoration for the truth classification
CP::SysReadHandle< xAOD::IParticleContainer > m_particlesHandle
particles container handle
ToolHandle< IClassificationTool > m_tool
truth classifier tool handle
virtual::StatusCode execute()
execute this algorithm
Class providing the definition of the 4-vector interface.
Select isolated Photons, Electrons and Muons.
const IParticle * getOriginalObject(const IParticle &copy)
This function can be used to conveniently get a pointer back to the original object from which a copy...
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.