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";
53 fEvt =
new HepMC::GenEvent() ;
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;
74 PData =
fPDGTable->particle(HepPDT::ParticleID(
abs(PartID))) ;
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 ;
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) ;
92 int APartID = -PartID ;
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::auto_ptr<HepMCProduct> BProduct(
new HepMCProduct()) ;
113 BProduct->addHepMCData(
fEvt );
114 e.
put(BProduct,
"unsmeared");
119 LogDebug(
"ParticleGun") <<
" FlatRandomOneOverPtGunProducer : Event Generation Done ";
T getParameter(std::string const &) const
EventNumber_t event() const
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)
virtual ~FlatRandomOneOverPtGunProducer()
ESHandle< HepPDT::ParticleDataTable > fPDGTable
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Cos< T >::type cos(const T &t)
Abs< T >::type abs(const T &t)
std::vector< int > fPartIDs
virtual void produce(Event &e, const EventSetup &es) override
HepPDT::ParticleData ParticleData
StreamID streamID() const