13 #include "CLHEP/Random/RandFlat.h" 24 if (fProbParticle_.size() !=
fPartIDs.size())
throw cms::Exception(
"Configuration") <<
"Not all probabilities given for all particle types " << fProbParticle_.size() <<
":" <<
fPartIDs.size() <<
" need them to match\n";
26 produces<HepMCProduct>(
"unsmeared");
27 produces<GenEventInfoProduct>();
30 <<
" particles in momentum range " << fMinP_ <<
":" << fMaxP_
36 for (
unsigned int k=1;
k<fProbParticle_.size(); ++
k)
37 fProbParticle_[
k] += fProbParticle_[
k-1];
38 for (
unsigned int k=0;
k<fProbParticle_.size(); ++
k)
39 fProbParticle_[
k] /= fProbParticle_[fProbParticle_.size()-1];
42 for (
unsigned int k=0;
k<fProbParticle_.size(); ++
k)
58 std::cout <<
"FlatRandomMultiParticlePGunProducer: Begin New Event Generation" << std::endl ;
65 fEvt =
new HepMC::GenEvent() ;
72 HepMC::GenVertex* Vtx =
new HepMC::GenVertex( HepMC::FourVector(0.,0.,0.));
77 double r1 = CLHEP::RandFlat::shoot(engine, 0., 1.);
78 for (
unsigned int ip=0; ip<
fPartIDs.size(); ip++) {
88 double mom = CLHEP::RandFlat::shoot(engine,
fMinP_,
fMaxP_);
93 double mass = PData->mass().value() ;
94 double energy =
sqrt(mom*mom + mass*mass);
96 double px = mom*
sin(theta)*
cos(phi);
97 double py = mom*
sin(theta)*
sin(phi);
98 double pz = mom*
cos(theta);
100 HepMC::FourVector
p(px,py,pz,energy) ;
103 Part->suggest_barcode(barcode);
104 Vtx->add_particle_out(Part);
107 HepMC::FourVector ap(-px,-py,-pz,energy) ;
108 int APartID = (PartID == 22 || PartID == 23) ? PartID : -PartID;
111 APart->suggest_barcode(barcode);
112 Vtx->add_particle_out(APart);
115 fEvt->add_vertex(Vtx) ;
117 fEvt->set_signal_process_id(20) ;
123 std::unique_ptr<HepMCProduct> BProduct(
new HepMCProduct()) ;
124 BProduct->addHepMCData(
fEvt );
131 std::cout <<
" FlatRandomMultiParticlePGunProducer : 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.
virtual ~FlatRandomMultiParticlePGunProducer()
Sin< T >::type sin(const T &t)
FlatRandomMultiParticlePGunProducer(const ParameterSet &pset)
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)
Abs< T >::type abs(const T &t)
std::vector< int > fPartIDs
HepPDT::ParticleData ParticleData
std::vector< double > fProbParticle_
StreamID streamID() const
virtual void produce(Event &e, const EventSetup &es) override