236{
237
238
241
242
244
245
247
248
250
251
258
262
264
266 ion->Ncoll_hard=static_cast<int>(jatt);
267 ion->Npart_proj=
static_cast<int>(
np);
268 ion->Npart_targ=
static_cast<int>(
nt);
269 ion->Ncoll=static_cast<int>(n0+n10+n01+n11);
270 ion->N_Nwounded_collisions=static_cast<int>(n01);
271 ion->Nwounded_N_collisions=static_cast<int>(n10);
272 ion->Nwounded_Nwounded_collisions=static_cast<int>(n11);
273 ion->spectator_neutrons=-1;
274 ion->spectator_protons=-1;
275 ion->impact_parameter=
b;
276 ion->event_plane_angle=bphi;
277 ion->sigma_inel_NN=sigmainel;
278 evt->set_heavy_ion(std::move(ion));
279
280
281
282 bool keptHistory = (
m_hiparnt.ihpr2(21) == 1);
283
284
285
287
288
289
290 std::vector<int> partOriginVertex_vec(numHijingPart, 0);
291 std::vector<int> partDecayVertex_vec(numHijingPart, -1);
292 std::vector<HepMC::GenParticlePtr> particleHepPartPtr_vec(numHijingPart, nullptr);
293
294
295
296 std::vector<HepMC::GenVertexPtr> vertexPtrVec;
297
298
299
300 CLHEP::HepLorentzVector newVertex;
301 newVertex = CLHEP::HepLorentzVector(0.,0.,0.,0.);
302
304 else if(
m_sel) newVertex = CLHEP::HepLorentzVector(
m_x,
m_y,
m_z, 0.);
305
307
309 vertexPtrVec.push_back(v1);
310
312 if (
m_frame ==
"CMS " ) eproj = eproj / 2.;
313
314 int proj_id = 2212;
315 if (
m_proj ==
"PBAR " ) {
316 proj_id = -2212;
317 }
else if (
m_proj ==
"N " ) {
318 proj_id = 2112;
319 }
else if (
m_proj ==
"NBAR " ) {
320 proj_id = -2112;
321 }
else if (
m_proj ==
"PI+ " ) {
322 proj_id = 211;
323 }
else if (
m_proj ==
"PI- " ) {
324 proj_id = -211;
325 }
else if (
m_proj ==
"A " ) {
326 proj_id = 3000000 +
m_iap;
327 }
329 v1->add_particle_in( part_p );
330
331 double etarg = 0.;
333
334 int targ_id = 2212;
335 if (
m_targ ==
"PBAR " ) {
336 targ_id = -2212;
337 }
else if (
m_targ ==
"N " ) {
338 targ_id = 2112;
339 }
else if (
m_targ ==
"NBAR " ) {
340 targ_id = -2112;
341 }
else if (
m_targ ==
"PI+ " ) {
342 targ_id = 211;
343 }
else if (
m_targ ==
"PI- " ) {
344 targ_id = -211;
345 }
else if (
m_targ ==
"A " ) {
346 targ_id = 3000000 +
m_iat;
347 }
349 v1->add_particle_in( part_t );
350
351 evt->set_beam_particles(std::move(part_p),std::move(part_t));
352
354 << " px, "
355 << " py, "
356 << " pz, "
357 << " Id, "
358 << " Source, "
359 << " Parent, "
360 << " Status, " );
361
362 bool inconsistency = false;
363
364
365
367 {
368
369
371
372
373
374 int parentIndex =
m_himain2.katt(i, 3) - 1;
375 int parentOriginIndex = 0;
376 int parentDecayIndex = -1;
377
378
379
380 if (parentIndex >= 0)
381 {
382 parentOriginIndex = partOriginVertex_vec[parentIndex];
383 parentDecayIndex = partDecayVertex_vec[parentIndex];
384 }
385
386
387
388
389
395 }
396
398 << std::setw(5) << i << ","
399 << std::setw(7) <<
m_himain2.patt(i, 1) <<
", "
400 << std::setw(7) <<
m_himain2.patt(i, 2) <<
", "
401 << std::setw(7) <<
m_himain2.patt(i, 3) <<
", "
402 << std::setw(7) <<
m_himain2.katt(i, 1) <<
", "
403 << std::setw(7) <<
m_himain2.katt(i, 2) <<
", "
404 << std::setw(7) <<
m_himain2.katt(i, 3) <<
", "
405 << std::setw(7) <<
m_himain2.katt(i, 4) <<
", "
406 << std::setw(7) <<
m_himain2.vatt(i, 1) <<
", "
407 << std::setw(7) <<
m_himain2.vatt(i, 2) <<
", "
408 << std::setw(7) <<
m_himain2.vatt(i, 3) );
409
412
413
414
415 int particleVertexIndex = 0;
416
417
418
419 if (keptHistory)
420 {
421
422
423
424 if (parentDecayIndex != -1)
425 {
426
427
428 HepGeom::Point3D<double> vertex_pos(vertexPtrVec[parentDecayIndex]->
position().
x(),
429 vertexPtrVec[parentDecayIndex]->
position().
y(),
430 vertexPtrVec[parentDecayIndex]->
position().
z());
431 double distance = vertex_pos.distance(particleStart.vect());
432
433
435 {
436
437
438 ATH_MSG_WARNING(
" Inconsistency in Hijing particle vertexing, particle # " << i
439 << " starting point (x,y,z) = ("
440 << particleStart.x() << ", "
441 << particleStart.y() << ", "
442 << particleStart.z() << ") "
443 << " a distance " << distance << " away from parent decay point " );
444
445
446
447
448 log << MSG::WARNING <<
" Parent decay vertex: (x,y,z) = " << vertexPtrVec[parentDecayIndex]->position().x()
449 << ", " << vertexPtrVec[parentDecayIndex]->position().y()
450 << ", " << vertexPtrVec[parentDecayIndex]->position().z()
451 << ", associated daughter IDs = ";
452
453 auto vertexPtrVec_particles_out_const_begin=vertexPtrVec[parentDecayIndex]->particles_out().begin();
454 auto vertexPtrVec_particles_out_const_end=vertexPtrVec[parentDecayIndex]->particles_out().end();
455 for (auto iter = vertexPtrVec_particles_out_const_begin;
456 iter != vertexPtrVec_particles_out_const_end;
458 {
459 log << (*iter) <<
", ";
460 }
461
463 inconsistency = true;
464 }
465
466
467
468 particleVertexIndex = parentDecayIndex;
469 }
470 else
471 {
472
473
474
475 HepGeom::Point3D<double> vertex_pos(vertexPtrVec[parentOriginIndex]->
position().
x(),
476 vertexPtrVec[parentOriginIndex]->
position().
y(),
477 vertexPtrVec[parentOriginIndex]->
position().
z());
478 double distance = vertex_pos.distance(particleStart.vect());
479
481 {
482
483
484
485
486 ATH_MSG_WARNING(
"HIJING BUG:: Particle found with displaced vertex but no parent " );
487 ATH_MSG_WARNING(
" Particle parameters: " << std::fixed << std::setprecision(2)
488 << std::setw(5) << i << ","
489 << std::setw(7) <<
m_himain2.patt(i, 1) <<
", "
490 << std::setw(7) <<
m_himain2.patt(i, 2) <<
", "
491 << std::setw(7) <<
m_himain2.patt(i, 3) <<
", "
492 << std::setw(7) <<
m_himain2.katt(i, 1) <<
", "
493 << std::setw(7) <<
m_himain2.katt(i, 2) <<
", "
494 << std::setw(7) <<
m_himain2.katt(i, 3) <<
", "
495 << std::setw(7) <<
m_himain2.katt(i, 4) <<
", "
496 << std::setw(7) <<
m_himain2.vatt(i, 1) <<
", "
497 << std::setw(7) <<
m_himain2.vatt(i, 2) <<
", "
498 << std::setw(7) <<
m_himain2.vatt(i, 3) );
499
500
501
502 particleVertexIndex = parentOriginIndex;
503
504 }
506 {
507
508
510 evt->add_vertex(newVertex_p);
511 vertexPtrVec.push_back(newVertex_p);
512 particleVertexIndex = vertexPtrVec.size() - 1;
513
514
515
516 partDecayVertex_vec[parentIndex] = particleVertexIndex;
517
518
519
520
521 newVertex_p->add_particle_in(particleHepPartPtr_vec[parentIndex]);
522 }
523 else {
524
525
526 particleVertexIndex = parentOriginIndex;
527 }
528 }
529 }
530 else
531 {
532
533
534 int foundVert = -1;
535 for (unsigned int ivert = 0; ivert < vertexPtrVec.size(); ivert++)
536 {
537
538 HepGeom::Point3D<double> vertex_pos(vertexPtrVec[ivert]->
position().
x(),
541 double distance = vertex_pos.distance(particleStart.vect());
543 {
544 foundVert = ivert;
545 break;
546 }
547 }
548
549 if (foundVert == -1)
550 {
551
552
554
555 evt->add_vertex(newVertex_p);
556 vertexPtrVec.push_back(std::move(newVertex_p));
557 particleVertexIndex = vertexPtrVec.size() - 1;
558 }
559 else
560 {
561 particleVertexIndex = foundVert;
562 }
563
564 }
565
566
567
569 int particleStatus = 1;
570 if (
m_himain2.katt(i, 4) == 11) particleStatus = 2;
571
572
573
578
580 particleStatus);
581
582
583
584
585
586 particleHepPartPtr_vec[
i-1] = newParticle_p;
587
588
589
590 vertexPtrVec[particleVertexIndex]->add_particle_out(std::move(newParticle_p));
591 partOriginVertex_vec[
i-1] = particleVertexIndex;
592
593 }
594
595 if (inconsistency)
596 {
598 {
599
600
602
603 ATH_MSG_WARNING(
" Hijing.cxx inconsistency: " << std::fixed << std::setprecision(2)
604
605 << std::setw(5) << i << ","
606 << std::setw(7) <<
m_himain2.patt(i, 1) <<
", "
607 << std::setw(7) <<
m_himain2.patt(i, 2) <<
", "
608 << std::setw(7) <<
m_himain2.patt(i, 3) <<
", "
609 << std::setw(7) <<
m_himain2.katt(i, 1) <<
", "
610 << std::setw(7) <<
m_himain2.katt(i, 2) <<
", "
611 << std::setw(7) <<
m_himain2.katt(i, 3) <<
", "
612 << std::setw(7) <<
m_himain2.katt(i, 4) <<
", "
613 << std::setw(7) <<
m_himain2.vatt(i, 1) <<
", "
614 << std::setw(7) <<
m_himain2.vatt(i, 2) <<
", "
615 << std::setw(7) <<
m_himain2.vatt(i, 3) );
616 }
617 }
618
619
620
621 for (
int isg = 1; isg <=
m_hijjet2.nsg(); isg++)
622 {
623 for (
int jparton = 1; jparton <=
m_hijjet2.njsg(isg); jparton++)
624 {
629
631 double e = std::sqrt(ptsq + pz*pz + mass*mass);
632 double mt = std::sqrt(ptsq + mass*mass);
633 double pt = std::sqrt(ptsq);
634
635 double pseud = 0.5*std::log((e + pz)/(e - pz));
636
637 int partonId =
m_hijjet2.k2sg(isg, jparton);
638
640 {
642 << ", pt = " << pt
643 << ", mt = " << mt
644 << ", eta = " << pseud );
645
646
647
649 }
650 }
651 }
652
653
654
657
658 for (int iproj = 1; iproj <= iap; iproj++)
659 {
660 for (
int jparton = 1; jparton <=
m_hijjet1.npj(iproj); jparton++)
661 {
666
668 double e = std::sqrt(ptsq + pz*pz + mass*mass);
669 double mt = std::sqrt(ptsq + mass*mass);
670 double pt = std::sqrt(ptsq);
671
672 double pseud = 0.5*std::log((e + pz)/(e - pz));
673
674 int partonId =
m_hijjet1.kfpj(iproj, jparton);
675
677 {
679 << ", pt = " << pt
680 << ", mt = " << mt
681 << ", eta = " << pseud );
682
683
684
686 }
687 }
688 }
689
690
691
692 for (int itarg = 1; itarg <= iat; itarg++)
693 {
694 for (
int jparton = 1; jparton <=
m_hijjet1.ntj(itarg); jparton++)
695 {
700
702 double e = std::sqrt(ptsq + pz*pz + mass*mass);
703 double mt = std::sqrt(ptsq + mass*mass);
704 double pt = std::sqrt(ptsq);
705
706 double pseud = 0.5*std::log((e + pz)/(e - pz));
707
708 int partonId =
m_hijjet1.kftj(itarg, jparton);
709
711 {
713 << ", pt = " << pt
714 << ", mt = " << mt
715 << ", eta = " << pseud );
716
717
718
720 }
721 }
722 }
723
724
725 evt->set_units(HepMC3::Units::MEV, HepMC3::Units::MM);
726
727
730 double ranz = CLHEP::RandFlat::shoot(p_Engine);
731
732 if (ranz < 0.5) {
733
734 for(auto pitr: *evt){
735 tmpmom= pitr->momentum();
736 tmpmom.setX(-tmpmom.x());
737 tmpmom.setY(-tmpmom.y());
738 tmpmom.setZ(-tmpmom.z());
739 tmpmom.setT(tmpmom.t());
740 pitr->set_momentum(tmpmom);
741 }
742 }
743 }
744
745
746 double totalCsc =
m_hiparnt.hint1(13) * Gaudi::Units::millibarn;
747 auto csc = std::make_shared<HepMC3::GenCrossSection>();
748 csc->set_cross_section(totalCsc/Gaudi::Units::picobarn, 0.0);
749 evt->set_cross_section(std::move(csc));
750
751 return StatusCode::SUCCESS;
752}
#define ATH_MSG_WARNING(x,...)
DoubleProperty m_vertexOffsetCut
DoubleProperty m_partonStoreMinPt
BooleanProperty m_keepAllDecayVertices
virtual CLHEP::HepLorentzVector randomizeVertex(CLHEP::HepRandomEngine *engine)
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
HepMC3::FourVector FourVector
HepMC3::GenHeavyIonPtr GenHeavyIonPtr
void set_signal_process_vertex(GenEvent *e, T &v)
void set_signal_process_id(GenEvent *e, const int i=0)
void set_random_states(GenEvent *e, std::vector< long int > &a)
GenParticlePtr newGenParticlePtr(const HepMC3::FourVector &mom=HepMC3::FourVector::ZERO_VECTOR(), int pid=0, int status=0)
HepMC3::GenParticlePtr GenParticlePtr
GenVertexPtr newGenVertexPtr(const HepMC3::FourVector &pos=HepMC3::FourVector::ZERO_VECTOR(), const int i=0)
HepMC3::GenVertexPtr GenVertexPtr
const Amg::Vector3D & position() const
Method to retrieve the position of the Intersection.