test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Py8EGun.cc
Go to the documentation of this file.
1 
4 
6 
7 // EvtGen plugin
8 //
9 #include "Pythia8Plugins/EvtGen.h"
10 
11 namespace gen {
12 
13 class Py8EGun : public Py8GunBase {
14 
15  public:
16 
17  Py8EGun( edm::ParameterSet const& );
18  ~Py8EGun() {}
19 
20  bool generatePartonsAndHadronize() override;
21  const char* classname() const override;
22 
23  private:
24 
25  // EGun particle(s) characteristics
26  double fMinEta;
27  double fMaxEta;
28  double fMinE ;
29  double fMaxE ;
31 
32 };
33 
34 // implementation
35 //
37  : Py8GunBase(ps)
38 {
39 
40  // ParameterSet defpset ;
41  edm::ParameterSet pgun_params =
42  ps.getParameter<edm::ParameterSet>("PGunParameters"); // , defpset ) ;
43  fMinEta = pgun_params.getParameter<double>("MinEta"); // ,-2.2);
44  fMaxEta = pgun_params.getParameter<double>("MaxEta"); // , 2.2);
45  fMinE = pgun_params.getParameter<double>("MinE"); // , 0.);
46  fMaxE = pgun_params.getParameter<double>("MaxE"); // , 0.);
47  fAddAntiParticle = pgun_params.getParameter<bool>("AddAntiParticle"); //, false) ;
48 
49 }
50 
52 {
53 
54  fMasterGen->event.reset();
55 
56  for ( size_t i=0; i<fPartIDs.size(); i++ )
57  {
58 
59  int particleID = fPartIDs[i]; // this is PDG - need to convert to Py8 ???
60 
61  double phi = (fMaxPhi-fMinPhi) * randomEngine().flat() + fMinPhi;
62  double ee = (fMaxE-fMinE) * randomEngine().flat() + fMinE;
63  double eta = (fMaxEta-fMinEta) * randomEngine().flat() + fMinEta;
64  double the = 2.*atan(exp(-eta));
65 
66  double mass = (fMasterGen->particleData).m0( particleID );
67 
68  double pp = sqrt( ee*ee - mass*mass );
69  double px = pp * sin(the) * cos(phi);
70  double py = pp * sin(the) * sin(phi);
71  double pz = pp * cos(the);
72 
73  if ( !((fMasterGen->particleData).isParticle( particleID )) )
74  {
75  particleID = std::fabs(particleID) ;
76  }
77  (fMasterGen->event).append( particleID, 1, 0, 0, px, py, pz, ee, mass );
78 
79 // Here also need to add anti-particle (if any)
80 // otherwise just add a 2nd particle of the same type
81 // (for example, gamma)
82 //
83  if ( fAddAntiParticle )
84  {
85  if ( (fMasterGen->particleData).isParticle( -particleID ) )
86  {
87  (fMasterGen->event).append( -particleID, 1, 0, 0, -px, -py, -pz, ee, mass );
88  }
89  else
90  {
91  (fMasterGen->event).append( particleID, 1, 0, 0, -px, -py, -pz, ee, mass );
92  }
93  }
94 
95  }
96 
97  if ( !fMasterGen->next() ) return false;
98 
99  if (evtgenDecays.get()) evtgenDecays->decay();
100 
101  event().reset(new HepMC::GenEvent);
102  return toHepMC.fill_next_event( fMasterGen->event, event().get() );
103 
104 }
105 
106 const char* Py8EGun::classname() const
107 {
108  return "Py8EGun";
109 }
110 
112 
113 } // end namespace
114 
115 using gen::Pythia8EGun;
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
bool fAddAntiParticle
Definition: Py8EGun.cc:30
std::auto_ptr< Pythia8::Pythia > fMasterGen
std::auto_ptr< EvtGenDecays > evtgenDecays
tuple pp
Definition: createTree.py:15
double fMinE
Definition: Py8EGun.cc:28
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
boost::dynamic_bitset append(const boost::dynamic_bitset<> &bs1, const boost::dynamic_bitset<> &bs2)
this method takes two bitsets bs1 and bs2 and returns result of bs2 appended to the end of bs1 ...
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
double fMinPhi
Definition: Py8GunBase.h:59
double fMinEta
Definition: Py8EGun.cc:26
virtual double flat() override
Definition: P8RndmEngine.cc:7
std::auto_ptr< HepMC::GenEvent > & event()
def gen
run2 Cosmic #### Run 256259 @ 0T 2015C### Run 272133 @ 3.8T 2016B###
T sqrt(T t)
Definition: SSEVec.h:18
double fMaxEta
Definition: Py8EGun.cc:27
bool generatePartonsAndHadronize() override
Definition: Py8EGun.cc:51
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
edm::GeneratorFilter< gen::Py8EGun, gen::ExternalDecayDriver > Pythia8EGun
Definition: Py8EGun.cc:111
std::vector< int > fPartIDs
Definition: Py8GunBase.h:58
const char * classname() const override
Definition: Py8EGun.cc:106
P8RndmEngine & randomEngine()
double fMaxE
Definition: Py8EGun.cc:29
Geom::Phi< T > phi() const
double fMaxPhi
Definition: Py8GunBase.h:60
HepMC::Pythia8ToHepMC toHepMC
Py8EGun(edm::ParameterSet const &)
Definition: Py8EGun.cc:36