Belle II Software development
Particle Class Reference

Class to store reconstructed particles. More...

#include <Particle.h>

Inheritance diagram for Particle:
RelationsInterface< BASE >

Public Types

enum  EParticleSourceObject {
  c_Undefined = 0 ,
  c_Track = 1 ,
  c_ECLCluster = 2 ,
  c_KLMCluster = 3 ,
  c_V0 = 4 ,
  c_MCParticle = 5 ,
  c_Composite = 6 ,
  c_NoMDSTSource = 7 ,
  c_Kink = 8
}
 particle source enumerators More...
 
enum  EFlavorType {
  c_Unflavored = 0 ,
  c_Flavored = 1
}
 describes flavor type, see getFlavorType(). More...
 
enum  {
  c_DimPosition = 3 ,
  c_DimMomentum = 4 ,
  c_DimMatrix = 7 ,
  c_SizeMatrix = c_DimMatrix * (c_DimMatrix + 1) / 2
}
 error matrix dimensions and size of 1D representation More...
 
enum  {
  c_Px ,
  c_Py ,
  c_Pz ,
  c_E ,
  c_X ,
  c_Y ,
  c_Z
}
 enumerator used for error matrix handling, shows also in which order the rows (columns) are defined More...
 
enum  PropertyFlags {
  c_Ordinary = 0 ,
  c_IsUnspecified = 1 ,
  c_IsIgnoreRadiatedPhotons = 2 ,
  c_IsIgnoreIntermediate = 4 ,
  c_IsIgnoreMassive = 8 ,
  c_IsIgnoreNeutrino = 16 ,
  c_IsIgnoreGamma = 32 ,
  c_IsIgnoreBrems = 64 ,
  c_IsIgnoreMisID = 128 ,
  c_IsIgnoreDecayInFlight = 256
}
 Flags that describe the particle property, which are used in the MC matching. More...
 

Public Member Functions

 Particle ()
 Default constructor.
 
 Particle (const ROOT::Math::PxPyPzEVector &momentum, const int pdgCode)
 Constructor from a Lorentz vector and PDG code.
 
 Particle (const ROOT::Math::PxPyPzEVector &momentum, const int pdgCode, EFlavorType flavorType, const EParticleSourceObject particleType, const unsigned mdstIndex)
 Constructor for final state particles.
 
 Particle (const ROOT::Math::PxPyPzEVector &momentum, const int pdgCode, EFlavorType flavorType, const std::vector< int > &daughterIndices, TClonesArray *arrayPointer=nullptr)
 Constructor for composite particles.
 
 Particle (const ROOT::Math::PxPyPzEVector &momentum, const int pdgCode, EFlavorType flavorType, const std::vector< int > &daughterIndices, int properties, TClonesArray *arrayPointer=nullptr)
 Constructor for composite particles.
 
 Particle (const ROOT::Math::PxPyPzEVector &momentum, const int pdgCode, EFlavorType flavorType, const std::vector< int > &daughterIndices, int properties, const std::vector< int > &daughterProperties, TClonesArray *arrayPointer=nullptr)
 Constructor for composite particles.
 
 Particle (const Track *track, const Const::ChargedStable &chargedStable)
 Constructor from a reconstructed track (mdst object Track);.
 
 Particle (int trackArrayIndex, const TrackFitResult *trackFit, const Const::ChargedStable &chargedStable)
 Constructor from a reconstructed Track given as TrackFitResult.
 
 Particle (const Kink *kink, const Const::ChargedStable &chargedStable, const unsigned trackFitResultIndex)
 Constructor from a kink object.
 
 Particle (const ECLCluster *eclCluster, const Const::ParticleType &type=Const::photon)
 Constructor of a photon from a reconstructed ECL cluster that is not matched to any charged track.
 
 Particle (const KLMCluster *klmCluster, const int pdgCode=Const::Klong.getPDGCode())
 Constructor from a reconstructed KLM cluster.
 
 Particle (const MCParticle *MCparticle)
 Constructor from MC particle (mdst object MCParticle)
 
 ~Particle ()
 Destructor.
 
void setPDGCode (const int pdg)
 Sets PDG code.
 
void set4Vector (const ROOT::Math::PxPyPzEVector &p4)
 Sets Lorentz vector.
 
void set4VectorDividingByMomentumScaling (const ROOT::Math::PxPyPzEVector &p4)
 Sets Lorentz vector dividing by the momentum scaling factor.
 
void setVertex (const ROOT::Math::XYZVector &vertex)
 Sets position (decay vertex)
 
void setEnergyLossCorrection (double energyLossCorrection)
 Sets Energy loss correction.
 
double getMomentumLossCorrectionFactor () const
 Returns effect of energy correction on the particle momentum.
 
void setMomentumScalingFactor (double momentumScalingFactor)
 Sets momentum scaling.
 
void setMomentumSmearingFactor (double momentumSmearingFactor)
 Sets momentum smearing.
 
void setJacobiMatrix (const TMatrixF &jacobiMatrix)
 Sets 4x6 jacobi matrix.
 
void setMomentumVertexErrorMatrix (const TMatrixFSym &errMatrix)
 Sets 7x7 error matrix.
 
void setPValue (double pValue)
 Sets chi^2 probability of fit.
 
void setProperty (const int properties)
 sets m_properties
 
void updateMomentum (const ROOT::Math::PxPyPzEVector &p4, const ROOT::Math::XYZVector &vertex, const TMatrixFSym &errMatrix, double pValue)
 Sets Lorentz vector, position, 7x7 error matrix and p-value.
 
void updateMass (const int pdgCode)
 Updates particle mass with the mass of the particle corresponding to the given PDG.
 
void appendDaughter (const Particle *daughter, const bool updateType=true, const int daughterProperty=c_Ordinary)
 Appends index of daughter to daughters index array.
 
void appendDaughter (int particleIndex, const bool updateType=true)
 Appends index of daughter to daughters index array.
 
void removeDaughter (const Particle *daughter, const bool updateType=true)
 Removes index of daughter from daughters index array.
 
bool replaceDaughter (const Particle *oldDaughter, Particle *newDaughter)
 Replace index of given daughter with new daughter, return true if a replacement is made.
 
bool replaceDaughterRecursively (const Particle *oldDaughter, Particle *newDaughter)
 Apply replaceDaughter to all Particles in the decay tree by looping recursively through it, return true if a replacement is made.
 
int getPDGCode (void) const
 Returns PDG code.
 
double getCharge (void) const
 Returns particle charge.
 
EFlavorType getFlavorType () const
 Returns flavor type of the decay (for FS particles: flavor type of particle)
 
EParticleSourceObject getParticleSource () const
 Returns particle source as defined with enum EParticleSourceObject.
 
unsigned getMdstArrayIndex (void) const
 Returns 0-based index of MDST store array object (0 for composite particles)
 
unsigned getTrackFitResultIndex (void) const
 Returns 0-based index of the TrackFitResult that should be associated with the Particle.
 
int getProperty () const
 Returns particle property as a bit pattern The values are defined in the PropertyFlags enum and described in detail there.
 
double getMass () const
 Returns invariant mass (= nominal for FS particles)
 
double getPDGMass (void) const
 Returns uncertainty on the invariant mass (requires valid momentum error matrix)
 
double getPDGLifetime () const
 Returns particle nominal lifetime.
 
double getEnergy () const
 Returns total energy.
 
ROOT::Math::PxPyPzEVector get4Vector () const
 Returns Lorentz vector.
 
ROOT::Math::XYZVector getMomentum () const
 Returns momentum vector.
 
double getMomentumMagnitude () const
 Returns momentum magnitude.
 
double getP () const
 Returns momentum magnitude (same as getMomentumMagnitude but with shorter name)
 
double getPx () const
 Returns x component of momentum.
 
double getPy () const
 Returns y component of momentum.
 
double getPz () const
 Returns z component of momentum.
 
double getEffectiveMomentumScale () const
 Returns effective momentum scale which is the product of the momentum scaling and smearing factors.
 
double getEnergyLossCorrection () const
 Returns Energy Loss Correction.
 
ROOT::Math::XYZVector getVertex () const
 Returns vertex position (POCA for charged, IP for neutral FS particles)
 
double getX () const
 Returns x component of vertex position.
 
double getY () const
 Returns y component of vertex position.
 
double getZ () const
 Returns z component of vertex position.
 
double getPValue () const
 Returns chi^2 probability of fit if done or -1.
 
TMatrixFSym getMomentumVertexErrorMatrix () const
 Returns 7x7 error matrix.
 
TMatrixFSym getMomentumErrorMatrix () const
 Returns the 4x4 momentum error matrix.
 
TMatrixFSym getVertexErrorMatrix () const
 Returns the 3x3 position error sub-matrix.
 
double getCosHelicity (const Particle *mother=nullptr) const
 Returns cosine of the helicity angle The helicity angle is defined in the rest frame of the particle as the angle between the negative momentum of the mother and.
 
double getCosHelicityDaughter (unsigned iDaughter, unsigned iGrandDaughter=0) const
 Returns cosine of the helicity angle of the given daughter defined by given grand daughter.
 
double getAcoplanarity () const
 Returns acoplanarity angle defined as the angle between the decay planes of the grand daughters in the particle's rest frame This assumes that the particle and its daughters have two daughters each.
 
int getMdstSource () const
 Returns unique identifier of final state particle (needed in particle combiner)
 
unsigned getNDaughters (void) const
 Returns number of daughter particles.
 
const std::vector< int > & getDaughterIndices () const
 Returns a vector of store array indices of daughter particles.
 
const std::vector< int > & getDaughterProperties () const
 Returns a vector of properties of daughter particles.
 
const ParticlegetDaughter (unsigned i) const
 Returns a pointer to the i-th daughter particle.
 
bool forEachDaughter (const std::function< bool(const Particle *)> &function, bool recursive=true, bool includeSelf=true) const
 Apply a function to all daughters of this particle.
 
std::vector< Belle2::Particle * > getDaughters () const
 Returns a vector of pointers to daughter particles.
 
std::vector< const Belle2::Particle * > getFinalStateDaughters () const
 Returns a vector of pointers to Final State daughter particles.
 
std::vector< const Belle2::Particle * > getAllDaughters () const
 Returns a vector of pointers to all generations' daughter particles.
 
std::vector< int > getMdstArrayIndices (EParticleSourceObject type) const
 Returns a vector of StoreArray indices of given MDST dataobjects.
 
bool overlapsWith (const Particle *oParticle) const
 Returns true if final state ancestors of oParticle overlap.
 
bool isCopyOf (const Particle *oParticle, bool doDetailedComparison=false) const
 Returns true if this Particle and oParticle are copies of each other.
 
const TrackgetTrack () const
 Returns the pointer to the Track object that was used to create this Particle (ParticleType == c_Track).
 
const TrackFitResultgetTrackFitResult () const
 Returns the pointer to the TrackFitResult that was used to create this Particle (ParticleType == c_Track).
 
const V0getV0 () const
 Returns the pointer to the V0 object that was used to create this Particle (if ParticleType == c_V0).
 
const KinkgetKink () const
 Returns the pointer to the Kink object that was used to create this Particle (if ParticleType == c_Kink).
 
const PIDLikelihoodgetPIDLikelihood () const
 Returns the pointer to the PIDLikelihood object that is related to the Track, which was used to create this Particle (ParticleType == c_Track).
 
const ECLClustergetECLCluster () const
 Returns the pointer to the ECLCluster object that was used to create this Particle (if ParticleType == c_ECLCluster).
 
double getECLClusterEnergy () const
 Returns the energy of the ECLCluster for the particle.
 
const KLMClustergetKLMCluster () const
 Returns the pointer to the KLMCluster object that was used to create this Particle (ParticleType == c_KLMCluster).
 
const MCParticlegetMCParticle () const
 Returns the pointer to the MCParticle object that was used to create this Particle (ParticleType == c_MCParticle).
 
std::string getName () const override
 Return name of this particle.
 
std::string getInfoHTML () const override
 Return a short summary of this object's contents in HTML format.
 
void print () const
 Prints the contents of a Particle object to standard output.
 
std::vector< std::string > getExtraInfoNames () const
 get a list of the extra info names
 
void removeExtraInfo ()
 Remove all stored extra info fields.
 
double getExtraInfo (const std::string &name) const
 Return given value if set.
 
bool hasExtraInfo (const std::string &name) const
 Return whether the extra info with the given name is set.
 
int getExtraInfoMap () const
 Return the id of the associated ParticleExtraInfoMap or -1 if no map is set.
 
unsigned int getExtraInfoSize () const
 Return the size of the extra info array.
 
void writeExtraInfo (const std::string &name, const double value)
 Sets the user defined extraInfo.
 
void setExtraInfo (const std::string &name, double value)
 Sets the user-defined data of given name to the given value.
 
void addExtraInfo (const std::string &name, double value)
 Sets the user-defined data of given name to the given value.
 
TClonesArray * getArrayPointer () const
 Returns the pointer to the store array which holds the daughter particles.
 
int getPDGCodeUsedForFit () const
 Return the always positive PDG code which was used for the track fit (if there was a track fit) of this particle.
 
bool wasExactFitHypothesisUsed () const
 Returns true if the type represented by this Particle object was used use as a mass hypothesis during the track of this Particle's parameters.
 
bool isMostLikely () const
 Returns true if the (track-based) particle is created with its most likely mass hypothesis based on PID likelihood.
 
std::pair< Const::ChargedStable, const TrackFitResult * > getMostLikelyTrackFitResult () const
 For a (track-based) particle, returns the charged stable mass hypothesis associated to the most probable TrackFitResult, and the TrackFitResult itself.
 
bool isMostLikelyTrackFitResult () const
 Returns true if the (track-based) particle is created with its most likely mass hypothesis based on TrackFitResult.
 
ECLCluster::EHypothesisBit getECLClusterEHypothesisBit () const
 Returns the ECLCluster EHypothesisBit for this Particle.
 
const ParticlegetParticleFromGeneralizedIndexString (const std::string &generalizedIndex) const
 Explores the decay tree of the particle and returns the (grand^n)daughter identified by a generalized index.
 
void updateJacobiMatrix ()
 Propagate the photon energy scaling to jacobian elements that were calculated using energy.
 
void fillFSPDaughters (std::vector< const Belle2::Particle * > &fspDaughters) const
 Fill final state particle daughters into a vector.
 
void fillAllDaughters (std::vector< const Belle2::Particle * > &allDaughters) const
 Fill all generations' daughters into a vector.
 
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.
 
int getArrayIndex () const
 Returns this object's array index (in StoreArray), or -1 if not found.
 

Private Member Functions

void setMomentumPositionErrorMatrix (const TrackFitResult *trackFit)
 Sets the momentum, position and error matrix for this particle (created from charged Track)
 
void resetErrorMatrix ()
 Resets 7x7 error matrix All elements are set to 0.0.
 
void resetJacobiMatrix ()
 Resets 4x6 error matrix All elements are set to 0.0.
 
void storeErrorMatrix (const TMatrixFSym &errMatrix)
 Stores 7x7 error matrix into private member m_errMatrix.
 
void storeJacobiMatrix (const TMatrixF &jacobiMatrix)
 Stores 4x6 Jacobi matrix into private member m_jacobiMatrix.
 
void fillDecayChain (std::vector< int > &decayChain) const
 Fill vector with (PDGCode, MdstSource) pairs for the entire decay chain.
 
void setFlavorType ()
 sets m_flavorType using m_pdgCode
 
void setMdstArrayIndex (const int arrayIndex)
 set mdst array index
 
int generatePDGCodeFromCharge (const int chargedSign, const Const::ChargedStable &chargedStable)
 Generate the PDG code with correct sign, using the charge.
 
 ClassDefOverride (Particle, 18)
 Class to store reconstructed particles.
 
 ClassDef (RelationsInterface, 0)
 defines interface for accessing relations of objects in StoreArray.
 

Private Attributes

int m_pdgCode
 PDG code.
 
