Belle II Software development
TestParticleFactory Class Reference

This is a class, which generates DataStore particles, according to the provided decay string e.g. More...

#include <TestParticleFactory.h>

Public Member Functions

const Belle2::ParticleproduceParticle (const std::string &decayString, const ROOT::Math::PxPyPzEVector &momentum, const ROOT::Math::XYZVector &vertex)
 Main method to produce particles.
 
Belle2::Particle::EParticleSourceObject getType (const Belle2::DecayDescriptorParticle *particleDescription)
 Helper method to get EParticleSourceObject from PDG code.
 
const Belle2::ParticlecreateParticle (const Belle2::DecayDescriptor *particleDescriptor, const ROOT::Math::PxPyPzEVector &momentum, const ROOT::Math::XYZVector &vertex)
 This method is used for recursion.
 
const Belle2::ParticlecreatePhoton (const ROOT::Math::PxPyPzEVector &momentum)
 Creates different photons for tests.
 
const Belle2::ParticlecreateCharged (const Belle2::DecayDescriptor *particleDescriptor, const ROOT::Math::PxPyPzEVector &momentum, const ROOT::Math::XYZVector &vertex)
 Creates different charged particles for tests.
 

Private Attributes

int m_photonIndex
 Used to differentiate photons from one another.
 

Detailed Description

This is a class, which generates DataStore particles, according to the provided decay string e.g.

"^K_S0 -> ^pi+ ^pi-". All particles are added to Belle2::StoreArray<Belle2::Particle> It is primarily used in the ROE tests.

Definition at line 27 of file TestParticleFactory.h.

Constructor & Destructor Documentation

◆ TestParticleFactory()

TestParticleFactory ( )
inline

Definition at line 29 of file TestParticleFactory.h.

29: m_photonIndex(0) {};
int m_photonIndex
Used to differentiate photons from one another.

◆ ~TestParticleFactory()

~TestParticleFactory ( )
inline

Definition at line 30 of file TestParticleFactory.h.

30{};

Member Function Documentation

◆ createCharged()

const Belle2::Particle * createCharged ( const Belle2::DecayDescriptor particleDescriptor,
const ROOT::Math::PxPyPzEVector &  momentum,
const ROOT::Math::XYZVector &  vertex 
)
inline

Creates different charged particles for tests.

Definition at line 138 of file TestParticleFactory.h.

140 {
141 auto* particleDescription = particleDescriptor->getMother();
142 ROOT::Math::XYZVector tmomentum(momentum.X(), momentum.Y(), momentum.Z());
143 const float pValue = 0.5;
144 const float bField = 1.5;
145 TMatrixDSym cov6(6);
146 int chargefactor = (abs(particleDescription->getPDGCode()) == Belle2::Const::electron.getPDGCode()
147 || abs(particleDescription->getPDGCode()) == Belle2::Const::muon.getPDGCode()) ? -1 : 1;
148 const int charge = (particleDescription->getPDGCode()) / abs(particleDescription->getPDGCode()) * chargefactor;
149 unsigned long long int CDCValue = static_cast<unsigned long long int>(0x300000000000000);
152 myTrackFits.appendNew(vertex, tmomentum, cov6, charge, Belle2::Const::ChargedStable(abs(particleDescription->getPDGCode())), pValue,
153 bField,
154 CDCValue, 16777215, 0);
155 Belle2::Track mytrack;
157 mytrack.setTrackFitResultIndex(Belle2::Const::ChargedStable(abs(particleDescription->getPDGCode())), myTrackFits.getEntries() - 1);
158 Belle2::Track* savedTrack = myTracks.appendNew(mytrack);
159 Belle2::Particle* part = myParticles.appendNew(savedTrack, Belle2::Const::ChargedStable(abs(particleDescription->getPDGCode())));
160 B2INFO("\tParticle PDG: " << part->getPDGCode() << " charge: " << part->getCharge() << " charge: " << charge << " momentum: " <<
161 part->getMomentumMagnitude() << " index: " << part->getArrayIndex());
162 return part;
163 }
Provides a type-safe way to pass members of the chargedStableSet set.
Definition: Const.h:589
int getPDGCode() const
PDG code.
Definition: Const.h:473
static const ChargedStable muon
muon particle
Definition: Const.h:660
static const ChargedStable electron
electron particle
Definition: Const.h:659
const DecayDescriptorParticle * getMother() const
return mother.
Class to store reconstructed particles.
Definition: Particle.h:75
int getPDGCode(void) const
Returns PDG code.
Definition: Particle.h:454
double getCharge(void) const
Returns particle charge.
Definition: Particle.cc:622
double getMomentumMagnitude() const
Returns momentum magnitude.
Definition: Particle.h:569
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
T * appendNew()
Construct a new T object at the end of the array.
Definition: StoreArray.h:246
int getEntries() const
Get the number of objects in the array.
Definition: StoreArray.h:216
Class that bundles various TrackFitResults.
Definition: Track.h:25
void setTrackFitResultIndex(const Const::ChargedStable &chargedStable, short index)
Set an index (for positive values) or unavailability-code (index = -1) for a specific mass hypothesis...
Definition: Track.h:174
double charge(int pdgCode)
Returns electric charge of a particle with given pdg code.
Definition: EvtPDLUtil.cc:44

