ATLAS Offline Software
Loading...
Searching...
No Matches
Trk::DecayInFlyTruthTrajectoryBuilder Class Referencefinal

#include <DecayInFlyTruthTrajectoryBuilder.h>

Inheritance diagram for Trk::DecayInFlyTruthTrajectoryBuilder:
Collaboration diagram for Trk::DecayInFlyTruthTrajectoryBuilder:

Public Types

typedef std::pair< HepMC::ConstGenParticlePtr, HepMC::ConstGenParticlePtrMotherDaughter
 Return type for the next method.

Public Member Functions

 DecayInFlyTruthTrajectoryBuilder (const std::string &type, const std::string &name, const IInterface *parent)
virtual StatusCode initialize ()
void buildTruthTrajectory (TruthTrajectory *result, const HepMC::ConstGenParticlePtr &input) const
 Build a TruthTrajectory this particle belongs to.
HepMC::ConstGenParticlePtr getMother (const HepMC::ConstGenParticlePtr &particle) const
 Returns an umambiguous mother of the truth particle on a TruthTrajectory, or 0.
HepMC::ConstGenParticlePtr getDaughter (const HepMC::ConstGenParticlePtr &particle) const
 Returns an umambiguous daughter of the truth particle on a TruthTrajectory, or 0.
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Static Public Member Functions

static MotherDaughter truthTrajectoryCuts (const HepMC::ConstGenVertexPtr &vtx)
 Decides if the vertex connects two particles on the same TruthTrajectory.
static const InterfaceID & interfaceID ()

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Definition at line 17 of file DecayInFlyTruthTrajectoryBuilder.h.

Member Typedef Documentation

◆ MotherDaughter

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ DecayInFlyTruthTrajectoryBuilder()

Trk::DecayInFlyTruthTrajectoryBuilder::DecayInFlyTruthTrajectoryBuilder ( const std::string & type,
const std::string & name,
const IInterface * parent )

Definition at line 23 of file DecayInFlyTruthTrajectoryBuilder.cxx.

27 : AthAlgTool(type,name,parent)
28{
29 declareInterface<Trk::ITruthTrajectoryBuilder>(this);
30}
AthAlgTool()
Default constructor:

Member Function Documentation

◆ buildTruthTrajectory()

void Trk::DecayInFlyTruthTrajectoryBuilder::buildTruthTrajectory ( TruthTrajectory * result,
const HepMC::ConstGenParticlePtr & input ) const
virtual

Build a TruthTrajectory this particle belongs to.


The result may be an empty TruthTrajectory (in case input did not pass the cuts).

Implements Trk::ITruthTrajectoryBuilder.

Definition at line 39 of file DecayInFlyTruthTrajectoryBuilder.cxx.

41{
42 result->clear();
43 if (input) {
46
47 // Extend trajectory outwards. The last particle should go at [0]
48 // in the TruthTrajectory, so we need to use a tmp storage while
49 // traversing the structure.
50 std::stack<HepMC::ConstGenParticlePtr> tmp;
51 while ( (next = getDaughter(current)) ) {
52 tmp.push(current = next);
53 }
54
55 // All particles in the TruthTrajectory will be from the same GenEvent
56 const int eventNumber = input->parent_event()->event_number();
57
58 // copy the outer half to result
59 while (!tmp.empty()) {
60 result->emplace_back(tmp.top(), eventNumber, HepMcParticleLink::IS_EVENTNUM);
61 tmp.pop();
62 }
63
64 // The input particle itself
65 result->emplace_back(input, eventNumber, HepMcParticleLink::IS_EVENTNUM);
66
67 // Now continue towards the interaction point
68 while ( (next = getMother(current)) ) {
69 result->emplace_back(current = next, eventNumber, HepMcParticleLink::IS_EVENTNUM);
70 }
71 }
72}
HepMC::ConstGenParticlePtr getDaughter(const HepMC::ConstGenParticlePtr &particle) const
Returns an umambiguous daughter of the truth particle on a TruthTrajectory, or 0.
HepMC::ConstGenParticlePtr getMother(const HepMC::ConstGenParticlePtr &particle) const
Returns an umambiguous mother of the truth particle on a TruthTrajectory, or 0.
const GenParticle * ConstGenParticlePtr
Definition GenParticle.h:38
@ next
Definition BinningData.h:33

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ getDaughter()

HepMC::ConstGenParticlePtr Trk::DecayInFlyTruthTrajectoryBuilder::getDaughter ( const HepMC::ConstGenParticlePtr & particle) const
virtual

Returns an umambiguous daughter of the truth particle on a TruthTrajectory, or 0.

This assumes no one mother can correspond to no more than one daughter. Implemented via truthTrajectoryCuts().

Implements Trk::ITruthTrajectoryBuilder.

Definition at line 131 of file DecayInFlyTruthTrajectoryBuilder.cxx.

