13 #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>();
31 std::cout <<
"Internal FlatRandomPGun is initialzed for " <<
fPartIDs.size() <<
" particles in momentum range " 32 << fMinP_ <<
":" << fMaxP_ << std::endl;
37 for (
unsigned int k = 1;
k < fProbParticle_.size(); ++
k)
38 fProbParticle_[
k] += fProbParticle_[
k - 1];
39 for (
unsigned int k = 0;
k < fProbParticle_.size(); ++
k)
40 fProbParticle_[
k] /= fProbParticle_[fProbParticle_.size() - 1];
43 for (
unsigned int k = 0;
k < fProbParticle_.size(); ++
k)
57 std::cout <<
"FlatRandomMultiParticlePGunProducer: Begin New Event Generation" << std::endl;
71 HepMC::GenVertex* Vtx =
new HepMC::GenVertex(HepMC::FourVector(0., 0., 0.));
76 double r1 = CLHEP::RandFlat::shoot(engine, 0., 1.);
77 for (
unsigned int ip = 0; ip <
fPartIDs.size(); ip++) {
85 std::cout <<
"Random " << r1 <<
" PartID " << PartID << std::endl;
87 double mom = CLHEP::RandFlat::shoot(engine,
fMinP_,
fMaxP_);
91 double mass = PData->mass().value();
94 double px = mom *
sin(theta) *
cos(phi);
95 double py = mom *
sin(theta) *
sin(phi);
96 double pz = mom *
cos(theta);
98 HepMC::FourVector
p(px, py, pz, energy);
101 Part->suggest_barcode(barcode);
102 Vtx->add_particle_out(Part);
105 HepMC::FourVector ap(-px, -py, -pz, energy);
106 int APartID = (PartID == 22 || PartID == 23) ? PartID : -PartID;
109 APart->suggest_barcode(barcode);
110 Vtx->add_particle_out(APart);
113 fEvt->add_vertex(Vtx);
115 fEvt->set_signal_process_id(20);
122 std::unique_ptr<HepMCProduct> BProduct(
new HepMCProduct());
123 BProduct->addHepMCData(
fEvt);
130 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.
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
~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_
StreamID streamID() const
void produce(Event &e, const EventSetup &es) override