255{
257
258
260 double E = sqrt(p*p + m*m);
261
262
263 double multiplicity_max = 0.25 *
E/1000. + 18.;
264
265
266 double randx , randy,
arg = 0.;
267
270
271 if (E > 15000.) {
274 } else {
277 }
278
279 for (;;) {
282 arg =
exp(-0.5*( (randx-p1)/p2 +
exp(-(randx-p1)/p2) ) );
283 if (randy < arg && randx>3 && randx<multiplicity_max) break;
284 }
285
286 randx *= (1.2-0.4*
exp(-0.001*p));
287
288 int Npart = (
int)randx;
289
290
291 if (Npart < 3) {
292 ATH_MSG_VERBOSE(
"[ had ] Number of particles smaller than 3, parameterisation not valid."
293 << " Doing Nothing");
294 return chDef;
295 }
296
298 << " with " << Npart << " outgoing particles " );
299
300
301
302
303 ATH_MSG_DEBUG(
"[ had ] create hadronic shower for particle with PDG ID "
304 <<
parent->pdgCode() <<
" and barcode "
306
307
308
309
310
322
324 }
325
327 << E << " | " << m << " | " << p << " | " );
328
331 ATH_MSG_VERBOSE(
"[ had ] interaction initiated by a secondary particle, no children saved " );
332 return chDef;
333 }
334
335 int gen_part = 0;
336
337
338
339 double chargedist = 0.;
340 std::vector<double>
charge(Npart);
341 std::vector<Trk::ParticleHypothesis> childType(Npart);
342 std::vector<double> newm(Npart);
343 std::vector<int> pdgid(Npart);
344
345
346
347
348
349
350
351 double pif = 0.10;
352 double nef = 0.30;
353 double prf = 0.30;
354
356 pif = 0.15;
357 nef = 0.25;
358 prf = 0.25;
359 }
361 pif = 0.06;
362 nef = 0.25;
363 prf = 0.35;
364 }
366 pif = 0.03;
367 nef = 0.35;
368 prf = 0.17;
369 }
370
371 for (
int i=0;
i<Npart;
i++) {
373 if (chargedist<pif) {
378 continue;
379 }
380 if ( chargedist<2*pif) {
385 continue;
386 }
387 if (chargedist<3*pif) {
392 continue;
393 }
394 if (chargedist<3*pif+nef) {
399 continue;
400 }
401 if (chargedist<3*pif+nef+prf) {
406 continue;
407 }
412 }
413
414
415 if ( childType[0] != particle ) {
416 for (
int i=1;
i<Npart;
i++) {
417 if (childType[i]==particle) {
418 childType[
i]=childType[0];
425 break;
426 }
427 }
428 }
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449 std::vector<double>
mom(Npart);
450 std::vector<double>
th(Npart);
451 std::vector<double> ph(Npart);
452
453
454 double eps = 2./Npart;
459
460
461
462
464 double ptot =
mom[0];
465
467 for (
int i=1;
i<Npart-2;
i++) {
469
471 if (ptemp.mag()<1-ptot) {
472 while ( fabs(ptemp.mag()-mom[i])>1-ptot-mom[i] ){
474 }
475 }
476
477 double p_rem=1-ptot-
mom[
i];
478 double cthmax = fmin(1.,(-ptemp.mag()*ptemp.mag()-mom[i]*mom[i]+p_rem*p_rem)/2/ptemp.mag()/mom[i]);
479
484 HepGeom::Vector3D<double> dnewHep = HepGeom::RotateZ3D(ptemp.phi())*HepGeom::RotateY3D(ptemp.theta())*
test;
488 ptemp +=
mom[
i]*dnew;
490 }
491
492 eps = 0.5;
494 mom[Npart-1] = 1-ptot-
mom[Npart-2];
495
496 if (ptemp.mag()<1-ptot) {
497 while (mom[Npart-1]+mom[Npart-2]<ptemp.mag()) {
499 mom[Npart-1] = 1-ptot-
mom[Npart-2];
500 }
501 }
502 if (ptemp.mag()<fabs(mom[Npart-1]-mom[Npart-2]) ) {
507 }
508 double cth =(-ptemp.mag()*ptemp.mag()-mom[Npart-2]*mom[Npart-2]+mom[Npart-1]*mom[Npart-1])/2/ptemp.mag()/
mom[Npart-2];
509 if (fabs(cth)>1.) cth = (cth>0.) ? 1. : -1.;
510
514 HepGeom::Vector3D<double> dnewHep = HepGeom::RotateZ3D(ptemp.phi())*HepGeom::RotateY3D(ptemp.theta())*
test;
516
517 th[Npart-2]=dnew.theta();
518 ph[Npart-2]=dnew.phi();
519 ptemp +=
mom[Npart-2]*dnew;
521 th[Npart-1]=dlast.theta();
522 ph[Npart-1]=dlast.phi();
523
524
525
526 double etot = 0.;
527 for (
int i=0;
i<Npart;
i++) etot += sqrt(mom[i]*mom[i]+newm[i]*newm[i]);
528 double summ = 0.;
529 for (
int i=0;
i<Npart;
i++) summ += newm[i];
530
531
532
533 float scale = sqrt(summ*summ+2*summ*p+m*m)/etot;
534 etot = 0.;
535 for (
int i=0;
i<Npart;
i++) {
537 etot += sqrt(mom[i]*mom[i]+newm[i]*newm[i]);
538 }
539
540
541 CLHEP::HepLorentzVector bv(p*particleDir.unit().x(),p*particleDir.unit().y(),p*particleDir.unit().z(),sqrt(etot*etot+p*p));
542 std::vector<CLHEP::HepLorentzVector> childBoost(Npart);
543
544
545
546
549
550 for (
int i=0;
i<Npart;
i++) {
552
554 in += childP;
555 CLHEP::HepLorentzVector newp(childP.x(),childP.y(),childP.z(),sqrt(mom[i]*mom[i]+newm[i]*newm[i]));
556 CLHEP::HepLorentzVector childPB = newp.boost(bv.boostVector());
557 childBoost[
i]=childPB;
559 }
560
561 double eout = 0.;
562
563
564
565
566
568 ISF::ISFParticleVector::iterator childrenIt =
children.begin();
569 unsigned short numChildren = 0;
570
571 for (
int i=0;
i<Npart;
i++) {
572 if (pdgid[i]<10000) {
575
576 eout += childBoost[
i].e();
577
578
588
594 }
595
597
599
600
603 ISF::ISFParticle *child = new ISF::ISFParticle ( vertex,
604 childP,
605 mass,
607 pdgid[i],
608 status,
609 time,
610 *parent,
611 id
612 );
613
615 ISF::ParticleUserInformation* validInfo = new ISF::ParticleUserInformation();
620 }
621
622 *childrenIt = child;
623 ++childrenIt; numChildren++;
624 }
625
626 gen_part++;
627 }
628 }
629
631 ISF::ISFTruthIncident truth( const_cast<ISF::ISFParticle&>(*parent),
632 children,
637
638
639 truth.updateChildParticleProperties();
640
641
645 delete nMom;
646 }
647
648
650
652
653 ATH_MSG_VERBOSE(
"[ had ] it was kinematically possible to create " << gen_part <<
" shower particles " );
654
656
657}
Scalar deltaPhi(const MatrixBase< Derived > &vec) const
Scalar phi() const
phi method
Scalar theta() const
theta method
#define ATH_MSG_VERBOSE(x)
double charge(const T &p)
#define MAXHADINTCHILDREN
void diff(const Jet &rJet1, const Jet &rJet2, std::map< std::string, double > varDiff)
Difference between jets - Non-Class function required by trigger.
constexpr int pow(int base, int exp) noexcept
void setUserInformation(ParticleUserInformation *userInfo)
void setGeneration(int gen)
void setProcess(int proc)
float m_hadIntChildEta[MAXHADINTCHILDREN]
nutple variable : hadronic interaction child eta
int m_hadIntChildPdg[MAXHADINTCHILDREN]
nutple variable : hadronic interaction child Pdg
float m_hadIntChildPcms[MAXHADINTCHILDREN]
nutple variable : hadronic interaction child Energy
float m_hadIntChildPhi[MAXHADINTCHILDREN]
nutple variable : hadronic interaction child phi
float m_hadIntChildDeltaEta[MAXHADINTCHILDREN]
nutple variable : hadronic interaction child delta eta
float m_hadIntChildDeltaPhi[MAXHADINTCHILDREN]
nutple variable : hadronic interaction child delta phi
float m_hadIntChildP[MAXHADINTCHILDREN]
nutple variable : hadronic interaction child Energy
float m_hadIntChildTh[MAXHADINTCHILDREN]
nutple variable : hadronic interaction child phi
float m_hadIntChildThc[MAXHADINTCHILDREN]
nutple variable : hadronic interaction child eta
Eigen::Matrix< double, 3, 1 > Vector3D
constexpr int UNDEFINED_ID
constexpr int SIM_STATUS_THRESHOLD
Constant definiting the status threshold for simulated particles, eg. can be used to separate generat...
int generations(const T &p)
Method to return how many interactions a particle has undergone during simulation (TODO migrate to be...
constexpr double neutronMassInMeV
the mass of the neutron (in MeV)
constexpr double mass[PARTICLEHYPOTHESES]
the array of masses
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses