17 #include "CLHEP/Random/RandFlat.h"
46 produces<HepMCProduct>(
"unsmeared");
47 produces<GenEventInfoProduct>();
62 cout <<
" MultiParticleInConeGunProducer : Begin New Event Generation" << endl ;
71 fEvt =
new HepMC::GenEvent() ;
78 HepMC::GenVertex* Vtx =
new HepMC::GenVertex(HepMC::FourVector(0.,0.,0.));
83 for (
unsigned int ip=0; ip<
fPartIDs.size(); ++ip)
91 PData =
fPDGTable->particle(HepPDT::ParticleID(
abs(PartID))) ;
92 double mass = PData->mass().value() ;
94 double mom = pt/
sin(theta) ;
95 double px = pt*
cos(phi) ;
96 double py = pt*
sin(phi) ;
97 double pz = mom*
cos(theta) ;
98 double energy2= mom*mom + mass*mass ;
101 HepMC::FourVector
p(px,py,pz,energy) ;
104 Part->suggest_barcode( barcode ) ;
106 Vtx->add_particle_out(Part);
111 for (
unsigned iPic=0; iPic!=
fInConeIds.size();iPic++){
117 double alpha = CLHEP::RandFlat::shoot(engine, -3.14159265358979323846, 3.14159265358979323846);
118 double dEta = dR*
cos(alpha);
127 double etaIc = eta+dEta;
128 double phiIc = phi+
dPhi;
130 const unsigned int maxL=100;
133 if (phiIc > 3.14159265358979323846) phiIc-=2*3.14159265358979323846;
134 else if(phiIc <-3.14159265358979323846) phiIc+=2*3.14159265358979323846;
136 if (
abs(phiIc)<3.14159265358979323846)
break;
149 cout <<
" MultiParticleInConeGunProducer : could not produce a particle "
159 PDataIc =
fPDGTable->particle(HepPDT::ParticleID(
abs(PartIDIc)));
163 double massIc= PDataIc->mass().value() ;
164 double momIc = momR * mom;
165 double energyIc =
sqrt(momIc*momIc + massIc*massIc);
167 double thetaIc = 2.*atan(
exp(-etaIc)) ;
168 double pxIc = momIc*
sin(thetaIc)*
cos(phiIc);
169 double pyIc = momIc*
sin(thetaIc)*
sin(phiIc);
170 double pzIc = momIc*
cos(thetaIc);
172 HepMC::FourVector pIc(pxIc,pyIc,pzIc,energyIc) ;
174 PartIc->suggest_barcode( barcode ) ;
176 Vtx->add_particle_out(PartIc);
182 fEvt->add_vertex(Vtx) ;
184 fEvt->set_signal_process_id(20) ;
192 BProduct->addHepMCData(
fEvt );
193 e.
put(BProduct,
"unsmeared");
200 cout <<
" MultiParticleInConeGunProducer : Event Generation Done " << endl;
T getParameter(std::string const &) const
EventNumber_t event() const
unsigned int fInConeMaxTry
Sin< T >::type sin(const T &t)
Geom::Theta< T > theta() const
std::vector< int > fInConeIds
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
MultiParticleInConeGunProducer(const ParameterSet &)
ESHandle< HepPDT::ParticleDataTable > fPDGTable
double dPhi(double phi1, double phi2)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
virtual 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
StreamID streamID() const
virtual ~MultiParticleInConeGunProducer()