CMS 3D CMS Logo

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) : Pythia6PartonGun(pset) {
19  // ParameterSet defpset ;
20  ParameterSet pgun_params = pset.getParameter<ParameterSet>("PGunParameters"); //, defpset ) ;
21  fMinEta = pgun_params.getParameter<double>("MinEta"); // ,-2.2);
22  fMaxEta = pgun_params.getParameter<double>("MaxEta"); // , 2.2);
23  fMinPt = pgun_params.getParameter<double>("MinPt"); // , 20.);
24  fMaxPt = pgun_params.getParameter<double>("MaxPt"); // , 420.);
25 }
26 
28 
29 void Pythia6PartonPtGun::generateEvent(CLHEP::HepRandomEngine*) {
30  Pythia6Service::InstanceWrapper guard(fPy6Service); // grab Py6 instance
31 
32  // now actualy, start cooking up the event gun
33  //
34 
35  // 1st, primary vertex
36  //
37  HepMC::GenVertex* Vtx = new HepMC::GenVertex(HepMC::FourVector(0., 0., 0.));
38 
39  // here re-create fEvt (memory)
40  //
41  fEvt = new HepMC::GenEvent();
42 
43  int ip = 1;
44 
45  int py6PID = HepPID::translatePDTtoPythia(fPartonID);
46  int dum = 0;
47  double pt = 0, mom = 0, ee = 0, the = 0, eta = 0;
48  double mass = pymass_(py6PID);
49 
50  // fill p(ip,5) (in PYJETS) with mass value right now,
51  // because the (hardcoded) mstu(10)=1 will make py1ent
52  // pick the mass from there
53  pyjets.p[4][ip - 1] = mass;
54 
55  double phi = (fMaxPhi - fMinPhi) * pyr_(&dum) + fMinPhi;
56 
57  eta = (fMaxEta - fMinEta) * pyr_(&dum) + fMinEta;
58 
59  the = 2. * atan(exp(-eta));
60 
61  pt = (fMaxPt - fMinPt) * pyr_(&dum) + fMinPt;
62 
63  mom = pt / sin(the);
64  ee = sqrt(mom * mom + mass * mass);
65 
66  py1ent_(ip, py6PID, ee, the, phi);
67 
68  double px = pyjets.p[0][ip - 1]; // pt*cos(phi) ;
69  double py = pyjets.p[1][ip - 1]; // pt*sin(phi) ;
70  double pz = pyjets.p[2][ip - 1]; // mom*cos(the) ;
71 
72  HepMC::FourVector p(px, py, pz, ee);
74  Part->suggest_barcode(ip);
75  Vtx->add_particle_out(Part);
76 
77  // now add anti-quark
78  ip = ip + 1;
79  HepMC::GenParticle* APart = addAntiParticle(ip, fPartonID, ee, eta, phi);
80  if (APart) {
81  Vtx->add_particle_out(APart);
82  } else {
83  // otherwise it should throw !
84  }
85 
86  // this should probably be configurable...
87  //
88  double qmax = 2. * ee;
89 
90  joinPartons(qmax);
91 
92  fEvt->add_vertex(Vtx);
93 
94  // run pythia
95  pyexec_();
96 
97  return;
98 }
99 
Pythia6PartonPtGun.h
EDProducer.h
gen::pymass_
double pymass_(int &)
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
multPhiCorr_741_25nsDY_cfi.py
py
Definition: multPhiCorr_741_25nsDY_cfi.py:12
edm
HLT enums.
Definition: AlignableModifier.h:19
gen::pyr_
double pyr_(int *idummy)
Definition: Pythia6Service.cc:59
gen::Pythia6Gun::fEvt
HepMC::GenEvent * fEvt
Definition: Pythia6Gun.h:66
gen::Pythia6PartonPtGun::~Pythia6PartonPtGun
~Pythia6PartonPtGun() override
Definition: Pythia6PartonPtGun.cc:27
gen::Pythia6PartonGun
Definition: Pythia6PartonGun.h:19
gen::Pythia6PartonPtGun::generateEvent
void generateEvent(CLHEP::HepRandomEngine *) override
Definition: Pythia6PartonPtGun.cc:29
gen::Pythia6PartonPtGun::fMaxPt
double fMaxPt
Definition: Pythia6PartonPtGun.h:24
HepMC::GenEvent
Definition: hepmc_rootio.cc:9
gen::pyexec_
void pyexec_()
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
gen::py1ent_
void py1ent_(int &ip, int &kf, double &pe, double &the, double &phi)
MakerMacros.h
gen::Pythia6Gun::addAntiParticle
HepMC::GenParticle * addAntiParticle(int &, int &, double &, double &, double &)
Definition: Pythia6Gun.cc:198
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
PVValHelper::eta
Definition: PVValidationHelpers.h:70
gen::p
double p[5][pyjets_maxn]
Definition: Cascade2Hadronizer.cc:76
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
gen::FortranInstance::InstanceWrapper
Definition: FortranInstance.h:54
gen
Definition: PythiaDecays.h:13
gen::Pythia6Gun::fMaxPhi
double fMaxPhi
Definition: Pythia6Gun.h:62
edm::ParameterSet
Definition: ParameterSet.h:47
gen::Pythia6PartonGun::joinPartons
void joinPartons(double qmax)
Definition: Pythia6PartonGun.cc:23
gen::Pythia6PartonPtGun::fMaxEta
double fMaxEta
Definition: Pythia6PartonPtGun.h:22
gen::Pythia6Gun::fMinPhi
double fMinPhi
Definition: Pythia6Gun.h:61
gen::Pythia6Gun::fPy6Service
Pythia6Service * fPy6Service
Definition: Pythia6Gun.h:56
gen::Pythia6PartonPtGun::fMinPt
double fMinPt
Definition: Pythia6PartonPtGun.h:23
multPhiCorr_741_25nsDY_cfi.px
px
Definition: multPhiCorr_741_25nsDY_cfi.py:10
GenParticle.GenParticle
GenParticle
Definition: GenParticle.py:18
EgHLTOffHistBins_cfi.mass
mass
Definition: EgHLTOffHistBins_cfi.py:34
EventSetup.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
Exception.h
gen::Pythia6PartonPtGun
Definition: Pythia6PartonPtGun.h:12
HepMCProduct.h
gen::Pythia6PartonPtGun::fMinEta
double fMinEta
Definition: Pythia6PartonPtGun.h:21
JetChargeProducer_cfi.exp
exp
Definition: JetChargeProducer_cfi.py:6
gen::Pythia6PartonGun::fPartonID
int fPartonID
Definition: Pythia6PartonGun.h:29
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27