CMS 3D CMS Logo

Pythia6JetGun.cc
Go to the documentation of this file.
1 
2 #include <iostream>
3 
4 #include "Pythia6JetGun.h"
5 
7 
10 
12 
14 
15 using namespace edm;
16 using namespace gen;
17 
18 Pythia6JetGun::Pythia6JetGun(const ParameterSet& pset)
19  : Pythia6ParticleGun(pset), fMinEta(0.), fMaxEta(0.), fMinE(0.), fMaxE(0.), fMinP(0.), fMaxP(0.) {
20  ParameterSet pgun_params = pset.getParameter<ParameterSet>("PGunParameters");
21  fMinEta = pgun_params.getParameter<double>("MinEta");
22  fMaxEta = pgun_params.getParameter<double>("MaxEta");
23  fMinE = pgun_params.getParameter<double>("MinE");
24  fMaxE = pgun_params.getParameter<double>("MaxE");
25  fMinP = pgun_params.getParameter<double>("MinP");
26  fMaxP = pgun_params.getParameter<double>("MaxP");
27 }
28 
30 
31 void Pythia6JetGun::generateEvent(CLHEP::HepRandomEngine*) {
32  Pythia6Service::InstanceWrapper guard(fPy6Service); // grab Py6 instance
33 
34  // now actualy, start cooking up the event gun
35  //
36 
37  // 1st, primary vertex
38  //
39  HepMC::GenVertex* Vtx = new HepMC::GenVertex(HepMC::FourVector(0., 0., 0.));
40 
41  // here re-create fEvt (memory)
42  //
43  fEvt = new HepMC::GenEvent();
44 
45  int ip = 1;
46  double totPx = 0.;
47  double totPy = 0.;
48  double totPz = 0.;
49  double totE = 0.;
50  double totM = 0.;
51  double phi, eta, the, ee, pp;
52  int dum = 0;
53  for (size_t i = 0; i < fPartIDs.size(); i++) {
54  int particleID = fPartIDs[i]; // this is PDG - need to convert to Py6 !!!
55  int py6PID = HepPID::translatePDTtoPythia(particleID);
56 
57  // internal numbers
58  //
59  phi = 2. * M_PI * pyr_(&dum);
60  the = std::acos(-1. + 2. * pyr_(&dum));
61 
62  // from input
63  //
64  ee = (fMaxE - fMinE) * pyr_(&dum) + fMinE;
65 
66  // fill p(ip,5) (in PYJETS) with mass value right now,
67  // because the (hardcoded) mstu(10)=1 will make py1ent
68  // pick the mass from there
69  double mass = pymass_(py6PID);
70  pyjets.p[4][ip - 1] = mass;
71 
72  // add entry to py6
73  //
74  py1ent_(ip, py6PID, ee, the, phi);
75 
76  // values for computing total mass
77  //
78  totPx += pyjets.p[0][ip - 1];
79  totPy += pyjets.p[1][ip - 1];
80  totPz += pyjets.p[2][ip - 1];
81  totE += pyjets.p[3][ip - 1];
82 
83  ip++;
84 
85  } // end forming up py6 record of the jet
86 
87  // compute total mass
88  //
89  totM = std::sqrt(totE * totE - (totPx * totPx + totPy * totPy + totPz * totPz));
90 
91  //now the boost (from input params)
92  //
93  pp = (fMaxP - fMinP) * pyr_(&dum) + fMinP;
94  ee = std::sqrt(totM * totM + pp * pp);
95 
96  //the boost direction (from input params)
97  //
98  phi = (fMaxPhi - fMinPhi) * pyr_(&dum) + fMinPhi;
99  eta = (fMaxEta - fMinEta) * pyr_(&dum) + fMinEta;
100  the = 2. * atan(exp(-eta));
101 
102  double betaX = pp / ee * std::sin(the) * std::cos(phi);
103  double betaY = pp / ee * std::sin(the) * std::sin(phi);
104  double betaZ = pp / ee * std::cos(the);
105 
106  // boost all particles
107  // the first 2 params (-1) tell to boost all (fisrt-to-last),
108  // and the next 2 params (0.) tell no rotation
109  //
110  int first = -1, last = -1;
111  double rothe = 0, rophi = 0.;
112 
113  pyrobo_(first, last, rothe, rophi, betaX, betaY, betaZ);
114 
115  // event should be formed from boosted record !!!
116  // that's why additional loop
117  //
118  for (int i = 0; i < pyjets.n; i++) {
119  HepMC::FourVector p(pyjets.p[0][i], pyjets.p[1][i], pyjets.p[2][i], pyjets.p[3][i]);
120  HepMC::GenParticle* Part = new HepMC::GenParticle(p, HepPID::translatePythiatoPDT(pyjets.k[1][i]), 1);
121  Part->suggest_barcode(i + 1);
122  Vtx->add_particle_out(Part);
123  }
124  fEvt->add_vertex(Vtx);
125 
126  // run pythia
127  pyexec_();
128 
129  return;
130 }
131 
mps_fire.i
i
Definition: mps_fire.py:428
EDProducer.h
gen::Pythia6JetGun
Definition: Pythia6JetGun.h:12
gen::pymass_
double pymass_(int &)
gen::Pythia6ParticleGun
Definition: Pythia6ParticleGun.h:28
edm
HLT enums.
Definition: AlignableModifier.h:19
gen::pyr_
double pyr_(int *idummy)
Definition: Pythia6Service.cc:60
gen::Pythia6Gun::fEvt
HepMC::GenEvent * fEvt
Definition: Pythia6Gun.h:66
Pythia6JetGun.h
HepMC::GenEvent
Definition: hepmc_rootio.cc:9
gen::pyexec_
void pyexec_()
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
gen::py1ent_
void py1ent_(int &ip, int &kf, double &pe, double &the, double &phi)
MakerMacros.h
dqmdumpme.last
last
Definition: dqmdumpme.py:56
EgammaObjectsElectrons_cfi.particleID
particleID
Definition: EgammaObjectsElectrons_cfi.py:4
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
PVValHelper::eta
Definition: PVValidationHelpers.h:70
gen::p
double p[5][pyjets_maxn]
Definition: Cascade2Hadronizer.cc:76
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
gen::FortranInstance::InstanceWrapper
Definition: FortranInstance.h:54
gen
Definition: PythiaDecays.h:13
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:112
gen::Pythia6JetGun::fMaxP
double fMaxP
Definition: Pythia6JetGun.h:27
gen::Pythia6Gun::fMaxPhi
double fMaxPhi
Definition: Pythia6Gun.h:62
gen::Pythia6ParticleGun::fPartIDs
std::vector< int > fPartIDs
Definition: Pythia6ParticleGun.h:36
edm::ParameterSet
Definition: ParameterSet.h:47
gen::Pythia6JetGun::fMinP
double fMinP
Definition: Pythia6JetGun.h:26
gen::pyrobo_
void pyrobo_(int &, int &, double &, double &, double &, double &, double &)
gen::Pythia6JetGun::fMaxEta
double fMaxEta
Definition: Pythia6JetGun.h:23
gen::Pythia6JetGun::generateEvent
void generateEvent(CLHEP::HepRandomEngine *) override
Definition: Pythia6JetGun.cc:31
gen::Pythia6Gun::fMinPhi
double fMinPhi
Definition: Pythia6Gun.h:61
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:49
gen::Pythia6Gun::fPy6Service
Pythia6Service * fPy6Service
Definition: Pythia6Gun.h:56
GenParticle.GenParticle
GenParticle
Definition: GenParticle.py:18
EgHLTOffHistBins_cfi.mass
mass
Definition: EgHLTOffHistBins_cfi.py:34
EventSetup.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
Exception.h
gen::Pythia6JetGun::fMinE
double fMinE
Definition: Pythia6JetGun.h:24
createTree.pp
pp
Definition: createTree.py:17
HepMCProduct.h
JetChargeProducer_cfi.exp
exp
Definition: JetChargeProducer_cfi.py:6
gen::Pythia6JetGun::~Pythia6JetGun
~Pythia6JetGun() override
Definition: Pythia6JetGun.cc:29
gen::Pythia6JetGun::fMaxE
double fMaxE
Definition: Pythia6JetGun.h:25
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
gen::Pythia6JetGun::fMinEta
double fMinEta
Definition: Pythia6JetGun.h:22