CMS 3D CMS Logo

Pythia6PartonPtGun.cc
Go to the documentation of this file.
1 
2 #include <iostream>
3 
4 #include "Pythia6PartonPtGun.h"
5 
7 
9 
11 
13 
14 using namespace edm;
15 using namespace gen;
16 
17 Pythia6PartonPtGun::Pythia6PartonPtGun(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  fMinPt = pgun_params.getParameter<double>("MinPt"); // , 20.);
23  fMaxPt = pgun_params.getParameter<double>("MaxPt"); // , 420.);
24 }
25 
27 
28 void Pythia6PartonPtGun::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 pt = 0, mom = 0, 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 
56  eta = (fMaxEta - fMinEta) * pyr_(&dum) + fMinEta;
57 
58  the = 2. * atan(exp(-eta));
59 
60  pt = (fMaxPt - fMinPt) * pyr_(&dum) + fMinPt;
61 
62  mom = pt / sin(the);
63  ee = sqrt(mom * mom + mass * mass);
64 
65  py1ent_(ip, py6PID, ee, the, phi);
66 
67  double px = pyjets.p[0][ip - 1]; // pt*cos(phi) ;
68  double py = pyjets.p[1][ip - 1]; // pt*sin(phi) ;
69  double pz = pyjets.p[2][ip - 1]; // mom*cos(the) ;
70 
71  HepMC::FourVector p(px, py, pz, ee);
73  Part->suggest_barcode(ip);
74  Vtx->add_particle_out(Part);
75 
76  // now add anti-quark
77  ip = ip + 1;
78  HepMC::GenParticle* APart = addAntiParticle(ip, fPartonID, ee, eta, phi);
79  if (APart) {
80  Vtx->add_particle_out(APart);
81  } else {
82  // otherwise it should throw !
83  }
84 
85  // this should probably be configurable...
86  //
87  double qmax = 2. * ee;
88 
89  joinPartons(qmax);
90 
91  fEvt->add_vertex(Vtx);
92 
93  // run pythia
94  pyexec_();
95 
96  return;
97 }
98 
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
double pyr_(int *idummy)
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
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
T sqrt(T t)
Definition: SSEVec.h:19
double pymass_(int &)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
double fMaxPhi
Definition: Pythia6Gun.h:64
void joinPartons(double qmax)
void generateEvent(CLHEP::HepRandomEngine *) override
void py1ent_(int &ip, int &kf, double &pe, double &the, double &phi)
HLT enums.
Pythia6Service * fPy6Service
Definition: Pythia6Gun.h:58
void pyexec_()