14 #include "CLHEP/Random/RandFlat.h" 26 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";
28 produces<HepMCProduct>(
"unsmeared");
29 produces<GenEventInfoProduct>();
34 <<
fPartIDs.size() <<
" particles in " 35 << fBinsP_ <<
" bins within momentum range " 36 << fMinP_ <<
":" <<
fMaxP_;
44 <<
" --> " << fProbP_[
k];
47 for (
unsigned int k=1;
k<fProbParticle_.size(); ++
k)
48 fProbParticle_[
k] += fProbParticle_[
k-1];
49 for (
unsigned int k=0;
k<fProbParticle_.size(); ++
k)
50 fProbParticle_[
k] /= fProbParticle_[fProbParticle_.size()-1];
53 for (
unsigned int k=0;
k<fProbParticle_.size(); ++
k)
57 fProbP_[
k] += fProbP_[
k-1];
59 fProbP_[
k] /= fProbP_[fBinsP_-1];
65 <<
" --> " << fProbP_[
k];
79 <<
"Begin New Event Generation";
86 fEvt =
new HepMC::GenEvent() ;
93 HepMC::GenVertex* Vtx =
new HepMC::GenVertex( HepMC::FourVector(0.,0.,0.));
98 double r1 = CLHEP::RandFlat::shoot(engine, 0., 1.);
99 for (
unsigned int ip=0; ip<
fPartIDs.size(); ip++) {
106 double r2 = CLHEP::RandFlat::shoot(engine, 0., 1.);
107 for (
int ip=0; ip<
fBinsP_; ip++) {
117 <<
" and for p " << r2 <<
" range " << minP
120 double mom = CLHEP::RandFlat::shoot(engine, minP, maxP);
125 double mass = PData->mass().value() ;
126 double energy =
sqrt(mom*mom + mass*mass);
128 double px = mom*
sin(theta)*
cos(phi);
129 double py = mom*
sin(theta)*
sin(phi);
130 double pz = mom*
cos(theta);
132 HepMC::FourVector
p(px,py,pz,energy) ;
135 Part->suggest_barcode(barcode);
136 Vtx->add_particle_out(Part);
139 HepMC::FourVector ap(-px,-py,-pz,energy) ;
140 int APartID = (PartID == 22 || PartID == 23) ? PartID : -PartID;
143 APart->suggest_barcode(barcode);
144 Vtx->add_particle_out(APart);
147 fEvt->add_vertex(Vtx) ;
149 fEvt->set_signal_process_id(20) ;
155 std::unique_ptr<HepMCProduct> BProduct(
new HepMCProduct()) ;
156 BProduct->addHepMCData(
fEvt );
163 edm::LogVerbatim(
"IOMC") <<
" RandomMultiParticlePGunProducer : 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< double > fProbParticle_
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.
RandomMultiParticlePGunProducer(const ParameterSet &pset)
void produce(Event &e, const EventSetup &es) override
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
StreamID streamID() const
std::vector< double > fProbP_