ATLAS Offline Software
Loading...
Searching...
No Matches
DerivationFramework::TruthClassificationDecorator Class Reference

#include <TruthClassificationDecorator.h>

Inheritance diagram for DerivationFramework::TruthClassificationDecorator:
Collaboration diagram for DerivationFramework::TruthClassificationDecorator:

Public Member Functions

virtual StatusCode initialize () override final
virtual StatusCode finalize () override final
virtual StatusCode addBranches (const EventContext &ctx) const override final

Private Attributes

std::atomic< unsigned int > m_ntotpart {}
SG::ReadHandleKey< xAOD::TruthParticleContainerm_particlesKey {this, "ParticlesKey", "TruthParticles", "ReadHandleKey for input TruthParticleContainer"}
SG::WriteDecorHandleKey< xAOD::TruthParticleContainerm_originDecoratorKey {this, "classifierParticleOrigin", m_particlesKey, "classifierParticleOrigin", "Particle origin decoration"}
SG::WriteDecorHandleKey< xAOD::TruthParticleContainerm_typeDecoratorKey {this, "classifierParticleType", m_particlesKey, "classifierParticleType", "Particle type decoration"}
SG::WriteDecorHandleKey< xAOD::TruthParticleContainerm_outcomeDecoratorKey {this, "classifierParticleOutCome", m_particlesKey, "classifierParticleOutCome", "Particle outcome decoration"}
SG::WriteDecorHandleKey< xAOD::TruthParticleContainerm_classificationDecoratorKey {this, "Classification", m_particlesKey, "Classification", "Classification code decorator"}
PublicToolHandle< IMCTruthClassifierm_classifier {this, "MCTruthClassifier", "MCTruthClassifier/MCTruthClassifier"}

Detailed Description

Definition at line 21 of file TruthClassificationDecorator.h.

Member Function Documentation

◆ addBranches()

StatusCode DerivationFramework::TruthClassificationDecorator::addBranches ( const EventContext & ctx) const
finaloverridevirtual

Definition at line 44 of file TruthClassificationDecorator.cxx.

45{
46
47 // Event context for multi-threading
48
49 // Retrieve truth collections
50 SG::ReadHandle<xAOD::TruthParticleContainer> truthParticles(m_particlesKey,ctx);
51 if (!truthParticles.isValid()) {
52 ATH_MSG_ERROR("Couldn't retrieve TruthParticle collection with name " << m_particlesKey);
53 return StatusCode::FAILURE;
54 }
55
56 unsigned int nParticles = truthParticles->size();
57 m_ntotpart += nParticles;
58
59 // Set up decorators
60 SG::WriteDecorHandle<xAOD::TruthParticleContainer, unsigned int> originDecorator(m_originDecoratorKey, ctx);
61 SG::WriteDecorHandle<xAOD::TruthParticleContainer, unsigned int> typeDecorator(m_typeDecoratorKey, ctx);
62 SG::WriteDecorHandle<xAOD::TruthParticleContainer, unsigned int> outcomeDecorator(m_outcomeDecoratorKey, ctx);
63 SG::WriteDecorHandle<xAOD::TruthParticleContainer, unsigned int> classificationDecorator(m_classificationDecoratorKey, ctx);
64
65 for (unsigned int i=0; i<nParticles; ++i) {
66 MCTruthPartClassifier::Info info;
67 auto classification = m_classifier->particleTruthClassifier((*truthParticles)[i], &info);
68 unsigned int particleOutCome = info.particleOutCome;
69 unsigned int result = (unsigned int)( (*truthParticles)[i] ? std::get<0>(MCTruthPartClassifier::defOrigOfParticle((*truthParticles)[i])) : 0 );
70 unsigned int particleType = classification.first;
71 unsigned int particleOrigin = classification.second;
72 typeDecorator(*((*truthParticles)[i])) = particleType;
73 originDecorator(*((*truthParticles)[i])) = particleOrigin;
74 outcomeDecorator(*((*truthParticles)[i])) = particleOutCome;
75
76 classificationDecorator(*((*truthParticles)[i])) = result;
77 }
78
79 return StatusCode::SUCCESS;
80}
#define ATH_MSG_ERROR(x)
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_originDecoratorKey
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_outcomeDecoratorKey
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_typeDecoratorKey
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_classificationDecoratorKey
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_particlesKey
std::tuple< unsigned int, T > defOrigOfParticle(T thePart)