int m_pdgCodeUsedForFit = 0
 PDG code used for the track fit.
 
double m_mass
 particle (invariant) mass
 
double m_px
 momentum component x
 
double m_py
 momentum component y
 
double m_pz
 momentum component z
 
double m_momentumScale = 1.0
 effective momentum scale factor
 
double m_momentumScalingFactor = 1.0
 momentum scaling factor
 
double m_momentumSmearingFactor = 1.0
 momentum smearing factor
 
double m_energyLossCorrection = 0.0
 energy loss correction.
 
double m_x
 position component x
 
double m_y
 position component y
 
double m_z
 position component z
 
double m_errMatrix [c_SizeMatrix] = {}
 error matrix (1D representation)
 
double m_jacobiMatrix [c_SizeMatrix] = {}
 error matrix (1D representation)
 
double m_pValue
 chi^2 probability of the fit.
 
std::vector< int > m_daughterIndices
 daughter particle indices
 
EFlavorType m_flavorType
 flavor type.
 
EParticleSourceObject m_particleSource
 (mdst) source of particle
 
unsigned m_mdstIndex
 0-based index of MDST store array object
 
unsigned m_trackFitResultIndex
 0-based index of related TrackFitResult, relevant for kinks
 
int m_properties
 particle property
 
std::vector< int > m_daughterProperties
 daughter particle properties
 
int m_identifier = -1
 Identifier that can be used to identify whether the particle is unique or is a copy or representation of another.
 
std::vector< double > m_extraInfo
 Stores associated user defined values.
 
TClonesArray * m_arrayPointer
 Internal pointer to DataStore array containing the daughters of this particle.
 
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 ParticleSubset
 

Detailed Description

Class to store reconstructed particles.

This class is a common representation of all particle types, e.g.:

  • final state particles (FS particles):
    • charged kaons/pions/electrons/muons/protons reconstructed as Track
    • photons reconstructed as ECLCluster (without associated Track)
    • long lived neutral kaons reconstructed in KLM (as KLMCluster without associated Track)
  • composite particles:
    • pre-reconstructed V0 particles: Kshort, Lambda baryon, converted photon, ...
    • reconstructed in decays (via combinations)

Private members are limited to those which completely define the particle and that are common to all particle types. These are:

  • particle mass
    • nominal for FS particles
    • invariant for composite particles
  • momentum vector (px, py, pz)
  • position (x, y, z)
    • POCA for charged FS particles
    • IP for photons, Klong and pi0
    • decay vertex for composite particles
  • 7x7 error matrix (order is: px, py, pz, E, x, y, z)
  • chi^2 probability of the fit (track fit, pi0 mass-constr. fit or vertex fit)
  • PDG code
  • vector of StoreArray<Particle> indices of daughter particles

Additional private members are needed in order to make composite particles (via combinations):

  • mdst index of an object from which the FS particle is created
  • source of the object from which the particle is created (see EParticleSourceObject)
  • flavor type (unflavored/flavored) of a decay or flavor type of FS particle

Finally, it is possible to store user-defined floating-point values using addExtraInfo() and getExtraInfo(), identified by a string key. These are general purpose functions for collecting additional information about reconstructed particles that can not be included into any existing data object. Different Particle objects can store different sets of values, and there are no hard-coded limitations on the number of values stored.

Definition at line 76 of file Particle.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

error matrix dimensions and size of 1D representation

Definition at line 104 of file Particle.h.

104 {c_DimPosition = 3, c_DimMomentum = 4, c_DimMatrix = 7,
105 c_SizeMatrix = c_DimMatrix * (c_DimMatrix + 1) / 2
106 };

◆ anonymous enum

anonymous enum

enumerator used for error matrix handling, shows also in which order the rows (columns) are defined

Definition at line 112 of file Particle.h.

112{c_Px, c_Py, c_Pz, c_E, c_X, c_Y, c_Z};

◆ EFlavorType

describes flavor type, see getFlavorType().

Enumerator
c_Unflavored 

Is its own antiparticle or we don't know whether it is a particle/antiparticle.

c_Flavored 

Is either particle or antiparticle.

Definition at line 96 of file Particle.h.

96 {
97 c_Unflavored = 0,
98 c_Flavored = 1,
99 };
@ c_Unflavored
Is its own antiparticle or we don't know whether it is a particle/antiparticle.
Definition: Particle.h:97
@ c_Flavored
Is either particle or antiparticle.
Definition: Particle.h:98

◆ EParticleSourceObject

particle source enumerators

Definition at line 83 of file Particle.h.

83 {
84 c_Undefined = 0,
85 c_Track = 1,
86 c_ECLCluster = 2,
87 c_KLMCluster = 3,
88 c_V0 = 4,
89 c_MCParticle = 5,
90 c_Composite = 6,
91 c_NoMDSTSource = 7,
92 c_Kink = 8
93 };

◆ PropertyFlags

Flags that describe the particle property, which are used in the MC matching.

Enumerator
c_IsUnspecified 

Ordinary particles.

Is the particle unspecified by marking @ ?

c_IsIgnoreRadiatedPhotons 

Is the particle MC matched with the ignore radiated photon flag set?

c_IsIgnoreIntermediate 

Is the particle MC matched with the ignore intermediate resonances flag set?

c_IsIgnoreMassive 

Is the particle MC matched with the ignore missing massive particle flag set?

c_IsIgnoreNeutrino 

Is the particle MC matched with the ignore missing neutrino flag set?

c_IsIgnoreGamma 

Is the particle MC matched with the ignore missing gamma flag set?

c_IsIgnoreBrems 

Is the particle MC matched with the ignore added Brems gamma flag set?

c_IsIgnoreMisID 

Is the particle MC matched with the ignore MisID flag set?

c_IsIgnoreDecayInFlight 

Is the particle MC matched with the ignore DecayInFlight flag set?

Definition at line 118 of file Particle.h.

118 {
119 c_Ordinary = 0,
120 c_IsUnspecified = 1,
124 c_IsIgnoreNeutrino = 16,
125 c_IsIgnoreGamma = 32,
126 c_IsIgnoreBrems = 64,
127 c_IsIgnoreMisID = 128,
129 };
@ c_IsIgnoreNeutrino
Is the particle MC matched with the ignore missing neutrino flag set?
Definition: Particle.h:124
@ c_IsIgnoreRadiatedPhotons
Is the particle MC matched with the ignore radiated photon flag set?
Definition: Particle.h:121
@ c_IsIgnoreGamma
Is the particle MC matched with the ignore missing gamma flag set?
Definition: Particle.h:125
@ c_IsUnspecified
Ordinary particles.
Definition: Particle.h:120
@ c_IsIgnoreBrems
Is the particle MC matched with the ignore added Brems gamma flag set?
Definition: Particle.h:126
@ c_IsIgnoreDecayInFlight
Is the particle MC matched with the ignore DecayInFlight flag set?
Definition: Particle.h:128
@ c_IsIgnoreMisID
Is the particle MC matched with the ignore MisID flag set?
Definition: Particle.h:127
@ c_IsIgnoreIntermediate
Is the particle MC matched with the ignore intermediate resonances flag set?
Definition: Particle.h:122
@ c_IsIgnoreMassive
Is the particle MC matched with the ignore missing massive particle flag set?
Definition: Particle.h:123

Constructor & Destructor Documentation

◆ Particle() [1/12]

Particle ( )

Default constructor.

All private members are set to 0. Particle type is set to c_Undefined.

Definition at line 46 of file Particle.cc.

46 :
47 m_pdgCode(0), m_mass(0), m_px(0), m_py(0), m_pz(0), m_x(0), m_y(0), m_z(0),
49 m_properties(0),
50 m_arrayPointer(nullptr)
51{
53}
double m_pValue
chi^2 probability of the fit.
Definition: Particle.h:1097
double m_pz
momentum component z
Definition: Particle.h:1087
unsigned m_mdstIndex
0-based index of MDST store array object
Definition: Particle.h:1101
double m_py
momentum component y
Definition: Particle.h:1086
double m_x
position component x
Definition: Particle.h:1092
double m_px
momentum component x
Definition: Particle.h:1085
TClonesArray * m_arrayPointer
Internal pointer to DataStore array containing the daughters of this particle.
Definition: Particle.h:1129
EParticleSourceObject m_particleSource
(mdst) source of particle
Definition: Particle.h:1100
void resetErrorMatrix()
Resets 7x7 error matrix All elements are set to 0.0.
Definition: Particle.cc:1164
EFlavorType m_flavorType
flavor type.
Definition: Particle.h:1099
double m_mass
particle (invariant) mass
Definition: Particle.h:1084
unsigned m_trackFitResultIndex
0-based index of related TrackFitResult, relevant for kinks
Definition: Particle.h:1102
double m_z
position component z
Definition: Particle.h:1094
int m_pdgCode
PDG code.
Definition: Particle.h:1082
double m_y
position component y
Definition: Particle.h:1093
int m_properties
particle property
Definition: Particle.h:1103

◆ Particle() [2/12]

Particle ( const ROOT::Math::PxPyPzEVector &  momentum,
const int  pdgCode 
)

Constructor from a Lorentz vector and PDG code.

All other private members are set to their default values (0).

Parameters
momentumLorentz vector
pdgCodePDG code

Definition at line 56 of file Particle.cc.

56 :
57 m_pdgCode(pdgCode), m_mass(0), m_px(0), m_py(0), m_pz(0), m_x(0), m_y(0), m_z(0),
59 m_arrayPointer(nullptr)
60{
62 set4Vector(momentum);
64 // set mass of stable charged particle to its nominal value
67 }
68}
The ParticleType class for identifying different particle types.
Definition: Const.h:408
static const ParticleSet chargedStableSet
set of charged stable particles
Definition: Const.h:618
void setFlavorType()
sets m_flavorType using m_pdgCode
Definition: Particle.cc:1235
void set4Vector(const ROOT::Math::PxPyPzEVector &p4)
Sets Lorentz vector.
Definition: Particle.h:282
void updateMass(const int pdgCode)
Updates particle mass with the mass of the particle corresponding to the given PDG.
Definition: Particle.cc:628

◆ Particle() [3/12]

Particle ( const ROOT::Math::PxPyPzEVector &  momentum,
const int  pdgCode,
EFlavorType  flavorType,
const EParticleSourceObject  particleType,
const unsigned  mdstIndex 
)

Constructor for final state particles.

All other private members are set to their default values (0).

Parameters
momentumLorentz vector
pdgCodePDG code
flavorTypeflavor type
particleTypeparticle source
mdstIndexmdst index

Definition at line 71 of file Particle.cc.

75 :
76 m_pdgCode(pdgCode), m_mass(0), m_px(0), m_py(0), m_pz(0), m_x(0), m_y(0), m_z(0),
78{
79 if (flavorType == c_Unflavored and pdgCode < 0)
80 m_pdgCode = -pdgCode;
81
82 setMdstArrayIndex(mdstIndex);
83 set4Vector(momentum);
85 // set mass of stable charged particle to its nominal value
88 }
89}
void setMdstArrayIndex(const int arrayIndex)
set mdst array index
Definition: Particle.cc:381

◆ Particle() [4/12]

Particle ( const ROOT::Math::PxPyPzEVector &  momentum,
const int  pdgCode,
EFlavorType  flavorType,
const std::vector< int > &  daughterIndices,
TClonesArray *  arrayPointer = nullptr 
)

Constructor for composite particles.

All other private members are set to their default values (0).

Parameters
momentumLorentz vector
pdgCodePDG code
flavorTypedecay flavor type
daughterIndicesindices of daughters in StoreArray<Particle>
arrayPointerpointer to store array which stores the daughters, if the particle itself is stored in the same array the pointer can be automatically determined

Definition at line 92 of file Particle.cc.

96 :
97 m_pdgCode(0), m_mass(0), m_px(0), m_py(0), m_pz(0), m_x(0), m_y(0), m_z(0),
98 m_pValue(-1),
99 m_daughterIndices(daughterIndices),
101 m_properties(0), m_arrayPointer(arrayPointer)
102{
103 m_pdgCode = pdgCode;
104 m_flavorType = flavorType;
105 if (flavorType == c_Unflavored and pdgCode < 0)
106 m_pdgCode = -pdgCode;
107 set4Vector(momentum);
109 // set mass of stable charged particle to its nominal value
112 }
113
114 if (!daughterIndices.empty()) {
115 m_particleSource = c_Composite;
116 if (getArrayPointer() == nullptr) {
117 B2FATAL("Composite Particle (with daughters) was constructed outside StoreArray without specifying daughter array!");
118 }
119 for (unsigned int i = 0; i < m_daughterIndices.size(); i++) {
120 m_daughterProperties.push_back(Particle::PropertyFlags::c_Ordinary);
121 }
122 }
123}
TClonesArray * getArrayPointer() const
Returns the pointer to the store array which holds the daughter particles.
Definition: Particle.h:981
std::vector< int > m_daughterProperties
daughter particle properties
Definition: Particle.h:1104
std::vector< int > m_daughterIndices
daughter particle indices
Definition: Particle.h:1098

◆ Particle() [5/12]

Particle ( const ROOT::Math::PxPyPzEVector &  momentum,
const int  pdgCode,
EFlavorType  flavorType,
const std::vector< int > &  daughterIndices,
int  properties,
TClonesArray *  arrayPointer = nullptr 
)

Constructor for composite particles.

All other private members are set to their default values (0).

Parameters
momentumLorentz vector
pdgCodePDG code
flavorTypedecay flavor type
daughterIndicesindices of daughters in StoreArray<Particle>
propertiesparticle property
arrayPointerpointer to store array which stores the daughters, if the particle itself is stored in the same array the pointer can be automatically determined

Definition at line 125 of file Particle.cc.

130 :
131 m_pdgCode(0), m_mass(0), m_px(0), m_py(0), m_pz(0), m_x(0), m_y(0), m_z(0),
132 m_pValue(-1),
133 m_daughterIndices(daughterIndices),
135 m_arrayPointer(arrayPointer)
136{
137 m_pdgCode = pdgCode;
138 m_flavorType = flavorType;
139 if (flavorType == c_Unflavored and pdgCode < 0)
140 m_pdgCode = -pdgCode;
141 set4Vector(momentum);
143 // set mass of stable charged particle to its nominal value
146 }
147 m_properties = properties;
148
149 if (!daughterIndices.empty()) {
150 m_particleSource = c_Composite;
151 if (getArrayPointer() == nullptr) {
152 B2FATAL("Composite Particle (with daughters) was constructed outside StoreArray without specifying daughter array!");
153 }
154 for (unsigned int i = 0; i < m_daughterIndices.size(); i++) {
155 m_daughterProperties.push_back(Particle::PropertyFlags::c_Ordinary);
156 }
157 }
158}

◆ Particle() [6/12]

Particle ( const ROOT::Math::PxPyPzEVector &  momentum,
const int  pdgCode,
EFlavorType  flavorType,
const std::vector< int > &  daughterIndices,
int  properties,
const std::vector< int > &  daughterProperties,
TClonesArray *  arrayPointer = nullptr 
)

Constructor for composite particles.

All other private members are set to their default values (0).

Parameters
momentumLorentz vector
pdgCodePDG code
flavorTypedecay flavor type
daughterIndicesindices of daughters in StoreArray<Particle>
propertiesparticle property
daughterPropertiesdaughter particle properties
arrayPointerpointer to store array which stores the daughters, if the particle itself is stored in the same array the pointer can be automatically determined

Definition at line 161 of file Particle.cc.

