12 #include "CLHEP/Random/RandFlat.h"
17 class HepRandomEngine;
47 <<
"Beam vertex offset (cm) " << xoff_ <<
":" << yoff_ <<
" and z position " <<
zpos_;
52 fFile_ =
new TFile(infileName.c_str());
68 if ((npart != 0) || (
event != 0) || (pdgid != 0) || (parxx != 0) || (paryy != 0) || (parzz != 0) || (parpx != 0) ||
69 (parpy != 0) || (parpz != 0))
70 throw cms::Exception(
"GenException") <<
"Branch address wrong in i/p file\n";
72 produces<HepMCProduct>(
"unsmeared");
73 produces<GenEventInfoProduct>();
81 edm::LogVerbatim(
"BeamMomentumGun") <<
"BeamMomentumGunProducer : Begin New Event Generation";
93 long int rjentry =
static_cast<long int>(CLHEP::RandFlat::shoot(engine, 0,
nentries_ - 1));
100 for (
unsigned int ip = 0; ip <
parPDGId_->size(); ip++) {
103 double mass = pData->mass().value();
109 HepMC::GenVertex* Vtx =
new HepMC::GenVertex(HepMC::FourVector(xp, yp, zp));
116 double px1 = pxGeV *
cos(phi) - pyGeV *
sin(phi);
117 double py1 = pxGeV *
sin(phi) + pyGeV *
cos(phi);
120 double px = px1 *
cos(theta) + pz1 *
sin(theta);
122 double pz = -px1 *
sin(theta) + pz1 *
cos(theta);
127 edm::LogVerbatim(
"BeamMomentumGun") <<
"px:py:pz [GeV] " << px <<
":" << py <<
":" << pz;
130 HepMC::FourVector
p(px, py, pz, energy);
132 part->suggest_barcode(barcode);
134 Vtx->add_particle_out(part);
137 HepMC::FourVector ap(-px, -py, -pz, energy);
138 int apartID = (partID == 22 || partID == 23) ? partID : -partID;
140 apart->suggest_barcode(barcode);
143 <<
"Add anti-particle " << apartID <<
":" << -px <<
":" << -py <<
":" << -pz;
145 Vtx->add_particle_out(apart);
148 fEvt->add_vertex(Vtx);
152 fEvt->set_signal_process_id(20);
157 std::unique_ptr<HepMCProduct> BProduct(
new HepMCProduct());
158 BProduct->addHepMCData(
fEvt);
165 edm::LogVerbatim(
"BeamMomentumGun") <<
"BeamMomentumGunProducer : Event Generation Done";
Log< level::Info, true > LogVerbatim
EventNumber_t event() const
static constexpr double MeV2GeV_
static constexpr double cm2mm_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
std::vector< float > * parPz_
Sin< T >::type sin(const T &t)
ESHandle< HepPDT::ParticleDataTable > fPDGTable
Geom::Theta< T > theta() const
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
std::vector< float > * parZ_
Cos< T >::type cos(const T &t)
Abs< T >::type abs(const T &t)
void produce(Event &e, const EventSetup &es) override
HepPDT::ParticleData ParticleData
std::vector< float > * parX_
T getParameter(std::string const &) const
std::vector< float > * parPy_
BeamMomentumGunProducer(const ParameterSet &)
std::vector< float > * parY_
StreamID streamID() const
std::vector< int > * parPDGId_
std::string fullPath() const
std::vector< float > * parPx_