18 #include "CLHEP/Random/RandFlat.h" 35 produces<HepMCProduct>(
"unsmeared");
36 produces<GenEventInfoProduct>();
52 std::cout <<
" ExpoRandomPGunProducer : Begin New Event Generation" 63 fEvt =
new HepMC::GenEvent() ;
70 HepMC::GenVertex* Vtx =
new HepMC::GenVertex(HepMC::FourVector(0.,0.,0.));
75 for (
unsigned int ip=0; ip<
fPartIDs.size(); ++ip)
78 double pmom = CLHEP::RandFlat::shoot(engine,
fMinP,
fMaxP);
79 double y = (1./
fMinP) * CLHEP::RandFlat::shoot(engine, 0.0, 1.0);
81 bool accpt = ( y <
f);
83 while ((pmom < fMinP || pmom >
fMaxP) || !accpt)
85 pmom = CLHEP::RandFlat::shoot(engine,
fMinP, fMaxP);
86 y = (1./
fMinP) * CLHEP::RandFlat::shoot(engine, 0.0, 1.0);
97 double mass = PData->mass().value() ;
100 double pt = mom *
sin(theta);
101 double px = pt *
cos(phi) ;
102 double py = pt *
sin(phi) ;
103 double pz = mom*
cos(theta) ;
104 double energy2= mom*mom + mass*
mass ;
105 double energy =
sqrt(energy2) ;
109 HepMC::FourVector
p(px,py,pz,energy) ;
112 Part->suggest_barcode( barcode ) ;
114 Vtx->add_particle_out(Part);
119 HepMC::FourVector ap(-px,-py,-pz,energy) ;
121 if ( PartID == 22 || PartID == 23 )
129 APart->suggest_barcode( barcode ) ;
131 Vtx->add_particle_out(APart) ;
136 fEvt->add_vertex(Vtx) ;
138 fEvt->set_signal_process_id(20) ;
146 BProduct->addHepMCData(
fEvt );
156 std::cout <<
" FlatRandomPGunProducer : Event Generation Done " << std::endl;
T getParameter(std::string const &) const
EventNumber_t event() const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
void produce(Event &e, const EventSetup &es) override
Sin< T >::type sin(const T &t)
Geom::Theta< T > theta() const
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
ESHandle< HepPDT::ParticleDataTable > fPDGTable
Cos< T >::type cos(const T &t)
ExpoRandomPGunProducer(const ParameterSet &pset)
Abs< T >::type abs(const T &t)
std::vector< int > fPartIDs
HepPDT::ParticleData ParticleData
~ExpoRandomPGunProducer() override
StreamID streamID() const