ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
DerivationFramework::TruthClassificationDecorator Class Reference

#include <TruthClassificationDecorator.h>

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

Public Member Functions

 TruthClassificationDecorator (const std::string &t, const std::string &n, const IInterface *p)
 
 ~TruthClassificationDecorator ()
 
StatusCode initialize ()
 
StatusCode finalize ()
 
virtual StatusCode addBranches () const
 

Private Attributes

std::atomic< unsigned int > m_ntotpart
 
SG::ReadHandleKey< xAOD::TruthParticleContainerm_particlesKey {this, "ParticlesKey", "TruthParticles", "ReadHandleKey for input TruthParticleContainer"}
 
SG::WriteDecorHandleKey< xAOD::TruthParticleContainerm_linkDecoratorKey {this, "originalTruthParticle", m_particlesKey, "originalTruthParticle", "Link to the original truth particle"}
 
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"}
 
ToolHandle< IMCTruthClassifierm_classifier
 

Detailed Description

Definition at line 21 of file TruthClassificationDecorator.h.

Constructor & Destructor Documentation

◆ TruthClassificationDecorator()

DerivationFramework::TruthClassificationDecorator::TruthClassificationDecorator ( const std::string &  t,
const std::string &  n,
const IInterface *  p 
)

Definition at line 19 of file TruthClassificationDecorator.cxx.

21  :
22 base_class(t,n,p),
23 m_ntotpart(0),
24 m_classifier("MCTruthClassifier/MCTruthClassifier")
25 {
26  declareProperty("MCTruthClassifier", m_classifier);
27 }

◆ ~TruthClassificationDecorator()

DerivationFramework::TruthClassificationDecorator::~TruthClassificationDecorator ( )

Definition at line 30 of file TruthClassificationDecorator.cxx.

30  {
31 }

Member Function Documentation

◆ addBranches()

StatusCode DerivationFramework::TruthClassificationDecorator::addBranches ( ) const
virtual

Definition at line 60 of file TruthClassificationDecorator.cxx.

61 {
62 
63  // Event context for multi-threading
64  const EventContext& ctx = Gaudi::Hive::currentContext();
65 
66  // Retrieve truth collections
68  if (!truthParticles.isValid()) {
69  ATH_MSG_ERROR("Couldn't retrieve TruthParticle collection with name " << m_particlesKey);
70  return StatusCode::FAILURE;
71  }
72 
73  unsigned int nParticles = truthParticles->size();
74  m_ntotpart += nParticles;
75 
76  // Set up decorators
82 
83  for (unsigned int i=0; i<nParticles; ++i) {
85  auto classification = m_classifier->particleTruthClassifier((*truthParticles)[i], &info);
86  unsigned int particleOutCome = info.particleOutCome;
87  unsigned int result = (unsigned int)( (*truthParticles)[i] ? std::get<0>(MCTruthPartClassifier::defOrigOfParticle((*truthParticles)[i])) : 0 );
88  unsigned int particleType = classification.first;
89  unsigned int particleOrigin = classification.second;
90  typeDecorator(*((*truthParticles)[i])) = particleType;
91  originDecorator(*((*truthParticles)[i])) = particleOrigin;
92  outcomeDecorator(*((*truthParticles)[i])) = particleOutCome;
93 
94  classificationDecorator(*((*truthParticles)[i])) = result;
95  }
96 
97  return StatusCode::SUCCESS;
98 }

◆ finalize()

StatusCode DerivationFramework::TruthClassificationDecorator::finalize ( )

Definition at line 52 of file TruthClassificationDecorator.cxx.

53 {
54  ATH_MSG_VERBOSE("finalize() ...");
55  ATH_MSG_INFO("Processed and decorated "<< m_ntotpart <<" truth particles");
56  return StatusCode::SUCCESS;
57 }

◆ initialize()

StatusCode DerivationFramework::TruthClassificationDecorator::initialize ( )

Definition at line 34 of file TruthClassificationDecorator.cxx.

35 {
36  ATH_MSG_VERBOSE("initialize() ...");
37  ATH_CHECK(m_classifier.retrieve());
38 
40  ATH_MSG_INFO("Decorating " << m_particlesKey.key() << " with classification information");
41 
42  // Decorators
48 
49  return StatusCode::SUCCESS;
50 }

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 42 of file TruthClassificationDecorator.h.

◆ m_classifier

ToolHandle<IMCTruthClassifier> DerivationFramework::TruthClassificationDecorator::m_classifier
private

Definition at line 44 of file TruthClassificationDecorator.h.

◆ m_linkDecoratorKey

SG::WriteDecorHandleKey<xAOD::TruthParticleContainer> DerivationFramework::TruthClassificationDecorator::m_linkDecoratorKey {this, "originalTruthParticle", m_particlesKey, "originalTruthParticle", "Link to the original truth particle"}
private

Definition at line 34 of file TruthClassificationDecorator.h.

◆ m_ntotpart

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

Definition at line 30 of file TruthClassificationDecorator.h.

◆ m_originDecoratorKey

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

Definition at line 36 of file TruthClassificationDecorator.h.

◆ m_outcomeDecoratorKey

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

Definition at line 40 of file TruthClassificationDecorator.h.

◆ m_particlesKey

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

Definition at line 31 of file TruthClassificationDecorator.h.

◆ m_typeDecoratorKey

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

Definition at line 38 of file TruthClassificationDecorator.h.


The documentation for this class was generated from the following files:
grepfile.info
info
Definition: grepfile.py:38
get_generator_info.result
result
Definition: get_generator_info.py:21
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SG::ReadHandle< xAOD::TruthParticleContainer >
DerivationFramework::TruthClassificationDecorator::m_classificationDecoratorKey
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_classificationDecoratorKey
Definition: TruthClassificationDecorator.h:43
DerivationFramework::TruthClassificationDecorator::m_outcomeDecoratorKey
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_outcomeDecoratorKey
Definition: TruthClassificationDecorator.h:41
DerivationFramework::TruthClassificationDecorator::m_originDecoratorKey
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_originDecoratorKey
Definition: TruthClassificationDecorator.h:37
MCTruthPartClassifier::defOrigOfParticle
std::tuple< unsigned int, T > defOrigOfParticle(T thePart)
Definition: TruthClassifiers.h:151
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
DerivationFramework::TruthClassificationDecorator::m_linkDecoratorKey
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_linkDecoratorKey
Definition: TruthClassificationDecorator.h:35
particleType
Definition: particleType.h:29
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:85
beamspotman.n
n
Definition: beamspotman.py:731
SG::WriteDecorHandle
Handle class for adding a decoration to an object.
Definition: StoreGate/StoreGate/WriteDecorHandle.h:100
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DerivationFramework::TruthClassificationDecorator::m_particlesKey
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_particlesKey
Definition: TruthClassificationDecorator.h:32
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
DerivationFramework::TruthClassificationDecorator::m_typeDecoratorKey
SG::WriteDecorHandleKey< xAOD::TruthParticleContainer > m_typeDecoratorKey
Definition: TruthClassificationDecorator.h:39
SG::WriteDecorHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
python.CaloAddPedShiftConfig.int
int
Definition: CaloAddPedShiftConfig.py:45
DerivationFramework::TruthClassificationDecorator::m_classifier
ToolHandle< IMCTruthClassifier > m_classifier
Definition: TruthClassificationDecorator.h:44
DerivationFramework::TruthClassificationDecorator::m_ntotpart
std::atomic< unsigned int > m_ntotpart
Definition: TruthClassificationDecorator.h:30
MCTruthPartClassifier::Info
Definition: IMCTruthClassifier.h:49