16 #include "CLHEP/Random/RandFlat.h" 17 #include "CLHEP/Units/GlobalSystemOfUnits.h" 18 #include "CLHEP/Units/GlobalPhysicalConstants.h" 19 #include "CLHEP/Random/RandFlat.h" 43 produces<HepMCProduct>(
"unsmeared");
44 produces<GenEventInfoProduct>();
56 LogDebug(
"CloseByParticleGunProducer") <<
" CloseByParticleGunProducer : Begin New Event Generation" << endl;
66 for (
int i = 0;
i < numParticles;
i++) {
68 particles.push_back(
fPartIDs[partIdx]);
72 double fR = CLHEP::RandFlat::shoot(engine,
fRMin,
fRMax);
73 double fZ = CLHEP::RandFlat::shoot(engine,
fZMin,
fZMax);
77 for (
unsigned int ip = 0; ip < particles.size(); ++ip) {
79 fR = CLHEP::RandFlat::shoot(engine, tmpR -
fDelta, tmpR +
fDelta);
80 phi = CLHEP::RandFlat::shoot(engine, tmpPhi -
fDelta / fR, tmpPhi +
fDelta / fR);
84 double fEn = CLHEP::RandFlat::shoot(engine,
fEnMin,
fEnMax);
85 int PartID = particles[ip];
87 double mass = PData->mass().value();
88 double mom2 = fEn * fEn - mass *
mass;
99 double x = fR *
cos(phi);
100 double y = fR *
sin(phi);
102 double timeOffset =
sqrt(x * x + y * y + fZ * fZ) / c * ns * c_light;
103 HepMC::GenVertex* Vtx =
new HepMC::GenVertex(HepMC::FourVector(x * cm, y * cm, fZ * cm, timeOffset));
105 HepMC::FourVector
p(px, py, pz, energy);
110 p.setX(momentum.x());
111 p.setY(momentum.y());
112 p.setZ(momentum.z());
115 Part->suggest_barcode(barcode);
118 Vtx->add_particle_out(Part);
124 fEvt->add_vertex(Vtx);
128 fEvt->set_signal_process_id(20);
135 BProduct->addHepMCData(
fEvt);
142 LogDebug(
"CloseByParticleGunProducer") <<
" CloseByParticleGunProducer : Event Generation Done " << endl;
CloseByParticleGunProducer(const ParameterSet &)
T getParameter(std::string const &) const
EventNumber_t event() const
static unsigned int partIdx(const InputGenJetsParticleSelector::ParticleVector &p, const reco::Candidate *particle)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Sin< T >::type sin(const T &t)
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
ESHandle< HepPDT::ParticleDataTable > fPDGTable
Cos< T >::type cos(const T &t)
Abs< T >::type abs(const T &t)
void produce(Event &e, const EventSetup &es) override
HepPDT::ParticleData ParticleData
~CloseByParticleGunProducer() override
XYZVectorD XYZVector
spatial vector with cartesian internal representation
std::vector< int > fPartIDs
StreamID streamID() const