Belle II Software light-2406-ragdoll
MCParticle Class Reference

A Class to store the Monte Carlo particle information. More...

#include <MCParticle.h>

Inheritance diagram for MCParticle:
Collaboration diagram for MCParticle:

Public Types

enum  StatusBit {
  c_PrimaryParticle = 1 << 0 ,
  c_StableInGenerator = 1 << 1 ,
  c_LeftDetector = 1 << 2 ,
  c_StoppedInDetector = 1 << 3 ,
  c_IsVirtual = 1 << 4 ,
  c_Initial = 1 << 5 ,
  c_IsISRPhoton = 1 << 6 ,
  c_IsFSRPhoton = 1 << 7 ,
  c_IsPHOTOSPhoton = 1 << 8 ,
  c_IsRadiativePhoton = c_IsISRPhoton | c_IsFSRPhoton | c_IsPHOTOSPhoton
}
 Exception is thrown if the requested index for the last child is out of range. More...
 

Public Member Functions

 MCParticle ()
 Default constructor for ROOT.
 
 MCParticle (TClonesArray *plist, const MCParticle &p)
 Construct MCParticle from a another MCParticle and the TClonesArray it is stored in.
 
int getPDG () const
 Return PDG code of particle.
 
unsigned int getStatus (unsigned short int bitmask=USHRT_MAX) const
 Return status code of particle.
 
bool hasStatus (unsigned short int bitmask) const
 Return if specific status bit is set.
 
float getMass () const
 Return the particle mass in GeV.
 
float getCharge () const
 Return the particle charge defined in TDatabasePDG.
 
float getEnergy () const
 Return particle energy in GeV.
 
bool hasValidVertex () const
 Indication whether vertex and time information is useful or just default.
 
float getProductionTime () const
 Return production time in ns.
 
float getDecayTime () const
 Return the decay time in ns.
 
float getLifetime () const
 Return the lifetime in ns.
 
ROOT::Math::XYZVector getVertex () const
 Return production vertex position, shorthand for getProductionVertex().
 
ROOT::Math::XYZVector getProductionVertex () const
 Return production vertex position.
 
ROOT::Math::XYZVector getMomentum () const
 Return momentum.
 
ROOT::Math::PxPyPzEVector get4Vector () const
 Return 4Vector of particle.
 
ROOT::Math::XYZVector getDecayVertex () const
 Return decay vertex.
 
int getIndex () const
 Get 1-based index of the particle in the corresponding MCParticle list.
 
int getArrayIndex () const
 Get 0-based index of the particle in the corresponding MCParticle list.
 
int getFirstDaughter () const
 Get 1-based index of first daughter, 0 if no daughters.
 
int getLastDaughter () const
 Get 1-based index of last daughter, 0 if no daughters.
 
std::vector< Belle2::MCParticle * > getDaughters () const
 Get vector of all daughter particles, empty vector if none.
 
const MCParticlegetDaughter (int i) const
 Return i-th daughter.
 
int getNDaughters () const
 Return number of daughter MCParticles.
 
MCParticlegetMother () const
 Returns a pointer to the mother particle.
 
int getSecondaryPhysicsProcess () const
 Returns the physics process type of a secondary particle.
 
Const::DetectorSet getSeenInDetector () const
 Return the seen-in flags of the entire Belle II subdetectors for an MC particle.
 
bool hasSeenInDetector (Const::DetectorSet set) const
 Return if the seen-in flag for a specific subdetector is set or not.
 
bool isVirtual () const
 Check if particle is virtual.
 
bool isInitial () const
 Check if particle is an initial particle such as ISR.
 
bool isPrimaryParticle () const
 Check if particle is a primary particle which was created by the generator (and not, for example material interaction)
 
void setPDG (int pdg)
 Set PDG code of the particle.
 
void setMassFromPDG ()
 Sets the mass for the particle from the particle's PDG code.
 
void setStatus (unsigned short int status)
 Set Status code for the particle.
 
void addStatus (unsigned short int bitmask)
 Add bitmask to current status.
 
void removeStatus (unsigned short int bitmask)
 Remove bitmask from current status.
 
void setMass (float mass)
 Set particle mass.
 
void setEnergy (float energy)
 Set energy.
 
void setValidVertex (bool valid)
 Set indication wether vertex and time information is valid or just default.
 
void setProductionTime (float time)
 Set production time.
 
void setDecayTime (float time)
 Set decay time.
 
void setProductionVertex (const ROOT::Math::XYZVector &vertex)
 Set production vertex position.
 
void setProductionVertex (float x, float y, float z)
 Set production vertex position.
 
void setMomentum (const ROOT::Math::XYZVector &momentum)
 Set particle momentum.
 
void setMomentum (float px, float py, float pz)
 Set particle momentum.
 
void set4Vector (const ROOT::Math::PxPyPzEVector &p4)
 Sets the 4Vector of particle.
 
void setDecayVertex (const ROOT::Math::XYZVector &vertex)
 Set decay vertex.
 
void setDecayVertex (float x, float y, float z)
 Set decay vertex.
 
void setSecondaryPhysicsProcess (int physicsProcess)
 Sets the physics process type of a secondary particle.
 
void setSeenInDetector (Const::DetectorSet set)
 Set the seen-in flags for the entire Belle II subdetectors for an Monte Carlo particle.
 
void addSeenInDetector (Const::DetectorSet set)
 Flag/Add a bit if the MC particle is seen in a specific subdetector.
 
void removeSeenInDetector (Const::DetectorSet set)
 Unflag/Remove the bit if the MC particle is not seen in a specific subdetector.
 
void fixParticleList () const
 Search the DataStore for the corresponding MCParticle array.
 
void setVirtual ()
 Set particle to virtual.
 
void setInitial ()
 Set particle to initial.
 
virtual std::string getName () const override
 Return name of this particle.
 
virtual std::string getInfoHTML () const override
 Return a short summary of this object's contents in HTML format.
 
const MCParticlegetParticleFromGeneralizedIndexString (const std::string &generalizedIndex) const
 Explores the decay tree of the MC particle and returns the (grand^n)daughter identified by a generalized index.
 
void addRelationTo (const RelationsInterface< BASE > *object, float weight=1.0, const std::string &namedRelation="") const
 Add a relation from this object to another object (with caching).
 
void addRelationTo (const TObject *object, float weight=1.0, const std::string &namedRelation="") const
 Add a relation from this object to another object (no caching, can be quite slow).
 
void copyRelations (const RelationsInterface< BASE > *sourceObj)
 Copies all relations of sourceObj (pointing from or to sourceObj) to this object (including weights).
 
template<class TO >
RelationVector< TO > getRelationsTo (const std::string &name="", const std::string &namedRelation="") const
 Get the relations that point from this object to another store array.
 
template<class FROM >
RelationVector< FROM > getRelationsFrom (const std::string &name="", const std::string &namedRelation="") const
 Get the relations that point from another store array to this object.
 
template<class T >
RelationVector< T > getRelationsWith (const std::string &name="", const std::string &namedRelation="") const
 Get the relations between this object and another store array.
 
template<class TO >
TO * getRelatedTo (const std::string &name="", const std::string &namedRelation="") const
 Get the object to which this object has a relation.
 
template<class FROM >
FROM * getRelatedFrom (const std::string &name="", const std::string &namedRelation="") const
 Get the object from which this object has a relation.
 
