9 #include <gsl/gsl_rng.h>
11 #include <HepMC/GenEvent.h>
12 #include <HepMC/GenParticle.h>
13 #include <HepMC/GenVertex.h>
14 #include <HepMC/HeavyIon.h>
15 #include <HepMC/SimpleVector.h>
17 #include <CLHEP/Vector/LorentzVector.h>
40 double ploss = p0 + b * p1 + exp((b - p2) / p3);
48 CLHEP::HepLorentzVector
pwithpF(CLHEP::HepLorentzVector
p, gsl_rng *RandomGenerator,
int id,
double pTspec,
double bphi)
51 if (!((
id == 2112) || (
id == 2212)))
53 std::cout <<
"wrong pid" << std::endl;
57 float pFmax = 0.28315;
58 if (
id == 2212) pFmax = 0.23276;
61 float pF = pFmax * pow(gsl_rng_uniform_pos(RandomGenerator), 1.0 / 3.0);
62 float cotheta = (gsl_rng_uniform_pos(RandomGenerator) - 0.5) * 2;
63 float phi = gsl_rng_uniform_pos(RandomGenerator) * 2 * M_PI;
64 float pFx = pF * sqrt(1 - cotheta * cotheta) * cos(phi);
65 float pFy = pF * sqrt(1 - cotheta * cotheta) * sin(phi);
66 float pFz = pF * cotheta;
67 float pSx = pTspec * cos(bphi);
68 float pSy = pTspec * sin(bphi);
77 float px = p.px() + pFx + pSx;
78 float py = p.py() + pFy + pSy;
79 float pz = p.pz() + pFz;
81 float const nrm = 0.938;
82 float e = sqrt(px * px + py * py + pz * pz + nrm * nrm);
84 CLHEP::HepLorentzVector
pwithpF(px, py, pz, e);
92 HepMC::HeavyIon *hi =
event->heavy_ion();
95 std::cout <<
PHWHERE <<
": Fermi Motion Afterburner needs the Heavy Ion Event Info, GenEvent::heavy_ion() returns NULL" << std::endl;
98 double b = hi->impact_parameter();
99 double bphi = hi->event_plane_angle();
100 double pnl =
ploss(b);
103 for (HepMC::GenEvent::particle_const_iterator
p = event->particles_begin(), prev =
event->particles_end();
p !=
event->particles_end(); prev =
p, ++
p)
106 if ((*p)->status() != 1)
continue;
107 int id = (*p)->pdg_id();
109 if (!((
id == 2112) || (
id == 2212)))
continue;
112 HepMC::GenParticle *
n = (*p);
113 float p_x = n->momentum().px();
114 float p_y = n->momentum().py();
115 if (!(p_x == 0 && p_y == 0))
continue;
120 if (pnl > gsl_rng_uniform_pos(RandomGenerator))
125 delete ((*p)->production_vertex())->remove_particle(*
p);
134 CLHEP::HepLorentzVector p0(n->momentum().px(), n->momentum().py(), n->momentum().pz(), n->momentum().e());
135 CLHEP::HepLorentzVector newp =
pwithpF(p0, RandomGenerator,
id, pTspec, bphi);
136 (*p)->set_momentum(newp);