CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Pythia6PartonPtGun.cc
Go to the documentation of this file.
1 
2 #include <iostream>
3 
4 #include "Pythia6PartonPtGun.h"
5 
7 
10 
12 
14 
15 using namespace edm;
16 using namespace gen;
17 
18 Pythia6PartonPtGun::Pythia6PartonPtGun( 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  fMinPt = pgun_params.getParameter<double>("MinPt"); // , 20.);
28  fMaxPt = pgun_params.getParameter<double>("MaxPt"); // , 420.);
29 
30 }
31 
33 {
34 }
35 
36 void Pythia6PartonPtGun::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 pt=0, mom=0, 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 
66  eta = (fMaxEta-fMinEta)*pyr_(&dum)+fMinEta;
67 
68  the = 2.*atan(exp(-eta));
69 
70  pt = (fMaxPt-fMinPt)*pyr_(&dum)+fMinPt;
71 
72  mom = pt/sin(the);
73  ee = sqrt(mom*mom+mass*mass);
74 
75  py1ent_(ip, py6PID, ee, the, phi);
76 
77  double px = pyjets.p[0][ip-1]; // pt*cos(phi) ;
78  double py = pyjets.p[1][ip-1]; // pt*sin(phi) ;
79  double pz = pyjets.p[2][ip-1]; // mom*cos(the) ;
80 
81  HepMC::FourVector p(px,py,pz,ee) ;
83  Part->suggest_barcode( ip ) ;
84  Vtx->add_particle_out(Part);
85 
86  // now add anti-quark
87  ip = ip + 1;
88  HepMC::GenParticle* APart = addAntiParticle( ip, fPartonID, ee, eta, phi );
89  if ( APart )
90  {
91  Vtx->add_particle_out(APart) ;
92  }
93  else
94  {
95  // otherwise it should throw !
96  }
97 
98  // this should probably be configurable...
99  //
100  double qmax = 2.*ee;
101 
102  joinPartons( qmax );
103 
104  fEvt->add_vertex(Vtx);
105 
106  // run pythia
107  pyexec_();
108 
109  return;
110 }
111 
T getParameter(std::string const &) const
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
HepMC::GenParticle * addAntiParticle(int &, int &, double &, double &, double &)
Definition: Pythia6Gun.cc:244
HepMC::GenEvent * fEvt
Definition: Pythia6Gun.h:71
double p[5][pyjets_maxn]
double fMinPhi
Definition: Pythia6Gun.h:66
T sqrt(T t)
Definition: SSEVec.h:18
double pymass_(int &)
void generateEvent(CLHEP::HepRandomEngine *)
double fMaxPhi
Definition: Pythia6Gun.h:67
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_()