1 #include "PhotosHEPEVTParticle.h"
10 for(
unsigned int i=0;i<
cache.size();i++)
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){
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)
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)
81 else m_daughter_end = bc;
94 if(mothers.size()>2)
Log::Fatal(
"PhotosHEPEVTParticle::setMothers: HEPEVT does not allow more than two mothers!");
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;
117 m_daughter_end = end;
122 std::vector<PhotosParticle*> mothers;
133 if(p1) mothers.push_back(p1);
134 if(p2) mothers.push_back(p2);
143 std::vector<PhotosParticle*> 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;
163 m_daughter_end = max_d;
170 if(m_daughter_end>=0)
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]);
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;
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))
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;
326 sprintf(buf,
"P: (%2i) %6i %2i | %11.4e %11.4e %11.4e %11.4e | %11.4e | M: %2i %2i | D: %2i %2i\n",
409 return m_second_mother;
417 return m_daughter_end;
void setStatus(int statu)
void setBarcode(int barcode)
bool isDaughterOf(PhotosHEPEVTParticle *p)
vector< PhotosHEPEVTParticle * > cache
int getDaughterRangeStart()
void addDaughter(PhotosParticle *daughter)
bool isMotherOf(PhotosHEPEVTParticle *p)
static void RedirectOutput(void(*func)(), ostream &where=*out)
int getSecondMotherIndex()
PhotosHEPEVTParticle * getParticle(int i)
virtual int getBarcode()=0
static void Fatal(string text, unsigned short int code=0)
PhotosHEPEVTParticle * createNewParticle(int pdg_id, int status, double mass, double px, double py, double pz, double e)
void createHistoryEntry()
std::vector< PhotosParticle * > getMothers()
std::vector< PhotosParticle * > getDaughters()
void setDaughterRangeEnd(int i)
void setDaughterRangeStart(int i)
bool checkMomentumConservation()
static void RevertOutput()
void setParticle(int i, PhotosHEPEVTParticle *p)
void setEvent(PhotosHEPEVTEvent *event)
std::vector< PhotosParticle * > getAllDecayProducts()
int getDaughterRangeEnd()
void setDaughters(std::vector< PhotosParticle * > daughters)
void setMass(double mass)
virtual void setMothers(std::vector< PhotosParticle * > mothers)=0
void addParticle(PhotosHEPEVTParticle *p)
void setPdgID(int pdg_id)
void setMothers(std::vector< PhotosParticle * > mothers)
PhotosHEPEVTEvent * m_event
virtual std::vector< PhotosParticle * > getMothers()=0
void createSelfDecayVertex(PhotosParticle *out)
PhotosHEPEVTParticle(int pdgid, int status, double px, double py, double pz, double e, double m, int ms, int me, int ds, int de)
int getFirstMotherIndex()