CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Pythia6PtGun.cc
Go to the documentation of this file.
1 
2 #include <iostream>
3 
4 #include "Pythia6PtGun.h"
5 
7 
10 
12 
14 
15 using namespace edm;
16 using namespace gen;
17 
18 Pythia6PtGun::Pythia6PtGun( const ParameterSet& pset ) :
19  Pythia6ParticleGun(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  fAddAntiParticle = pgun_params.getParameter<bool>("AddAntiParticle"); //, false) ;
30 
31 }
32 
34 {
35 }
36 
38 {
39 
40  Pythia6Service::InstanceWrapper guard(fPy6Service); // grab Py6 instance
41 
42  // now actualy, start cooking up the event gun
43  //
44 
45  // 1st, primary vertex
46  //
47  HepMC::GenVertex* Vtx = new HepMC::GenVertex( HepMC::FourVector(0.,0.,0.));
48 
49  // here re-create fEvt (memory)
50  //
51  fEvt = new HepMC::GenEvent() ;
52 
53  int ip=1;
54  for ( size_t i=0; i<fPartIDs.size(); i++ )
55  {
56  int particleID = fPartIDs[i]; // this is PDG - need to convert to Py6 !!!
57  int py6PID = HepPID::translatePDTtoPythia( particleID );
58  int dum = 0;
59  double pt=0, mom=0, ee=0, the=0, eta=0;
60  double mass = pymass_(py6PID);
61 
62  // fill p(ip,5) (in PYJETS) with mass value right now,
63  // because the (hardcoded) mstu(10)=1 will make py1ent
64  // pick the mass from there
65  pyjets.p[4][ip-1]=mass;
66 
67  double phi = (fMaxPhi-fMinPhi)*pyr_(&dum)+fMinPhi;
68 
69  eta = (fMaxEta-fMinEta)*pyr_(&dum)+fMinEta;
70 
71  the = 2.*atan(exp(-eta));
72 
73  pt = (fMaxPt-fMinPt)*pyr_(&dum)+fMinPt;
74 
75  mom = pt/sin(the);
76  ee = sqrt(mom*mom+mass*mass);
77 
78  py1ent_(ip, py6PID, ee, the, phi);
79 
80  double px = pyjets.p[0][ip-1]; // pt*cos(phi) ;
81  double py = pyjets.p[1][ip-1]; // pt*sin(phi) ;
82  double pz = pyjets.p[2][ip-1]; // mom*cos(the) ;
83 
84  HepMC::FourVector p(px,py,pz,ee) ;
85  HepMC::GenParticle* Part =
86  new HepMC::GenParticle(p,particleID,1);
87  Part->suggest_barcode( ip ) ;
88  Vtx->add_particle_out(Part);
89 
91  {
92  ip = ip + 1;
93  HepMC::GenParticle* APart = addAntiParticle( ip, particleID, ee, eta, phi );
94  if ( APart ) Vtx->add_particle_out(APart) ;
95  }
96  ip++;
97  }
98 
99  fEvt->add_vertex(Vtx);
100 
101  // run pythia
102  pyexec_();
103 
104  return;
105 }
106 
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
#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:238
HepMC::GenEvent * fEvt
Definition: Pythia6Gun.h:61
T eta() const
double p[5][pyjets_maxn]
double fMinPhi
Definition: Pythia6Gun.h:56
T sqrt(T t)
Definition: SSEVec.h:48
double pymass_(int &)
std::vector< int > fPartIDs
double fMaxPhi
Definition: Pythia6Gun.h:57
virtual ~Pythia6PtGun()
Definition: Pythia6PtGun.cc:33
void py1ent_(int &ip, int &kf, double &pe, double &the, double &phi)
Pythia6Service * fPy6Service
Definition: Pythia6Gun.h:51
double pyr_(int *idummy)
void pyexec_()
Definition: DDAxes.h:10