CMS 3D CMS Logo

Pythia6EGun.cc
Go to the documentation of this file.
1 
2 #include <iostream>
3 
4 #include "Pythia6EGun.h"
5 
7 
9 
11 
13 
14 using namespace edm;
15 using namespace gen;
16 
17 Pythia6EGun::Pythia6EGun(const ParameterSet& pset) : Pythia6ParticleGun(pset) {
18  // ParameterSet defpset ;
19  ParameterSet pgun_params = pset.getParameter<ParameterSet>("PGunParameters"); // , defpset ) ;
20  fMinEta = pgun_params.getParameter<double>("MinEta"); // ,-2.2);
21  fMaxEta = pgun_params.getParameter<double>("MaxEta"); // , 2.2);
22  fMinE = pgun_params.getParameter<double>("MinE"); // , 0.);
23  fMaxE = pgun_params.getParameter<double>("MaxE"); // , 0.);
24  fAddAntiParticle = pgun_params.getParameter<bool>("AddAntiParticle"); //, false) ;
25 }
26 
28 
29 void Pythia6EGun::generateEvent(CLHEP::HepRandomEngine*) {
30  Pythia6Service::InstanceWrapper guard(fPy6Service); // grab Py6 instance
31 
32  // now actualy, start cooking up the event gun
33  //
34 
35  // 1st, primary vertex
36  //
37  HepMC::GenVertex* Vtx = new HepMC::GenVertex(HepMC::FourVector(0., 0., 0.));
38 
39  // here re-create fEvt (memory)
40  //
41  fEvt = new HepMC::GenEvent();
42 
43  int ip = 1;
44  for (size_t i = 0; i < fPartIDs.size(); i++) {
45  int particleID = fPartIDs[i]; // this is PDG - need to convert to Py6 !!!
46  int py6PID = HepPID::translatePDTtoPythia(particleID);
47  int dum = 0;
48  double ee = 0, the = 0, eta = 0;
49  double mass = pymass_(particleID);
50 
51  // fill p(ip,5) (in PYJETS) with mass value right now,
52  // because the (hardcoded) mstu(10)=1 will make py1ent
53  // pick the mass from there
54  pyjets.p[4][ip - 1] = mass;
55 
56  double phi = (fMaxPhi - fMinPhi) * pyr_(&dum) + fMinPhi;
57  ee = (fMaxE - fMinE) * pyr_(&dum) + fMinE;
58  eta = (fMaxEta - fMinEta) * pyr_(&dum) + fMinEta;
59  the = 2. * atan(exp(-eta));
60 
61  py1ent_(ip, py6PID, ee, the, phi);
62 
63  double px = pyjets.p[0][ip - 1]; // pt*cos(phi) ;
64  double py = pyjets.p[1][ip - 1]; // pt*sin(phi) ;
65  double pz = pyjets.p[2][ip - 1]; // mom*cos(the) ;
66 
67  HepMC::FourVector p(px, py, pz, ee);
69  Part->suggest_barcode(ip);
70  Vtx->add_particle_out(Part);
71 
72  if (fAddAntiParticle) {
73  ip = ip + 1;
74  HepMC::GenParticle* APart = addAntiParticle(ip, particleID, ee, eta, phi);
75  if (APart)
76  Vtx->add_particle_out(APart);
77  }
78  ip++;
79  }
80 
81  fEvt->add_vertex(Vtx);
82 
83  // run pythia
84  pyexec_();
85 
86  return;
87 }
88 
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
double pyr_(int *idummy)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
HepMC::GenParticle * addAntiParticle(int &, int &, double &, double &, double &)
Definition: Pythia6Gun.cc:200
HepMC::GenEvent * fEvt
Definition: Pythia6Gun.h:68
double p[5][pyjets_maxn]
double fMinPhi
Definition: Pythia6Gun.h:63
double pymass_(int &)
std::vector< int > fPartIDs
double fMaxPhi
Definition: Pythia6Gun.h:64
~Pythia6EGun() override
Definition: Pythia6EGun.cc:27
void py1ent_(int &ip, int &kf, double &pe, double &the, double &phi)
HLT enums.
Pythia6Service * fPy6Service
Definition: Pythia6Gun.h:58
void pyexec_()
void generateEvent(CLHEP::HepRandomEngine *) override
Definition: Pythia6EGun.cc:29