131 {
132 if(mother) {
133 MotherDaughter res = truthTrajectoryCuts(mother->end_vertex());
134 if(res.first == mother) return res.second;
135 }
136 return {nullptr};
137}
std::pair< std::vector< unsigned int >, bool > res
static MotherDaughter truthTrajectoryCuts(const HepMC::ConstGenVertexPtr &vtx)
Decides if the vertex connects two particles on the same TruthTrajectory.
std::pair< HepMC::ConstGenParticlePtr, HepMC::ConstGenParticlePtr > MotherDaughter
Return type for the next method.

◆ getMother()

HepMC::ConstGenParticlePtr Trk::DecayInFlyTruthTrajectoryBuilder::getMother ( const HepMC::ConstGenParticlePtr & particle) const
virtual

Returns an umambiguous mother of the truth particle on a TruthTrajectory, or 0.

Implemented via truthTrajectoryCuts().

Implements Trk::ITruthTrajectoryBuilder.

Definition at line 140 of file DecayInFlyTruthTrajectoryBuilder.cxx.

140 {
141 if(daughter) {
142 MotherDaughter res = truthTrajectoryCuts(daughter->production_vertex());
143 if(res.second == daughter) return res.first;
144 }
145 return {nullptr};
146}

◆ initialize()

StatusCode Trk::DecayInFlyTruthTrajectoryBuilder::initialize ( )
virtual

Definition at line 34 of file DecayInFlyTruthTrajectoryBuilder.cxx.

34 {
35 return StatusCode::SUCCESS;
36}

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ interfaceID()

const InterfaceID & Trk::ITruthTrajectoryBuilder::interfaceID ( )
inlinestaticinherited

Definition at line 27 of file ITruthTrajectoryBuilder.h.

static const InterfaceID IID_ITruthTrajectoryBuilder("Trk::ITruthTrajectoryBuilder", 1, 0)

◆ msg()

MsgStream & AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and DerivationFramework::CfAthAlgTool.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ truthTrajectoryCuts()

DecayInFlyTruthTrajectoryBuilder::MotherDaughter Trk::DecayInFlyTruthTrajectoryBuilder::truthTrajectoryCuts ( const HepMC::ConstGenVertexPtr & vtx)
static

Decides if the vertex connects two particles on the same TruthTrajectory.

Returns the (mother,daughter) pair, where either of the two can be NULL.

This interface implies that there is one-to-one correspondence between mother and daughter particles; i.e. TruthTrajectories are not allowed to branch.

Definition at line 76 of file DecayInFlyTruthTrajectoryBuilder.cxx.

77{
78 HepMC::ConstGenParticlePtr mother{nullptr};
79 HepMC::ConstGenParticlePtr daughter{nullptr};
80 // only truth vertices with 1 incoming particle
81 // Restrict to quasi-elastic processes (e.g. brems, delta-rays, pi->pi+Delta).
82 //
83 // Require not more than 2 outgoing particles. Note that
84 // delta-rays for primary==electron is a special case, because we have two
85 // outgoing particles with the same PDG id. The "correct" one
86 // is that with the higher energy (NOT pt).
87 //
88 // allow 1 outgoing to cover possible vertexes from interaction in detector material
89 if(vtx && (vtx->particles_in_size() == 1) && (vtx->particles_out_size() <= 2) ) {
90
91#ifdef HEPMC3
92 mother = vtx->particles_in().front();
93#else
94 mother = *vtx->particles_in_const_begin();
95#endif
96 // Allow status code 1 and 2. E.g. a pion that produced a long track can decay outside of InDet and have status==2.
97 if( mother && MC::isPhysical(mother) ) {
98
99 int num_passed_cuts = 0;
100 HepMC::ConstGenParticlePtr passed_cuts{nullptr};
101 for(const HepMC::ConstGenParticlePtr& candidate: *vtx){
102 if(candidate->pdg_id() == mother->pdg_id()) {
103
104 if(passed_cuts && MC::isElectron(mother)) { // second negative electron is a special case
105 if(candidate->momentum().e() > passed_cuts->momentum().e()) {
106 passed_cuts = candidate; // don't increment num_passed_cuts, we are replacing chosen particle
107 }
108 }
109 else {
110 passed_cuts = candidate;
111 ++num_passed_cuts;
112 }
113 }
114 // allow pi/k->mu decay
115 else if(std::abs(candidate->pdg_id()) == 13){
116 passed_cuts = candidate;
117 ++num_passed_cuts;
118 }
119 }
120
121 if(num_passed_cuts==1) { // disallow hadronic pi->N*pi etc.
122 daughter = std::move(passed_cuts);
123 }
124 }
125 }
126
127 return std::make_pair(mother, daughter);
128}
bool isElectron(const T &p)
bool isPhysical(const T &p)
Identify if the particle is physical, i.e. is stable or decayed.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


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