◆ createParticle()

const Belle2::Particle * createParticle ( const Belle2::DecayDescriptor particleDescriptor,
const ROOT::Math::PxPyPzEVector &  momentum,
const ROOT::Math::XYZVector &  vertex 
)
inline

This method is used for recursion.

Definition at line 81 of file TestParticleFactory.h.

83 {
84 Belle2::Particle::EParticleSourceObject type = getType(particleDescriptor->getMother());
85 if (type == Belle2::Particle::EParticleSourceObject::c_Track) {
86 return createCharged(particleDescriptor, momentum, vertex);
87 }
88 if (type == Belle2::Particle::EParticleSourceObject::c_ECLCluster) {
89 return createPhoton(momentum);
90 }
92 //Create composite particle:
93 auto* motherDescriptor = particleDescriptor->getMother();
94 B2INFO("Mother PDG: " << motherDescriptor->getPDGCode() << " selected: " << motherDescriptor->isSelected() << " name: " <<
95 motherDescriptor->getNameSimple());
96 unsigned int nDaughters = particleDescriptor->getNDaughters();
97 Belle2::Particle mother(momentum, motherDescriptor->getPDGCode());
98 for (unsigned int i = 0; i < nDaughters; i++) {
99 auto* daughter = particleDescriptor->getDaughter(i)->getMother();
100 B2INFO("\tDaughter PDG: " << daughter->getPDGCode() << " selected: " << daughter->isSelected() << " name: " <<
101 daughter->getNameSimple());
102 auto* daughterParticle = createParticle(particleDescriptor->getDaughter(i), momentum, vertex);
103 mother.appendDaughter(daughterParticle);
104 }
105 auto* result = myParticles.appendNew(mother);
106 return result;
107 };
const DecayDescriptor * getDaughter(int i) const
return i-th daughter (0 based index).
int getNDaughters() const
return number of direct daughters.
EParticleSourceObject
particle source enumerators
Definition: Particle.h:82
const Belle2::Particle * createPhoton(const ROOT::Math::PxPyPzEVector &momentum)
Creates different photons for tests.
Belle2::Particle::EParticleSourceObject getType(const Belle2::DecayDescriptorParticle *particleDescription)
Helper method to get EParticleSourceObject from PDG code.
const Belle2::Particle * createParticle(const Belle2::DecayDescriptor *particleDescriptor, const ROOT::Math::PxPyPzEVector &momentum, const ROOT::Math::XYZVector &vertex)
This method is used for recursion.
const Belle2::Particle * createCharged(const Belle2::DecayDescriptor *particleDescriptor, const ROOT::Math::PxPyPzEVector &momentum, const ROOT::Math::XYZVector &vertex)
Creates different charged particles for tests.

◆ createPhoton()

const Belle2::Particle * createPhoton ( const ROOT::Math::PxPyPzEVector &  momentum)
inline

Creates different photons for tests.

Definition at line 112 of file TestParticleFactory.h.

