CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Py8JetGun.cc
Go to the documentation of this file.
1 
4 
7 
8 namespace gen {
9 
10 class Py8JetGun : public Py8GunBase {
11 
12  public:
13 
14  Py8JetGun( edm::ParameterSet const& );
16 
18  const char* classname() const;
19 
20  private:
21 
22  // PtGun particle(s) characteristics
23  double fMinEta;
24  double fMaxEta;
25  double fMinP ;
26  double fMaxP ;
27  double fMinE ;
28  double fMaxE ;
29 
30 };
31 
32 // implementation
33 //
35  : Py8GunBase(ps)
36 {
37 
38  // ParameterSet defpset ;
39  edm::ParameterSet pgun_params =
40  ps.getParameter<edm::ParameterSet>("PGunParameters"); // , defpset ) ;
41  fMinEta = pgun_params.getParameter<double>("MinEta"); // ,-2.2);
42  fMaxEta = pgun_params.getParameter<double>("MaxEta"); // , 2.2);
43  fMinP = pgun_params.getParameter<double>("MinP"); // , 0.);
44  fMaxP = pgun_params.getParameter<double>("MaxP"); // , 0.);
45  fMinE = pgun_params.getParameter<double>("MinE"); // , 0.);
46  fMaxE = pgun_params.getParameter<double>("MaxE"); // , 0.);
47 
48 }
49 
51 {
52 
53  fMasterGen->event.reset();
54 
55  double totPx = 0.;
56  double totPy = 0.;
57  double totPz = 0.;
58  double totE = 0.;
59  double totM = 0.;
60  double phi, eta, the, ee, pp;
61 
62  for ( size_t i=0; i<fPartIDs.size(); i++ )
63  {
64 
65  int particleID = fPartIDs[i]; // this is PDG - need to convert to Py8 ???
66 
67  // FIXME !!!
68  // Ouch, it's using bare randomEngine pointer - that's NOT safe.
69  // Need to hold a pointer somewhere properly !!!
70  //
71  phi = 2. * M_PI * randomEngine->flat() ;
72  the = acos( -1. + 2.*randomEngine->flat() );
73 
74  // from input
75  //
76  ee = (fMaxE-fMinE)*randomEngine->flat() + fMinE;
77 
78  double mass = (fMasterGen->particleData).m0( particleID );
79 
80  pp = sqrt( ee*ee - mass*mass );
81 
82  double px = pp * sin(the) * cos(phi);
83  double py = pp * sin(the) * sin(phi);
84  double pz = pp * cos(the);
85 
86  if ( !((fMasterGen->particleData).isParticle( particleID )) )
87  {
88  particleID = std::fabs(particleID) ;
89  }
90  (fMasterGen->event).append( particleID, 1, 0, 0, px, py, pz, ee, mass );
91 
92  // values for computing total mass
93  //
94  totPx += px;
95  totPy += py;
96  totPz += pz;
97  totE += ee;
98 
99  }
100 
101  totM = sqrt( totE*totE - (totPx*totPx+totPy*totPy+totPz*totPz) );
102 
103  //now the boost (from input params)
104  //
105  pp = (fMaxP-fMinP)*randomEngine->flat() + fMinP;
106  ee = sqrt( totM*totM + pp*pp );
107 
108  //the boost direction (from input params)
109  //
110  phi = (fMaxPhi-fMinPhi)*randomEngine->flat() + fMinPhi;
111  eta = (fMaxEta-fMinEta)*randomEngine->flat() + fMinEta;
112  the = 2.*atan(exp(-eta));
113 
114  double betaX = pp/ee * std::sin(the) * std::cos(phi);
115  double betaY = pp/ee * std::sin(the) * std::sin(phi);
116  double betaZ = pp/ee * std::cos(the);
117 
118  // boost all particles
119  //
120  (fMasterGen->event).bst( betaX, betaY, betaZ );
121 
122  if ( !fMasterGen->next() ) return false;
123 
124  event().reset(new HepMC::GenEvent);
125  return toHepMC.fill_next_event( fMasterGen->event, event().get() );
126 
127 }
128 
129 const char* Py8JetGun::classname() const
130 {
131  return "Py8JetGun";
132 }
133 
135 
136 } // end namespace
137 
138 using gen::Pythia8JetGun;
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
std::auto_ptr< Pythia8::Pythia > fMasterGen
double fMinEta
Definition: Py8JetGun.cc:23
double fMinE
Definition: Py8JetGun.cc:27
tuple pp
Definition: createTree.py:15
CLHEP::HepRandomEngine * randomEngine
Definition: PYR.cc:4
const char * classname() const
Definition: Py8JetGun.cc:129
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
double fMinPhi
Definition: Py8GunBase.h:66
double fMaxP
Definition: Py8JetGun.cc:26
T eta() const
double fMaxE
Definition: Py8JetGun.cc:28
Py8JetGun(edm::ParameterSet const &)
Definition: Py8JetGun.cc:34
T sqrt(T t)
Definition: SSEVec.h:46
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
std::vector< int > fPartIDs
Definition: Py8GunBase.h:65
std::auto_ptr< HepMC::GenEvent > & event()
Definition: Py8GunBase.h:60
#define M_PI
Definition: BFit3D.cc:3
edm::GeneratorFilter< gen::Py8JetGun, gen::ExternalDecayDriver > Pythia8JetGun
Definition: Py8JetGun.cc:134
double fMaxPhi
Definition: Py8GunBase.h:67
tuple mass
Definition: scaleCards.py:27
HepMC::Pythia8ToHepMC toHepMC
double fMinP
Definition: Py8JetGun.cc:25
double fMaxEta
Definition: Py8JetGun.cc:24
bool generatePartonsAndHadronize()
Definition: Py8JetGun.cc:50
Definition: DDAxes.h:10