CMS 3D CMS Logo

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