16 #include "CLHEP/Random/RandFlat.h"
17 #include "CLHEP/Units/GlobalSystemOfUnits.h"
18 #include "CLHEP/Units/GlobalPhysicalConstants.h"
19 #include "CLHEP/Random/RandFlat.h"
30 if (fControlledByEta) {
34 LogError(
"CloseByParticleGunProducer") <<
" Please fix MinEta and MaxEta values in the configuration";
39 LogError(
"CloseByParticleGunProducer") <<
" Please fix RMin and RMax values in the configuration";
52 produces<HepMCProduct>(
"unsmeared");
53 produces<GenEventInfoProduct>();
65 LogDebug(
"CloseByParticleGunProducer") <<
" CloseByParticleGunProducer : Begin New Event Generation" << endl;
73 double fZ = CLHEP::RandFlat::shoot(engine,
fZMin,
fZMax);
77 fR = CLHEP::RandFlat::shoot(engine,
fRMin,
fRMax);
80 fR = (fZ / sinh(fEta));
87 for (
unsigned int ip = 0; ip < numParticles; ++ip) {
89 fR = CLHEP::RandFlat::shoot(engine, tmpR -
fDelta, tmpR +
fDelta);
90 phi = CLHEP::RandFlat::shoot(engine, tmpPhi -
fDelta / fR, tmpPhi +
fDelta / fR);
103 double mass = PData->mass().value();
104 double mom2 = fEn * fEn - mass *
mass;
115 double x = fR *
cos(phi);
116 double y = fR *
sin(phi);
117 constexpr
double c = 2.99792458e+1;
118 double timeOffset =
sqrt(x * x + y * y + fZ * fZ) / c * ns * c_light;
119 HepMC::GenVertex* Vtx =
new HepMC::GenVertex(HepMC::FourVector(x * cm, y * cm, fZ * cm, timeOffset));
121 HepMC::FourVector
p(px, py, pz, energy);
126 p.setX(momentum.x());
127 p.setY(momentum.y());
128 p.setZ(momentum.z());
131 Part->suggest_barcode(barcode);
134 Vtx->add_particle_out(Part);
140 fEvt->add_vertex(Vtx);
144 fEvt->set_signal_process_id(20);
151 BProduct->addHepMCData(
fEvt);
158 LogDebug(
"CloseByParticleGunProducer") <<
" CloseByParticleGunProducer : Event Generation Done " << endl;
CloseByParticleGunProducer(const ParameterSet &)
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.
const edm::EventSetup & c
Sin< T >::type sin(const T &t)
Log< level::Error, false > LogError
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
T getParameter(std::string const &) const
std::vector< int > fPartIDs
StreamID streamID() const