CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Pythia6PartonEGun.cc
Go to the documentation of this file.
1 
2 #include <iostream>
3 
4 #include "Pythia6PartonEGun.h"
5 
7 
10 
12 
14 
15 using namespace edm;
16 using namespace gen;
17 
18 Pythia6PartonEGun::Pythia6PartonEGun( const ParameterSet& pset ) :
19  Pythia6PartonGun(pset)
20 {
21 
22  // ParameterSet defpset ;
23  ParameterSet pgun_params =
24  pset.getParameter<ParameterSet>("PGunParameters"); //, defpset ) ;
25  fMinEta = pgun_params.getParameter<double>("MinEta"); // ,-2.2);
26  fMaxEta = pgun_params.getParameter<double>("MaxEta"); // , 2.2);
27  fMinE = pgun_params.getParameter<double>("MinE"); // , 20.);
28  fMaxE = pgun_params.getParameter<double>("MaxE"); // , 420.);
29 
30 }
31 
33 {
34 }
35 
36 void Pythia6PartonEGun::generateEvent(CLHEP::HepRandomEngine*)
37 {
38 
39  Pythia6Service::InstanceWrapper guard(fPy6Service); // grab Py6 instance
40 
41  // now actualy, start cooking up the event gun
42  //
43 
44  // 1st, primary vertex
45  //
46  HepMC::GenVertex* Vtx = new HepMC::GenVertex( HepMC::FourVector(0.,0.,0.));
47 
48  // here re-create fEvt (memory)
49  //
50  fEvt = new HepMC::GenEvent() ;
51 
52  int ip=1;
53 
54  int py6PID = HepPID::translatePDTtoPythia( fPartonID );
55  int dum = 0;
56  double ee=0, the=0, eta=0;
57  double mass = pymass_(py6PID);
58 
59  // fill p(ip,5) (in PYJETS) with mass value right now,
60  // because the (hardcoded) mstu(10)=1 will make py1ent
61  // pick the mass from there
62  pyjets.p[4][ip-1]=mass;
63 
64  double phi = (fMaxPhi-fMinPhi)*pyr_(&dum)+fMinPhi;
65  ee = (fMaxE-fMinE)*pyr_(&dum)+fMinE;
66  eta = (fMaxEta-fMinEta)*pyr_(&dum)+fMinEta;
67  the = 2.*atan(exp(-eta));
68 
69  py1ent_(ip, py6PID, ee, the, phi);
70 
71  double px = pyjets.p[0][ip-1]; // pt*cos(phi) ;
72  double py = pyjets.p[1][ip-1]; // pt*sin(phi) ;
73  double pz = pyjets.p[2][ip-1]; // mom*cos(the) ;
74 
75  HepMC::FourVector p(px,py,pz,ee) ;
77  Part->suggest_barcode( ip ) ;
78  Vtx->add_particle_out(Part);
79 
80  // now add anti-quark
81  ip = ip + 1;
82  HepMC::GenParticle* APart = addAntiParticle( ip, fPartonID, ee, eta, phi );
83  if ( APart )
84  {
85  Vtx->add_particle_out(APart) ;
86  }
87  else
88  {
89  // otherwise it should throw !
90  }
91 
92  // this should probably be configurable...
93  //
94  double qmax = 2.*ee;
95 
96  joinPartons( qmax );
97 
98  fEvt->add_vertex(Vtx);
99 
100  // run pythia
101  pyexec_();
102 
103  return;
104 }
105 
T getParameter(std::string const &) const
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
HepMC::GenParticle * addAntiParticle(int &, int &, double &, double &, double &)
Definition: Pythia6Gun.cc:244
HepMC::GenEvent * fEvt
Definition: Pythia6Gun.h:71
def gen
run2 Cosmic #### Run 256259 @ 0T 2015C### Run 272133 @ 3.8T 2016B###
double p[5][pyjets_maxn]
double fMinPhi
Definition: Pythia6Gun.h:66
double pymass_(int &)
double fMaxPhi
Definition: Pythia6Gun.h:67
void generateEvent(CLHEP::HepRandomEngine *)
void joinPartons(double qmax)
Geom::Phi< T > phi() const
void py1ent_(int &ip, int &kf, double &pe, double &the, double &phi)
Pythia6Service * fPy6Service
Definition: Pythia6Gun.h:61
double pyr_(int *idummy)
void pyexec_()