11 #include <generators/modules/pairgen/PairGenModule.h>
12 #include <framework/dataobjects/MCInitialParticles.h>
16 #include <TLorentzVector.h>
17 #include <TLorentzRotation.h>
19 using namespace TMath;
36 "Simple module to generate tracks of given PDG back to back in CMS.\n"
44 addParam(
"pdgCode", m_PDG,
45 "PDG code for generated particles", 11);
46 addParam(
"saveBoth", m_saveBoth,
47 "Store both particles if true, one if false",
true);
50 void PairGenModule::initialize()
52 m_initialParticleGeneration.initialize();
55 void PairGenModule::event()
58 m_particleGraph.clear();
63 double phi = gRandom->Uniform(0, 2.0 * Pi());
66 while (1 + Cos(theta)*Cos(theta) < value) {
67 theta = gRandom->Uniform(0, 1.0 * Pi());
68 value = gRandom->Uniform(0, 2.0);
70 double CMSEnergy = initial.
getMass();
71 TLorentzRotation boostCMSToLab = initial.
getCMSToLab();
77 for (
int n = 1; n <= nParticles; n++) {
80 int sign = (n % 2) * 2 - 1;
81 p.setStatus(MCParticle::c_PrimaryParticle);
82 p.setPDG(sign * m_PDG);
84 p.setFirstDaughter(0);
87 double m = p.getMass();
88 double momentum = Sqrt(CMSEnergy * CMSEnergy / 4 - m * m);
90 double pz = momentum * Cos(theta);
91 double px = momentum * Sin(theta) * Cos(phi);
92 double py = momentum * Sin(theta) * Sin(phi);
93 double e = Sqrt(momentum * momentum + m * m);
95 TLorentzVector vp(sign * px, sign * py, sign * pz, e);
96 vp.Transform(boostCMSToLab);
98 p.setMomentum(vp(0), vp(1), vp(2));
100 p.setProductionVertex(initial.
getVertex());
101 p.addStatus(MCParticle::c_StableInGenerator);
105 p.setDecayTime(numeric_limits<double>::infinity());
108 p.setProductionTime(initial.
getTime());
111 m_particleGraph.generateList();
112 }
catch (runtime_error& e) {