113 {
116 Belle2::ECLCluster myECL;
117 myECL.setIsTrack(false);
118 //TRandom3 generator;
120 myECL.setEnergy(momentum.E());
122 //This is necessary to avoid isCopyOf == true for Belle2::ECLClusters:
124 Belle2::ECLCluster* savedECL = myECLClusters.appendNew(myECL);
125
126 Belle2::Particle p(savedECL);
127 Belle2::Particle* part = myParticles.appendNew(p);
128 B2INFO("\tParticle PDG: " << part->getPDGCode() << " charge: " << part->getCharge() << " momentum: " <<
129 part->getMomentumMagnitude() << " index: " << part->getArrayIndex() << " eclindex: " << part->getECLCluster()->getArrayIndex()
130 << " theta: " << part->getECLCluster()->getTheta());
131 return part;
132 }
ECL cluster data.
Definition: ECLCluster.h:27
void setConnectedRegionId(int crid)
Set connected region id.
Definition: ECLCluster.h:142
void setClusterId(int clusterid)
Set cluster id.
Definition: ECLCluster.h:145
void setHypothesis(EHypothesisBit hypothesis)
Set hypotheses.
Definition: ECLCluster.h:123
void setEnergy(double energy)
Set Corrected Energy (GeV).
Definition: ECLCluster.h:226
double getTheta() const
Return Corrected Theta of Shower (radian).
Definition: ECLCluster.h:307
void setIsTrack(bool istrack)
Set m_isTrack true if the cluster matches with a track.
Definition: ECLCluster.h:104
@ c_nPhotons
CR is split into n photons (N1)
const ECLCluster * getECLCluster() const
Returns the pointer to the ECLCluster object that was used to create this Particle (if ParticleType =...
Definition: Particle.cc:891

◆ getType()

Belle2::Particle::EParticleSourceObject getType ( const Belle2::DecayDescriptorParticle particleDescription)
inline

Helper method to get EParticleSourceObject from PDG code.

Definition at line 64 of file TestParticleFactory.h.

65 {
66 int pdg = abs(particleDescription->getPDGCode());
67 if (pdg == Belle2::Const::pion.getPDGCode() || pdg == Belle2::Const::electron.getPDGCode()
68 || pdg == Belle2::Const::kaon.getPDGCode() || pdg == Belle2::Const::muon.getPDGCode()
69 || pdg == Belle2::Const::proton.getPDGCode()) {
70 return Belle2::Particle::EParticleSourceObject::c_Track;
71 }
72 if (pdg == Belle2::Const::photon.getPDGCode()) {
73 return Belle2::Particle::EParticleSourceObject::c_ECLCluster;
74 }
75 return Belle2::Particle::EParticleSourceObject::c_Composite;
76 }
static const ChargedStable pion
charged pion particle
Definition: Const.h:661
static const ChargedStable proton
proton particle
Definition: Const.h:663
static const ChargedStable kaon
charged kaon particle
Definition: Const.h:662
static const ParticleType photon
photon particle
Definition: Const.h:673
int getPDGCode() const
Return PDG code.

◆ produceParticle()

const Belle2::Particle * produceParticle ( const std::string &  decayString,
const ROOT::Math::PxPyPzEVector &  momentum,
const ROOT::Math::XYZVector &  vertex 
)
inline

Main method to produce particles.

For simplification, all particles are created with the same momentum and decay vertex. If for example "^K_S0 -> ^pi+ ^pi-" decay string is provided as an argument, the factory will produce two daughter pions with opposite charges first, and then these pions will be used to form mother K_S0 particle which will be returned. The decay string can have any complexity and all PDG codes of allowed and charges will be respected.

Definition at line 41 of file TestParticleFactory.h.

43 {
44 Belle2::DecayDescriptor* decaydescriptor = new Belle2::DecayDescriptor();
45 bool isString = decaydescriptor->init(decayString);
46 if (!isString) {
47 B2INFO("Decay string is not defined: " << decayString);
48 delete decaydescriptor;
49 return nullptr;
50 }
51 std::vector<std::string> strNames = decaydescriptor->getSelectionNames();
52 for (auto& name : strNames) {
53 B2INFO("Creation of particle: " << name);
54 }
55 // Recursive function
56 auto* result = createParticle(decaydescriptor, momentum, vertex);
57 delete decaydescriptor;
58 return result;
59 };
The DecayDescriptor stores information about a decay tree or parts of a decay tree.
bool init(const std::string &str)
Initialise the DecayDescriptor from given string.
std::vector< std::string > getSelectionNames()
Return list of human readable names of selected particles.

Member Data Documentation

◆ m_photonIndex

int m_photonIndex
private

Used to differentiate photons from one another.

Definition at line 166 of file TestParticleFactory.h.


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