14 #include "CLHEP/Random/RandFlat.h" 15 #include "CLHEP/Units/GlobalSystemOfUnits.h" 29 produces<HepMCProduct>(
"unsmeared");
30 produces<GenEventInfoProduct>();
32 edm::LogInfo(
"ParticleGun") <<
"FlatRandomOneOverPtGunProducer: initialized with minimum and maximum 1/pt " << fMinOneOverPt <<
":" <<
fMaxOneOverPt;
44 LogDebug(
"ParticleGun") <<
" FlatRandomOneOverPtGunProducer : Begin New Event Generation";
59 HepMC::GenVertex* Vtx =
new HepMC::GenVertex(HepMC::FourVector(0.,0.,0.));
64 for (
unsigned int ip=0; ip<
fPartIDs.size(); ++ip) {
66 double xx = CLHEP::RandFlat::shoot(engine, 0.0, 1.0);
71 if (pt != 0) pt = 1./
pt;
75 double mass = PData->mass().value() ;
77 double mom = pt/
sin(theta) ;
78 double px = pt*
cos(phi) ;
79 double py = pt*
sin(phi) ;
80 double pz = mom*
cos(theta) ;
81 double energy2= mom*mom + mass*
mass ;
82 double energy =
sqrt(energy2) ;
83 HepMC::FourVector
p(px,py,pz,energy) ;
85 Part->suggest_barcode( barcode ) ;
87 Vtx->add_particle_out(Part);
88 LogDebug(
"ParticleGun") <<
"FlatRandomOneOverPtGunProducer: Event generated with pt:eta:phi " << pt <<
" " << eta <<
" " << phi <<
" (" << theta/CLHEP::deg <<
":" << phi/CLHEP::deg <<
")";
91 HepMC::FourVector ap(-px,-py,-pz,energy) ;
93 if ( PartID == 22 || PartID == 23 ) {
97 APart->suggest_barcode( barcode ) ;
99 Vtx->add_particle_out(APart) ;
104 fEvt->add_vertex(Vtx) ;
106 fEvt->set_signal_process_id(20) ;
112 std::unique_ptr<HepMCProduct> BProduct(
new HepMCProduct()) ;
113 BProduct->addHepMCData(
fEvt );
119 LogDebug(
"ParticleGun") <<
" FlatRandomOneOverPtGunProducer : 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.
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.
FlatRandomOneOverPtGunProducer(const ParameterSet &pset)
ESHandle< HepPDT::ParticleDataTable > fPDGTable
Cos< T >::type cos(const T &t)
Abs< T >::type abs(const T &t)
std::vector< int > fPartIDs
void produce(Event &e, const EventSetup &es) override
~FlatRandomOneOverPtGunProducer() override
HepPDT::ParticleData ParticleData
StreamID streamID() const