14 #include "CLHEP/Random/RandFlat.h" 18 const unsigned int np = 6;
29 produces<HepMCProduct>(
"unsmeared");
30 produces<GenEventInfoProduct>();
31 edm::LogVerbatim(
"ParticleGun") <<
"FileRandomMultiParticlePGun is initialzed with i/p file " <<
file 32 <<
" and use momentum range " <<
fMinP_ <<
":" <<
fMaxP_;
47 for (
int ip = 0; ip <
fPBin_; ++ip) {
48 for (
int ie = 0; ie <
fEtaBin_; ++ie) {
50 std::vector<double>
prob(
np, 0);
55 for (
unsigned int k = 0;
k <
np; ++
k) {
60 for (
unsigned int k = 0;
k <
np; ++
k)
62 int indx = (ip + 1) *
kfactor + ie;
66 <<
"FileRandomMultiParticlePGun [" << ip <<
"," << ie <<
", " << indx <<
"] Probability " <<
prob[0]
78 CLHEP::HepRandomEngine* engine = &rng->
getEngine(
e.streamID());
81 edm::LogVerbatim(
"ParticleGun") <<
"FileRandomMultiParticlePGunProducer: Begin New Event Generation";
94 HepMC::GenVertex* Vtx =
new HepMC::GenVertex(HepMC::FourVector(0., 0., 0.));
97 double mom = CLHEP::RandFlat::shoot(engine,
fMinP_,
fMaxP_);
102 if (ipp ==
fP_.end())
104 int ip =
static_cast<int>(ipp -
fP_.begin());
107 edm::LogVerbatim(
"ParticleGun") <<
"FileRandomMultiParticlePGunProducer: p " << mom <<
" Eta " <<
eta <<
" Phi " 108 << phi <<
" Index " << indx;
112 int barcode(0), partID(
fPartIDs[0]);
113 double r1 = CLHEP::RandFlat::shoot(engine, 0., 1.);
114 for (
unsigned int ip = 0; ip <
fPartIDs.size(); ip++) {
122 double mass = PData->mass().value();
132 Part->suggest_barcode(barcode);
133 Vtx->add_particle_out(Part);
135 fEvt->add_vertex(Vtx);
136 fEvt->set_event_number(
e.id().event());
137 fEvt->set_signal_process_id(20);
142 std::unique_ptr<HepMCProduct> BProduct(
new HepMCProduct());
143 BProduct->addHepMCData(
fEvt);
149 edm::LogVerbatim(
"ParticleGun") <<
"FileRandomMultiParticlePGunProducer : Event Generation Done";
Log< level::Info, true > LogVerbatim
T getParameter(std::string const &) const
Sin< T >::type sin(const T &t)
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
void produce(Event &e, const EventSetup &es) override
ESHandle< HepPDT::ParticleDataTable > fPDGTable
Cos< T >::type cos(const T &t)
std::vector< int > fPartIDs
HepPDT::ParticleData ParticleData
std::vector< double > fP_
~FileRandomMultiParticlePGunProducer() override
FileRandomMultiParticlePGunProducer(const ParameterSet &pset)
std::map< int, std::vector< double > > fProbParticle_
const unsigned int kfactor
Geom::Theta< T > theta() const