CMS 3D CMS Logo

Pythia6PartonEGun.cc
Go to the documentation of this file.
1 
2 #include <iostream>
3 
4 #include "Pythia6PartonEGun.h"
5 
7 
9 
11 
13 
14 using namespace edm;
15 using namespace gen;
16 
17 Pythia6PartonEGun::Pythia6PartonEGun(const ParameterSet& pset) : Pythia6PartonGun(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"); // , 20.);
23  fMaxE = pgun_params.getParameter<double>("MaxE"); // , 420.);
24 }
25 
27 
28 void Pythia6PartonEGun::generateEvent(CLHEP::HepRandomEngine*) {
29  Pythia6Service::InstanceWrapper guard(fPy6Service); // grab Py6 instance
30 
31  // now actualy, start cooking up the event gun
32  //
33 
34  // 1st, primary vertex
35  //
36  HepMC::GenVertex* Vtx = new HepMC::GenVertex(HepMC::FourVector(0., 0., 0.));
37 
38  // here re-create fEvt (memory)
39  //
40  fEvt = new HepMC::GenEvent();
41 
42  int ip = 1;
43 
44  int py6PID = HepPID::translatePDTtoPythia(fPartonID);
45  int dum = 0;
46  double ee = 0, the = 0, eta = 0;
47  double mass = pymass_(py6PID);
48 
49  // fill p(ip,5) (in PYJETS) with mass value right now,
50  // because the (hardcoded) mstu(10)=1 will make py1ent
51  // pick the mass from there
52  pyjets.p[4][ip - 1] = mass;
53 
54  double phi = (fMaxPhi - fMinPhi) * pyr_(&dum) + fMinPhi;
55  ee = (fMaxE - fMinE) * pyr_(&dum) + fMinE;
56  eta = (fMaxEta - fMinEta) * pyr_(&dum) + fMinEta;
57  the = 2. * atan(exp(-eta));
58 
59  py1ent_(ip, py6PID, ee, the, phi);
60 
61  double px = pyjets.p[0][ip - 1]; // pt*cos(phi) ;
62  double py = pyjets.p[1][ip - 1]; // pt*sin(phi) ;
63  double pz = pyjets.p[2][ip - 1]; // mom*cos(the) ;
64 
65  HepMC::FourVector p(px, py, pz, ee);
67  Part->suggest_barcode(ip);
68  Vtx->add_particle_out(Part);
69 
70  // now add anti-quark
71  ip = ip + 1;
72  HepMC::GenParticle* APart = addAntiParticle(ip, fPartonID, ee, eta, phi);
73  if (APart) {
74  Vtx->add_particle_out(APart);
75  } else {
76  // otherwise it should throw !
77  }
78 
79  // this should probably be configurable...
80  //
81  double qmax = 2. * ee;
82 
83  joinPartons(qmax);
84 
85  fEvt->add_vertex(Vtx);
86 
87  // run pythia
88  pyexec_();
89 
90  return;
91 }
92 
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
double pyr_(int *idummy)
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 &)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
double fMaxPhi
Definition: Pythia6Gun.h:64
void joinPartons(double qmax)
void py1ent_(int &ip, int &kf, double &pe, double &the, double &phi)
HLT enums.
Pythia6Service * fPy6Service
Definition: Pythia6Gun.h:58
void generateEvent(CLHEP::HepRandomEngine *) override
void pyexec_()