17 #include "CLHEP/Random/RandFlat.h"
41 produces<HepMCProduct>(
"unsmeared");
42 produces<GenEventInfoProduct>();
54 cout <<
" MultiParticleInConeGunProducer : Begin New Event Generation" << endl;
70 HepMC::GenVertex* Vtx =
new HepMC::GenVertex(HepMC::FourVector(0., 0., 0.));
75 for (
unsigned int ip = 0; ip <
fPartIDs.size(); ++ip) {
81 double mass = PData->mass().value();
83 double mom = pt /
sin(theta);
84 double px = pt *
cos(phi);
85 double py = pt *
sin(phi);
86 double pz = mom *
cos(theta);
87 double energy2 = mom * mom + mass *
mass;
90 HepMC::FourVector
p(px, py, pz, energy);
92 Part->suggest_barcode(barcode);
94 Vtx->add_particle_out(Part);
100 for (
unsigned iPic = 0; iPic !=
fInConeIds.size(); iPic++) {
101 unsigned int nTry = 0;
106 double alpha = CLHEP::RandFlat::shoot(engine, -3.14159265358979323846, 3.14159265358979323846);
107 double dEta = dR *
cos(alpha);
108 double dPhi = dR *
sin(alpha);
116 double etaIc = eta + dEta;
117 double phiIc = phi + dPhi;
119 const unsigned int maxL = 100;
121 while (iL++ < maxL) {
122 if (phiIc > 3.14159265358979323846)
123 phiIc -= 2 * 3.14159265358979323846;
124 else if (phiIc < -3.14159265358979323846)
125 phiIc += 2 * 3.14159265358979323846;
127 if (
abs(phiIc) < 3.14159265358979323846)
140 cout <<
" MultiParticleInConeGunProducer : could not produce a particle " <<
fInConeIds[iPic] <<
" in cone "
152 double massIc = PDataIc->mass().value();
153 double momIc = momR * mom;
154 double energyIc =
sqrt(momIc * momIc + massIc * massIc);
156 double thetaIc = 2. * atan(
exp(-etaIc));
157 double pxIc = momIc *
sin(thetaIc) *
cos(phiIc);
158 double pyIc = momIc *
sin(thetaIc) *
sin(phiIc);
159 double pzIc = momIc *
cos(thetaIc);
161 HepMC::FourVector pIc(pxIc, pyIc, pzIc, energyIc);
163 PartIc->suggest_barcode(barcode);
165 Vtx->add_particle_out(PartIc);
171 fEvt->add_vertex(Vtx);
173 fEvt->set_signal_process_id(20);
180 BProduct->addHepMCData(
fEvt);
187 cout <<
" MultiParticleInConeGunProducer : Event Generation Done " << endl;
EventNumber_t event() const
unsigned int fInConeMaxTry
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Sin< T >::type sin(const T &t)
Geom::Theta< T > theta() const
Exp< T >::type exp(const T &t)
std::vector< int > fInConeIds
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
MultiParticleInConeGunProducer(const ParameterSet &)
ESHandle< HepPDT::ParticleDataTable > fPDGTable
void produce(Event &e, const EventSetup &es) override
Cos< T >::type cos(const T &t)
Abs< T >::type abs(const T &t)
std::vector< int > fPartIDs
HepPDT::ParticleData ParticleData
T getParameter(std::string const &) const
~MultiParticleInConeGunProducer() override
StreamID streamID() const