template<class T >
T * getRelated (const std::string &name="", const std::string &namedRelation="") const
 Get the object to or from which this object has a relation.
 
template<class TO >
std::pair< TO *, float > getRelatedToWithWeight (const std::string &name="", const std::string &namedRelation="") const
 Get first related object & weight of relation pointing to an array.
 
template<class FROM >
std::pair< FROM *, float > getRelatedFromWithWeight (const std::string &name="", const std::string &namedRelation="") const
 Get first related object & weight of relation pointing from an array.
 
template<class T >
std::pair< T *, float > getRelatedWithWeight (const std::string &name="", const std::string &namedRelation="") const
 Get first related object & weight of relation pointing from/to an array.
 
std::string getInfo () const
 Return a short summary of this object's contents in raw text format.
 
std::string getArrayName () const
 Get name of array this object is stored in, or "" if not found.
 

Protected Member Functions

 ClassDefOverride (MCParticle, 5)
 A Class to store the Monte Carlo particle information.
 
TClonesArray * getArrayPointer () const
 Returns the pointer to the raw DataStore array holding this object (protected since these arrays are easy to misuse).
 

Protected Attributes

TClonesArray * m_plist
 Internal pointer to DataStore Array containing particles belonging to this collection.
 
int m_index
 transient pointer to particle list
 
unsigned short int m_status
 transient 1-based index of particle
 
int m_pdg
 PDG-Code of the particle.
 
float m_mass
 mass of the particle
 
float m_energy
 energy of the particle
 
float m_momentum_x
 momentum of particle, x component
 
float m_momentum_y
 momentum of particle, y component
 
float m_momentum_z
 momentum of particle, z component
 
bool m_validVertex
 indication wether vertex and time information is useful or just default
 
float m_productionTime
 production time
 
float m_productionVertex_x
 production vertex of particle, x component
 
float m_productionVertex_y
 production vertex of particle, y component
 
float m_productionVertex_z
 production vertex of particle, z component
 
float m_decayTime
 decay time
 
float m_decayVertex_x
 decay vertex of particle, x component
 
float m_decayVertex_y
 decay vertex of particle, y component
 
float m_decayVertex_z
 decay vertex of particle, z component
 
int m_mother
 1-based index of the mother particle
 
int m_firstDaughter
 1-based index of first daughter particle in collection, 0 if no daughters
 
int m_lastDaughter
 1-based index of last daughter particle in collection, 0 if no daughters
 
int m_secondaryPhysicsProcess
 physics process type of a secondary particle
 
Const::DetectorSet m_seenIn
 Each bit is a seen-in flag for the corresoponding subdetector of Belle II.
 

Static Protected Attributes

static const double c_epsilon = 10e-7
 limit of precision for two doubles to be the same.
 

Private Member Functions

 ClassDef (RelationsInterface, 0)
 defines interface for accessing relations of objects in StoreArray.
 

Private Attributes

DataStore::StoreEntrym_cacheDataStoreEntry
 Cache of the data store entry to which this object belongs.
 
int m_cacheArrayIndex
 Cache of the index in the TClonesArray to which this object belongs.
 

Friends

class FixMergedObjectsModule
 

Detailed Description

A Class to store the Monte Carlo particle information.

Definition at line 32 of file MCParticle.h.

Member Enumeration Documentation

◆ StatusBit

enum StatusBit

Exception is thrown if the requested index for the last child is out of range.

Exception is thrown if no pointer to the particle list was set. Exception is thrown if the pdg value of the MCParticle is not known to the internal database (TDatabasePDG). The status information for the MCParticle.

Enumerator
c_PrimaryParticle 

bit 0: Particle is primary particle.

For example, All the particles from the generator.

c_StableInGenerator 

bit 1: Particle is stable, i.e., not decaying in the generator.


c_LeftDetector 

bit 2: Particle left the detector (the simulation volume).

c_StoppedInDetector 

bit 3: Particle was stopped in the detector (the simulation volume).

c_IsVirtual 

bit 4: Particle is virtual and not going to Geant4.

Exchange boson, off-shell, unknown to Geant4, etc.

c_Initial 

bit 5: Particle is initial such as e+ or e- and not going to Geant4

c_IsISRPhoton 

bit 6: Particle is from initial state radiation

c_IsFSRPhoton 

bit 7: Particle is from finial state radiation

c_IsPHOTOSPhoton 

bit 8: Particle is an radiative photon from PHOTOS

c_IsRadiativePhoton 

combined flag to test whether the particle is radiative

Definition at line 45 of file MCParticle.h.

45 {
47 c_PrimaryParticle = 1 << 0,
49 c_StableInGenerator = 1 << 1,
51 c_LeftDetector = 1 << 2,
53 c_StoppedInDetector = 1 << 3,
55 c_IsVirtual = 1 << 4,
57 c_Initial = 1 << 5,
59 c_IsISRPhoton = 1 << 6,
61 c_IsFSRPhoton = 1 << 7,
63 c_IsPHOTOSPhoton = 1 << 8,
66 };
@ c_IsFSRPhoton
bit 7: Particle is from finial state radiation
Definition: MCParticle.h:61
@ c_Initial
bit 5: Particle is initial such as e+ or e- and not going to Geant4
Definition: MCParticle.h:57
@ c_IsPHOTOSPhoton
bit 8: Particle is an radiative photon from PHOTOS
Definition: MCParticle.h:63
@ c_IsRadiativePhoton
combined flag to test whether the particle is radiative
Definition: MCParticle.h:65
@ c_PrimaryParticle
bit 0: Particle is primary particle.
Definition: MCParticle.h:47
@ c_LeftDetector
bit 2: Particle left the detector (the simulation volume).
Definition: MCParticle.h:51
@ c_IsVirtual
bit 4: Particle is virtual and not going to Geant4.
Definition: MCParticle.h:55
@ c_StableInGenerator
bit 1: Particle is stable, i.e., not decaying in the generator.
Definition: MCParticle.h:49
@ c_StoppedInDetector
bit 3: Particle was stopped in the detector (the simulation volume).
Definition: MCParticle.h:53
@ c_IsISRPhoton
bit 6: Particle is from initial state radiation
Definition: MCParticle.h:59

Constructor & Destructor Documentation

◆ MCParticle() [1/2]

MCParticle ( )
inline

Default constructor for ROOT.

Definition at line 72 of file MCParticle.h.

72 :
73 m_plist(0), m_index(0), m_status(0),
74 m_pdg(0), m_mass(0), m_energy(0),
81 m_mother(0),
84 m_seenIn() {}
int m_lastDaughter
1-based index of last daughter particle in collection, 0 if no daughters
Definition: MCParticle.h:562
float m_productionVertex_x
production vertex of particle, x component
Definition: MCParticle.h:551
int m_firstDaughter
1-based index of first daughter particle in collection, 0 if no daughters
Definition: MCParticle.h:561
float m_mass
mass of the particle
Definition: MCParticle.h:542
float m_decayVertex_z
decay vertex of particle, z component
Definition: MCParticle.h:558
float m_decayTime
decay time
Definition: MCParticle.h:555
float m_productionVertex_z
production vertex of particle, z component
Definition: MCParticle.h:553
float m_energy
energy of the particle
Definition: MCParticle.h:543
float m_productionVertex_y
production vertex of particle, y component
Definition: MCParticle.h:552
int m_pdg
PDG-Code of the particle.
Definition: MCParticle.h:541
int m_mother
1-based index of the mother particle
Definition: MCParticle.h:560
float m_momentum_x
momentum of particle, x component
Definition: MCParticle.h:544
float m_decayVertex_x
decay vertex of particle, x component
Definition: MCParticle.h:556
unsigned short int m_status
transient 1-based index of particle
Definition: MCParticle.h:540
float m_momentum_z
momentum of particle, z component
Definition: MCParticle.h:546
int m_secondaryPhysicsProcess
physics process type of a secondary particle
Definition: MCParticle.h:565
bool m_validVertex
indication wether vertex and time information is useful or just default
Definition: MCParticle.h:548
float m_productionTime
production time
Definition: MCParticle.h:550
int m_index
transient pointer to particle list
Definition: MCParticle.h:538
float m_momentum_y
momentum of particle, y component
Definition: MCParticle.h:545
Const::DetectorSet m_seenIn
Each bit is a seen-in flag for the corresoponding subdetector of Belle II.
Definition: MCParticle.h:567
TClonesArray * m_plist
Internal pointer to DataStore Array containing particles belonging to this collection.
Definition: MCParticle.h:532
float m_decayVertex_y
decay vertex of particle, y component
Definition: MCParticle.h:557

◆ MCParticle() [2/2]

MCParticle ( TClonesArray *  plist,
const MCParticle p 
)
inline

Construct MCParticle from a another MCParticle and the TClonesArray it is stored in.

Used by MCParticleGraph to build a valid tree of MCParticles from particle and decay information

See also
class MCParticleGraph

Definition at line 94 of file MCParticle.h.

94 :
95 m_plist(plist), m_index(p.m_index), m_status(p.m_status),
96 m_pdg(p.m_pdg), m_mass(p.m_mass), m_energy(p.m_energy),
97 m_momentum_x(p.m_momentum_x), m_momentum_y(p.m_momentum_y), m_momentum_z(p.m_momentum_z),
98 m_validVertex(p.m_validVertex), m_productionTime(p.m_productionTime),
99 m_productionVertex_x(p.m_productionVertex_x), m_productionVertex_y(p.m_productionVertex_y),
100 m_productionVertex_z(p.m_productionVertex_z),
101 m_decayTime(p.m_decayTime), m_decayVertex_x(p.m_decayVertex_x),
102 m_decayVertex_y(p.m_decayVertex_y), m_decayVertex_z(p.m_decayVertex_z),
103 m_mother(p.m_mother),
104 m_firstDaughter(p.m_firstDaughter), m_lastDaughter(p.m_lastDaughter),
105 m_secondaryPhysicsProcess(p.m_secondaryPhysicsProcess),
106 m_seenIn(p.m_seenIn) {}

Member Function Documentation

◆ addRelationTo() [1/2]

void addRelationTo ( const RelationsInterface< BASE > *  object,
float  weight = 1.0,
const std::string &  namedRelation = "" 
) const
inlineinherited

Add a relation from this object to another object (with caching).

Parameters
objectThe object to which the relation should point.
weightThe weight of the relation.
namedRelationAdditional name for the relation, or "" for the default naming

Definition at line 142 of file RelationsObject.h.

143 {
144 if (object)
146 object, object->m_cacheDataStoreEntry, object->m_cacheArrayIndex, weight, namedRelation);
147 }
void addRelation(const TObject *fromObject, StoreEntry *&fromEntry, int &fromIndex, const TObject *toObject, StoreEntry *&toEntry, int &toIndex, float weight, const std::string &namedRelation)
Add a relation from an object in a store array to another object in a store array.
Definition: DataStore.cc:492
static DataStore & Instance()
Instance of singleton Store.
Definition: DataStore.cc:54
DataStore::StoreEntry * m_cacheDataStoreEntry
Cache of the data store entry to which this object belongs.
int m_cacheArrayIndex
Cache of the index in the TClonesArray to which this object belongs.

◆ addRelationTo() [2/2]

void addRelationTo ( const TObject *  object,
float  weight = 1.0,
const std::string &  namedRelation = "" 
) const
inlineinherited

Add a relation from this object to another object (no caching, can be quite slow).

Parameters
objectThe object to which the relation should point.
weightThe weight of the relation.
namedRelationAdditional name for the relation, or "" for the default naming

Definition at line 155 of file RelationsObject.h.

156 {
157 StoreEntry* toEntry = nullptr;
158 int toIndex = -1;
159 DataStore::Instance().addRelation(this, m_cacheDataStoreEntry, m_cacheArrayIndex, object, toEntry, toIndex, weight, namedRelation);
160 }

◆ addSeenInDetector()

void addSeenInDetector ( Const::DetectorSet  set)
inline

Flag/Add a bit if the MC particle is seen in a specific subdetector.

Parameters
setThe ID for Belle II subdetector(s), in either Const::DetectorSet or Const::EDetector format

Definition at line 480 of file MCParticle.h.

480{ m_seenIn += set; }

◆ addStatus()

void addStatus ( unsigned short int  bitmask)
inline

Add bitmask to current status.

Parameters
bitmaskThe status code which should be added to the existing MonteCarlo particle status code.

Definition at line 353 of file MCParticle.h.

353{ m_status |= bitmask; }

◆ copyRelations()

void copyRelations ( const RelationsInterface< BASE > *  sourceObj)
inlineinherited

Copies all relations of sourceObj (pointing from or to sourceObj) to this object (including weights).

Useful if you want to make a complete copy of a StoreArray object to make modifications to it, but retain all information on linked objects.

Note: this only works if sourceObj inherits from the same base (e.g. RelationsObject), and only for related objects that also inherit from the same base.

Definition at line 170 of file RelationsObject.h.

171 {
172 if (!sourceObj)
173 return;
174 auto fromRels = sourceObj->getRelationsFrom<RelationsInterface<BASE>>("ALL");
175 for (unsigned int iRel = 0; iRel < fromRels.size(); iRel++) {
176 fromRels.object(iRel)->addRelationTo(this, fromRels.weight(iRel));
177 }
178
179 auto toRels = sourceObj->getRelationsTo<RelationsInterface<BASE>>("ALL");
180 for (unsigned int iRel = 0; iRel < toRels.size(); iRel++) {
181 this->addRelationTo(toRels.object(iRel), toRels.weight(iRel));
182 }
183 }
void addRelationTo(const RelationsInterface< BASE > *object, float weight=1.0, const std::string &namedRelation="") const
Add a relation from this object to another object (with caching).

◆ fixParticleList()

void fixParticleList ( ) const

Search the DataStore for the corresponding MCParticle array.

This function should not be needed by normal users and is called automatically if the pointer to the particle list is not set when needed, e.g. after deserialization.

Definition at line 82 of file MCParticle.cc.

83{
84 if (m_plist != 0) return;
85
86 TClonesArray* plist(0);
87
88 //Search default location
89 //TODO: this could be replaced with RelationsObject::getArrayIndex()/getArrayName()
90 StoreArray<MCParticle> MCParticles;
91 if (MCParticles && MCParticles.getPtr()->IndexOf(this) >= 0) {
92 plist = MCParticles.getPtr();
93 } else {
94 //Search all StoreArrays which happen to store MCParticles
96 for (DataStore::StoreEntryConstIter iter = map.begin(); iter != map.end(); ++iter) {
97 TClonesArray* value = dynamic_cast<TClonesArray*>(iter->second.ptr);
98 if (value && value->GetClass() == Class() && value->IndexOf(this) >= 0) {
99 plist = value;
100 break;
101 }
102 }
103 }
104 //Could not find any collection, raise exception
105 if (!plist) {
106 B2ERROR("Could not determine StoreArray the MCParticle belongs to !");
107 throw NoParticleListSetError();
108 }
109
110 //Set plist pointer and index for whole array
111 for (int i = 0; i < plist->GetEntriesFast(); i++) {
112 MCParticle& mc = *(static_cast<MCParticle*>(plist->At(i)));
113 mc.m_plist = plist;
114 mc.m_index = i + 1;
115 }
116}
StoreEntryMap::const_iterator StoreEntryConstIter
const_iterator for a StoreEntry map.
Definition: DataStore.h:89
StoreEntryMap & getStoreEntryMap(EDurability durability)
Get a reference to the object/array map.
Definition: DataStore.h:325
@ c_Event
Different object in each event, all objects/arrays are invalidated after event() function has been ca...
Definition: DataStore.h:59
std::map< std::string, StoreEntry > StoreEntryMap
Map for StoreEntries.
Definition: DataStore.h:87
A Class to store the Monte Carlo particle information.
Definition: MCParticle.h:32
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
TClonesArray * getPtr() const
Raw access to the underlying TClonesArray.
Definition: StoreArray.h:311

◆ get4Vector()

ROOT::Math::PxPyPzEVector get4Vector ( ) const
inline

Return 4Vector of particle.

Returns
The 4-vector of the MonteCarlo particle.

Definition at line 207 of file MCParticle.h.

208 {
209 return ROOT::Math::PxPyPzEVector(m_momentum_x, m_momentum_y, m_momentum_z, m_energy);
210 }

◆ getArrayIndex()

int getArrayIndex ( ) const
inline

Get 0-based index of the particle in the corresponding MCParticle list.

This is the function for users who want to use the indices of the TClonesArray. To get the corresponding mother and daughter indices use ->getMother()->getArrayIndex().

Returns
The index of the MonteCarlo particle in the corresponding MCParticle array Careful: These indices do not follow the standard from (Fortran) generators, where the first particle has index 1. In the array the first particle has index 0.

Definition at line 244 of file MCParticle.h.

244{ fixParticleList(); return m_index - 1; }
void fixParticleList() const
Search the DataStore for the corresponding MCParticle array.
Definition: MCParticle.cc:82

◆ getArrayName()

std::string getArrayName ( ) const
inlineinherited

Get name of array this object is stored in, or "" if not found.

Definition at line 377 of file RelationsObject.h.

378 {
381 }
bool findStoreEntry(const TObject *object, StoreEntry *&entry, int &index)
Find an object in an array in the data store.
Definition: DataStore.cc:398
std::string name
Name of the entry.
Definition: StoreEntry.h:53

◆ getArrayPointer()

TClonesArray * getArrayPointer ( ) const
inlineprotectedinherited

Returns the pointer to the raw DataStore array holding this object (protected since these arrays are easy to misuse).

Definition at line 418 of file RelationsObject.h.

419 {
422 return nullptr;
424 }
TClonesArray * getPtrAsArray() const
Return ptr cast to TClonesArray.
Definition: StoreEntry.cc:83

◆ getCharge()

float getCharge ( ) const

Return the particle charge defined in TDatabasePDG.

Returns
The charge of the particle in units of q(positron).

Definition at line 36 of file MCParticle.cc.

37{
38 // Geant4 "optical photon" (m_pdg == 0) is not known to TDatabasePDG::Instance().
39 if (m_pdg == 0) {
40 return 0.0;
41 }
42
43 if (TDatabasePDG::Instance()->GetParticle(m_pdg) == nullptr) {
44 B2ERROR("PDG=" << m_pdg << " ***code unknown to TDatabasePDG");
45 return 0.0;
46 }
47
48 return TDatabasePDG::Instance()->GetParticle(m_pdg)->Charge() / 3.0;
49}

◆ getDaughter()

const MCParticle * getDaughter ( int  i) const

Return i-th daughter.

Definition at line 67 of file MCParticle.cc.

68{
69 if (i >= getNDaughters()) {
70 return nullptr;
71 }
72 return getDaughters().at(i);
73}
std::vector< Belle2::MCParticle * > getDaughters() const
Get vector of all daughter particles, empty vector if none.
Definition: MCParticle.cc:52
int getNDaughters() const
Return number of daughter MCParticles.
Definition: MCParticle.cc:75

◆ getDaughters()

vector< MCParticle * > getDaughters ( ) const

Get vector of all daughter particles, empty vector if none.

Throws an exception of type LastChildIndexOutOfRangError if the last daughter is out of the index range.

Returns
A list of all daughter particles. The list is empty if the MonteCarlo particle doesn't have any daughters.

Definition at line 52 of file MCParticle.cc.

53{
54 vector<MCParticle*> result;
55 if (m_firstDaughter > 0) {
57 if (m_lastDaughter > m_plist->GetEntriesFast()) throw LastChildIndexOutOfRangError();
58 TClonesArray& plist = *m_plist;
59 result.reserve(m_lastDaughter - m_firstDaughter + 1);
60 for (int i = m_firstDaughter - 1; i < m_lastDaughter; i++) {
61 result.push_back(static_cast<MCParticle*>(plist[i]));
62 }
63 }
64 return result;
65}

◆ getDecayTime()

float getDecayTime ( ) const
inline

Return the decay time in ns.

Returns
The timestamp of the decay of the MonteCarlo particle in ns. If the particle is stable the time is set to infinity. If the particle crosses the simulation volume boundary, it is set to the crossing time.

Definition at line 168 of file MCParticle.h.

168{ return m_decayTime; }

◆ getDecayVertex()

ROOT::Math::XYZVector getDecayVertex ( ) const
inline

Return decay vertex.

Returns
The decay vertex of the MonteCarlo particle in cm. If the particle crosses the simulation volume boundary, it is set to the crossing position.

Definition at line 219 of file MCParticle.h.

220 {
221 return ROOT::Math::XYZVector(m_decayVertex_x, m_decayVertex_y, m_decayVertex_z);
222 }

◆ getEnergy()

float getEnergy ( ) const
inline

Return particle energy in GeV.

Returns
Returns the particle energy in GeV.

Definition at line 147 of file MCParticle.h.

147{ return m_energy; }

◆ getFirstDaughter()

int getFirstDaughter ( ) const
inline

Get 1-based index of first daughter, 0 if no daughters.

Returns
The index of the first daughter of the MonteCarlo particle. The index is 0 if the MonteCarlo particle doesn't have any daughters.

Definition at line 251 of file MCParticle.h.

251{ return m_firstDaughter; }

◆ getIndex()

int getIndex ( ) const
inline

Get 1-based index of the particle in the corresponding MCParticle list.

This is used by the MCParticle Graph.

Returns
The index of the MonteCarlo particle in the corresponding MCParticle list (starts with 1)

Definition at line 230 of file MCParticle.h.

230{ fixParticleList(); return m_index; }

◆ getInfo()

std::string getInfo ( ) const
inlineinherited

Return a short summary of this object's contents in raw text format.

Returns the contents of getInfoHTML() while translating line-breaks etc.

Note
: You don't need to implement this function (it's not virtual), getInfoHTML() is enough.

Definition at line 370 of file RelationsObject.h.

371 {
373 }
virtual std::string getInfoHTML() const
Return a short summary of this object's contents in HTML format.
std::string htmlToPlainText(const std::string &html)
See RelationsObject::getInfo()

◆ getInfoHTML()

std::string getInfoHTML ( ) const
overridevirtual

Return a short summary of this object's contents in HTML format.

Reimplemented from RelationsInterface< BASE >.

Definition at line 125 of file MCParticle.cc.

126{
127 std::stringstream out;
128 out << "<b>Charge</b>=" << (int)getCharge();
129 out << ", <b>PDG</b>=" << getPDG();
130 out << " (" << getName() << ")";
131 out << "<br>";
132 out << "<b>isPrimaryParticle</b>=" << isPrimaryParticle();
133 out << ",<b>isInitial</b>=" << isInitial();
134 out << ",<b>isVirtual</b>=" << isVirtual();
135 out << "<br>";
136
137 out << "<b>pT</b>=" << getMomentum().Rho();
138 out << ", <b>pZ</b>=" << m_momentum_z;
139 out << "<br>";
140 std::string unitType = HTML::chooseUnitOfLength(getProductionVertex());
141 int precision = 3;
142 out << "<b>V</b>=" << HTML::getStringConvertToUnit(getProductionVertex(), precision, unitType);
143
144 const MCParticle* mom = getMother();
145 if (mom) {
146 out << "<br>";
147 out << "<b>Mother</b>: " << mom->getArrayName() << "[" << mom->getArrayIndex() << "] (" << mom->getName() << ")";
148 }
149 return out.str();
150}
virtual std::string getName() const override
Return name of this particle.
Definition: MCParticle.cc:117
int getArrayIndex() const
Get 0-based index of the particle in the corresponding MCParticle list.
Definition: MCParticle.h:244
ROOT::Math::XYZVector getProductionVertex() const
Return production vertex position.
Definition: MCParticle.h:189
float getCharge() const
Return the particle charge defined in TDatabasePDG.
Definition: MCParticle.cc:36
int getPDG() const
Return PDG code of particle.
Definition: MCParticle.h:112
ROOT::Math::XYZVector getMomentum() const
Return momentum.
Definition: MCParticle.h:198
std::string getArrayName() const
Get name of array this object is stored in, or "" if not found.
bool isInitial() const
Check if particle is an initial particle such as ISR.
Definition: MCParticle.h:590
MCParticle * getMother() const
Returns a pointer to the mother particle.
Definition: MCParticle.h:600
bool isPrimaryParticle() const
Check if particle is a primary particle which was created by the generator (and not,...
Definition: MCParticle.h:595
bool isVirtual() const
Check if particle is virtual.
Definition: MCParticle.h:575
std::string getStringConvertToUnit(const ROOT::Math::XYZVector &vec, int precision=2, const std::string &unitType="cm")
get a string with vector coordinates: (x, y, z).
Definition: HTML.cc:85
std::string chooseUnitOfLength(const ROOT::Math::XYZVector &vec)
get a string with a unit type to convert a vector, so that it is easily readable.
Definition: HTML.cc:102

◆ getLastDaughter()

int getLastDaughter ( ) const
inline

Get 1-based index of last daughter, 0 if no daughters.

Returns
The index of the last daughter of the MonteCarlo particle. The index is 0 if the MonteCarlo particle doesn't have any daughters.

Definition at line 259 of file MCParticle.h.

259{ return m_lastDaughter; }

◆ getLifetime()

float getLifetime ( ) const
inline

Return the lifetime in ns.

A convenient method to get the lifetime of the MonteCarlo particle.

Returns
The lifetime of the MonteCarlo particle in ns. If the particle crosses the simulation volume boundary, it is set to the time spent inside the volume.

Definition at line 177 of file MCParticle.h.

177{ return m_decayTime - m_productionTime; }

◆ getMass()

float getMass ( ) const
inline

Return the particle mass in GeV.

Returns
The mass of the particle in GeV.

Definition at line 135 of file MCParticle.h.

135{ return m_mass; }

◆ getMomentum()

ROOT::Math::XYZVector getMomentum ( ) const
inline

Return momentum.

Returns
The momentum of the MonteCarlo particle in GeV.

Definition at line 198 of file MCParticle.h.

199 {
200 return ROOT::Math::XYZVector(m_momentum_x, m_momentum_y, m_momentum_z);
201 }

◆ getName()

std::string getName ( ) const
overridevirtual

Return name of this particle.

Reimplemented from RelationsInterface< BASE >.

Definition at line 117 of file MCParticle.cc.

118{
119 const TParticlePDG* p = TDatabasePDG::Instance()->GetParticle(m_pdg);
120 if (p)
121 return p->GetName();
122 else //handle unknown PDG codes
123 return std::to_string(m_pdg);
124}

◆ getNDaughters()

int getNDaughters ( ) const

Return number of daughter MCParticles.

Definition at line 75 of file MCParticle.cc.

76{
77 if (getFirstDaughter() == 0) //no daughters
78 return 0;
79 return getLastDaughter() - getFirstDaughter() + 1;
80}
int getLastDaughter() const
Get 1-based index of last daughter, 0 if no daughters.
Definition: MCParticle.h:259
int getFirstDaughter() const
Get 1-based index of first daughter, 0 if no daughters.
Definition: MCParticle.h:251

◆ getParticleFromGeneralizedIndexString()

const MCParticle * getParticleFromGeneralizedIndexString ( const std::string &  generalizedIndex) const

Explores the decay tree of the MC particle and returns the (grand^n)daughter identified by a generalized index.

The generalized index consists of a colon-separated list of daughter indexes, starting from the root particle: 0:1:3 identifies the fourth daughter (3) of the second daughter (1) of the first daughter (0) of the mother particle. This method mirrors the method used in the Particle class.

Parameters
generalizedIndexthe generalized index of the particle to be returned
Returns
a particle in the decay tree of the root particle.

Definition at line 152 of file MCParticle.cc.

153{
154 // Split the generalizedIndex string in a vector of strings.
155 std::vector<std::string> generalizedIndexes;
156 boost::split(generalizedIndexes, generalizedIndex, boost::is_any_of(":"));
157
158 if (generalizedIndexes.empty()) {
159 B2WARNING("Generalized index of MC daughter particle is empty. Skipping.");
160 return nullptr;
161 }
162
163 // To explore a decay tree of unknown depth, we need a place to store
164 // both the root particle and the daughter particle at each iteration
165 const MCParticle* dauPart =
166 nullptr; // This will be eventually returned
167 const MCParticle* currentPart = this; // This is the root particle of the next iteration
168
169 // Loop over the generalizedIndexes until you get to the particle you want
170 for (auto& indexString : generalizedIndexes) {
171 // indexString is a string. First try to convert it into an int
172 int dauIndex = 0;
173 try {
174 dauIndex = Belle2::convertString<int>(indexString);
175 } catch (std::invalid_argument&) {
176 B2WARNING("Found the string " << indexString << "instead of a daughter index.");
177 return nullptr;
178 }
179
180 // Check that the daughter index is smaller than the number of daughters of the current root particle
181 if (dauIndex >= int(currentPart->getNDaughters()) or dauIndex < 0) {
182 B2WARNING("Daughter index out of range" << LogVar("daughter index", dauIndex));
183 B2WARNING("Trying to access non-existing particle.");
184 return nullptr;
185 } else {
186 dauPart = currentPart->getDaughter(dauIndex); // Pick the particle indicated by the generalizedIndex
187 currentPart = dauPart;
188 }
189 }
190 return dauPart;
191}
const MCParticle * getDaughter(int i) const
Return i-th daughter.
Definition: MCParticle.cc:67
Class to store variables with their name which were sent to the logging service.

◆ getPDG()

int getPDG ( ) const
inline

Return PDG code of particle.

Returns
The PDG code of the MonteCarlo particle.

Definition at line 112 of file MCParticle.h.

112{ return m_pdg; }

◆ getProductionTime()

float getProductionTime ( ) const
inline

Return production time in ns.

Returns
The timestamp of the MonteCarlo particle production in ns.

Definition at line 159 of file MCParticle.h.

159{ return m_productionTime; }

◆ getProductionVertex()

ROOT::Math::XYZVector getProductionVertex ( ) const
inline

Return production vertex position.

Returns
The production vertex of the MonteCarlo particle in cm.

Definition at line 189 of file MCParticle.h.

190 {
191 return ROOT::Math::XYZVector(m_productionVertex_x, m_productionVertex_y, m_productionVertex_z);
192 }

◆ getRelated()

T * getRelated ( const std::string &  name = "",
const std::string &  namedRelation = "" 
) const
inlineinherited

Get the object to or from which this object has a relation.

Template Parameters
TThe class of objects to or from which the relation points.
Parameters
nameThe name of the store array to or from which the relation points. If empty the default store array name for class T will be used. If the special name "ALL" is given all store arrays containing objects of type T are considered.
namedRelationAdditional name for the relation, or "" for the default naming
Returns
The first related object or a null pointer.

Definition at line 278 of file RelationsObject.h.

279 {
281 T::Class(), name, namedRelation).object);
282 }
@ c_BothSides
Combination of c_FromSide and c_ToSide.
Definition: DataStore.h:79
Belle2::RelationEntry getRelationWith(ESearchSide searchSide, const TObject *object, StoreEntry *&entry, int &index, const TClass *withClass, const std::string &withName, const std::string &namedRelation)
Get the first relation between an object and another object in a store array.
Definition: DataStore.cc:597
TObject * object
Pointer to the object.
Definition: RelationEntry.h:32

◆ getRelatedFrom()

FROM * getRelatedFrom ( const std::string &  name = "",
const std::string &  namedRelation = "" 
) const
inlineinherited

Get the object from which this object has a relation.

Template Parameters
FROMThe class of objects from which the relation points.
Parameters
nameThe name of the store array from which the relation points. If empty the default store array name for class FROM will be used. If the special name "ALL" is given all store arrays containing objects of type FROM are considered.
namedRelationAdditional name for the relation, or "" for the default naming
Returns
The first related object or a null pointer.

Definition at line 263 of file RelationsObject.h.

264 {
266 m_cacheArrayIndex, FROM::Class(), name, namedRelation).object);
267 }
@ c_FromSide
Return relations/objects pointed from (to a given object).
Definition: DataStore.h:77

◆ getRelatedFromWithWeight()

std::pair< FROM *, float > getRelatedFromWithWeight ( const std::string &  name = "",
const std::string &  namedRelation = "" 
) const
inlineinherited

Get first related object & weight of relation pointing from an array.

Template Parameters
FROMThe class of objects from which the relation points.
Parameters
nameThe name of the store array from which the relation points. If empty the default store array name for class FROM will be used. If the special name "ALL" is given all store arrays containing objects of type FROM are considered.
namedRelationAdditional name for the relation, or "" for the default naming
Returns
Pair of first related object and the relation weight, or (NULL, 1.0) if none found.

Definition at line 314 of file RelationsObject.h.

316 {
318 FROM::Class(), name, namedRelation);
319 return std::make_pair(static_cast<FROM*>(entry.object), entry.weight);
320 }

◆ getRelatedTo()

TO * getRelatedTo ( const std::string &  name = "",
const std::string &  namedRelation = "" 
) const
inlineinherited

Get the object to which this object has a relation.

Template Parameters
TOThe class of objects to which the relation points.
Parameters
nameThe name of the store array to which the relation points. If empty the default store array name for class TO will be used. If the special name "ALL" is given all store arrays containing objects of type TO are considered.
namedRelationAdditional name for the relation, or "" for the default naming
Returns
The first related object or a null pointer.

Definition at line 248 of file RelationsObject.h.

249 {
251 TO::Class(), name, namedRelation).object);
252 }
@ c_ToSide
Return relations/objects pointed to (from a given object).
Definition: DataStore.h:78

◆ getRelatedToWithWeight()

std::pair< TO *, float > getRelatedToWithWeight ( const std::string &  name = "",
const std::string &  namedRelation = "" 
) const
inlineinherited

Get first related object & weight of relation pointing to an array.

Template Parameters
TOThe class of objects to which the relation points.
Parameters
nameThe name of the store array to which the relation points. If empty the default store array name for class TO will be used. If the special name "ALL" is given all store arrays containing objects of type TO are considered.
namedRelationAdditional name for the relation, or "" for the default naming
Returns
Pair of first related object and the relation weight, or (NULL, 1.0) if none found.

Definition at line 297 of file RelationsObject.h.

299 {
301 TO::Class(), name, namedRelation);
302 return std::make_pair(static_cast<TO*>(entry.object), entry.weight);
303 }

◆ getRelatedWithWeight()

std::pair< T *, float > getRelatedWithWeight ( const std::string &  name = "",
const std::string &  namedRelation = "" 
) const
inlineinherited

Get first related object & weight of relation pointing from/to an array.

Template Parameters
TThe class of objects to or from which the relation points.
Parameters
nameThe name of the store array to or from which the relation points. If empty the default store array name for class T will be used. If the special name "ALL" is given all store arrays containing objects of type T are considered.
namedRelationAdditional name for the relation, or "" for the default naming
Returns
Pair of first related object and the relation weight, or (NULL, 1.0) if none found.

Definition at line 331 of file RelationsObject.h.

333 {
335 T::Class(), name, namedRelation);
336 return std::make_pair(static_cast<T*>(entry.object), entry.weight);
337 }

◆ getRelationsFrom()

RelationVector< FROM > getRelationsFrom ( const std::string &  name = "",
const std::string &  namedRelation = "" 
) const
inlineinherited

Get the relations that point from another store array to this object.

Template Parameters
FROMThe class of objects from which the relations point.
Parameters
nameThe name of the store array from which the relations point. If empty the default store array name for class FROM will be used. If the special name "ALL" is given all store arrays containing objects of type FROM are considered.
namedRelationAdditional name for the relation, or "" for the default naming
Returns
A vector of relations.

Definition at line 212 of file RelationsObject.h.

214 {
216 m_cacheArrayIndex, FROM::Class(), name, namedRelation));
217 }
RelationVector< T > getRelationsWith(const std::string &name="", const std::string &namedRelation="") const
Get the relations between this object and another store array.

◆ getRelationsTo()

RelationVector< TO > getRelationsTo ( const std::string &  name = "",
const std::string &  namedRelation = "" 
) const
inlineinherited

Get the relations that point from this object to another store array.

Template Parameters
TOThe class of objects to which the relations point.
Parameters
nameThe name of the store array to which the relations point. If empty the default store array name for class TO will be used. If the special name "ALL" is given all store arrays containing objects of type TO are considered.
namedRelationAdditional name for the relation, or "" for the default naming
Returns
A vector of relations.

Definition at line 197 of file RelationsObject.h.

198 {
200 m_cacheArrayIndex, TO::Class(), name, namedRelation));
201 }

◆ getRelationsWith()

RelationVector< T > getRelationsWith ( const std::string &  name = "",
const std::string &  namedRelation = "" 
) const
inlineinherited

Get the relations between this object and another store array.

Relations in both directions are returned.

Template Parameters
TThe class of objects to or from which the relations point.
Parameters
nameThe name of the store array to or from which the relations point. If empty the default store array name for class T will be used. If the special name "ALL" is given all store arrays containing objects of type T are considered.
namedRelationAdditional name for the relation, or "" for the default naming
Returns
A vector of relations.

Definition at line 230 of file RelationsObject.h.

231 {
233 m_cacheArrayIndex, T::Class(), name, namedRelation));
234 }

◆ getSecondaryPhysicsProcess()

int getSecondaryPhysicsProcess ( ) const
inline

Returns the physics process type of a secondary particle.

Returns
Returns an integer indicating the physics process type of a secondary particle. 0 if the particle is primary. -1 if no information is found. For the details, see the Geant4 package: (*G4Track)->GetCreatorProcess()->GetProcessSubType() processes/electromagnetic/utils/include/G4EmProcessSubType.hh processes/hadronic/management/include/G4HadronicProcessType.hh processes/decay/include/G4DecayProcessType.hh

Definition at line 297 of file MCParticle.h.

◆ getSeenInDetector()

Const::DetectorSet getSeenInDetector ( ) const
inline

Return the seen-in flags of the entire Belle II subdetectors for an MC particle.

Returns
Returns the entire seen-in flags

Definition at line 303 of file MCParticle.h.

303{ return m_seenIn; }

◆ getStatus()

unsigned int getStatus ( unsigned short int  bitmask = USHRT_MAX) const
inline

Return status code of particle.

Parameters
bitmaskTakes an optional bitmask that is compared to the status of the particle.
Returns
Returns the status code of the particle. If a bitmask is given and it matches the the status it returns the value of the bitmask and 0 if not.

Definition at line 122 of file MCParticle.h.

122{ return m_status & bitmask; }

◆ getVertex()

ROOT::Math::XYZVector getVertex ( ) const
inline

Return production vertex position, shorthand for getProductionVertex().

Returns
The production vertex of the MonteCarlo particle in cm.

Definition at line 183 of file MCParticle.h.

183{ return getProductionVertex(); }

◆ hasSeenInDetector()

bool hasSeenInDetector ( Const::DetectorSet  set) const
inline

Return if the seen-in flag for a specific subdetector is set or not.

Parameters
setThe ID for Belle II subdetector(s), in either Const::DetectorSet or Const::EDetector format.
Returns
Returns true if the corresponding bit is set.

Definition at line 310 of file MCParticle.h.

310{ return m_seenIn.contains(set); }
bool contains(const DetectorSet &set) const
Check whether this set contains another set.
Definition: Const.h:235

◆ hasStatus()

bool hasStatus ( unsigned short int  bitmask) const
inline

Return if specific status bit is set.

Parameters
bitmaskThe bitmask which is compared to the status of the particle.
Returns
Returns true if the bitmask matches the status code of the particle.

Definition at line 129 of file MCParticle.h.

129{ return (m_status & bitmask) == bitmask; }

◆ hasValidVertex()

bool hasValidVertex ( ) const
inline

Indication whether vertex and time information is useful or just default.

Returns
Returns True if the vertex and time information is useful.

Definition at line 153 of file MCParticle.h.

153{ return m_validVertex; }

◆ removeSeenInDetector()

void removeSeenInDetector ( Const::DetectorSet  set)
inline

Unflag/Remove the bit if the MC particle is not seen in a specific subdetector.

Parameters
setThe ID for Belle II subdetector(s), in either Const::DetectorSet or Const::EDetector format

Definition at line 486 of file MCParticle.h.

486{ m_seenIn -= set; }

◆ removeStatus()

void removeStatus ( unsigned short int  bitmask)
inline

Remove bitmask from current status.

Parameters
bitmaskThe status code which should be removed from the existing MonteCarlo particle status code.

Definition at line 360 of file MCParticle.h.

360{ m_status &= (~bitmask); }

◆ set4Vector()

void set4Vector ( const ROOT::Math::PxPyPzEVector &  p4)
inline

Sets the 4Vector of particle.

Parameters
p44Vector

Definition at line 438 of file MCParticle.h.

439 {
440 m_momentum_x = p4.px(); m_momentum_y = p4.py(); m_momentum_z = p4.pz(); m_energy = p4.energy();
441 }

◆ setDecayTime()

void setDecayTime ( float  time)
inline

Set decay time.

Parameters
timeThe timestamp of the decay of the MonteCarlo time.

Definition at line 390 of file MCParticle.h.

390{ m_decayTime = time; }

◆ setDecayVertex() [1/2]

void setDecayVertex ( const ROOT::Math::XYZVector &  vertex)
inline

Set decay vertex.

Parameters
vertexThe position of the decay vertex given as XYZVector.

Definition at line 447 of file MCParticle.h.

448 {
449 m_decayVertex_x = vertex.X(); m_decayVertex_y = vertex.Y(), m_decayVertex_z = vertex.Z();
450 }

◆ setDecayVertex() [2/2]

void setDecayVertex ( float  x,
float  y,
float  z 
)
inline

Set decay vertex.

The position of the decay vertex is given as three float parameters.

Parameters
xThe x position of the decay vertex.
yThe y position of the decay vertex.
zThe z position of the decay vertex.

Definition at line 459 of file MCParticle.h.

460 {
462 }

◆ setEnergy()

void setEnergy ( float  energy)
inline

Set energy.

Parameters
energyThe energy of the MonteCarlo particle.

Definition at line 372 of file MCParticle.h.

372{ m_energy = energy; }

◆ setInitial()

void setInitial ( )
inline

Set particle to initial.

(A bit more convinient)

Definition at line 505 of file MCParticle.h.

void addStatus(unsigned short int bitmask)
Add bitmask to current status.
Definition: MCParticle.h:353

◆ setMass()

void setMass ( float  mass)
inline

Set particle mass.

Parameters
massThe MonteCarlo particle mass.

Definition at line 366 of file MCParticle.h.

366{ m_mass = mass; }

◆ setMassFromPDG()

void setMassFromPDG ( )

Sets the mass for the particle from the particle's PDG code.

Definition at line 28 of file MCParticle.cc.

29{
30 if (TDatabasePDG::Instance()->GetParticle(m_pdg) == nullptr)
31 throw(ParticlePDGNotKnownError() << m_pdg);
32 m_mass = TDatabasePDG::Instance()->GetParticle(m_pdg)->Mass();
33}

◆ setMomentum() [1/2]

void setMomentum ( const ROOT::Math::XYZVector &  momentum)
inline

Set particle momentum.

Parameters
momentumThe momentum of the MonteCarlo particle given as XYZVector.

Definition at line 417 of file MCParticle.h.

