 |
Belle II Software
release-05-02-19
|
1 #include "PhotosHEPEVTParticle.h"
9 for (
unsigned int i = 0; i <
cache.size(); i++)
15 int me,
int ds,
int de)
38 if (!
m_event)
Log::Fatal(
"PhotosHEPEVTParticle::addDaughter - particle not in event record");
40 std::vector<PhotosParticle*> mothers = daughter->getMothers();
44 daughter->setMothers(mothers);
46 int bc = daughter->getBarcode();
48 if (m_daughter_end < 0) {
53 else if (m_daughter_end != bc - 1) {
57 for (
int i = bc - 1; i > m_daughter_end; i--) {
70 int m = check->getDaughterRangeEnd();
71 if (m != -1 && m > m_daughter_end) {
72 check->setDaughterRangeEnd(m + 1);
73 check->setDaughterRangeStart(check->getDaughterRangeStart() + 1);
81 int m1 = check->m_first_mother;
82 int m2 = check->m_second_mother;
84 if (m1 > m_daughter_end) {
85 ++check->m_first_mother;
87 if (m2 > m_daughter_end) {
88 ++check->m_second_mother;
92 }
else m_daughter_end = bc;
100 if (
m_barcode < 0 && mothers.size() > 0) {
102 evt->addParticle(
this);
105 if (mothers.size() > 2)
Log::Fatal(
"PhotosHEPEVTParticle::setMothers: HEPEVT does not allow more than two mothers!");
108 if (mothers.size() > 1) m_second_mother = mothers[1]->
getBarcode();
115 if (
m_event == NULL)
Log::Fatal(
"PhotosHEPEVTParticle::setDaughters: particle not inside event record.");
117 int beg = 65535, end = -1;
119 for (
unsigned int i = 0; i < daughters.size(); i++) {
120 int bc = daughters[i]->getBarcode();
121 if (bc < 0)
Log::Fatal(
"PhotosHEPEVTParticle::setDaughters: all daughters has to be in event record first");
122 if (bc < beg) beg = bc;
123 if (bc > end) end = bc;
125 if (end == -1) beg = -1;
128 m_daughter_end = end;
134 std::vector<PhotosParticle*> mothers;
145 if (p1) mothers.push_back(p1);
146 if (p2) mothers.push_back(p2);
156 std::vector<PhotosParticle*> daughters;
158 if (!
m_event)
return daughters;
162 if (m_daughter_end < 0) {
163 int min_d = 65535, max_d = -1;
166 if (i < min_d) min_d = i;
167 if (i > max_d) max_d = i;
172 m_daughter_end = max_d;
179 if (m_daughter_end >= 0) {
183 Log::Warning() <<
"PhotosHEPEVTParticle::getDaughters(): No particle with index " << i << endl;
187 daughters.push_back(p);
196 std::vector<PhotosParticle*> list;
201 std::vector<PhotosParticle*> daughters =
getDaughters();
204 list.insert(list.end(), daughters.begin(), daughters.end());
212 for (
unsigned int i = 0; i < list.size(); i++) {
213 std::vector<PhotosParticle*> daughters2 = list[i]->getDaughters();
216 for (
unsigned int j = 0; j < daughters2.size(); j++) {
218 for (
unsigned int k = 0; k < list.size(); k++)
224 if (add) list.push_back(daughters2[j]);
235 if (m_daughter_end < 0)
return true;
242 double px = 0.0, py = 0.0, pz = 0.0, e = 0.0;
243 double px2 = 0.0, py2 = 0.0, pz2 = 0.0, e2 = 0.0;
253 if (first_mother_idx >= 0) {
261 if (second_mother_idx >= 0) {
269 double dp = sqrt((px - px2) * (px - px2) + (py - py2) * (py - py2) + (pz - pz2) * (pz - pz2));
271 double m1 = sqrt(fabs(e * e - px * px - py * py - pz * pz));
272 double m2 = sqrt(fabs(e2 * e2 - px2 * px2 - py2 * py2 - pz2 * pz2));
274 if (fabs(m1 - m2) > 0.0001 || dp > 0.0001 * (e + e2)) {
278 cout <<
" TO: " << endl;
288 int pdg_id,
int status,
double mass,
289 double px,
double py,
double pz,
double e)
295 cache.push_back(
new PhotosHEPEVTParticle(pdg_id, status, px, py, pz, e, mass, -1, -1, -1, -1));
301 Log::Warning() <<
"PhotosParticle::createHistoryEntry() not implemented for HEPEVT." << endl;
306 Log::Warning() <<
"PhotosHEPEVTParticle::createSelfDecayVertex() not implemented for HEPEVT." << endl;
311 int bc = p->getBarcode();
319 int bc = p->getBarcode();
328 sprintf(buf,
"P: (%2i) %6i %2i | %11.4e %11.4e %11.4e %11.4e | %11.4e | M: %2i %2i | D: %2i %2i\n",
430 return m_second_mother;
440 return m_daughter_end;
~PhotosHEPEVTParticle()
Default destructor.
void setMass(double mass)
Set the mass of this particle.
std::vector< PhotosParticle * > getMothers()
Returns the mothers of this particle via a vector of PhotosParticle.
void setEvent(PhotosHEPEVTEvent *event)
Set event of this particle.
std::vector< PhotosParticle * > getAllDecayProducts()
Returns all particles in the decay tree of this particle via a vector of PhotosParticle.
int getPdgID()
Get the PDG ID code of this particle.
void setDaughters(std::vector< PhotosParticle * > daughters)
Set the daughters of this particle via a vector of PhotosParticle.
void setPdgID(int pdg_id)
Set the PDG ID code of this particle.
void setPz(double pz)
Set the pz component of the four vector.
int m_status
Status (stable, decayed)
PhotosHEPEVTParticle * getParticle(int i)
Get particle at index 'i'.
int getFirstMotherIndex()
Get index of first mother.
PhotosHEPEVTEvent * m_event
Event from which this particle is taken.
void setStatus(int statu)
Set the status of this particle.
bool isMotherOf(PhotosHEPEVTParticle *p)
Check if particle 'p' is mother of this particle.
static void RedirectOutput(void(*func)(), ostream &where= *out)
Redirects output to log.
void createSelfDecayVertex(PhotosParticle *out)
Create a self-decay vertex for this particle with 'out' being the outgoing particle in new vertex.
int getBarcode()
Get the barcode (position in list) of this particle.
bool checkMomentumConservation()
Check that the 4 momentum in conserved in the decay of this particle.
int getParticleCount()
Get higher-most index of the particles in event (nhep)
int m_first_mother
Indexes of mothers (-1 if do not have mothers)
void addDaughter(PhotosParticle *daughter)
Add a new daughter to this particle.
int getSecondMotherIndex()
Get index of second mother.
void print()
Print information on this particle into standard output.
vector< PhotosHEPEVTParticle * > cache
List of created particles - if they are not in the event, they will be deleted when no longer needed.
double getPz()
Returns the pz component of the four vector.
double getPx()
Returns the px component of the four vector.
int getStatus()
Get the status of this particle.
double m_generated_mass
Mass saved at generation step.
bool isDaughterOf(PhotosHEPEVTParticle *p)
Check if particle 'p' is daughter of this particle.
void createHistoryEntry()
Creating history entries not implemented in HEPEVT.
PhotosHEPEVTParticle(int pdgid, int status, double px, double py, double pz, double e, double m, int ms, int me, int ds, int de)
Default constructor.
double getMass()
Get the mass stored (i.e.
void setMothers(std::vector< PhotosParticle * > mothers)
Set the mothers of this particle via a vector of PhotosParticle.
static void RevertOutput()
WARNING! If You're redirecting more than one function, do not forget to use RevertOutput() afterwards...
void setPx(double px)
Set the px component of the four vector.
double getE()
Returns the energy component of the four vector.
double getPy()
Returns the py component of the four vector.
std::vector< PhotosParticle * > getDaughters()
Returns the daughters of this particle via a vector of PhotosParticle.
PhotosHEPEVTParticle * createNewParticle(int pdg_id, int status, double mass, double px, double py, double pz, double e)
Creates a new particle of type PhotosHEPEVTParticle, with the given properties.
void setBarcode(int barcode)
Set barcode (position in list) of this particle.
int getDaughterRangeStart()
Get index of first daughter.
bool hasDaughters()
Return whether the particle has any chidren.
void setParticle(int i, PhotosHEPEVTParticle *p)
Set particle at index 'i'.
static void Fatal(string text, unsigned short int code=0)
Terminates the program with added default message or 'text'.
void setE(double e)
Set the energy component of the four vector.
int getDaughterRangeEnd()
Get index of last daughter.
void setPy(double py)
Set the px component of the four vector.
int m_barcode
Position in the event record.
int m_daughter_start
Range of indexes of daughters (-1 if do not have daughters)