167 :
168 m_pdgCode(0), m_mass(0), m_px(0), m_py(0), m_pz(0), m_x(0), m_y(0), m_z(0),
169 m_pValue(-1),
170 m_daughterIndices(daughterIndices),
172 m_daughterProperties(daughterProperties),
173 m_arrayPointer(arrayPointer)
174{
175 m_pdgCode = pdgCode;
176 m_flavorType = flavorType;
177 if (flavorType == c_Unflavored and pdgCode < 0)
178 m_pdgCode = -pdgCode;
179 set4Vector(momentum);
181 // set mass of stable charged particle to its nominal value
184 }
185 m_properties = properties;
186
187 if (!daughterIndices.empty()) {
188 m_particleSource = c_Composite;
189 if (getArrayPointer() == nullptr) {
190 B2FATAL("Composite Particle (with daughters) was constructed outside StoreArray without specifying daughter array!");
191 }
192 }
193}

◆ Particle() [7/12]

Particle ( const Track track,
const Const::ChargedStable chargedStable 
)

Constructor from a reconstructed track (mdst object Track);.

Parameters
trackpointer to Track object
chargedStableType of charged particle

Definition at line 196 of file Particle.cc.

197 :
198 Particle(track ? track->getArrayIndex() : 0, track ? track->getTrackFitResultWithClosestMass(chargedStable) : nullptr,
199 chargedStable)
200{
201}
Particle()
Default constructor.
Definition: Particle.cc:46

◆ Particle() [8/12]

Particle ( int  trackArrayIndex,
const TrackFitResult trackFit,
const Const::ChargedStable chargedStable 
)

Constructor from a reconstructed Track given as TrackFitResult.

To be used to create Particle objects from tracks with full control over the hypothesis (e.g. V0 daughters).

Parameters
trackArrayIndextrack StoreArray index
trackFitpointer to TrackFitResult object
chargedStableType of charged particle

Definition at line 203 of file Particle.cc.

205 :
206 m_pdgCode(0), m_mass(0), m_px(0), m_py(0), m_pz(0), m_x(0), m_y(0), m_z(0),
208 m_arrayPointer(nullptr)
209{
210 if (!trackFit) return;
211
212 m_flavorType = c_Flavored; //tracks are charged
213 m_particleSource = c_Track;
214
215 setMdstArrayIndex(trackArrayIndex);
216
218 m_pdgCode = generatePDGCodeFromCharge(trackFit->getChargeSign(), chargedStable);
219
220 // set mass
221 if (TDatabasePDG::Instance()->GetParticle(m_pdgCode) == nullptr)
222 B2FATAL("PDG=" << m_pdgCode << " ***code unknown to TDatabasePDG");
223 m_mass = TDatabasePDG::Instance()->GetParticle(m_pdgCode)->Mass() ;
224
225 // set momentum, position and error matrix
227}
int getPDGCode() const
PDG code.
Definition: Const.h:473
void setMomentumPositionErrorMatrix(const TrackFitResult *trackFit)
Sets the momentum, position and error matrix for this particle (created from charged Track)
Definition: Particle.cc:1086
int m_pdgCodeUsedForFit
PDG code used for the track fit.
Definition: Particle.h:1083
int generatePDGCodeFromCharge(const int chargedSign, const Const::ChargedStable &chargedStable)
Generate the PDG code with correct sign, using the charge.
Definition: Particle.cc:1467
short getChargeSign() const
Return track charge (1 or -1).
Const::ParticleType getParticleType() const
Getter for ParticleType of the mass hypothesis of the track fit.

◆ Particle() [9/12]

Particle ( const Kink kink,
const Const::ChargedStable chargedStable,
const unsigned  trackFitResultIndex 
)

Constructor from a kink object.

Parameters
kinkpointer to Kink object
chargedStableType of charged particle
trackFitResultIndexindex of TrackFitResult to be associated with Particle

Definition at line 229 of file Particle.cc.

229 :
230 m_pdgCode(0), m_mass(0), m_px(0), m_py(0), m_pz(0), m_x(0), m_y(0), m_z(0),
232 m_arrayPointer(nullptr)
233{
234 if (!kink) return;
235
237 m_particleSource = c_Kink;
238
240 m_trackFitResultIndex = trackFitResultIndex;
241
242 StoreArray<TrackFitResult> trackFitResults{};
243 const TrackFitResult* particleTrackFitResult = trackFitResults[m_trackFitResultIndex];
244
245 m_pdgCode = generatePDGCodeFromCharge(particleTrackFitResult->getChargeSign(), chargedStable);
246
247 // set mass
248 if (TDatabasePDG::Instance()->GetParticle(m_pdgCode) == nullptr)
249 B2FATAL("PDG=" << m_pdgCode << " ***code unknown to TDatabasePDG");
250 m_mass = TDatabasePDG::Instance()->GetParticle(m_pdgCode)->Mass() ;
251
252 // set momentum, position and error matrix
253 setMomentumPositionErrorMatrix(particleTrackFitResult);
254}
int getArrayIndex() const
Returns this object's array index (in StoreArray), or -1 if not found.
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
Values of the result of a track fit with a given particle hypothesis.

◆ Particle() [10/12]

Particle ( const ECLCluster eclCluster,
const Const::ParticleType type = Const::photon 
)
explicit

Constructor of a photon from a reconstructed ECL cluster that is not matched to any charged track.

Parameters
eclClusterpointer to ECLCluster object
typethe kind of ParticleType we want (photon by default)

Definition at line 256 of file Particle.cc.

256 :
257 m_pdgCode(type.getPDGCode()), m_mass(type.getMass()), m_px(0), m_py(0), m_pz(0), m_x(0), m_y(0), m_z(0),
259{
260 if (!eclCluster) return;
261
263
264 // returns default vertex from clusterutils (from beam parameters if available)
265 // leave it like that for the moment to make it transparent
266 ClusterUtils C;
267 const XYZVector clustervertex = C.GetIPPosition();
268 setVertex(clustervertex);
269
270 const PxPyPzEVector clustermom = C.Get4MomentumFromCluster(eclCluster, clustervertex, getECLClusterEHypothesisBit());
271 m_px = clustermom.Px();
272 m_py = clustermom.Py();
273 m_pz = clustermom.Pz();
274
275 m_particleSource = c_ECLCluster;
276 setMdstArrayIndex(eclCluster->getArrayIndex());
277
278 // set Chi^2 probability:
279 //TODO: gamma quality can be written here
280 m_pValue = 1;
281
282 // get error matrix.
284
285}
Class to provide momentum-related information from ECLClusters.
Definition: ClusterUtils.h:38
const ROOT::Math::PxPyPzEVector Get4MomentumFromCluster(const ECLCluster *cluster, ECLCluster::EHypothesisBit hypo)
Returns four momentum vector.
Definition: ClusterUtils.cc:25
const ROOT::Math::XYZVector GetIPPosition()
Returns default IP position from beam parameters.
void updateJacobiMatrix()
Propagate the photon energy scaling to jacobian elements that were calculated using energy.
Definition: Particle.cc:288
void setVertex(const ROOT::Math::XYZVector &vertex)
Sets position (decay vertex)
Definition: Particle.h:306
ECLCluster::EHypothesisBit getECLClusterEHypothesisBit() const
Returns the ECLCluster EHypothesisBit for this Particle.
Definition: Particle.h:1029

◆ Particle() [11/12]

Particle ( const KLMCluster klmCluster,
const int  pdgCode = Const::Klong.getPDGCode() 
)
explicit

Constructor from a reconstructed KLM cluster.

Parameters
klmClusterpointer to KLMCluster object
pdgCodePDG code (Klong by default)

Definition at line 326 of file Particle.cc.

326 :
327 m_pdgCode(0), m_mass(0), m_px(0), m_py(0), m_pz(0), m_x(0), m_y(0), m_z(0),
329{
330 if (!klmCluster) return;
331
332 m_pdgCode = pdgCode;
334
335 set4Vector(klmCluster->getMomentum());
336 setVertex(XYZVector(0, 0, 0)); // so far KLMCluster don't provide reliable / usable position information
337 updateMass(m_pdgCode); // KLMCluster internally use Klong mass, overwrite here to allow neutrons
338
339 m_particleSource = c_KLMCluster;
340 setMdstArrayIndex(klmCluster->getArrayIndex());
341
342 // set Chi^2 probability:
343 //TODO: KL quality can be written here
344 m_pValue = -1;
345
346 // TODO: set error matrix
348 //storeErrorMatrix(klmCluster->getErrorMatrix());
349}
ROOT::Math::PxPyPzEVector getMomentum() const
Get momentum.
Definition: KLMCluster.cc:49

◆ Particle() [12/12]

Particle ( const MCParticle MCparticle)
explicit

Constructor from MC particle (mdst object MCParticle)

Parameters
MCparticlepointer to MCParticle object

Definition at line 352 of file Particle.cc.

352 :
353 m_pdgCode(0), m_mass(0), m_px(0), m_py(0), m_pz(0), m_x(0), m_y(0), m_z(0),
355{
356 if (!mcParticle) return;
357
358 m_pdgCode = mcParticle->getPDG();
359 m_particleSource = c_MCParticle; // TODO: what about daughters if not FS particle?
360
361 setMdstArrayIndex(mcParticle->getArrayIndex());
362
363
365
366 // mass and momentum
367 m_mass = mcParticle->getMass();
368 m_px = mcParticle->getMomentum().X();
369 m_py = mcParticle->getMomentum().Y();
370 m_pz = mcParticle->getMomentum().Z();
371 // production vertex
372 // TODO: good only for FS particles, for composite we must use decay vertex
373 setVertex(mcParticle->getVertex());
374
376}

Member Function Documentation

◆ addExtraInfo()

void addExtraInfo ( const std::string &  name,
double  value 
)

Sets the user-defined data of given name to the given value.

throws std::runtime_error if variable is already set.

Definition at line 1421 of file Particle.cc.

1422{
1423 if (hasExtraInfo(name))
1424 throw std::runtime_error(std::string("addExtraInfo: Value '") + name + "' already set!");
1425
1427 if (!extraInfoMap)
1428 extraInfoMap.create();
1429 if (m_extraInfo.empty()) {
1430 unsigned int mapID = extraInfoMap->getMapForNewVar(name);
1431 m_extraInfo.push_back(mapID);
1432 m_extraInfo.push_back(value);
1433 } else {
1434 unsigned int oldMapID = m_extraInfo[0];
1435 unsigned int insertIndex = m_extraInfo.size();
1436 unsigned int mapID = extraInfoMap->getMapForNewVar(name, oldMapID, insertIndex);
1437
1438 m_extraInfo[0] = mapID; //update map
1439 m_extraInfo.push_back(value); //add value
1440 }
1441}
std::vector< double > m_extraInfo
Stores associated user defined values.
Definition: Particle.h:1120
bool hasExtraInfo(const std::string &name) const
Return whether the extra info with the given name is set.
Definition: Particle.cc:1351
bool create(bool replace=false)
Create a default object in the data store.
Type-safe access to single objects in the data store.
Definition: StoreObjPtr.h:96

◆ 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:491
static DataStore & Instance()
Instance of singleton Store.
Definition: DataStore.cc:53
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 }

◆ appendDaughter() [1/2]

void appendDaughter ( const Particle daughter,
const bool  updateType = true,
const int  daughterProperty = c_Ordinary 
)

Appends index of daughter to daughters index array.

Parameters
daughterpointer to the daughter particle
updateTypebool to set whether particle type should be updated
daughterPropertyproperty of the daughter particle

Definition at line 707 of file Particle.cc.

708{
709 if (updateType) {
710 // is it a composite particle or fsr corrected?
711 m_particleSource = c_Composite;
712 }
713
714 // add daughter index
715 m_daughterIndices.push_back(daughter->getArrayIndex());
716 m_daughterProperties.push_back(daughterProperty);
717}

◆ appendDaughter() [2/2]

void appendDaughter ( int  particleIndex,
const bool  updateType = true 
)
inline

Appends index of daughter to daughters index array.

Parameters
particleIndexindex of daughter in StoreArray<Particle>
updateTypebool to set whether particle type should be updated

Definition at line 427 of file Particle.h.

428 {
429 if (updateType) {
430 // is it a composite particle or fsr corrected?
431 m_particleSource = c_Composite;
432 }
433 m_daughterIndices.push_back(particleIndex);
434 m_daughterProperties.push_back(c_Ordinary);
435 }

◆ 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).

◆ fillAllDaughters()

void fillAllDaughters ( std::vector< const Belle2::Particle * > &  allDaughters) const

Fill all generations' daughters into a vector.

Function is called recursively

Parameters
allDaughtersvector of daughter particles

Definition at line 1212 of file Particle.cc.

1213{
1214 // this is FSP
1215 if (getNDaughters() == 0)
1216 return;
1217
1218 // this is not FSP (fill it and go one level down)
1219 for (unsigned i = 0; i < getNDaughters(); i++) {
1220 allDaughters.push_back(getDaughter(i));
1221 getDaughter(i)->fillAllDaughters(allDaughters);
1222 }
1223}
void fillAllDaughters(std::vector< const Belle2::Particle * > &allDaughters) const
Fill all generations' daughters into a vector.
Definition: Particle.cc:1212
unsigned getNDaughters(void) const
Returns number of daughter particles.
Definition: Particle.h:747
const Particle * getDaughter(unsigned i) const
Returns a pointer to the i-th daughter particle.
Definition: Particle.cc:662

◆ fillDecayChain()

void fillDecayChain ( std::vector< int > &  decayChain) const
private

Fill vector with (PDGCode, MdstSource) pairs for the entire decay chain.

Used to determine if two Particles are copies or not.

Function is called recursively

Parameters
decayChainvector of (PDGCode, MdstSource) pairs for each particle in the decay chain of this particle

Definition at line 1225 of file Particle.cc.

1226{
1227 decayChain.push_back(m_pdgCode);
1228 decayChain.push_back(getMdstSource());
1229
1230 for (unsigned i = 0; i < getNDaughters(); i++)
1231 getDaughter(i)->fillDecayChain(decayChain);
1232}
int getMdstSource() const
Returns unique identifier of final state particle (needed in particle combiner)
Definition: Particle.cc:400
void fillDecayChain(std::vector< int > &decayChain) const
Fill vector with (PDGCode, MdstSource) pairs for the entire decay chain.
Definition: Particle.cc:1225

◆ fillFSPDaughters()

void fillFSPDaughters ( std::vector< const Belle2::Particle * > &  fspDaughters) const

Fill final state particle daughters into a vector.

Function is called recursively

Parameters
fspDaughtersvector of daughter particles

Definition at line 1199 of file Particle.cc.

1200{
1201 // this is FSP
1202 if (getNDaughters() == 0) {
1203 fspDaughters.push_back(this);
1204 return;
1205 }
1206
1207 // this is not FSP (go one level down)
1208 for (unsigned i = 0; i < getNDaughters(); i++)
1209 getDaughter(i)->fillFSPDaughters(fspDaughters);
1210}
void fillFSPDaughters(std::vector< const Belle2::Particle * > &fspDaughters) const
Fill final state particle daughters into a vector.
Definition: Particle.cc:1199

◆ forEachDaughter()

bool forEachDaughter ( const std::function< bool(const Particle *)> &  function,
bool  recursive = true,
bool  includeSelf = true 
) const

Apply a function to all daughters of this particle.

Parameters
functionfunction object to run on each daughter. If this function returns true the processing will be stopped immediately.
recursiveif true go through all daughters of daughters as well
includeSelfif true also apply the function to this particle
Returns
true if the function returned true for any of the particles it was applied to

Definition at line 1443 of file Particle.cc.

1445{
1446 std::queue<const Particle*> qq;
1447 // If we include ourselves add only this, otherwise directly all children
1448 if (includeSelf) {
1449 qq.push(this);
1450 } else {
1451 for (size_t i = 0; i < getNDaughters(); ++i) qq.push(getDaughter(i));
1452 }
1453 // Now just repeat until done: take the child, run the functor, remove the
1454 // child, add all children if needed
1455 while (!qq.empty()) {
1456 const Particle* p = qq.front();
1457 if (function(p)) return true;
1458 qq.pop();
1459 // Add children if we go through all children recursively or if we look at
1460 // the current particle: we always want the direct children.
1461 if (recursive || p == this)
1462 for (size_t i = 0; i < p->getNDaughters(); ++i) qq.push(p->getDaughter(i));
1463 }
1464 return false;
1465}
Class to store reconstructed particles.
Definition: Particle.h:76

◆ generatePDGCodeFromCharge()

int generatePDGCodeFromCharge ( const int  chargedSign,
const Const::ChargedStable chargedStable 
)
private

Generate the PDG code with correct sign, using the charge.

Parameters
chargedSigncharge of the particle
chargedStableType of charged particle

Definition at line 1467 of file Particle.cc.

1468{
1469 int absPDGCode = chargedStable.getPDGCode();
1470 int PDGCode = absPDGCode * chargeSign;
1471 // flip sign of PDG code for leptons: their PDG code is positive if the lepton charge is negative and vice versa
1472 if (chargedStable == Const::muon || chargedStable == Const::electron) PDGCode = -PDGCode;
1473 return PDGCode;
1474}
static const ChargedStable muon
muon particle
Definition: Const.h:660
static const ChargedStable electron
electron particle
Definition: Const.h:659

◆ get4Vector()

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

Returns Lorentz vector.

Returns
Lorentz vector

Definition at line 567 of file Particle.h.

568 {
569 double correction = getMomentumLossCorrectionFactor();
570 return ROOT::Math::PxPyPzEVector(m_momentumScale * correction * m_px,
571 m_momentumScale * correction * m_py,
572 m_momentumScale * correction * m_pz,
573 getEnergy());
574 }
double m_momentumScale
effective momentum scale factor
Definition: Particle.h:1088
double getEnergy() const
Returns total energy.
Definition: Particle.h:555
double getMomentumLossCorrectionFactor() const
Returns effect of energy correction on the particle momentum.
Definition: Particle.h:326

◆ getAcoplanarity()

double getAcoplanarity ( ) const

Returns acoplanarity angle defined as the angle between the decay planes of the grand daughters in the particle's rest frame This assumes that the particle and its daughters have two daughters each.

Returns
acoplanarity angle

Definition at line 564 of file Particle.cc.

565{
566 // check that we have a decay to two daughters and then two grand daughters each
567 if (getNDaughters() != 2) {
568 B2ERROR("Cannot calculate acoplanarity of particle 'name' because the number of daughters is not 2"
569 << LogVar("name", getName()) << LogVar("# of daughters", getNDaughters()));
570 return std::numeric_limits<double>::quiet_NaN();
571 }
572 const Particle* daughter0 = getDaughter(0);
573 const Particle* daughter1 = getDaughter(1);
574 if ((daughter0->getNDaughters() != 2) || (daughter1->getNDaughters() != 2)) {
575 B2ERROR("Cannot calculate acoplanarity of particle 'name' because the number of grand daughters is not 2"
576 << LogVar("name", getName()) << LogVar("# of grand daughters of first daughter", daughter0->getNDaughters())
577 << LogVar("# of grand daughters of second daughter", daughter1->getNDaughters()));
578 return std::numeric_limits<double>::quiet_NaN();
579 }
580
581 // boost vector to the rest frame of the particle
582 Boost boost(get4Vector().BoostToCM());
583
584 // momenta of the daughters and grand daughters in the particle's rest frame
585 PxPyPzEVector pDaughter0 = boost * daughter0->get4Vector();
586 PxPyPzEVector pGrandDaughter0 = boost * daughter0->getDaughter(0)->get4Vector();
587 PxPyPzEVector pDaughter1 = boost * daughter1->get4Vector();
588 PxPyPzEVector pGrandDaughter1 = boost * daughter1->getDaughter(0)->get4Vector();
589
590 // calculate angle between normal vectors
591 XYZVector normal0 = pDaughter0.Vect().Cross(pGrandDaughter0.Vect());
592 XYZVector normal1 = -pDaughter1.Vect().Cross(pGrandDaughter1.Vect());
593 double result = acos(normal0.Unit().Dot(normal1.Unit()));
594 if (normal0.Cross(normal1).Dot(pDaughter0.Vect()) < 0) result = -result;
595
596 return result;
597}
std::string getName() const override
Return name of this particle.
Definition: Particle.cc:1250
ROOT::Math::PxPyPzEVector get4Vector() const
Returns Lorentz vector.
Definition: Particle.h:567
Class to store variables with their name which were sent to the logging service.

◆ getAllDaughters()

std::vector< const Belle2::Particle * > getAllDaughters ( ) const

Returns a vector of pointers to all generations' daughter particles.

Returns
vector of pointers to all generations' daughter particles

Definition at line 688 of file Particle.cc.

689{
690 std::vector<const Particle*> allDaughters;
691 fillAllDaughters(allDaughters);
692
693 return allDaughters;
694}

◆ getArrayIndex()

int getArrayIndex ( ) const
inlineinherited

Returns this object's array index (in StoreArray), or -1 if not found.

Definition at line 385 of file RelationsObject.h.

386 {
388 return m_cacheArrayIndex;
389 }
bool findStoreEntry(const TObject *object, StoreEntry *&entry, int &index)
Find an object in an array in the data store.
Definition: DataStore.cc:397

◆ 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.

◆ getArrayPointer()

TClonesArray * getArrayPointer ( ) const
inline

Returns the pointer to the store array which holds the daughter particles.

Warning
TClonesArray is dangerously easy to misuse, please avoid.

Definition at line 981 of file Particle.h.