◆ finalize()

StatusCode DerivationFramework::TruthClassificationDecorator::finalize ( )
finaloverridevirtual

Definition at line 36 of file TruthClassificationDecorator.cxx.

37{
38 ATH_MSG_VERBOSE("finalize() ...");
39 ATH_MSG_INFO("Processed and decorated "<< m_ntotpart <<" truth particles");
40 return StatusCode::SUCCESS;
41}
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)

◆ initialize()

StatusCode DerivationFramework::TruthClassificationDecorator::initialize ( )
finaloverridevirtual

Definition at line 19 of file TruthClassificationDecorator.cxx.

20{
21 ATH_MSG_VERBOSE("initialize() ...");
22 ATH_CHECK(m_classifier.retrieve());
23
24 ATH_CHECK( m_particlesKey.initialize() );
25 ATH_MSG_INFO("Decorating " << m_particlesKey.key() << " with classification information");
26
27 // Decorators
28 ATH_CHECK(m_originDecoratorKey.initialize());
29 ATH_CHECK(m_typeDecoratorKey.initialize());
30 ATH_CHECK(m_outcomeDecoratorKey.initialize());
32
33 return StatusCode::SUCCESS;
34}
#define ATH_CHECK
Evaluate an expression and check for errors.

Member Data Documentation

◆ m_classificationDecoratorKey

SG::WriteDecorHandleKey<xAOD::TruthParticleContainer> DerivationFramework::TruthClassificationDecorator::m_classificationDecoratorKey {this, "Classification", m_particlesKey, "Classification", "Classification code decorator"}
private

Definition at line 41 of file TruthClassificationDecorator.h.

42{this, "Classification", m_particlesKey, "Classification", "Classification code decorator"};

◆ m_classifier

PublicToolHandle<IMCTruthClassifier> DerivationFramework::TruthClassificationDecorator::m_classifier {this, "MCTruthClassifier", "MCTruthClassifier/MCTruthClassifier"}
private

Definition at line 43 of file TruthClassificationDecorator.h.

43{this, "MCTruthClassifier", "MCTruthClassifier/MCTruthClassifier"};

◆ m_ntotpart

std::atomic<unsigned int> DerivationFramework::TruthClassificationDecorator::m_ntotpart {}
mutableprivate

Definition at line 31 of file TruthClassificationDecorator.h.

31{};

◆ m_originDecoratorKey

SG::WriteDecorHandleKey<xAOD::TruthParticleContainer> DerivationFramework::TruthClassificationDecorator::m_originDecoratorKey {this, "classifierParticleOrigin", m_particlesKey, "classifierParticleOrigin", "Particle origin decoration"}
private

Definition at line 35 of file TruthClassificationDecorator.h.

36{this, "classifierParticleOrigin", m_particlesKey, "classifierParticleOrigin", "Particle origin decoration"};

◆ m_outcomeDecoratorKey

SG::WriteDecorHandleKey<xAOD::TruthParticleContainer> DerivationFramework::TruthClassificationDecorator::m_outcomeDecoratorKey {this, "classifierParticleOutCome", m_particlesKey, "classifierParticleOutCome", "Particle outcome decoration"}
private

Definition at line 39 of file TruthClassificationDecorator.h.

40{this, "classifierParticleOutCome", m_particlesKey, "classifierParticleOutCome", "Particle outcome decoration"};

◆ m_particlesKey

SG::ReadHandleKey<xAOD::TruthParticleContainer> DerivationFramework::TruthClassificationDecorator::m_particlesKey {this, "ParticlesKey", "TruthParticles", "ReadHandleKey for input TruthParticleContainer"}
private

Definition at line 32 of file TruthClassificationDecorator.h.

33{this, "ParticlesKey", "TruthParticles", "ReadHandleKey for input TruthParticleContainer"};

◆ m_typeDecoratorKey

SG::WriteDecorHandleKey<xAOD::TruthParticleContainer> DerivationFramework::TruthClassificationDecorator::m_typeDecoratorKey {this, "classifierParticleType", m_particlesKey, "classifierParticleType", "Particle type decoration"}
private

Definition at line 37 of file TruthClassificationDecorator.h.

38{this, "classifierParticleType", m_particlesKey, "classifierParticleType", "Particle type decoration"};

The documentation for this class was generated from the following files: