14 #include "CLHEP/Random/RandFlat.h"
24 if (fProbParticle_.size() !=
fPartIDs.size())
25 throw cms::Exception(
"Configuration") <<
"Not all probabilities given for all particle types "
26 << fProbParticle_.size() <<
":" <<
fPartIDs.size() <<
" need them to match\n";
28 produces<HepMCProduct>(
"unsmeared");
29 produces<GenEventInfoProduct>();
32 <<
" 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];
51 edm::LogVerbatim(
"ParticleGun") <<
"FlatRandomMultiParticlePGunProducer: Begin New Event Generation";
64 HepMC::GenVertex* Vtx =
new HepMC::GenVertex(HepMC::FourVector(0., 0., 0.));
69 double r1 = CLHEP::RandFlat::shoot(engine, 0., 1.);
70 for (
unsigned int ip = 0; ip <
fPartIDs.size(); ip++) {
78 double mom = CLHEP::RandFlat::shoot(engine,
fMinP_,
fMaxP_);
82 double mass = PData->mass().value();
85 double px = mom *
sin(theta) *
cos(phi);
86 double py = mom *
sin(theta) *
sin(phi);
87 double pz = mom *
cos(theta);
89 HepMC::FourVector
p(px, py, pz, energy);
92 Part->suggest_barcode(barcode);
93 Vtx->add_particle_out(Part);
96 HepMC::FourVector ap(-px, -py, -pz, energy);
97 int APartID = (PartID == 22 || PartID == 23) ? PartID : -PartID;
100 APart->suggest_barcode(barcode);
101 Vtx->add_particle_out(APart);
104 fEvt->add_vertex(Vtx);
106 fEvt->set_signal_process_id(20);
111 std::unique_ptr<HepMCProduct> BProduct(
new HepMCProduct());
112 BProduct->addHepMCData(
fEvt);
119 edm::LogVerbatim(
"ParticleGun") <<
" FlatRandomMultiParticlePGunProducer : Event Generation Done";
Log< level::Info, true > LogVerbatim
EventNumber_t event() const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Sin< T >::type sin(const T &t)
FlatRandomMultiParticlePGunProducer(const ParameterSet &pset)
Geom::Theta< T > theta() const
Exp< T >::type exp(const T &t)
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
ESHandle< HepPDT::ParticleDataTable > fPDGTable
~FlatRandomMultiParticlePGunProducer() override
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_
T getParameter(std::string const &) const
StreamID streamID() const
void produce(Event &e, const EventSetup &es) override