982 {
983 if (!m_arrayPointer)
985 return m_arrayPointer;
986 }
TClonesArray * getArrayPointer() const
Returns the pointer to the raw DataStore array holding this object (protected since these arrays are ...

◆ getCharge()

double getCharge ( void  ) const

Returns particle charge.

Returns
particle charge in units of elementary charge

Definition at line 653 of file Particle.cc.

654{
655 if (TDatabasePDG::Instance()->GetParticle(m_pdgCode) == nullptr) {
656 B2ERROR("PDG=" << m_pdgCode << " ***code unknown to TDatabasePDG");
657 return 0.0;
658 }
659 return TDatabasePDG::Instance()->GetParticle(m_pdgCode)->Charge() / 3.0;
660}

◆ getCosHelicity()

double getCosHelicity ( const Particle mother = nullptr) const

Returns cosine of the helicity angle The helicity angle is defined in the rest frame of the particle as the angle between the negative momentum of the mother and.

  • the momentum of the first daughter for two body decays
  • the momentum of the photon for pi0 Dalitz decays
  • the direction perpendicular to the daughter momenta for three body decays
    Parameters
    mothermother particle, if not given the center of mass system is taken as mother frame
    Returns
    cosine of the helicity angle

Definition at line 490 of file Particle.cc.

491{
492 // boost vector to the rest frame of the particle
493 Boost boost(get4Vector().BoostToCM());
494
495 // momentum of the mother in the particle's rest frame
496 PxPyPzEVector pMother;
497 if (mother) {
498 pMother = mother->get4Vector();
499 } else {
500 static DBObjPtr<CollisionBoostVector> cmsBoost;
502 pMother.SetE(cmsMass->getMass());
503 pMother = Boost(cmsBoost->getBoost()) * pMother;
504 }
505 pMother = boost * pMother;
506
507 // momentum of the daughter (or normal vector) in the particle's rest frame
508 PxPyPzEVector pDaughter;
509 if (getNDaughters() == 2) { // two body decay
510 pDaughter = boost * getDaughter(0)->get4Vector();
511 } else if (getNDaughters() == 3) {
512 if (getPDGCode() == Const::pi0.getPDGCode()) { // pi0 Dalitz decay
513 for (auto& daughter : getDaughters()) {
514 if (daughter->getPDGCode() == Const::photon.getPDGCode()) {
515 pDaughter = daughter->get4Vector();
516 }
517 }
518 pDaughter = boost * pDaughter;
519 } else { // three body decay
520 PxPyPzEVector pDaughter0 = boost * getDaughter(0)->get4Vector();
521 PxPyPzEVector pDaughter1 = boost * getDaughter(1)->get4Vector();
522
523 XYZVector pDaughterNormal(pDaughter0.Vect().Cross(pDaughter1.Vect()));
524 pDaughter.SetPxPyPzE(pDaughterNormal.X(), pDaughterNormal.Y(), pDaughterNormal.Z(), 0); // energy doesn't matter
525 }
526 }
527
528 double mag2 = pMother.P2() * pDaughter.P2();
529 if (mag2 <= 0) return std::numeric_limits<double>::quiet_NaN();
530 return -pMother.Vect().Dot(pDaughter.Vect()) / sqrt(mag2);
531}
static const ParticleType pi0
neutral pion particle
Definition: Const.h:674
static const ParticleType photon
photon particle
Definition: Const.h:673
Class for accessing objects in the database.
Definition: DBObjPtr.h:21
int getPDGCode(void) const
Returns PDG code.
Definition: Particle.h:465
std::vector< Belle2::Particle * > getDaughters() const
Returns a vector of pointers to daughter particles.
Definition: Particle.cc:668
double sqrt(double a)
sqrt for double
Definition: beamHelpers.h:28

◆ getCosHelicityDaughter()

double getCosHelicityDaughter ( unsigned  iDaughter,
unsigned  iGrandDaughter = 0 
) const

Returns cosine of the helicity angle of the given daughter defined by given grand daughter.

Parameters
iDaughter0-based index of daughter particle
iGrandDaughter0-based index of grand daughter particle
Returns
cosine of the helicity angle

Definition at line 533 of file Particle.cc.

534{
535 // check existence of daughter
536 if (getNDaughters() <= iDaughter) {
537 B2ERROR("No daughter of particle 'name' with index 'iDaughter' for calculation of helicity angle"
538 << LogVar("name", getName()) << LogVar("iDaughter", iDaughter));
539 return std::numeric_limits<double>::quiet_NaN();
540 }
541
542 // boost vector to the rest frame of the daughter particle
543 const Particle* daughter = getDaughter(iDaughter);
544 Boost boost(daughter->get4Vector().BoostToCM());
545
546 // momentum of the this particle in the daughter's rest frame
547 PxPyPzEVector pMother = boost * get4Vector();
548
549 // check existence of grand daughter
550 if (daughter->getNDaughters() <= iGrandDaughter) {
551 B2ERROR("No grand daughter of daughter 'iDaughter' of particle 'name' with index 'iGrandDaughter' for calculation of helicity angle"
552 << LogVar("name", getName()) << LogVar("iDaughter", iDaughter) << LogVar("iGrandDaughter", iGrandDaughter));
553 return std::numeric_limits<double>::quiet_NaN();
554 }
555
556 // momentum of the grand daughter in the daughter's rest frame
557 PxPyPzEVector pGrandDaughter = boost * daughter->getDaughter(iGrandDaughter)->get4Vector();
558
559 double mag2 = pMother.P2() * pGrandDaughter.P2();
560 if (mag2 <= 0) return std::numeric_limits<double>::quiet_NaN();
561 return -pMother.Vect().Dot(pGrandDaughter.Vect()) / sqrt(mag2);
562}

◆ getDaughter()

const Particle * getDaughter ( unsigned  i) const

Returns a pointer to the i-th daughter particle.

Parameters
i0-based index of daughter particle
Returns
Pointer to i-th daughter particles

Definition at line 662 of file Particle.cc.

663{
664 if (i >= getNDaughters()) return nullptr;
665 return static_cast<Particle*>(getArrayPointer()->At(m_daughterIndices[i]));
666}

◆ getDaughterIndices()

const std::vector< int > & getDaughterIndices ( ) const
inline

Returns a vector of store array indices of daughter particles.

Returns
vector of store array indices of daughter particle

Definition at line 756 of file Particle.h.

757 {
758 return m_daughterIndices;
759 }

◆ getDaughterProperties()

const std::vector< int > & getDaughterProperties ( ) const
inline

Returns a vector of properties of daughter particles.

Returns
vector of daughter properties

Definition at line 765 of file Particle.h.

766 {
768 }

◆ getDaughters()

std::vector< Belle2::Particle * > getDaughters ( ) const

Returns a vector of pointers to daughter particles.

Returns
vector of pointers to daughter particles

Definition at line 668 of file Particle.cc.

669{
670 const unsigned int nDaughters = getNDaughters();
671 std::vector<Particle*> daughters(nDaughters);
672
673 const TClonesArray* array = getArrayPointer();
674 for (unsigned i = 0; i < nDaughters; i++)
675 daughters[i] = static_cast<Particle*>(array->At(m_daughterIndices[i]));
676
677 return daughters;
678}

◆ getECLCluster()

const ECLCluster * getECLCluster ( ) const

Returns the pointer to the ECLCluster object that was used to create this Particle (if ParticleType == c_ECLCluster).

Returns the pointer to the most energetic ECLCluster matched to the track (if ParticleType == c_Track). NULL pointer is returned, if the Particle has no relation to an ECLCluster (either the particle is a different type or there was no track match).

Returns
const pointer to the ECLCluster

Definition at line 976 of file Particle.cc.

977{
978 if (m_particleSource == c_ECLCluster) {
979 StoreArray<ECLCluster> eclClusters{};
980 return eclClusters[m_mdstIndex];
981 } else if (m_particleSource == c_Track) {
982 // a track may be matched to several clusters under different hypotheses
983 // take the most energetic of the c_nPhotons hypothesis as "the" cluster
984 StoreArray<Track> tracks{};
985 const ECLCluster* bestTrackMatchedCluster = nullptr;
986 double highestEnergy = -1.0;
987 // loop over all clusters matched to this track
988 for (const ECLCluster& cluster : tracks[m_mdstIndex]->getRelationsTo<ECLCluster>()) {
989 // ignore everything except the nPhotons hypothesis
990 if (!cluster.hasHypothesis(ECLCluster::EHypothesisBit::c_nPhotons))
991 continue;
992 // check if we're most energetic thus far
993 if (cluster.getEnergy(ECLCluster::EHypothesisBit::c_nPhotons) > highestEnergy) {
994 highestEnergy = cluster.getEnergy(ECLCluster::EHypothesisBit::c_nPhotons);
995 bestTrackMatchedCluster = &cluster;
996 }
997 }
998 return bestTrackMatchedCluster;
999 } else {
1000 return nullptr;
1001 }
1002}
ECL cluster data.
Definition: ECLCluster.h:27
@ c_nPhotons
CR is split into n photons (N1)

◆ getECLClusterEHypothesisBit()

ECLCluster::EHypothesisBit getECLClusterEHypothesisBit ( ) const
inline

Returns the ECLCluster EHypothesisBit for this Particle.

Definition at line 1029 of file Particle.h.

1030 {
1031 const int pdg = abs(getPDGCode());
1032 if ((pdg == Const::photon.getPDGCode())
1033 or (pdg == Const::electron.getPDGCode())
1034 or (pdg == Const::muon.getPDGCode())
1035 or (pdg == Const::pion.getPDGCode())
1036 or (pdg == Const::kaon.getPDGCode())
1037 or (pdg == Const::proton.getPDGCode())
1038 or (pdg == Const::deuteron.getPDGCode())) {
1040 } else if ((pdg == Const::Klong.getPDGCode())
1041 or (pdg == Const::neutron.getPDGCode())) {
1043 } else {
1045 }
1046 }
static const ParticleType neutron
neutron particle
Definition: Const.h:675
static const ChargedStable pion
charged pion particle
Definition: Const.h:661
static const ParticleType Klong
K^0_L particle.
Definition: Const.h:678
static const ChargedStable proton
proton particle
Definition: Const.h:663
static const ChargedStable kaon
charged kaon particle
Definition: Const.h:662
static const ChargedStable deuteron
deuteron particle
Definition: Const.h:664
@ c_neutralHadron
CR is reconstructed as a neutral hadron (N2)
@ c_none
None as initializer.

◆ getECLClusterEnergy()

double getECLClusterEnergy ( ) const

Returns the energy of the ECLCluster for the particle.

The return value depends on the ECLCluster hypothesis.

Returns
energy of the ECLCluster

Definition at line 1004 of file Particle.cc.

1005{
1006 const ECLCluster* cluster = this->getECLCluster();
1007 if (!cluster) return 0;
1008 return cluster->getEnergy(this->getECLClusterEHypothesisBit());
1009}
const ECLCluster * getECLCluster() const
Returns the pointer to the ECLCluster object that was used to create this Particle (if ParticleType =...
Definition: Particle.cc:976

◆ getEffectiveMomentumScale()

double getEffectiveMomentumScale ( ) const
inline

Returns effective momentum scale which is the product of the momentum scaling and smearing factors.

Returns
momentum scaling factor

Definition at line 634 of file Particle.h.

635 {
636 return m_momentumScale;
637 }

◆ getEnergy()

double getEnergy ( ) const
inline

Returns total energy.

Returns
total energy

Definition at line 555 of file Particle.h.

556 {
561 }
double m_energyLossCorrection
energy loss correction.
Definition: Particle.h:1091

◆ getEnergyLossCorrection()

double getEnergyLossCorrection ( ) const
inline

Returns Energy Loss Correction.

Returns
Energy Loss Correction

Definition at line 643 of file Particle.h.

644 {
646 }

◆ getExtraInfo()

double getExtraInfo ( const std::string &  name) const

Return given value if set.

throws std::runtime_error if variable is not set.

Definition at line 1374 of file Particle.cc.

1375{
1376 if (m_extraInfo.empty())
1377 throw std::runtime_error(std::string("getExtraInfo: Value '") + name + "' not found in Particle!");
1378
1379 //get index for name
1380 const auto mapID = (unsigned int)m_extraInfo[0];
1382 if (!extraInfoMap) {
1383 B2FATAL("ParticleExtraInfoMap not available, but needed for storing extra info in Particle!");
1384 }
1385 unsigned int index = extraInfoMap->getIndex(mapID, name);
1386 if (index == 0 or index >= m_extraInfo.size()) //actually indices start at 1
1387 throw std::runtime_error(std::string("getExtraInfo: Value '") + name + "' not found in Particle!");
1388
1389 return m_extraInfo[index];
1390
1391}

◆ getExtraInfoMap()

int getExtraInfoMap ( ) const
inline

Return the id of the associated ParticleExtraInfoMap or -1 if no map is set.

Definition at line 949 of file Particle.h.

950 {
951 return !m_extraInfo.empty() ? m_extraInfo[0] : -1;
952 }

◆ getExtraInfoNames()

std::vector< std::string > getExtraInfoNames ( ) const

get a list of the extra info names

Definition at line 1260 of file Particle.cc.

1261{
1262 std::vector<std::string> out;
1263 if (!m_extraInfo.empty()) {
1265 if (!extraInfoMap)
1266 B2FATAL("ParticleExtraInfoMap not available, but needed for storing extra info in Particle!");
1267 const ParticleExtraInfoMap::IndexMap& map = extraInfoMap->getMap(m_extraInfo[0]);
1268 for (auto const& ee : map) out.push_back(ee.first);
1269 }
1270 return out;
1271}
std::map< std::string, unsigned int > IndexMap
string -> index map.

◆ getExtraInfoSize()

unsigned int getExtraInfoSize ( ) const
inline

Return the size of the extra info array.

Definition at line 955 of file Particle.h.

956 {
957 return m_extraInfo.size();
958 }

◆ getFinalStateDaughters()

std::vector< const Belle2::Particle * > getFinalStateDaughters ( ) const

Returns a vector of pointers to Final State daughter particles.

Returns
vector of pointers to final state daughter particles

Definition at line 680 of file Particle.cc.

681{
682 std::vector<const Particle*> fspDaughters;
683 fillFSPDaughters(fspDaughters);
684
685 return fspDaughters;
686}

◆ getFlavorType()

EFlavorType getFlavorType ( ) const
inline

Returns flavor type of the decay (for FS particles: flavor type of particle)

Returns
flavor type (0=unflavored, 1=flavored)

Definition at line 480 of file Particle.h.

481 {
482 return m_flavorType;
483 }

◆ 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 1273 of file Particle.cc.

1274{
1275 std::stringstream stream;
1276 stream << std::setprecision(4);
1277 stream << "<b>collection</b>=" << getArrayName();
1278 stream << "<br>";
1279 stream << " <b>PDGCode</b>=" << m_pdgCode;
1280 stream << " <b>Charge</b>=" << getCharge();
1281 stream << " <b>PDGMass</b>=" << getPDGMass();
1282 stream << "<br>";
1283 stream << " <b>flavorType</b>=" << m_flavorType;
1284 stream << " <b>particleSource</b>=" << m_particleSource;
1285 stream << " <b>particleTypeUsedForFit</b>=" << m_pdgCodeUsedForFit;
1286 stream << "<br>";
1287
1288 stream << " <b>mdstIndex</b>=" << m_mdstIndex;
1289 stream << " <b>arrayIndex</b>=" << getArrayIndex();
1290 stream << " <b>identifier</b>=" << m_identifier;
1291 stream << " <b>daughterIndices</b>: ";
1292 for (int daughterIndex : m_daughterIndices) {
1293 stream << daughterIndex << ", ";
1294 }
1295 if (m_daughterIndices.empty()) stream << " (none)";
1296 stream << "<br>";
1297
1298 if (!m_daughterIndices.empty()) {
1299 stream << " <b>daughter PDGCodes</b>: ";
1300 for (unsigned i = 0; i < m_daughterIndices.size(); i++) {
1301 const Particle* p = getDaughter(i);
1302 if (p) {stream << p->getPDGCode() << ", ";}
1303 else {stream << "?, ";}
1304 }
1305 stream << "<br>";
1306 }
1307
1308 stream << " <b>mass</b>=" << m_mass;
1309 stream << "<br>";
1310
1311 stream << " <b>momentum</b>=" << HTML::getString(ROOT::Math::XYZVector(getPx(), getPy(), getPz()));
1312 stream << " <b>p</b>=" << getP();
1313 stream << "<br>";
1314
1315 stream << " <b>momentum scaling factor</b>=" << m_momentumScale;
1316 stream << "<br>";
1317
1318 stream << " <b>Energy loss correction</b>=" << m_energyLossCorrection;
1319 stream << "<br>";
1320
1321 stream << " <b>position</b>=" << HTML::getString(ROOT::Math::XYZVector(m_x, m_y, m_z));
1322 stream << "<br>";
1323
1324 stream << " <b>p-value of fit</b> (if done): ";
1325 stream << m_pValue;
1326 stream << "<br>";
1327
1328 stream << " <b>error matrix</b> (px, py, pz, E, x, y ,z):<br>";
1330
1331 stream << " <b>extra info</b>=( ";
1332 if (!m_extraInfo.empty()) {
1334 if (!extraInfoMap) {
1335 B2FATAL("ParticleExtraInfoMap not available, but needed for storing extra info in Particle!");
1336 }
1337 const ParticleExtraInfoMap::IndexMap& map = extraInfoMap->getMap(m_extraInfo[0]);
1338 const unsigned int nVars = m_extraInfo.size();
1339 for (const auto& pair : map) {
1340 if (pair.second < nVars) {
1341 stream << pair.first << "=" << m_extraInfo[pair.second] << " ";
1342 }
1343 }
1344
1345 }
1346 stream << ") " << "<br>";
1347
1348 return stream.str();
1349}
double getPx() const
Returns x component of momentum.
Definition: Particle.h:607
double getPz() const
Returns z component of momentum.
Definition: Particle.h:625
double getPy() const
Returns y component of momentum.
Definition: Particle.h:616
double getPDGMass(void) const
Returns uncertainty on the invariant mass (requires valid momentum error matrix)
Definition: Particle.cc:635
double getCharge(void) const
Returns particle charge.
Definition: Particle.cc:653
TMatrixFSym getMomentumVertexErrorMatrix() const
Returns 7x7 error matrix.
Definition: Particle.cc:451
double getP() const
Returns momentum magnitude (same as getMomentumMagnitude but with shorter name)
Definition: Particle.h:598
int m_identifier
Identifier that can be used to identify whether the particle is unique or is a copy or representation...
Definition: Particle.h:1113
std::string getArrayName() const
Get name of array this object is stored in, or "" if not found.
std::string getString(const TMatrixFBase &matrix, int precision=2, bool color=true)
get HTML table representing a matrix.
Definition: HTML.cc:24

◆ getKink()

const Kink * getKink ( ) const

Returns the pointer to the Kink object that was used to create this Particle (if ParticleType == c_Kink).

NULL pointer is returned if the Particle was not made from a Kink.

Returns
const pointer to the Kink

Definition at line 966 of file Particle.cc.

967{
968 if (m_particleSource == c_Kink) {
969 StoreArray<Kink> kinks{};
970 return kinks[m_mdstIndex];
971 } else {
972 return nullptr;
973 }
974}

◆ getKLMCluster()

const KLMCluster * getKLMCluster ( ) const

Returns the pointer to the KLMCluster object that was used to create this Particle (ParticleType == c_KLMCluster).

Returns the pointer to the KLMCluster object associated to this Particle if ParticleType == c_Track. NULL pointer is returned, if the Particle has no relation to the KLMCluster.

Returns
const pointer to the KLMCluster

Definition at line 1011 of file Particle.cc.

1012{
1013 if (m_particleSource == c_KLMCluster) {
1014 StoreArray<KLMCluster> klmClusters{};
1015 return klmClusters[m_mdstIndex];
1016 } else if (m_particleSource == c_Track) {
1017 // If there is an associated KLMCluster, it's the closest one
1018 StoreArray<Track> tracks{};
1019 const KLMCluster* klmCluster = tracks[m_mdstIndex]->getRelatedTo<KLMCluster>();
1020 return klmCluster;
1021 } else {
1022 return nullptr;
1023 }
1024}
KLM cluster data.
Definition: KLMCluster.h:28

◆ getMass()

double getMass ( ) const
inline

Returns invariant mass (= nominal for FS particles)

Returns
invariant mass

Definition at line 527 of file Particle.h.

528 {
529 return m_mass;
530 }

◆ getMCParticle()

const MCParticle * getMCParticle ( ) const

Returns the pointer to the MCParticle object that was used to create this Particle (ParticleType == c_MCParticle).

Returns the best MC match for this particle (if ParticleType == c_Track or c_ECLCluster or c_KLMCluster) NULL pointer is returned, if the Particle was not made from MCParticle or not matched.

Returns
const pointer to the MCParticle

Definition at line 1027 of file Particle.cc.

1028{
1029 if (m_particleSource == c_MCParticle) {
1030 StoreArray<MCParticle> mcParticles{};
1031 return mcParticles[m_mdstIndex];
1032 } else {
1033 const MCParticle* related = this->getRelated<MCParticle>();
1034 if (related)
1035 return related;
1036 }
1037 return nullptr;
1038}
A Class to store the Monte Carlo particle information.
Definition: MCParticle.h:32

◆ getMdstArrayIndex()

unsigned getMdstArrayIndex ( void  ) const
inline

Returns 0-based index of MDST store array object (0 for composite particles)

Returns
index of MDST store array object

Definition at line 498 of file Particle.h.

499 {
500 return m_mdstIndex;
501 }

◆ getMdstArrayIndices()

std::vector< int > getMdstArrayIndices ( EParticleSourceObject  type) const

Returns a vector of StoreArray indices of given MDST dataobjects.

Parameters
typeEParticleSourceObject corresponding to a given MDST dataobject
Returns
vector of StoreArray indices of a given MDST dataobjects

Definition at line 696 of file Particle.cc.

697{
698 std::vector<int> mdstIndices;
699 for (const Particle* fsp : getFinalStateDaughters()) {
700 // is this FSP daughter constructed from given MDST source
701 if (fsp->getParticleSource() == source)
702 mdstIndices.push_back(fsp->getMdstArrayIndex());
703 }
704 return mdstIndices;
705}
std::vector< const Belle2::Particle * > getFinalStateDaughters() const
Returns a vector of pointers to Final State daughter particles.
Definition: Particle.cc:680

◆ getMdstSource()

int getMdstSource ( ) const

Returns unique identifier of final state particle (needed in particle combiner)

Returns
unique identifier of final state particle

Definition at line 400 of file Particle.cc.

401{
402 // Is identifier already set
403 if (m_identifier > -1)
404 return m_identifier + (m_particleSource << 24);
405
406 // Identifier is not set.
407 int identifier = 0;
408 if (m_particleSource == c_ECLCluster) {
409 const ECLCluster* cluster = this->getECLCluster();
410 if (cluster) {
411 identifier = cluster->getUniqueClusterId();
412 } else {
413 B2ERROR("Particle is of type = ECLCluster has identifier not set and no relation to ECLCluster.\n"
414 "This has happen because old microDST is analysed with newer version of software.");
415 }
416 } else {
417 identifier = m_mdstIndex;
418 }
419
420 return identifier + (m_particleSource << 24);
421}

◆ getMomentum()

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

Returns momentum vector.

Returns
momentum vector

Definition at line 580 of file Particle.h.

581 {
582 return m_momentumScale * getMomentumLossCorrectionFactor() * ROOT::Math::XYZVector(m_px, m_py, m_pz);
583 };

◆ getMomentumErrorMatrix()

TMatrixFSym getMomentumErrorMatrix ( ) const

Returns the 4x4 momentum error matrix.

Returns
The 4x4 momentum error matrix (order: px,py,pz,E)

Definition at line 466 of file Particle.cc.

467{
468 TMatrixFSym mom;
469 const TMatrixFSym& full = getMomentumVertexErrorMatrix();
470
471 // get 4x4 (momentum) submatrix from the full error matrix
472 // momentum related elements are in [0,...,3]x[0,...,3] block
473 full.GetSub(0, 3, mom, "S");
474
475 return mom;
476}

◆ getMomentumLossCorrectionFactor()

double getMomentumLossCorrectionFactor ( ) const
inline

Returns effect of energy correction on the particle momentum.

Returns
momentum change

Definition at line 326 of file Particle.h.

327 {
328 if (m_energyLossCorrection == 0.0) {
329 return 1.0;
330 }
331 double origP = m_momentumScale * sqrt(m_px * m_px + m_py * m_py + m_pz * m_pz);
332 if (origP == 0.0) {
333 return 1.0;
334 }
335 double origE = sqrt(origP * origP + m_mass * m_mass);
336
337 double newP = sqrt((origE - m_energyLossCorrection) * (origE - m_energyLossCorrection) - m_mass * m_mass);
338 return newP / origP;
339 }

◆ getMomentumMagnitude()

double getMomentumMagnitude ( ) const
inline

Returns momentum magnitude.

Returns
momentum magnitude

Definition at line 589 of file Particle.h.

590 {
591 return getP();
592 };

◆ getMomentumVertexErrorMatrix()

TMatrixFSym getMomentumVertexErrorMatrix ( ) const

Returns 7x7 error matrix.

Returns
7x7 error matrix (order: px,py,pz,E,x,y,z)

Definition at line 451 of file Particle.cc.

452{
453 TMatrixFSym m(c_DimMatrix);
454
455 int element = 0;
456 for (int irow = 0; irow < c_DimMatrix; irow++) {
457 for (int icol = irow; icol < c_DimMatrix; icol++) {
458 m(irow, icol) = m(icol, irow) = m_errMatrix[element];
459 element++;
460 }
461 }
462 return m;
463}
double m_errMatrix[c_SizeMatrix]
error matrix (1D representation)
Definition: Particle.h:1095

◆ getMostLikelyTrackFitResult()

std::pair< Const::ChargedStable, const TrackFitResult * > getMostLikelyTrackFitResult ( ) const

For a (track-based) particle, returns the charged stable mass hypothesis associated to the most probable TrackFitResult, and the TrackFitResult itself.

Definition at line 1483 of file Particle.cc.

1484{
1485
1486 const auto track = this->getTrack();
1487
1488 if (!track) {
1489 return std::make_pair(Const::ChargedStable(std::abs(this->getPDGCode())), nullptr);
1490 }
1491
1492 // Find the track fit with the highest pValue
1493 auto trackFitResults = track->getTrackFitResults();
1494 auto it_maxPValue = std::max_element(std::begin(trackFitResults), std::end(trackFitResults),
1495 [](auto tfrAndM1, auto tfrAndM2) {return tfrAndM1.second->getPValue() < tfrAndM2.second->getPValue();});
1496
1497 return trackFitResults[std::distance(std::begin(trackFitResults), it_maxPValue)];
1498
1499}
Provides a type-safe way to pass members of the chargedStableSet set.
Definition: Const.h:589
const Track * getTrack() const
Returns the pointer to the Track object that was used to create this Particle (ParticleType == c_Trac...
Definition: Particle.cc:916

◆ getName()

std::string getName ( ) const
overridevirtual

Return name of this particle.

Reimplemented from RelationsInterface< BASE >.

Definition at line 1250 of file Particle.cc.

1251{
1252 return TDatabasePDG::Instance()->GetParticle(m_pdgCode)->GetName();
1253}

◆ getNDaughters()

unsigned getNDaughters ( void  ) const
inline

Returns number of daughter particles.

Returns
number of daughter particles

Definition at line 747 of file Particle.h.

748 {
749 return m_daughterIndices.size();
750 }

◆ getP()

double getP ( ) const
inline

Returns momentum magnitude (same as getMomentumMagnitude but with shorter name)

Returns
momentum magnitude

Definition at line 598 of file Particle.h.

599 {
601 };

◆ getParticleFromGeneralizedIndexString()

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

Explores the decay tree of the 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.

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

Definition at line 1041 of file Particle.cc.

1042{
1043 // Split the generalizedIndex string in a vector of strings.
1044 std::vector<std::string> generalizedIndexes;
1045 boost::split(generalizedIndexes, generalizedIndex, boost::is_any_of(":"));
1046
1047 if (generalizedIndexes.empty()) {
1048 B2WARNING("Generalized index of daughter particle is empty. Skipping.");
1049 return nullptr;
1050 }
1051
1052 // To explore a decay tree of unknown depth, we need a place to store
1053 // both the root particle and the daughter particle at each iteration
1054 const Particle* dauPart =
1055 nullptr; // This will be eventually returned
1056 const Particle* currentPart = this; // This is the root particle of the next iteration
1057
1058 // Loop over the generalizedIndexes until you get to the particle you want
1059 for (auto& indexString : generalizedIndexes) {
1060 // indexString is a string. First try to convert it into an int
1061 int dauIndex = 0;
1062 try {
1063 dauIndex = Belle2::convertString<int>(indexString);
1064 } catch (std::invalid_argument&) {
1065 B2WARNING("Found the string " << indexString << "instead of a daughter index.");
1066 return nullptr;
1067 }
1068
1069 // Check that the daughter index is smaller than the number of daughters of the current root particle
1070 if (dauIndex >= int(currentPart->getNDaughters()) or dauIndex < 0) {
1071 B2WARNING("Daughter index out of range" << LogVar("Daughter index", dauIndex));
1072 B2WARNING("Trying to access non-existing particle.");
1073 return nullptr;
1074 } else {
1075 dauPart = currentPart->getDaughter(dauIndex); // Pick the particle indicated by the generalizedIndex
1076 currentPart = dauPart;
1077 }
1078 }
1079 return dauPart;
1080}

◆ getParticleSource()

EParticleSourceObject getParticleSource ( ) const
inline

Returns particle source as defined with enum EParticleSourceObject.

Returns
particle type

Definition at line 489 of file Particle.h.

490 {
491 return m_particleSource;
492 }

◆ getPDGCode()

int getPDGCode ( void  ) const
inline

Returns PDG code.

Returns
PDG code

Definition at line 465 of file Particle.h.

466 {
467 return m_pdgCode;
468 }

◆ getPDGCodeUsedForFit()

int getPDGCodeUsedForFit ( ) const
inline

Return the always positive PDG code which was used for the track fit (if there was a track fit) of this particle.

This can be different than the Particle's PDG id as not all mass hypothesis are fitted during the reconstruction.

Definition at line 993 of file Particle.h.

994 {
995 return std::abs(m_pdgCodeUsedForFit);
996 }

◆ getPDGLifetime()

double getPDGLifetime ( ) const

Returns particle nominal lifetime.

Returns
nominal lifetime [sec]

Definition at line 644 of file Particle.cc.

645{
646 if (TDatabasePDG::Instance()->GetParticle(m_pdgCode) == nullptr) {
647 B2ERROR("PDG=" << m_pdgCode << " ***code unknown to TDatabasePDG");
648 return 0.0;
649 }
650 return TDatabasePDG::Instance()->GetParticle(m_pdgCode)->Lifetime();
651}

◆ getPDGMass()

double getPDGMass ( void  ) const

Returns uncertainty on the invariant mass (requires valid momentum error matrix)

Returns
mass error Returns particle nominal mass
nominal mass

Definition at line 635 of file Particle.cc.

636{
637 if (TDatabasePDG::Instance()->GetParticle(m_pdgCode) == nullptr) {
638 B2ERROR("PDG=" << m_pdgCode << " ***code unknown to TDatabasePDG");
639 return 0.0;
640 }
641 return TDatabasePDG::Instance()->GetParticle(m_pdgCode)->Mass();
642}

◆ getPIDLikelihood()

const PIDLikelihood * getPIDLikelihood ( ) const

Returns the pointer to the PIDLikelihood object that is related to the Track, which was used to create this Particle (ParticleType == c_Track).

NULL pointer is returned, if the Particle was not made from Track or if the Track has no relation to the PIDLikelihood

Returns
const pointer to the Track

Definition at line 947 of file Particle.cc.

948{
949 if (m_particleSource == c_Track) {
950 StoreArray<Track> tracks{};
951 return tracks[m_mdstIndex]->getRelated<PIDLikelihood>();
952 } else
953 return nullptr;
954}
Class to collect log likelihoods from TOP, ARICH, dEdx, ECL and KLM aimed for output to mdst includes...
Definition: PIDLikelihood.h:29

◆ getProperty()

int getProperty ( ) const
inline

Returns particle property as a bit pattern The values are defined in the PropertyFlags enum and described in detail there.

Returns
Combination of Properties describing the particle property

Definition at line 518 of file Particle.h.

519 {
520 return m_properties;
521 }

◆ getPValue()

double getPValue ( ) const
inline

Returns chi^2 probability of fit if done or -1.

Returns
p-value of fit (nan means no fit done)

Definition at line 687 of file Particle.h.

688 {
689 return m_pValue;
690 }

◆ getPx()

double getPx ( ) const
inline

Returns x component of momentum.

Returns
x component of momentum

Definition at line 607 of file Particle.h.

608 {
610 }

◆ getPy()

double getPy ( ) const
inline

Returns y component of momentum.

Returns
y component of momentum

Definition at line 616 of file Particle.h.

617 {
619 }

◆ getPz()

double getPz ( ) const
inline

Returns z component of momentum.

Returns
z component of momentum

Definition at line 625 of file Particle.h.

626 {
628 }

◆ 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:596
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 }

◆ getTrack()

const Track * getTrack ( ) const

Returns the pointer to the Track object that was used to create this Particle (ParticleType == c_Track).

NULL pointer is returned, if the Particle was not made from Track.

Returns
const pointer to the Track

Definition at line 916 of file Particle.cc.

917{
918 if (m_particleSource == c_Track) {
919 StoreArray<Track> tracks{};
920 return tracks[m_mdstIndex];
921 } else
922 return nullptr;
923}

◆ getTrackFitResult()

const TrackFitResult * getTrackFitResult ( ) const

Returns the pointer to the TrackFitResult that was used to create this Particle (ParticleType == c_Track).

NULL pointer is returned, if the Particle was not made from Track.

Returns
const pointer to the TrackFitResult

Definition at line 925 of file Particle.cc.

926{
927 // if the particle is related to a TrackFitResult then return this
928 auto* selfrelated = this->getRelatedTo<TrackFitResult>();
929 if (selfrelated && !std::isnan(selfrelated->getPValue()))
930 return selfrelated;
931
932 if (m_particleSource == c_Kink) {
933 StoreArray<TrackFitResult> trackFitResults{};
934 return trackFitResults[m_trackFitResultIndex];
935 }
936
937 // if not get the TFR with closest mass to this particle
938 auto* selftrack = this->getTrack();
939 if (selftrack)
940 return selftrack->getTrackFitResultWithClosestMass(
941 Belle2::Const::ChargedStable(std::abs(this->getPDGCode())));
942
943 // otherwise we're probably not a track based particle
944 return nullptr;
945}

◆ getTrackFitResultIndex()

unsigned getTrackFitResultIndex ( void  ) const
inline

Returns 0-based index of the TrackFitResult that should be associated with the Particle.

Returns
index of TrackFitResult

Definition at line 507 of file Particle.h.

508 {
510 }

◆ getV0()

const V0 * getV0 ( ) const

Returns the pointer to the V0 object that was used to create this Particle (if ParticleType == c_V0).

NULL pointer is returned if the Particle was not made from a V0.

Returns
const pointer to the V0

Definition at line 956 of file Particle.cc.

957{
958 if (m_particleSource == c_V0) {
959 StoreArray<V0> v0s{};
960 return v0s[m_mdstIndex];
961 } else {
962 return nullptr;
963 }
964}

◆ getVertex()

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

Returns vertex position (POCA for charged, IP for neutral FS particles)

Returns
vertex position

Definition at line 651 of file Particle.h.

652 {
653 return ROOT::Math::XYZVector(m_x, m_y, m_z);
654 };

◆ getVertexErrorMatrix()

TMatrixFSym getVertexErrorMatrix ( ) const

Returns the 3x3 position error sub-matrix.

Returns
The 3x3 position error matrix (order: x,y,z)

Definition at line 478 of file Particle.cc.

479{
480 TMatrixFSym pos;
481 const TMatrixFSym& full = getMomentumVertexErrorMatrix();
482
483 // get 3x3 (position) submatrix from the full error matrix
484 // vertex related elements are in [4,5,6]x[4,5,6] block
485 full.GetSub(4, 6, pos, "S");
486
487 return pos;
488}

◆ getX()

double getX ( ) const
inline

Returns x component of vertex position.

Returns
x component of vertex position

Definition at line 660 of file Particle.h.

661 {
662 return m_x;
663 }

◆ getY()

double getY ( ) const
inline

Returns y component of vertex position.

Returns
y component of vertex position

Definition at line 669 of file Particle.h.

670 {
671 return m_y;
672 }

◆ getZ()

double getZ ( ) const
inline

Returns z component of vertex position.

Returns
z component of vertex position

Definition at line 678 of file Particle.h.

679 {
680 return m_z;
681 }

◆ hasExtraInfo()

bool hasExtraInfo ( const std::string &  name) const

Return whether the extra info with the given name is set.

Definition at line 1351 of file Particle.cc.

1352{
1353 if (m_extraInfo.empty())
1354 return false;
1355
1356 //get index for name
1357 const auto mapID = (unsigned int)m_extraInfo[0];
1359 if (!extraInfoMap) {
1360 B2FATAL("ParticleExtraInfoMap not available, but needed for storing extra info in Particle!");
1361 }
1362 unsigned int index = extraInfoMap->getIndex(mapID, name);
1363 if (index == 0 or index >= m_extraInfo.size()) //actually indices start at 1
1364 return false;
1365
1366 return true;
1367}

◆ isCopyOf()

bool isCopyOf ( const Particle oParticle,
bool  doDetailedComparison = false 
) const

Returns true if this Particle and oParticle are copies of each other.

Copies are defined as: o) The decay chain of both Particles is exactly the same o) Both Particles are constructed from exactly the same final state particles

  • Examples: M1 -> (C1 -> F1 F2) (C2 -> F3 F4) M2 -> (C1 -> F1 F2) (C2 -> F3 F5) M3 -> (C1 -> F1 F2) F3 F4 M4 -> (C1 -> F1 F2) (C2 -> F3 F4) and M4 is kinematically fitted (its momentum updated)

