1 #include "PhotosHEPEVTParticle.h"
10 for(
unsigned int i=0;i<cache.size();i++)
11 if(cache[i]->m_barcode<0)
15 PhotosHEPEVTParticle::PhotosHEPEVTParticle(
int pdgid,
int status,
double px,
double py,
double pz,
double e,
double m,
int ms,
int me,
int ds,
int de){
27 m_daughter_start = ds;
37 if(!m_event)
Log::Fatal(
"PhotosHEPEVTParticle::addDaughter - particle not in event record");
39 std::vector<PhotosParticle*> mothers = daughter->
getMothers();
47 if(m_daughter_end < 0)
49 m_daughter_start = bc;
53 else if(m_daughter_end != bc-1)
58 for(
int i=bc-1;i>m_daughter_end;i--)
70 for(
int i=0;i<m_daughter_end;i++)
74 if(m!=-1 && m>m_daughter_end)
76 check->setDaughterRangeEnd(m+1);
81 else m_daughter_end = bc;
88 if(m_barcode<0 && mothers.size()>0)
94 if(mothers.size()>2)
Log::Fatal(
"PhotosHEPEVTParticle::setMothers: HEPEVT does not allow more than two mothers!");
96 if(mothers.size()>0) m_first_mother = mothers[0]->
getBarcode();
97 if(mothers.size()>1) m_second_mother = mothers[1]->
getBarcode();
103 if(m_event==NULL)
Log::Fatal(
"PhotosHEPEVTParticle::setDaughters: particle not inside event record.");
105 int beg = 65535, end = -1;
107 for(
unsigned int i=0;i<daughters.size();i++)
109 int bc = daughters[i]->getBarcode();
110 if(bc<0)
Log::Fatal(
"PhotosHEPEVTParticle::setDaughters: all daughters has to be in event record first");
114 if(end == -1) beg = -1;
116 m_daughter_start = beg;
117 m_daughter_end = end;
122 std::vector<PhotosParticle*> mothers;
128 if(m_first_mother == m_second_mother) m_second_mother = -1;
130 if(m_first_mother>=0) p1 = m_event->
getParticle(m_first_mother);
131 if(m_second_mother>=0) p2 = m_event->
getParticle(m_second_mother);
133 if(p1) mothers.push_back(p1);
134 if(p2) mothers.push_back(p2);
143 std::vector<PhotosParticle*> daughters;
145 if(!m_event)
return daughters;
151 int min_d=65535, max_d=-1;
156 if(i<min_d) min_d = i;
157 if(i>max_d) max_d = i;
162 m_daughter_start = min_d;
163 m_daughter_end = max_d;
170 if(m_daughter_end>=0)
172 for(
int i=m_daughter_start;i<=m_daughter_end;i++)
177 Log::Warning()<<
"PhotosHEPEVTParticle::getDaughters(): No particle with index "<<i<<endl;
181 daughters.push_back(p);
190 std::vector<PhotosParticle*> list;
195 std::vector<PhotosParticle*> daughters =
getDaughters();
198 list.insert(list.end(),daughters.begin(),daughters.end());
206 for(
unsigned int i=0;i<list.size();i++)
208 std::vector<PhotosParticle*> daughters2 = list[i]->getDaughters();
211 for(
unsigned int j=0;j<daughters2.size();j++)
214 for(
unsigned int k=0;k<list.size();k++)
215 if( daughters2[j]->
getBarcode() == list[k]->getBarcode() )
221 if(add) list.push_back(daughters2[j]);
230 if(!m_event)
return true;
231 if(m_daughter_end < 0)
return true;
238 double px =0.0, py =0.0, pz =0.0, e =0.0;
239 double px2=0.0, py2=0.0, pz2=0.0, e2=0.0;
241 for(
int i=m_daughter_start;i<=m_daughter_end;i++)
250 if(first_mother_idx>=0)
259 if(second_mother_idx>=0)
268 double dp = sqrt( (px-px2)*(px-px2) + (py-py2)*(py-py2) + (pz-pz2)*(pz-pz2) );
270 double m1 = sqrt( fabs( e*e - px*px - py*py - pz*pz ) );
271 double m2 = sqrt( fabs( e2*e2 - px2*px2 - py2*py2 - pz2*pz2 ) );
273 if( fabs(m1-m2) > 0.0001 || dp > 0.0001*(e+e2))
279 for(
int i=m_daughter_start;i<=m_daughter_end;i++) m_event->
getParticle(i)->
print();
288 int pdg_id,
int status,
double mass,
289 double px,
double py,
double pz,
double e){
294 cache.push_back(
new PhotosHEPEVTParticle(pdg_id,status,px,py,pz,e,mass,-1,-1,-1,-1));
300 Log::Warning()<<
"PhotosParticle::createHistoryEntry() not implemented for HEPEVT."<<endl;
305 Log::Warning()<<
"PhotosHEPEVTParticle::createSelfDecayVertex() not implemented for HEPEVT."<<endl;
311 if(bc==m_first_mother || bc==m_second_mother)
return true;
319 if(bc>=m_daughter_start && bc<=m_daughter_end)
return true;
326 sprintf(buf,
"P: (%2i) %6i %2i | %11.4e %11.4e %11.4e %11.4e | %11.4e | M: %2i %2i | D: %2i %2i\n",
327 m_barcode, m_pdgid, m_status, m_px, m_py, m_pz, m_e, m_generated_mass,
328 m_first_mother, m_second_mother, m_daughter_start, m_daughter_end);
344 m_generated_mass = mass;
356 return m_generated_mass;
405 return m_first_mother;
409 return m_second_mother;
413 return m_daughter_start;
417 return m_daughter_end;
PhotosHEPEVTParticle * createNewParticle(int pdg_id, int status, double mass, double px, double py, double pz, double e)
int getDaughterRangeStart()
bool checkMomentumConservation()
void setEvent(PhotosHEPEVTEvent *event)
std::vector< PhotosParticle * > getMothers()
void setStatus(int statu)
PhotosHEPEVTParticle * getParticle(int i)
std::vector< PhotosParticle * > getAllDecayProducts()
int getFirstMotherIndex()
std::vector< PhotosParticle * > getDaughters()
bool isMotherOf(PhotosHEPEVTParticle *p)
virtual int getBarcode()=0
virtual void setMothers(std::vector< PhotosParticle * > mothers)=0
void createHistoryEntry()
void setDaughters(std::vector< PhotosParticle * > daughters)
int getDaughterRangeEnd()
int getSecondMotherIndex()
void setMass(double mass)
void setMothers(std::vector< PhotosParticle * > mothers)
PhotosHEPEVTParticle(int pdgid, int status, double px, double py, double pz, double e, double m, int ms, int me, int ds, int de)
static void Fatal(string text, unsigned short int code=0)
void setBarcode(int barcode)
bool isDaughterOf(PhotosHEPEVTParticle *p)
void createSelfDecayVertex(PhotosParticle *out)
virtual std::vector< PhotosParticle * > getMothers()=0
void setPdgID(int pdg_id)
void setParticle(int i, PhotosHEPEVTParticle *p)
static void RevertOutput()
void addDaughter(PhotosParticle *daughter)
void addParticle(PhotosHEPEVTParticle *p)
static void RedirectOutput(void(*func)(), ostream &where=*out)