9 #include <generators/modules/pairgen/PairGenModule.h>
10 #include <framework/dataobjects/MCInitialParticles.h>
14 #include <TLorentzVector.h>
15 #include <TLorentzRotation.h>
17 using namespace TMath;
34 "Simple module to generate tracks of given PDG back to back in CMS.\n"
42 addParam(
"pdgCode", m_PDG,
43 "PDG code for generated particles", 11);
44 addParam(
"saveBoth", m_saveBoth,
45 "Store both particles if true, one if false",
true);
48 void PairGenModule::initialize()
50 m_initialParticleGeneration.initialize();
53 void PairGenModule::event()
56 m_particleGraph.clear();
61 double phi = gRandom->Uniform(0, 2.0 * Pi());
64 while (1 + Cos(theta)*Cos(theta) < value) {
65 theta = gRandom->Uniform(0, 1.0 * Pi());
66 value = gRandom->Uniform(0, 2.0);
68 double CMSEnergy = initial.
getMass();
69 TLorentzRotation boostCMSToLab = initial.
getCMSToLab();
75 for (
int n = 1; n <= nParticles; n++) {
78 int sign = (n % 2) * 2 - 1;
79 p.setStatus(MCParticle::c_PrimaryParticle);
80 p.setPDG(sign * m_PDG);
82 p.setFirstDaughter(0);
85 double m = p.getMass();
86 double momentum = Sqrt(CMSEnergy * CMSEnergy / 4 - m * m);
88 double pz = momentum * Cos(theta);
89 double px = momentum * Sin(theta) * Cos(phi);
90 double py = momentum * Sin(theta) * Sin(phi);
91 double e = Sqrt(momentum * momentum + m * m);
93 TLorentzVector vp(sign * px, sign * py, sign * pz, e);
94 vp.Transform(boostCMSToLab);
96 p.setMomentum(vp(0), vp(1), vp(2));
98 p.setProductionVertex(initial.
getVertex());
99 p.addStatus(MCParticle::c_StableInGenerator);
103 p.setDecayTime(numeric_limits<double>::infinity());
106 p.setProductionTime(initial.
getTime());
109 m_particleGraph.generateList();
110 }
catch (runtime_error& e) {
This class contains the initial state for the given event.
const TLorentzRotation & getCMSToLab() const
Return the LorentzRotation to convert from CMS to lab frame.
const TVector3 & getVertex() const
Get the position of the collision.
double getMass() const
Get the invariant mass of the collision (= energy in CMS)
double getTime() const
Get collison time.
Class to represent Particle data in graph.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.