418 {
419 m_momentum_x = momentum.X(); m_momentum_y = momentum.Y(), m_momentum_z = momentum.Z();
420 }

◆ setMomentum() [2/2]

void setMomentum ( float  px,
float  py,
float  pz 
)
inline

Set particle momentum.

The momentum of the MonteCarlo particle is given as three float parameters.

Parameters
pxThe x component of the momentum vector.
pyThe y component of the momentum vector.
pzThe z component of the momentum vector.

Definition at line 429 of file MCParticle.h.

430 {
431 m_momentum_x = px, m_momentum_y = py; m_momentum_z = pz;
432 }

◆ setPDG()

void setPDG ( int  pdg)
inline

Set PDG code of the particle.

Parameters
pdgThe PDG code of the MonteCarlo particle.

Definition at line 335 of file MCParticle.h.

335{ m_pdg = pdg; }

◆ setProductionTime()

void setProductionTime ( float  time)
inline

Set production time.

Parameters
timeThe timestamp of the production of the MonteCarlo particle.

Definition at line 384 of file MCParticle.h.

384{ m_productionTime = time; }

◆ setProductionVertex() [1/2]

void setProductionVertex ( const ROOT::Math::XYZVector &  vertex)
inline

Set production vertex position.

Parameters
vertexThe position of the production vertex given as XYZVector.

Definition at line 396 of file MCParticle.h.

397 {
398 m_productionVertex_x = vertex.X(); m_productionVertex_y = vertex.Y(), m_productionVertex_z = vertex.Z();
399 }

◆ setProductionVertex() [2/2]

void setProductionVertex ( float  x,
float  y,
float  z 
)
inline

Set production vertex position.

The position of the production vertex is given as three float parameters.

Parameters
xThe x position of the production vertex.
yThe y position of the production vertex.
zThe z position of the production vertex.

Definition at line 408 of file MCParticle.h.

◆ setSecondaryPhysicsProcess()

void setSecondaryPhysicsProcess ( int  physicsProcess)
inline

Sets the physics process type of a secondary particle.

Parameters
physicsProcessphysics process type as an integer number for a secondary particle.

Definition at line 468 of file MCParticle.h.

468{ m_secondaryPhysicsProcess = physicsProcess; }

◆ setSeenInDetector()

void setSeenInDetector ( Const::DetectorSet  set)
inline

Set the seen-in flags for the entire Belle II subdetectors for an Monte Carlo particle.

Parameters
setThe ID for Belle II subdetector(s), in either Const::DetectorSet or Const::EDetector format

Definition at line 474 of file MCParticle.h.

474{ m_seenIn = set; }

◆ setStatus()

void setStatus ( unsigned short int  status)
inline

Set Status code for the particle.

Parameters
statusThe status code of the MonteCarlo particle.

Definition at line 346 of file MCParticle.h.

346{ m_status = status; }

◆ setValidVertex()

void setValidVertex ( bool  valid)
inline

Set indication wether vertex and time information is valid or just default.

Parameters
validSet to true if the vertex is valid.

Definition at line 378 of file MCParticle.h.

378{ m_validVertex = valid; }

◆ setVirtual()

void setVirtual ( )
inline

Set particle to virtual.

(A bit more convinient)

Definition at line 500 of file MCParticle.h.

Friends And Related Function Documentation

◆ FixMergedObjectsModule

friend class FixMergedObjectsModule
friend

Definition at line 571 of file MCParticle.h.

Member Data Documentation

◆ c_epsilon

const double c_epsilon = 10e-7
staticprotected

limit of precision for two doubles to be the same.

Definition at line 563 of file MCParticle.h.

◆ m_cacheArrayIndex

int m_cacheArrayIndex
mutableprivateinherited

Cache of the index in the TClonesArray to which this object belongs.

Definition at line 432 of file RelationsObject.h.

◆ m_cacheDataStoreEntry

DataStore::StoreEntry* m_cacheDataStoreEntry
mutableprivateinherited

Cache of the data store entry to which this object belongs.

Definition at line 429 of file RelationsObject.h.

◆ m_decayTime

float m_decayTime
protected

decay time

Definition at line 555 of file MCParticle.h.

◆ m_decayVertex_x

float m_decayVertex_x
protected

decay vertex of particle, x component

Definition at line 556 of file MCParticle.h.

◆ m_decayVertex_y

float m_decayVertex_y
protected

decay vertex of particle, y component

Definition at line 557 of file MCParticle.h.

◆ m_decayVertex_z

float m_decayVertex_z
protected

decay vertex of particle, z component

Definition at line 558 of file MCParticle.h.

◆ m_energy

float m_energy
protected

energy of the particle

Definition at line 543 of file MCParticle.h.

◆ m_firstDaughter

int m_firstDaughter
protected

1-based index of first daughter particle in collection, 0 if no daughters

Definition at line 561 of file MCParticle.h.

◆ m_index

int m_index
protected

transient pointer to particle list

1-based index of the particle, will be set automatically after deserialisation if needed.

Definition at line 538 of file MCParticle.h.

◆ m_lastDaughter

int m_lastDaughter
protected

1-based index of last daughter particle in collection, 0 if no daughters

Definition at line 562 of file MCParticle.h.

◆ m_mass

float m_mass
protected

mass of the particle

Definition at line 542 of file MCParticle.h.

◆ m_momentum_x

float m_momentum_x
protected

momentum of particle, x component

Definition at line 544 of file MCParticle.h.

◆ m_momentum_y

float m_momentum_y
protected

momentum of particle, y component

Definition at line 545 of file MCParticle.h.

◆ m_momentum_z

float m_momentum_z
protected

momentum of particle, z component

Definition at line 546 of file MCParticle.h.

◆ m_mother

int m_mother
protected

1-based index of the mother particle

Definition at line 560 of file MCParticle.h.

◆ m_pdg

int m_pdg
protected

PDG-Code of the particle.

Definition at line 541 of file MCParticle.h.

◆ m_plist

TClonesArray* m_plist
protected

Internal pointer to DataStore Array containing particles belonging to this collection.

This is a transient member and will not be written to file. The pointer will be set correctly on first access after deserialisation

Definition at line 532 of file MCParticle.h.

◆ m_productionTime

float m_productionTime
protected

production time

Definition at line 550 of file MCParticle.h.

◆ m_productionVertex_x

float m_productionVertex_x
protected

production vertex of particle, x component

Definition at line 551 of file MCParticle.h.

◆ m_productionVertex_y

float m_productionVertex_y
protected

production vertex of particle, y component

Definition at line 552 of file MCParticle.h.

◆ m_productionVertex_z

float m_productionVertex_z
protected

production vertex of particle, z component

Definition at line 553 of file MCParticle.h.

◆ m_secondaryPhysicsProcess

int m_secondaryPhysicsProcess
protected

physics process type of a secondary particle

Definition at line 565 of file MCParticle.h.

◆ m_seenIn

Const::DetectorSet m_seenIn
protected

Each bit is a seen-in flag for the corresoponding subdetector of Belle II.

Definition at line 567 of file MCParticle.h.

◆ m_status

unsigned short int m_status
protected

transient 1-based index of particle

status code

Definition at line 540 of file MCParticle.h.

◆ m_validVertex

bool m_validVertex
protected

indication wether vertex and time information is useful or just default

Definition at line 548 of file MCParticle.h.


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