CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Pythia6PtYDistGun.cc
Go to the documentation of this file.
1 
2 #include <iostream>
3 
4 #include "Pythia6PtYDistGun.h"
6 
8 
11 
13 
15 
17 
18 using namespace edm;
19 using namespace gen;
20 
21 Pythia6PtYDistGun::Pythia6PtYDistGun( const ParameterSet& pset ) :
22  Pythia6ParticleGun(pset), fPtYGenerator(0)
23 {
24 
25  ParameterSet pgun_params =
26  pset.getParameter<ParameterSet>("PGunParameters");
27 
28  fPtYGenerator = new PtYDistributor( pgun_params.getParameter<FileInPath>("kinematicsFile"),
30  pgun_params.getParameter<double>("MaxPt"),
31  pgun_params.getParameter<double>("MinPt"),
32  pgun_params.getParameter<double>("MaxY"),
33  pgun_params.getParameter<double>("MinY"),
34  pgun_params.getParameter<int>("PtBinning"),
35  pgun_params.getParameter<int>("YBinning") );
36 }
37 
39 {
40  if ( fPtYGenerator ) delete fPtYGenerator;
41 }
42 
44 {
45  Pythia6Service::InstanceWrapper guard(fPy6Service); // grab Py6 instance
46 
47  // now actualy, start cooking up the event gun
48  //
49 
50  // 1st, primary vertex
51  //
52  HepMC::GenVertex* Vtx = new HepMC::GenVertex( HepMC::FourVector(0.,0.,0.) );
53 
54  // here re-create fEvt (memory)
55  //
56  fEvt = new HepMC::GenEvent() ;
57 
58  int ip=1;
59 
60  for ( size_t i=0; i<fPartIDs.size(); i++ )
61  {
62 
63  int particleID = fPartIDs[i]; // this is PDG - need to convert to Py6 !!!
64  int py6PID = HepPID::translatePDTtoPythia( particleID );
65 
66  int dum = 0;
67  double pt=0, y=0, u=0, ee=0, the=0;
68 
69  pt = fPtYGenerator->firePt();
70  y = fPtYGenerator->fireY();
71  u = exp(y);
72 
73  double mass = pymass_(py6PID);
74 
75  // fill p(ip,5) (in PYJETS) with mass value right now,
76  // because the (hardcoded) mstu(10)=1 will make py1ent
77  // pick the mass from there
78  pyjets.p[4][ip-1]=mass;
79 
80  ee = 0.5*std::sqrt(mass*mass+pt*pt)*(u*u+1)/u;
81 
82  double pz = std::sqrt(ee*ee-pt*pt-mass*mass);
83  if ( y < 0. ) pz *= -1;
84 
85  double phi = (fMaxPhi-fMinPhi)*pyr_(&dum)+fMinPhi;
86 
87  the = atan(pt/pz);
88  if ( pz < 0. ) the += M_PI ;
89 
90  py1ent_(ip, py6PID, ee, the, phi);
91 
92 /*
93  double px = pt*cos(phi) ;
94  double py = pt*sin(phi) ;
95 */
96  double px = pyjets.p[0][ip-1]; // pt*cos(phi) ;
97  double py = pyjets.p[1][ip-1]; // pt*sin(phi) ;
98  pz = pyjets.p[2][ip-1]; // mom*cos(the) ;
99 
100  HepMC::FourVector p(px,py,pz,ee) ;
101  HepMC::GenParticle* Part =
102  new HepMC::GenParticle(p,particleID,1);
103  Part->suggest_barcode( ip ) ;
104  Vtx->add_particle_out(Part);
105 
106  ip++;
107 
108  }
109 
110  fEvt->add_vertex(Vtx);
111 
112  // run pythia
113  pyexec_();
114 
115  return;
116 }
117 
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
HepMC::GenEvent * fEvt
Definition: Pythia6Gun.h:62
CLHEP::HepRandomEngine & getEngineReference()
double p[5][pyjets_maxn]
PtYDistributor * fPtYGenerator
double fMinPhi
Definition: Pythia6Gun.h:57
T sqrt(T t)
Definition: SSEVec.h:46
double pymass_(int &)
std::vector< int > fPartIDs
double fMaxPhi
Definition: Pythia6Gun.h:58
#define M_PI
Definition: BFit3D.cc:3
void py1ent_(int &ip, int &kf, double &pe, double &the, double &phi)
tuple mass
Definition: scaleCards.py:27
Pythia6Service * fPy6Service
Definition: Pythia6Gun.h:52
double pyr_(int *idummy)
void pyexec_()
Definition: DDAxes.h:10