3 #include "PhotosBranch.h"
4 #include "PhotosParticle.h"
5 #include "HEPEVT_struct.h"
11 vector<PhotosParticle*> HEPEVT_struct::m_particle_list;
12 int HEPEVT_struct::ME_channel = 0;
13 int HEPEVT_struct::decay_idx = 0;
15 void HEPEVT_struct::clear()
18 m_particle_list.clear();
46 int first_mother,
int last_mother,
47 int first_daughter,
int last_daughter)
53 Log::Warning() <<
"Index given to HEPEVT_struct::add_particle "
54 <<
"is too low (it must be > 0)." << endl;
57 m_particle_list.push_back(particle);
61 hep.nhep = hep.nhep + 1;
63 hep.isthep[i] = particle->getStatus();
64 hep.idhep[i] = particle->getPdgID();
66 hep.jmohep[i][0] = first_mother;
67 hep.jmohep[i][1] = last_mother;
69 hep.jdahep[i][0] = first_daughter;
70 hep.jdahep[i][1] = last_daughter;
72 hep.phep[i][0] = particle->getPx();
73 hep.phep[i][1] = particle->getPy();
74 hep.phep[i][2] = particle->getPz();
75 hep.phep[i][3] = particle->getE();
79 if (!Photos::massFrom4Vector) hep.phep[i][4] = particle->getMass();
80 else hep.phep[i][4] = particle->getVirtuality();
82 int pdgid = abs(particle->getPdgID());
85 if (Photos::forceMassList) {
86 for (
unsigned int j = 0; j < Photos::forceMassList->size(); j++) {
87 if (pdgid == abs(Photos::forceMassList->at(j)->first)) {
88 double mass = Photos::forceMassList->at(j)->second;
93 if (mass < 0.0) mass = particle->getMass();
94 hep.phep[i][4] = mass;
110 HEPEVT_struct::clear();
114 vector<PhotosParticle*> mothers = branch->
getMothers();
115 int nmothers = mothers.size();
120 if (decay_particle) decay_idx = nmothers + 1;
123 vector<PhotosParticle*> daughters = branch->
getDaughters();
124 int ndaughters = daughters.size();
126 for (
int i = 0; i < nmothers; i++) {
128 add_particle(idx++, mothers.at(i),
130 decay_idx, decay_idx);
132 add_particle(idx++, mothers.at(i),
134 nmothers + 1, nmothers + ndaughters);
138 add_particle(idx++, decay_particle,
140 nmothers + 2, nmothers + 1 + ndaughters);
142 for (
int i = 0; i < ndaughters; i++) {
144 add_particle(idx++, daughters.at(i),
145 decay_idx, decay_idx,
148 add_particle(idx++, daughters.at(i),
153 Log::Debug(1000,
false) <<
"HEPEVT_struct returning: " << ((decay_idx) ? decay_idx : 1) <<
" from " << idx - 1 <<
" particles." <<
155 return (decay_idx) ? decay_idx : 1;
158 void HEPEVT_struct::get()
164 if (hep.nhep == (
int) m_particle_list.size())
170 int first_new = (int) m_particle_list.size();
172 int particle_count = m_particle_list.size();
173 int daughters_start = hep.jmohep[first_new][0];
174 int new_particles = hep.nhep - m_particle_list.size();
175 bool isParticleCreated = (new_particles > 0);
177 std::vector<PhotosParticle*> new_particles_list;
190 if (hep.jmohep[first_new][1] > 0)
191 daughters_start = hep.jmohep[first_new][1];
193 index = particle_count;
196 for (; new_particles > 0; new_particles--, index++) {
215 PhotosParticle* mother = m_particle_list.at(hep.jmohep[index][0] - 1);
216 mother->addDaughter(new_particle);
219 new_particles_list.push_back(new_particle);
223 m_particle_list.push_back(new_particle);
229 bool special =
false;
233 if (isParticleCreated) {
234 std::vector<PhotosParticle*> daughters;
242 for (
int i = daughters_start; i < particle_count; i++) {
245 daughters.push_back(p);
251 if (daughters.size() == 0) special =
false;
255 for (
unsigned int i = 0; i < daughters.size(); i++) {
256 if (daughters[i]->getStatus() == 1) {
264 std::vector<PhotosParticle*> daughters2 = daughters[i]->getDaughters();
266 if (daughters2.size() != 1 ||
267 daughters2[0]->getPdgID() != daughters[i]->getPdgID()) {
274 double px1 = 0.0, py1 = 0.0, pz1 = 0.0, e1 = 0.0;
275 double px2 = 0.0, py2 = 0.0, pz2 = 0.0, e2 = 0.0;
279 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++) {
291 px2 += daughters[i]->getDaughters().at(0)->getPx();
292 py2 += daughters[i]->getDaughters().at(0)->getPy();
293 pz2 += daughters[i]->getDaughters().at(0)->getPz();
294 e2 += daughters[i]->getDaughters().at(0)->getE();
300 p1 = m_particle_list.at(0)->createNewParticle(0, -1, 0.0, px1, py1, pz1, e1);
301 p2 = m_particle_list.at(0)->createNewParticle(0, -2, 0.0, px2, py2, pz2, e2);
304 for (
unsigned int i = 0; i < new_particles_list.size(); i++) {
307 new_particles_list[i]->getPx(),
308 new_particles_list[i]->getPy(),
309 new_particles_list[i]->getPz(),
310 new_particles_list[i]->getE());
315 new_particles_list[i]->createSelfDecayVertex(boosted);
320 Log::Warning() <<
"Hidden interaction, all daughters self decay."
321 <<
"Potentially over simplified solution applied." << endl;
329 for (index = daughters_start; index < particle_count && index < (int) m_particle_list.size(); index++) {
333 if (hep.idhep[index] != particle->getPdgID())
334 Log::Fatal(
"HEPEVT_struct::get(): Something is wrong with the HEPEVT struct", 5);
337 if (isParticleCreated && Photos::isCreateHistoryEntries) {
338 particle->createHistoryEntry();
345 double threshold = NO_BOOST_THRESHOLD * hep.phep[index][3];
346 if (fabs(hep.phep[index][0] - particle->getPx()) > threshold ||
347 fabs(hep.phep[index][1] - particle->getPy()) > threshold ||
348 fabs(hep.phep[index][2] - particle->getPz()) > threshold ||
349 fabs(hep.phep[index][3] - particle->getE()) > threshold) update =
true;
357 particle->boostDaughtersToRestFrame(particle);
360 particle->setPx(hep.phep[index][0]);
361 particle->setPy(hep.phep[index][1]);
362 particle->setPz(hep.phep[index][2]);
363 particle->setE(hep.phep[index][3]);
366 particle->boostDaughtersFromRestFrame(particle);
368 if (special && particle->getDaughters().size() > 0) {
380 particled->
setPx(particle->getPx());
381 particled->
setPy(particle->getPy());
382 particled->
setPz(particle->getPz());
383 particled->
setE(particle->getE());
403 void HEPEVT_struct::prepare()
408 void HEPEVT_struct::complete()
413 void HEPEVT_struct::check_ME_channel()
419 if (decay_idx == 2)
return;
420 if (hep.idhep[0]*hep.idhep[1] > 0)
return;
422 Log::Debug(900) <<
"ME_channel: Mothers PDG: " << hep.idhep[0] <<
" " << hep.idhep[1] << endl;
424 Log::Debug(900,
false) <<
" Intermediate: " << hep.idhep[decay_idx - 1] << endl;
426 int firstDaughter = 3;
427 if (decay_idx == 0) firstDaughter = 2;
430 int mother1 = abs(hep.idhep[0]);
431 int mother2 = abs(hep.idhep[1]);
432 if (mother1 < 1 || (mother1 > 6 && mother1 < 11) || mother1 > 16)
return;
433 if (mother2 < 1 || (mother2 > 6 && mother2 < 11) || mother2 > 16)
return;
441 for (
int i = firstDaughter; i < hep.nhep; i++) {
442 int pdg = abs(hep.idhep[i]);
443 if (pdg == 11 || pdg == 13 || pdg == 15) {
444 if (firstPDG == 0) firstPDG = hep.idhep[i];
446 secondPDG = hep.idhep[i];
448 if (firstPDG * secondPDG > 0) secondPDG = 0;
454 if (ME_channel == 0 && firstPDG != 0 && secondPDG != 0 &&
455 firstPDG == -secondPDG) ME_channel = 1;
461 for (
int i = firstDaughter; i < hep.nhep; i++) {
462 int pdg = abs(hep.idhep[i]);
463 if (pdg >= 11 && pdg <= 16) {
464 if (firstPDG == 0) firstPDG = hep.idhep[i];
466 secondPDG = hep.idhep[i];
468 if (firstPDG * secondPDG > 0) secondPDG = 0;
474 firstPDG = abs(firstPDG);
475 secondPDG = abs(secondPDG);
477 if (ME_channel == 0 && firstPDG != 0 && secondPDG != 0 &&
478 ((firstPDG == 11 && secondPDG == 12) || (firstPDG == 12 && secondPDG == 11) ||
479 (firstPDG == 13 && secondPDG == 14) || (firstPDG == 14 && secondPDG == 13) ||
480 (firstPDG == 15 && secondPDG == 16) || (firstPDG == 16 && secondPDG == 15)
484 Log::Debug(901) <<
"ME_channel: Found ME_channel: " << ME_channel << endl;
489 if (ME_channel > 0 && decay_idx) {
490 int pdg = hep.idhep[decay_idx - 1];
492 if (ME_channel == 1 && !(pdg == 22 || pdg == 23)) ME_channel = 0;
493 if (ME_channel == 2 && !(pdg == 24 || pdg == -24)) ME_channel = 0;
496 Log::Debug(901,
false) <<
" but set to 0: wrong intermediate particle: " << pdg << endl;
501 switch (ME_channel) {
503 case 1:
if (!Photos::meCorrectionWtForZ) ME_channel = 0;
break;
504 case 2:
if (!Photos::meCorrectionWtForW) ME_channel = 0;
break;
505 default: Log::Error() <<
"Unimplemented ME channel: " << ME_channel << endl;
break;
507 Log::Debug(902) <<
"ME_channel: Finally, after flag check, ME_channel is: " << ME_channel << endl;
PhotosParticle * getDecayingParticle()
Return decaying particle.
vector< PhotosParticle * > getMothers()
Get list of mothers.
vector< PhotosParticle * > getDaughters()
Get list of daughters.
virtual void setE(double e)=0
Set the energy component of the four vector.
void boostToRestFrame(PhotosParticle *boost)
Transform this particles four momentum from the lab frome into the rest frame of the paramter PhotosP...
virtual void setPy(double py)=0
Set the px component of the four vector.
virtual void setPx(double px)=0
Set the px component of the four vector.
virtual void setPz(double pz)=0
Set the pz component of the four vector.
virtual PhotosParticle * createNewParticle(int pdg_id, int status, double mass, double px, double py, double pz, double e)=0
Create a new particle of the same type, with the given properties.
void boostDaughtersFromRestFrame(PhotosParticle *boost)
Transform this particles four momentum from the lab frame to the rest frame of the parameter PhotosPa...
void boostFromRestFrame(PhotosParticle *boost)
Transform this particles four momentum from the rest frame of the paramter PhotosParticle,...
void boostDaughtersToRestFrame(PhotosParticle *boost)
Transform the four momentum of all the daughters recursively into the frame of the "particle" PhotosP...