13 #include "CLHEP/Random/RandFlat.h" 18 class HepRandomEngine;
48 <<
"Beam vertex offset (cm) " << xoff_ <<
":" << yoff_ <<
" and z position " <<
zpos_;
53 fFile_ =
new TFile(infileName.c_str());
69 if ((npart != 0) || (
event != 0) || (pdgid != 0) || (parxx != 0) || (paryy != 0) || (parzz != 0) || (parpx != 0) ||
70 (parpy != 0) || (parpz != 0))
71 throw cms::Exception(
"GenException") <<
"Branch address wrong in i/p file\n";
73 produces<HepMCProduct>(
"unsmeared");
74 produces<GenEventInfoProduct>();
82 edm::LogVerbatim(
"BeamMomentumGun") <<
"BeamMomentumGunProducer : Begin New Event Generation";
94 long int rjentry =
static_cast<long int>(CLHEP::RandFlat::shoot(engine, 0,
nentries_ - 1));
101 for (
unsigned int ip = 0; ip <
parPDGId_->size(); ip++) {
104 double mass = pData->mass().value();
109 HepMC::GenVertex* Vtx =
new HepMC::GenVertex(HepMC::FourVector(xp, yp,
zpos_));
113 double momRand2 = pxGeV * pxGeV + pyGeV * pyGeV + pzGeV * pzGeV;
118 double px = mom *
sin(theta) *
cos(phi);
119 double py = mom *
sin(theta) *
sin(phi);
120 double pz = mom *
cos(theta);
123 edm::LogVerbatim(
"BeamMomentumGun") <<
"px:py:pz " << px <<
":" << py <<
":" << pz;
125 HepMC::FourVector
p(px, py, pz, energy);
127 part->suggest_barcode(barcode);
129 Vtx->add_particle_out(part);
132 HepMC::FourVector ap(-px, -py, -pz, energy);
133 int apartID = (partID == 22 || partID == 23) ? partID : -partID;
135 apart->suggest_barcode(barcode);
138 <<
"Add anti-particle " << apartID <<
":" << -px <<
":" << -py <<
":" << -pz;
140 Vtx->add_particle_out(apart);
143 fEvt->add_vertex(Vtx);
147 fEvt->set_signal_process_id(20);
152 std::unique_ptr<HepMCProduct> BProduct(
new HepMCProduct());
153 BProduct->addHepMCData(
fEvt);
160 edm::LogVerbatim(
"BeamMomentumGun") <<
"BeamMomentumGunProducer : Event Generation Done";
T getParameter(std::string const &) const
EventNumber_t event() const
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_
std::vector< float > * parPy_
std::vector< float > * parY_
StreamID streamID() const
std::vector< int > * parPDGId_
std::string fullPath() const
std::vector< float > * parPx_