3 #include "PhotosBranch.h"
4 #include "PhotosParticle.h"
5 #include "HEPEVT_struct.h"
12 vector<PhotosParticle*> HEPEVT_struct::m_particle_list;
13 int HEPEVT_struct::ME_channel=0;
14 int HEPEVT_struct::decay_idx=0;
16 void HEPEVT_struct::clear(){
18 m_particle_list.clear();
46 int first_mother,
int last_mother,
47 int first_daughter,
int last_daughter){
52 Log::Warning()<<
"Index given to HEPEVT_struct::add_particle "
53 <<
"is too low (it must be > 0)."<<endl;
56 m_particle_list.push_back(particle);
60 hep.nhep = hep.nhep + 1;
65 hep.jmohep[i][0]=first_mother;
66 hep.jmohep[i][1]=last_mother;
68 hep.jdahep[i][0]=first_daughter;
69 hep.jdahep[i][1]=last_daughter;
71 hep.phep[i][0]=particle->
getPx();
72 hep.phep[i][1]=particle->
getPy();
73 hep.phep[i][2]=particle->
getPz();
74 hep.phep[i][3]=particle->
getE();
78 if(!Photos::massFrom4Vector) hep.phep[i][4]=particle->
getMass();
81 int pdgid = abs(particle->
getPdgID());
84 if(Photos::forceMassList)
86 for(
unsigned int j=0;j<Photos::forceMassList->size();j++)
88 if(pdgid == abs(Photos::forceMassList->at(j)->first))
90 double mass = Photos::forceMassList->at(j)->second;
95 if(mass<0.0) mass = particle->
getMass();
96 hep.phep[i][4] = mass;
112 HEPEVT_struct::clear();
116 vector<PhotosParticle *> mothers = branch->
getMothers();
117 int nmothers=mothers.size();
122 if(decay_particle) decay_idx=nmothers+1;
125 vector<PhotosParticle *> daughters = branch->
getDaughters();
126 int ndaughters=daughters.size();
128 for(
int i=0;i<nmothers;i++)
131 add_particle(idx++,mothers.at(i),
133 decay_idx,decay_idx);
135 add_particle(idx++,mothers.at(i),
137 nmothers+1,nmothers+ndaughters);
141 add_particle(idx++,decay_particle,
143 nmothers+2,nmothers+1+ndaughters);
145 for(
int i=0;i<ndaughters;i++)
148 add_particle(idx++,daughters.at(i),
152 add_particle(idx++,daughters.at(i),
157 Log::Debug(1000,
false)<<
"HEPEVT_struct returning: "<<( (decay_idx) ? decay_idx : 1 )<<
" from "<<idx-1<<
" particles."<<endl;
158 return (decay_idx) ? decay_idx : 1;
161 void HEPEVT_struct::get(){
166 if(hep.nhep == (
int) m_particle_list.size())
171 int particle_count = m_particle_list.size();
172 int daughters_start = hep.jmohep[hep.nhep-1][0];
173 int new_particles = hep.nhep - m_particle_list.size();
174 bool isParticleCreated = (new_particles>0);
176 std::vector<PhotosParticle*> new_particles_list;
187 if(hep.jmohep[hep.nhep-1][1]>0)
188 daughters_start = hep.jmohep[hep.nhep-1][1];
190 index = particle_count;
193 for(;new_particles>0; new_particles--, index++){
212 PhotosParticle * mother = m_particle_list.at(hep.jmohep[index][0]-1);
216 new_particles_list.push_back(new_particle);
226 if( isParticleCreated )
228 std::vector<PhotosParticle*> daughters;
236 for(
int i=daughters_start;i<particle_count;i++)
240 daughters.push_back(p);
246 if(daughters.size()==0) special =
false;
250 for(
unsigned int i=0;i<daughters.size();i++)
252 if(daughters[i]->getStatus()==1)
261 std::vector<PhotosParticle*> daughters2 = daughters[i]->getDaughters();
263 if(daughters2.size()!=1 ||
264 daughters2[0]->getPdgID() != daughters[i]->getPdgID() )
273 double px1=0.0, py1=0.0, pz1=0.0, e1=0.0;
274 double px2=0.0, py2=0.0, pz2=0.0, e2=0.0;
278 for(
int i=0; i < particle_count-daughters_start; i++)
280 px1+=daughters[i]->getPx();
281 py1+=daughters[i]->getPy();
282 pz1+=daughters[i]->getPz();
283 e1 +=daughters[i]->getE();
288 for(
int i=0; i < particle_count-daughters_start; i++)
292 px2 += daughters[i]->getDaughters().at(0)->getPx();
293 py2 += daughters[i]->getDaughters().at(0)->getPy();
294 pz2 += daughters[i]->getDaughters().at(0)->getPz();
295 e2 += daughters[i]->getDaughters().at(0)->getE();
305 for(
unsigned int i=0;i<new_particles_list.size();i++)
309 new_particles_list[i]->getPx(),
310 new_particles_list[i]->getPy(),
311 new_particles_list[i]->getPz(),
312 new_particles_list[i]->getE() );
317 new_particles_list[i]->createSelfDecayVertex(boosted);
322 Log::Warning()<<
"Hidden interaction, all daughters self decay."
323 <<
"Potentially over simplified solution applied."<<endl;
331 for(index=daughters_start; index < particle_count && index < (int) m_particle_list.size(); index++){
335 if(hep.idhep[index]!=particle->
getPdgID())
336 Log::Fatal(
"HEPEVT_struct::get(): Something is wrong with the HEPEVT struct",5);
339 if(isParticleCreated && Photos::isCreateHistoryEntries)
348 double threshold = NO_BOOST_THRESHOLD*hep.phep[index][3];
349 if( fabs(hep.phep[index][0]-particle->
getPx()) > threshold ||
350 fabs(hep.phep[index][1]-particle->
getPy()) > threshold ||
351 fabs(hep.phep[index][2]-particle->
getPz()) > threshold ||
352 fabs(hep.phep[index][3]-particle->
getE()) > threshold ) update=
true;
364 particle->
setPx(hep.phep[index][0]);
365 particle->
setPy(hep.phep[index][1]);
366 particle->
setPz(hep.phep[index][2]);
367 particle->
setE(hep.phep[index][3]);
387 particled->
setE ( particle->
getE() );
407 void HEPEVT_struct::prepare()
412 void HEPEVT_struct::complete()
417 void HEPEVT_struct::check_ME_channel()
423 if(decay_idx==2)
return;
424 if(hep.idhep[0]*hep.idhep[1]>0)
return;
426 Log::Debug(900)<<
"ME_channel: Mothers PDG: "<<hep.idhep[0]<<
" "<<hep.idhep[1]<<endl;
428 Log::Debug(900,
false)<<
" Intermediate: "<<hep.idhep[decay_idx-1]<<endl;
431 if(decay_idx==0) firstDaughter=2;
434 int mother1 = abs(hep.idhep[0]);
435 int mother2 = abs(hep.idhep[1]);
436 if( mother1<1 || (mother1>6 && mother1<11) || mother1>16 )
return;
437 if( mother2<1 || (mother2>6 && mother2<11) || mother2>16 )
return;
445 for(
int i=firstDaughter; i<hep.nhep;i++)
447 int pdg = abs(hep.idhep[i]);
448 if(pdg==11 || pdg==13 || pdg==15)
450 if(firstPDG==0) firstPDG=hep.idhep[i];
453 secondPDG=hep.idhep[i];
455 if(firstPDG*secondPDG>0) secondPDG=0;
461 if( ME_channel==0 && firstPDG!=0 && secondPDG!=0 &&
462 firstPDG==-secondPDG ) ME_channel=1;
468 for(
int i=firstDaughter; i<hep.nhep;i++)
470 int pdg = abs(hep.idhep[i]);
471 if(pdg>=11 && pdg<=16)
473 if(firstPDG==0) firstPDG=hep.idhep[i];
476 secondPDG=hep.idhep[i];
478 if(firstPDG*secondPDG>0) secondPDG=0;
484 firstPDG =abs(firstPDG);
485 secondPDG=abs(secondPDG);
487 if( ME_channel==0 && firstPDG!=0 && secondPDG!=0 &&
488 ( ( firstPDG==11 && secondPDG==12 ) || (firstPDG == 12 && secondPDG == 11) ||
489 ( firstPDG==13 && secondPDG==14 ) || (firstPDG == 14 && secondPDG == 13) ||
490 ( firstPDG==15 && secondPDG==16 ) || (firstPDG == 16 && secondPDG == 15)
494 Log::Debug(901)<<
"ME_channel: Found ME_channel: "<<ME_channel<<endl;
499 if(ME_channel>0 && decay_idx)
501 int pdg=hep.idhep[decay_idx-1];
503 if(ME_channel==1 && !(pdg==22 || pdg==23) ) ME_channel=0;
504 if(ME_channel==2 && !(pdg==24 || pdg==-24)) ME_channel=0;
507 Log::Debug(901,
false)<<
" but set to 0: wrong intermediate particle: "<<pdg<<endl;
515 case 1:
if(!Photos::meCorrectionWtForZ) ME_channel=0;
break;
516 case 2:
if(!Photos::meCorrectionWtForW) ME_channel=0;
break;
517 default: Log::Error()<<
"Unimplemented ME channel: "<<ME_channel<<endl;
break;
519 Log::Debug(902)<<
"ME_channel: Finally, after flag check, ME_channel is: "<<ME_channel<<endl;
virtual void setPz(double pz)=0
void boostToRestFrame(PhotosParticle *boost)
void boostDaughtersFromRestFrame(PhotosParticle *boost)
vector< PhotosParticle * > getDaughters()
vector< PhotosParticle * > getMothers()
PhotosParticle * getDecayingParticle()
virtual PhotosParticle * createNewParticle(int pdg_id, int status, double mass, double px, double py, double pz, double e)=0
void boostDaughtersToRestFrame(PhotosParticle *boost)
virtual void setPx(double px)=0
virtual double getVirtuality()
virtual void setPy(double py)=0
void boostFromRestFrame(PhotosParticle *boost)
virtual void addDaughter(PhotosParticle *daughter)=0
virtual void setE(double e)=0
virtual int getStatus()=0
virtual void createHistoryEntry()=0
virtual std::vector< PhotosParticle * > getDaughters()=0
virtual double getMass()=0