M1 and M2 are not copies since condition 2 is not fulfilled. M1 and M3 are not copies since condition 1 is not fulfilled. M1 and M4 are copies since both conditions are fulfilled.

Parameters
oParticlepointer to other particle
doDetailedComparisonif true, this means that particles of different PDG codes, but created from the same track or cluster will be indicated as copies. Returns B2FATAL in case of comparison of c_MCParticle type to a non c_MCParticle.
Returns
true if particles are copies of each-other, otherwise false

Definition at line 783 of file Particle.cc.

784{
785 // the name of the game is to as quickly as possible determine
786 // that the Particles are not copies
787 if (this->getPDGCode() != oParticle->getPDGCode() and !doDetailedComparison)
788 return false;
789
790 unsigned nDaughters = this->getNDaughters();
791 if (nDaughters != oParticle->getNDaughters())
792 return false;
793
794 if (nDaughters) {
795 // has daughters: check if the decay chain is the same and it ends with
796 // the same FSPs
797 std::vector<int> thisDecayChain(nDaughters * 2);
798 std::vector<int> othrDecayChain(nDaughters * 2);
799
800 for (unsigned i = 0; i < nDaughters; i++) {
801 this->getDaughter(i)->fillDecayChain(thisDecayChain);
802 oParticle->getDaughter(i)->fillDecayChain(othrDecayChain);
803 }
804
805 // Even if the daughters have been provided in a different order in the
806 // decay string the particles should be identified as copies / duplicates.
807 // Therefore, the decay chain vectors, which contain both the pdg codes and
808 // the mdst sources, are sorted here before comparing them.
809 sort(thisDecayChain.begin(), thisDecayChain.end());
810 sort(othrDecayChain.begin(), othrDecayChain.end());
811
812 for (unsigned i = 0; i < thisDecayChain.size(); i++)
813 if (thisDecayChain[i] != othrDecayChain[i])
814 return false;
815
816 } else if (this->getMdstSource() != oParticle->getMdstSource() and !doDetailedComparison) {
817 // has no daughters: it's a FSP, compare MDST source and index
818 // Check if this or compared particle is a kink. If so, check that the particle is not a copy of daughter or mother.
819 // For consistency, return true if the daughter or mother is a copy of the target particle.
820 if (this->getParticleSource() == EParticleSourceObject::c_Kink &&
821 oParticle->getParticleSource() == EParticleSourceObject::c_Track) {
822 const Kink* kink = this->getKink();
823 const short motherTrackIndex = kink->getMotherTrackIndex();
824 const short daughterTrackIndex = kink->getDaughterTrackIndex();
825 const short trackIndex = oParticle->getTrack()->getArrayIndex();
826 if (trackIndex == motherTrackIndex || trackIndex == daughterTrackIndex)
827 return true;
828 }
829 if (this->getParticleSource() == EParticleSourceObject::c_Track &&
830 oParticle->getParticleSource() == EParticleSourceObject::c_Kink) {
831 const Kink* kink = oParticle->getKink();
832 const short motherTrackIndex = kink->getMotherTrackIndex();
833 const short daughterTrackIndex = kink->getDaughterTrackIndex();
834 const short trackIndex = this->getTrack()->getArrayIndex();
835 if (trackIndex == motherTrackIndex || trackIndex == daughterTrackIndex)
836 return true;
837 }
838 return false;
839 }
840 // Stop here if we do not want a detailed comparison
841 if (!doDetailedComparison)
842 return true;
843 //If we compare here a reconstructed Particle to a generated MCParticle
844 //it means that something went horribly wrong and we must stop
845 if ((this->getParticleSource() == EParticleSourceObject::c_MCParticle
846 and oParticle->getParticleSource() != EParticleSourceObject::c_MCParticle)
847 or (this->getParticleSource() != EParticleSourceObject::c_MCParticle
848 and oParticle->getParticleSource() == EParticleSourceObject::c_MCParticle)) {
849 B2WARNING("Something went wrong: MCParticle is being compared to a non MC Particle. Please check your script!\n"
850 " If the MCParticle <-> Particle comparison happens in the RestOfEventBuilder,\n"
851 " the Rest Of Event may contain signal side particles.");
852 return false;
853 }
854 if (this->getParticleSource() == EParticleSourceObject::c_MCParticle
855 and oParticle->getParticleSource() == EParticleSourceObject::c_MCParticle) {
856 return this->getMCParticle() == oParticle->getMCParticle();
857 }
858 if (this->getParticleSource() != oParticle->getParticleSource()) {
859 // Check if this or compared particle is a kink. If so, check that the particle is not a copy of daughter or mother.
860 // For consistency, return true if the daughter or mother is a copy of the target particle.
861 if (this->getParticleSource() == EParticleSourceObject::c_Kink &&
862 oParticle->getParticleSource() == EParticleSourceObject::c_Track) {
863 const Kink* kink = this->getKink();
864 const short motherTrackIndex = kink->getMotherTrackIndex();
865 const short daughterTrackIndex = kink->getDaughterTrackIndex();
866 const short trackIndex = oParticle->getTrack()->getArrayIndex();
867 if (trackIndex == motherTrackIndex || trackIndex == daughterTrackIndex)
868 return true;
869 }
870 if (this->getParticleSource() == EParticleSourceObject::c_Track &&
871 oParticle->getParticleSource() == EParticleSourceObject::c_Kink) {
872 const Kink* kink = oParticle->getKink();
873 const short motherTrackIndex = kink->getMotherTrackIndex();
874 const short daughterTrackIndex = kink->getDaughterTrackIndex();
875 const short trackIndex = this->getTrack()->getArrayIndex();
876 if (trackIndex == motherTrackIndex || trackIndex == daughterTrackIndex)
877 return true;
878 }
879 return false;
880 }
881 if (this->getMdstSource() == oParticle->getMdstSource()) {
882 return true;
883 }
884 if (this->getTrack() && oParticle->getTrack() &&
885 this->getTrack()->getArrayIndex() != oParticle->getTrack()->getArrayIndex()) {
886 return false;
887 }
888 if (this->getKLMCluster() && oParticle->getKLMCluster()
889 && this->getKLMCluster()->getArrayIndex() != oParticle->getKLMCluster()->getArrayIndex()) {
890 return false;
891 }
892
893 // It can be a bit more complicated for ECLClusters as we might also have to ensure they are connected-region unique
894 if (this->getECLCluster() && oParticle->getECLCluster()
895 && this->getECLCluster()->getArrayIndex() != oParticle->getECLCluster()->getArrayIndex()) {
896
897 // if either is a track then they must be different
898 if (this->getECLCluster()->isTrack() or oParticle->getECLCluster()->isTrack())
899 return false;
900
901 // we cannot combine two particles of different hypotheses from the same
902 // connected region (as their energies overlap)
904 return false;
905
906 // in the rare case that both are neutral and the hypotheses are different,
907 // we must also check that they are from different connected regions
908 // otherwise they come from the "same" underlying ECLShower
909 if (this->getECLCluster()->getConnectedRegionId() != oParticle->getECLCluster()->getConnectedRegionId())
910 return false;
911 }
912 return true;
913
914}
bool isTrack() const
Return true if the cluster matches with track.
Definition: ECLCluster.h:235
int getConnectedRegionId() const
Return connected region id.
Definition: ECLCluster.h:250
Object holding information for Kinks.
Definition: Kink.h:32
short getDaughterTrackIndex() const
Get index of the daughter Track (it is the same as mother's in case of track splitting).
Definition: Kink.h:73
short getMotherTrackIndex() const
Get index of the mother Track.
Definition: Kink.h:67
const KLMCluster * getKLMCluster() const
Returns the pointer to the KLMCluster object that was used to create this Particle (ParticleType == c...
Definition: Particle.cc:1011
const MCParticle * getMCParticle() const
Returns the pointer to the MCParticle object that was used to create this Particle (ParticleType == c...
Definition: Particle.cc:1027
const Kink * getKink() const
Returns the pointer to the Kink object that was used to create this Particle (if ParticleType == c_Ki...
Definition: Particle.cc:966
EParticleSourceObject getParticleSource() const
Returns particle source as defined with enum EParticleSourceObject.
Definition: Particle.h:489

◆ isMostLikely()

bool isMostLikely ( ) const

Returns true if the (track-based) particle is created with its most likely mass hypothesis based on PID likelihood.

Definition at line 1476 of file Particle.cc.

1477{
1478 const PIDLikelihood* likelihood = Particle::getPIDLikelihood();
1479 if (likelihood) return likelihood->getMostLikely().getPDGCode() == std::abs(m_pdgCode);
1480 else return false;
1481}
Const::ChargedStable getMostLikely(const double *fractions=nullptr, Const::PIDDetectorSet set=Const::PIDDetectorSet::set()) const
Return most likely particle among chargedStableSet; if prior fractions not given equal prior probabil...
const PIDLikelihood * getPIDLikelihood() const
Returns the pointer to the PIDLikelihood object that is related to the Track, which was used to creat...
Definition: Particle.cc:947

◆ isMostLikelyTrackFitResult()

bool isMostLikelyTrackFitResult ( ) const

Returns true if the (track-based) particle is created with its most likely mass hypothesis based on TrackFitResult.

Definition at line 1501 of file Particle.cc.

1502{
1503 const auto trackFit = this->getTrackFitResult();
1504 if (!trackFit) return false;
1505
1506 return (trackFit == this->getMostLikelyTrackFitResult().second);
1507}
std::pair< Const::ChargedStable, const TrackFitResult * > getMostLikelyTrackFitResult() const
For a (track-based) particle, returns the charged stable mass hypothesis associated to the most proba...
Definition: Particle.cc:1483
const TrackFitResult * getTrackFitResult() const
Returns the pointer to the TrackFitResult that was used to create this Particle (ParticleType == c_Tr...
Definition: Particle.cc:925

◆ overlapsWith()

bool overlapsWith ( const Particle oParticle) const

Returns true if final state ancestors of oParticle overlap.

Parameters
oParticlepointer to particle
Returns
true if overlap, otherwise false

Definition at line 768 of file Particle.cc.

769{
770 // obtain vectors of daughter final state particles
771 std::vector<const Particle*> thisFSPs = this->getFinalStateDaughters();
772 std::vector<const Particle*> otherFSPs = oParticle->getFinalStateDaughters();
773
774 // check if they share any of the FSPs
775 for (auto& thisFSP : thisFSPs)
776 for (auto& otherFSP : otherFSPs)
777 if (thisFSP->getMdstSource() == otherFSP->getMdstSource())
778 return true;
779
780 return false;
781}

◆ print()

void print ( ) const

Prints the contents of a Particle object to standard output.

Definition at line 1255 of file Particle.cc.

1256{
1257 B2INFO(getInfo());
1258}
std::string getInfo() const
Return a short summary of this object's contents in raw text format.

◆ removeDaughter()

void removeDaughter ( const Particle daughter,
const bool  updateType = true 
)

Removes index of daughter from daughters index array.

Parameters
daughterpointer to the daughter particle
updateTypebool whether particle type should be updated if last daughter was removed

Definition at line 719 of file Particle.cc.

720{
721 if (getNDaughters() == 0)
722 return;
723
724 for (unsigned i = 0; i < getNDaughters(); i++) {
725 if (m_daughterIndices[i] == daughter->getArrayIndex()) {
726 m_daughterIndices.erase(m_daughterIndices.begin() + i);
728 i--;
729 }
730 }
731
732 if (getNDaughters() == 0 and updateType)
733 m_particleSource = c_Undefined;
734}

◆ removeExtraInfo()

void removeExtraInfo ( )

Remove all stored extra info fields.

Definition at line 1369 of file Particle.cc.

1370{
1371 m_extraInfo.clear();
1372}

◆ replaceDaughter()

bool replaceDaughter ( const Particle oldDaughter,
Particle newDaughter 
)

Replace index of given daughter with new daughter, return true if a replacement is made.

Parameters
oldDaughterpointer to the daughter that will be removed
newDaughterpointer to the particle that will be added as a daughter

Definition at line 736 of file Particle.cc.

737{
738 int index = oldDaughter->getArrayIndex();
739
740 for (unsigned i = 0; i < getNDaughters(); i++) {
741 if (m_daughterIndices[i] == index) {
742 auto ite_index = m_daughterIndices.erase(m_daughterIndices.begin() + i);
743 m_daughterIndices.insert(ite_index, newDaughter->getArrayIndex());
744 auto ite_property = m_daughterProperties.erase(m_daughterProperties.begin() + i);
745 m_daughterProperties.insert(ite_property, Particle::PropertyFlags::c_Ordinary);
746
747 newDaughter->writeExtraInfo("original_index", index);
748 return true;
749 }
750 }
751 return false;
752}
void writeExtraInfo(const std::string &name, const double value)
Sets the user defined extraInfo.
Definition: Particle.cc:1393

◆ replaceDaughterRecursively()

bool replaceDaughterRecursively ( const Particle oldDaughter,
Particle newDaughter 
)

Apply replaceDaughter to all Particles in the decay tree by looping recursively through it, return true if a replacement is made.

Parameters
oldDaughterpointer to the daughter that will be removed
newDaughterpointer to the particle that will be added as a daughter

Definition at line 754 of file Particle.cc.

755{
756 bool isReplaced = this->replaceDaughter(oldDaughter, newDaughter);
757 if (isReplaced)
758 return true;
759 for (auto& daughter : this->getDaughters()) {
760 isReplaced = daughter->replaceDaughterRecursively(oldDaughter, newDaughter);
761 if (isReplaced)
762 return true;
763 }
764 return false;
765}
bool replaceDaughter(const Particle *oldDaughter, Particle *newDaughter)
Replace index of given daughter with new daughter, return true if a replacement is made.
Definition: Particle.cc:736

◆ resetErrorMatrix()

void resetErrorMatrix ( )
private

Resets 7x7 error matrix All elements are set to 0.0.

Definition at line 1164 of file Particle.cc.

1165{
1166 for (double& i : m_errMatrix)
1167 i = 0.0;
1168}

◆ resetJacobiMatrix()

void resetJacobiMatrix ( )
private

Resets 4x6 error matrix All elements are set to 0.0.

Definition at line 1170 of file Particle.cc.

1171{
1172 for (double& i : m_jacobiMatrix)
1173 i = 0.0;
1174}
double m_jacobiMatrix[c_SizeMatrix]
error matrix (1D representation)
Definition: Particle.h:1096

◆ set4Vector()

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

Sets Lorentz vector.

Parameters
p4Lorentz vector

Definition at line 282 of file Particle.h.

283 {
284 m_px = p4.Px();
285 m_py = p4.Py();
286 m_pz = p4.Pz();
287 m_mass = p4.M();
288 }

◆ set4VectorDividingByMomentumScaling()

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

Sets Lorentz vector dividing by the momentum scaling factor.

Parameters
p4Lorentz vector

Definition at line 294 of file Particle.h.

295 {
296 m_px = p4.Px() / m_momentumScale;
297 m_py = p4.Py() / m_momentumScale;
298 m_pz = p4.Pz() / m_momentumScale;
299 m_mass = p4.M();
300 }

◆ setEnergyLossCorrection()

void setEnergyLossCorrection ( double  energyLossCorrection)
inline

Sets Energy loss correction.

Parameters
energyLossCorrectionCorrection factor

Definition at line 317 of file Particle.h.

318 {
319 m_energyLossCorrection = energyLossCorrection;
320 }

◆ setExtraInfo()

void setExtraInfo ( const std::string &  name,
double  value 
)

Sets the user-defined data of given name to the given value.

throws std::runtime_error if variable isn't set.

Definition at line 1402 of file Particle.cc.

1403{
1404 if (m_extraInfo.empty())
1405 throw std::runtime_error(std::string("setExtraInfo: Value '") + name + "' not found in Particle!");
1406
1407 //get index for name
1408 const auto mapID = (unsigned int)m_extraInfo[0];
1410 if (!extraInfoMap) {
1411 B2FATAL("ParticleExtraInfoMap not available, but needed for storing extra info in Particle!");
1412 }
1413 unsigned int index = extraInfoMap->getIndex(mapID, name);
1414 if (index == 0 or index >= m_extraInfo.size()) //actually indices start at 1
1415 throw std::runtime_error(std::string("setExtraInfo: Value '") + name + "' not found in Particle!");
1416
1417 m_extraInfo[index] = value;
1418
1419}

◆ setFlavorType()

void setFlavorType ( )
private

sets m_flavorType using m_pdgCode

Definition at line 1235 of file Particle.cc.

1236{
1238 if (m_pdgCode < 0) return;
1239 if (m_pdgCode == Const::photon.getPDGCode()) {m_flavorType = c_Unflavored; return;} // gamma
1240 if (m_pdgCode == Const::Kshort.getPDGCode()) {m_flavorType = c_Unflavored; return;} // K_s
1241 if (m_pdgCode == Const::Klong.getPDGCode()) {m_flavorType = c_Unflavored; return;} // K_L
1242 if (m_pdgCode == 43) {m_flavorType = c_Unflavored; return;} // Xu0
1243 int nnn = m_pdgCode / 10;
1244 int q3 = nnn % 10; nnn /= 10;
1245 int q2 = nnn % 10; nnn /= 10;
1246 int q1 = nnn % 10;
1247 if (q1 == 0 && q2 == q3) m_flavorType = c_Unflavored; // unflavored meson
1248}
static const ParticleType Kshort
K^0_S particle.
Definition: Const.h:677

◆ setJacobiMatrix()

void setJacobiMatrix ( const TMatrixF &  jacobiMatrix)

Sets 4x6 jacobi matrix.

Parameters
jacobiMatrix4x6 momentum and vertex error matrix (order: px,py,pz,E,x,y,z)

Definition at line 438 of file Particle.cc.

439{
440 // check if provided Jacobi Matrix is of dimension 4x6
441 // if not, reset the error matrix and print warning
442 if (m.GetNrows() != 4 || m.GetNcols() != 6) {
444 B2WARNING("Jacobi Matrix is not 4x6 ");
445 return;
446 }
448}
void resetJacobiMatrix()
Resets 4x6 error matrix All elements are set to 0.0.
Definition: Particle.cc:1170
void storeJacobiMatrix(const TMatrixF &jacobiMatrix)
Stores 4x6 Jacobi matrix into private member m_jacobiMatrix.
Definition: Particle.cc:1187

◆ setMdstArrayIndex()

void setMdstArrayIndex ( const int  arrayIndex)
private

set mdst array index

Definition at line 381 of file Particle.cc.

382{
383 m_mdstIndex = arrayIndex;
384
385 // set the identifier
386 if (m_particleSource == c_ECLCluster) {
387 const ECLCluster* cluster = this->getECLCluster();
388 if (cluster) {
389 m_identifier = cluster->getUniqueClusterId();
390 } else {
391 B2ERROR("Particle is of type = ECLCluster has identifier not set and no relation to ECLCluster.\n"
392 "This has happen because old microDST is analysed with newer version of software.");
393 }
394 } else {
396 }
397}

◆ setMomentumPositionErrorMatrix()

void setMomentumPositionErrorMatrix ( const TrackFitResult trackFit)
private

Sets the momentum, position and error matrix for this particle (created from charged Track)

Definition at line 1086 of file Particle.cc.

1087{
1088 // set momentum
1089 m_px = trackFit->getMomentum().X();
1090 m_py = trackFit->getMomentum().Y();
1091 m_pz = trackFit->getMomentum().Z();
1092
1093 // set position at which the momentum is given (= POCA)
1094 setVertex(trackFit->getPosition());
1095
1096 // set Chi^2 probability
1097 m_pValue = trackFit->getPValue();
1098
1099 // set error matrix
1100 const auto cov6 = trackFit->getCovariance6();
1101 constexpr unsigned order[] = {c_X, c_Y, c_Z, c_Px, c_Py, c_Pz};
1102
1103 TMatrixFSym errMatrix(c_DimMatrix);
1104 for (int i = 0; i < 6; i++) {
1105 for (int j = i; j < 6; j++) {
1106 // although it seems to make no sense to fill all elements of the
1107 // symmetric matrix, it has to be (do not touch this code)
1108 errMatrix(order[j], order[i]) = errMatrix(order[i], order[j]) = cov6(i, j);
1109 }
1110 }
1111
1112 /*
1113 E = sqrt(px^2 + py^2 + pz^2 + m^2) thus:
1114 cov(x,E) = cov(px,x) *dE/dpx + cov(py,x) *dE/dpy + cov(pz,x) *dE/dpz
1115 cov(y,E) = cov(px,y) *dE/dpx + cov(py,y) *dE/dpy + cov(pz,y) *dE/dpz
1116 cov(z,E) = cov(px,z) *dE/dpx + cov(py,z) *dE/dpy + cov(pz,z) *dE/dpz
1117 cov(px,E) = cov(px,px)*dE/dpx + cov(px,py)*dE/dpy + cov(px,pz)*dE/dpz
1118 cov(py,E) = cov(py,px)*dE/dpx + cov(py,py)*dE/dpy + cov(py,pz)*dE/dpz
1119 cov(pz,E) = cov(pz,px)*dE/dpx + cov(pz,py)*dE/dpy + cov(pz,pz)*dE/dpz
1120 cov(E,E) = cov(px,px)*(dE/dpx)^2 + cov(py,py)*(dE/dpy)^2 + cov(pz,pz)*(dE/dpz)^2
1121 + 2*cov(px,py)*dE/dpx*dE/dpy
1122 + 2*cov(py,pz)*dE/dpy*dE/dpz
1123 + 2*cov(pz,px)*dE/dpz*dE/dpx
1124 dE/dpx = px/E etc.
1125 */
1126
1127 const double E = getEnergy();
1128 const double dEdp[] = {m_px / E, m_py / E, m_pz / E};
1129 constexpr unsigned compMom[] = {c_Px, c_Py, c_Pz};
1130 constexpr unsigned compPos[] = {c_X, c_Y, c_Z};
1131
1132 // covariances (p,E)
1133 for (unsigned int i : compMom) {
1134 double Cov = 0;
1135 for (int k = 0; k < 3; k++) {
1136 Cov += errMatrix(i, compMom[k]) * dEdp[k];
1137 }
1138 errMatrix(i, c_E) = Cov;
1139 }
1140
1141 // covariances (x,E)
1142 for (unsigned int comp : compPos) {
1143 double Cov = 0;
1144 for (int k = 0; k < 3; k++) {
1145 Cov += errMatrix(comp, compMom[k]) * dEdp[k];
1146 }
1147 errMatrix(c_E, comp) = Cov;
1148 }
1149
1150 // variance (E,E)
1151 double Cov = 0;
1152 for (int i = 0; i < 3; i++) {
1153 Cov += errMatrix(compMom[i], compMom[i]) * dEdp[i] * dEdp[i];
1154 }
1155 for (int i = 0; i < 3; i++) {
1156 int k = (i + 1) % 3;
1157 Cov += 2 * errMatrix(compMom[i], compMom[k]) * dEdp[i] * dEdp[k];
1158 }
1159 errMatrix(c_E, c_E) = Cov;
1160
1161 storeErrorMatrix(errMatrix);
1162}
R E
internal precision of FFTW codelets
void storeErrorMatrix(const TMatrixFSym &errMatrix)
Stores 7x7 error matrix into private member m_errMatrix.
Definition: Particle.cc:1176
double getPValue() const
Getter for Chi2 Probability of the track fit.
TMatrixDSym getCovariance6() const
Position and Momentum Covariance Matrix.
ROOT::Math::XYZVector getMomentum() const
Getter for vector of momentum at closest approach of track in r/phi projection.
ROOT::Math::XYZVector getPosition() const
Getter for vector of position at closest approach of track in r/phi projection.

◆ setMomentumScalingFactor()

void setMomentumScalingFactor ( double  momentumScalingFactor)
inline

Sets momentum scaling.

Parameters
momentumScalingFactorscaling factor

Definition at line 345 of file Particle.h.

346 {
347 m_momentumScalingFactor = momentumScalingFactor;
349 }
double m_momentumSmearingFactor
momentum smearing factor
Definition: Particle.h:1090
double m_momentumScalingFactor
momentum scaling factor
Definition: Particle.h:1089

◆ setMomentumSmearingFactor()

void setMomentumSmearingFactor ( double  momentumSmearingFactor)
inline

Sets momentum smearing.

Parameters
momentumSmearingFactorscaling factor

Definition at line 355 of file Particle.h.

◆ setMomentumVertexErrorMatrix()

void setMomentumVertexErrorMatrix ( const TMatrixFSym &  errMatrix)

Sets 7x7 error matrix.

Parameters
errMatrix7x7 momentum and vertex error matrix (order: px,py,pz,E,x,y,z)

Definition at line 424 of file Particle.cc.

425{
426 // check if provided Error Matrix is of dimension 7x7
427 // if not, reset the error matrix and print warning
428 if (m.GetNrows() != c_DimMatrix || m.GetNcols() != c_DimMatrix) {
430 B2WARNING("Error Matrix is not 7x7 ");
431 return;
432 }
434
435}

◆ setPDGCode()

void setPDGCode ( const int  pdg)
inline

Sets PDG code.

Parameters
pdgPDG code

Definition at line 273 of file Particle.h.

274 {
275 m_pdgCode = pdg;
276 }

◆ setProperty()

void setProperty ( const int  properties)
inline

sets m_properties

Definition at line 385 of file Particle.h.

386 {
387 m_properties = properties;
388 }

◆ setPValue()

void setPValue ( double  pValue)
inline

Sets chi^2 probability of fit.

Parameters
pValuep-value of fit

Definition at line 377 of file Particle.h.

378 {
379 m_pValue = pValue;
380 }

◆ setVertex()

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

Sets position (decay vertex)

Parameters
vertexposition

Definition at line 306 of file Particle.h.

307 {
308 m_x = vertex.X();
309 m_y = vertex.Y();
310 m_z = vertex.Z();
311 };

◆ storeErrorMatrix()

void storeErrorMatrix ( const TMatrixFSym &  errMatrix)
private

Stores 7x7 error matrix into private member m_errMatrix.

Parameters
errMatrix7x7 error matrix

Definition at line 1176 of file Particle.cc.

1177{
1178 int element = 0;
1179 for (int irow = 0; irow < c_DimMatrix; irow++) {
1180 for (int icol = irow; icol < c_DimMatrix; icol++) {
1181 m_errMatrix[element] = m(irow, icol);
1182 element++;
1183 }
1184 }
1185}

◆ storeJacobiMatrix()

void storeJacobiMatrix ( const TMatrixF &  jacobiMatrix)
private

Stores 4x6 Jacobi matrix into private member m_jacobiMatrix.

Parameters
jacobiMatrix4x6 error matrix

Definition at line 1187 of file Particle.cc.

1188{
1189 int element = 0;
1190 for (int irow = 0; irow < 4; irow++) {
1191 for (int icol = 0; icol < 6; icol++) {
1192 m_jacobiMatrix[element] = m(irow, icol);
1193 element++;
1194 }
1195 }
1196}

◆ updateJacobiMatrix()

void updateJacobiMatrix ( )

Propagate the photon energy scaling to jacobian elements that were calculated using energy.

Definition at line 288 of file Particle.cc.

289{
290 ClusterUtils C;
291
292 const ECLCluster* cluster = this->getECLCluster();
293
294 const XYZVector clustervertex = C.GetIPPosition();
295
296 // Get Jacobi matrix.
297 TMatrixD jacobi = C.GetJacobiMatrix4x6FromCluster(cluster, clustervertex, getECLClusterEHypothesisBit());
298 storeJacobiMatrix(jacobi);
299
300 // Propagate the photon energy scaling to jacobian elements that were calculated using energy.
301 TMatrixD scaledJacobi(4, 6);
302
303 int element = 0;
304
305 for (int irow = 0; irow < 4; irow++) {
306 for (int icol = 0; icol < 6; icol++) {
307 if (icol != 0 && irow != 3) {
308 scaledJacobi(irow, icol) = m_jacobiMatrix[element] * m_momentumScale;
309 } else {
310 scaledJacobi(irow, icol) = m_jacobiMatrix[element];
311 }
312 element++;
313 }
314 }
315
316 storeJacobiMatrix(scaledJacobi);
317
318 // Get covariance matrix of IP distribution.
319 const TMatrixDSym clustervertexcovmat = C.GetIPPositionCovarianceMatrix();
320
321 // Set error matrix.
322 TMatrixDSym clustercovmat = C.GetCovarianceMatrix7x7FromCluster(cluster, clustervertexcovmat, scaledJacobi);
323 storeErrorMatrix(clustercovmat);
324}
const TMatrixDSym GetCovarianceMatrix7x7FromCluster(const ECLCluster *cluster, const TMatrixD &jacobiMatrix)
Returns 7x7 covariance matrix (px, py, pz, E, x, y, z)
const TMatrixD GetJacobiMatrix4x6FromCluster(const ECLCluster *cluster, ECLCluster::EHypothesisBit hypo)
Returns 4x6 Jacobi matrix (px, py, pz, E)
Definition: ClusterUtils.cc:54
const TMatrixDSym GetIPPositionCovarianceMatrix()
Returns default IP position covariance matrix from beam parameters.

◆ updateMass()

void updateMass ( const int  pdgCode)

Updates particle mass with the mass of the particle corresponding to the given PDG.

Parameters
pdgCodePDG code of the particle with the desired mass

Definition at line 628 of file Particle.cc.

629{
630 if (TDatabasePDG::Instance()->GetParticle(pdgCode) == nullptr)
631 B2FATAL("PDG=" << pdgCode << " ***code unknown to TDatabasePDG");
632 m_mass = TDatabasePDG::Instance()->GetParticle(pdgCode)->Mass() ;
633}

◆ updateMomentum()

void updateMomentum ( const ROOT::Math::PxPyPzEVector &  p4,
const ROOT::Math::XYZVector &  vertex,
const TMatrixFSym &  errMatrix,
double  pValue 
)
inline

Sets Lorentz vector, position, 7x7 error matrix and p-value.

Parameters
p4Lorentz vector
vertexpoint (position or vertex)
errMatrix7x7 momentum and vertex error matrix (order: px,py,pz,E,x,y,z)
pValuechi^2 probability of the fit

Definition at line 397 of file Particle.h.

401 {
402 set4Vector(p4);
403 setVertex(vertex);
405 m_pValue = pValue;
406 }
void setMomentumVertexErrorMatrix(const TMatrixFSym &errMatrix)
Sets 7x7 error matrix.
Definition: Particle.cc:424

◆ wasExactFitHypothesisUsed()

bool wasExactFitHypothesisUsed ( ) const
inline

Returns true if the type represented by this Particle object was used use as a mass hypothesis during the track of this Particle's parameters.

Definition at line 1003 of file Particle.h.

1004 {
1005 return std::abs(m_pdgCodeUsedForFit) == std::abs(m_pdgCode);
1006 }

◆ writeExtraInfo()

void writeExtraInfo ( const std::string &  name,
const double  value 
)

Sets the user defined extraInfo.

Adds it if necessary, overwrites existing ones if they share the same name.

Definition at line 1393 of file Particle.cc.

1394{
1395 if (this->hasExtraInfo(name)) {
1396 this->setExtraInfo(name, value);
1397 } else {
1398 this->addExtraInfo(name, value);
1399 }
1400}
void setExtraInfo(const std::string &name, double value)
Sets the user-defined data of given name to the given value.
Definition: Particle.cc:1402
void addExtraInfo(const std::string &name, double value)
Sets the user-defined data of given name to the given value.
Definition: Particle.cc:1421

Friends And Related Function Documentation

◆ ParticleSubset

friend class ParticleSubset
friend

Definition at line 1200 of file Particle.h.

Member Data Documentation

◆ m_arrayPointer

TClonesArray* m_arrayPointer
mutableprivate

Internal pointer to DataStore array containing the daughters of this particle.

This is a transient member and will not be written to file. The pointer is set by getArrayPointer() when first called.

Definition at line 1129 of file Particle.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_daughterIndices

std::vector<int> m_daughterIndices
private

daughter particle indices

Definition at line 1098 of file Particle.h.

◆ m_daughterProperties

std::vector<int> m_daughterProperties
private

daughter particle properties

Definition at line 1104 of file Particle.h.

◆ m_energyLossCorrection

double m_energyLossCorrection = 0.0
private

energy loss correction.

defined as 'm_energyLossCorrection = E_measured - E_true'

Definition at line 1091 of file Particle.h.

◆ m_errMatrix

double m_errMatrix[c_SizeMatrix] = {}
private

error matrix (1D representation)

Definition at line 1095 of file Particle.h.

◆ m_extraInfo

std::vector<double> m_extraInfo
private

Stores associated user defined values.

Order is given by string -> index mapping in ParticleExtraInfoMap. entry 0 is reserved specifies which map to use.

Definition at line 1120 of file Particle.h.

◆ m_flavorType

EFlavorType m_flavorType
private

flavor type.

Definition at line 1099 of file Particle.h.

◆ m_identifier

int m_identifier = -1
private

Identifier that can be used to identify whether the particle is unique or is a copy or representation of another.

For example a kaon and pion particles constructed from the same Track are representations of the same physical object in the detector and cannot be used in the reconstruction of the same decay chain

Definition at line 1113 of file Particle.h.

◆ m_jacobiMatrix

double m_jacobiMatrix[c_SizeMatrix] = {}
private

error matrix (1D representation)

Definition at line 1096 of file Particle.h.

◆ m_mass

double m_mass
private

particle (invariant) mass

Definition at line 1084 of file Particle.h.

◆ m_mdstIndex

unsigned m_mdstIndex
private

0-based index of MDST store array object

Definition at line 1101 of file Particle.h.

◆ m_momentumScale

double m_momentumScale = 1.0
private

effective momentum scale factor

Definition at line 1088 of file Particle.h.

◆ m_momentumScalingFactor

double m_momentumScalingFactor = 1.0
private

momentum scaling factor

Definition at line 1089 of file Particle.h.

◆ m_momentumSmearingFactor

double m_momentumSmearingFactor = 1.0
private

momentum smearing factor

Definition at line 1090 of file Particle.h.

◆ m_particleSource

EParticleSourceObject m_particleSource
private

(mdst) source of particle

Definition at line 1100 of file Particle.h.

◆ m_pdgCode

int m_pdgCode
private

PDG code.

Definition at line 1082 of file Particle.h.

◆ m_pdgCodeUsedForFit

int m_pdgCodeUsedForFit = 0
private

PDG code used for the track fit.

Definition at line 1083 of file Particle.h.

◆ m_properties

int m_properties
private

particle property

Definition at line 1103 of file Particle.h.

◆ m_pValue

double m_pValue
private

chi^2 probability of the fit.

Default is nan

Definition at line 1097 of file Particle.h.

◆ m_px

double m_px
private

momentum component x

Definition at line 1085 of file Particle.h.

◆ m_py

double m_py
private

momentum component y

Definition at line 1086 of file Particle.h.

◆ m_pz

double m_pz
private

momentum component z

Definition at line 1087 of file Particle.h.

◆ m_trackFitResultIndex

unsigned m_trackFitResultIndex
private

0-based index of related TrackFitResult, relevant for kinks

Definition at line 1102 of file Particle.h.

◆ m_x

double m_x
private

position component x

Definition at line 1092 of file Particle.h.

◆ m_y

double m_y
private

position component y

Definition at line 1093 of file Particle.h.

◆ m_z

double m_z
private

position component z

Definition at line 1094 of file Particle.h.


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