12 #include "CLHEP/Random/RandFlat.h" 17 class HepRandomEngine;
47 <<
"Beam vertex offset (cm) " <<
xoff_ <<
":" <<
yoff_ <<
" and z position " <<
zpos_;
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";
84 CLHEP::HepRandomEngine* engine = &rng->
getEngine(
e.streamID());
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);
132 part->suggest_barcode(barcode);
134 Vtx->add_particle_out(
part);
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);
151 fEvt->set_event_number(
e.id().event());
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
static constexpr double MeV2GeV_
T getParameter(std::string const &) const
static constexpr double cm2mm_
std::vector< float > * parPz_
Sin< T >::type sin(const T &t)
ESHandle< HepPDT::ParticleDataTable > fPDGTable
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_
std::vector< float > * parPy_
BeamMomentumGunProducer(const ParameterSet &)
std::vector< float > * parY_
std::vector< int > * parPDGId_
Geom::Theta< T > theta() const
std::vector< float > * parPx_