17 #include "CLHEP/Random/RandFlat.h" 18 #include "CLHEP/Units/GlobalSystemOfUnits.h" 19 #include "CLHEP/Units/GlobalPhysicalConstants.h" 20 #include "CLHEP/Random/RandFlat.h" 32 LogError(
"CloseByParticleGunProducer") <<
" Please choose a minimum energy greater than 1 GeV, otherwise time " 33 "information may be invalid or not reliable";
40 LogError(
"CloseByParticleGunProducer") <<
" Please fix MinEta and MaxEta values in the configuration";
45 LogError(
"CloseByParticleGunProducer") <<
" Please fix RMin and RMax values in the configuration";
63 LogError(
"CloseByParticleGunProducer") <<
" Please fix TMin and TMax values in the configuration";
67 produces<HepMCProduct>(
"unsmeared");
68 produces<GenEventInfoProduct>();
77 desc.add<
bool>(
"AddAntiParticle",
false);
80 psd0.
add<
bool>(
"ControlledByEta",
false);
81 psd0.
add<
double>(
"Delta", 10);
82 psd0.
add<
double>(
"EnMax", 200.0);
83 psd0.
add<
double>(
"EnMin", 25.0);
84 psd0.
add<
bool>(
"MaxEnSpread",
false);
85 psd0.
add<
double>(
"MaxEta", 2.7);
86 psd0.
add<
double>(
"MaxPhi", 3.14159265359);
87 psd0.
add<
double>(
"MinEta", 1.7);
88 psd0.
add<
double>(
"MinPhi", -3.14159265359);
89 psd0.
add<
int>(
"NParticles", 2);
90 psd0.
add<
bool>(
"Overlapping",
false);
91 psd0.
add<std::vector<int>>(
"PartID",
95 psd0.
add<
bool>(
"Pointing",
true);
96 psd0.
add<
double>(
"RMax", 120);
97 psd0.
add<
double>(
"RMin", 60);
98 psd0.
add<
bool>(
"RandomShoot",
false);
99 psd0.
add<
double>(
"ZMax", 321);
100 psd0.
add<
double>(
"ZMin", 320);
101 psd0.
add<
bool>(
"UseDeltaT",
false);
102 psd0.
add<
double>(
"TMin", 0.);
103 psd0.
add<
double>(
"TMax", 0.05);
104 psd0.
add<
double>(
"OffsetFirst", 0.);
107 desc.addUntracked<
int>(
"Verbosity", 0);
108 desc.addUntracked<
unsigned int>(
"firstRun", 1);
109 desc.add<
std::string>(
"psethack",
"random particles in phi and r windows");
110 descriptions.
add(
"CloseByParticleGunProducer",
desc);
115 CLHEP::HepRandomEngine* engine = &rng->
getEngine(
e.streamID());
118 LogDebug(
"CloseByParticleGunProducer") <<
" CloseByParticleGunProducer : Begin New Event Generation" << endl;
128 double fZ = CLHEP::RandFlat::shoot(engine,
fZMin,
fZMax);
149 for (
unsigned int ip = 0; ip < numParticles; ++ip) {
151 fR = CLHEP::RandFlat::shoot(engine, tmpR -
fDelta, tmpR +
fDelta);
152 phi = CLHEP::RandFlat::shoot(engine, tmpPhi -
fDelta /
fR, tmpPhi +
fDelta /
fR);
165 double mass = PData->mass().value();
166 double mom2 = fEn * fEn -
mass *
mass;
178 double y =
fR *
sin(phi);
185 p.setX(momentum.x());
186 p.setY(momentum.y());
187 p.setZ(momentum.z());
191 double pathLength = 0.;
192 const double speed =
p.pz() /
p.e() * c_light / cm;
193 if (PData->charge()) {
196 (c_light * field.inTesla({0.f, 0.f, 0.f}).z());
198 pathLength =
std::sqrt(arc * arc + fZ * fZ);
207 HepMC::GenVertex* Vtx =
new HepMC::GenVertex(HepMC::FourVector(
x * cm, y * cm, fZ * cm,
timeOffset));
210 Part->suggest_barcode(barcode);
213 Vtx->add_particle_out(Part);
219 fEvt->add_vertex(Vtx);
222 fEvt->set_event_number(
e.id().event());
223 fEvt->set_signal_process_id(20);
230 BProduct->addHepMCData(
fEvt);
237 LogDebug(
"CloseByParticleGunProducer") <<
" CloseByParticleGunProducer : Event Generation Done " << endl;
CloseByParticleGunProducer(const ParameterSet &)
static void fillDescriptions(ConfigurationDescriptions &descriptions)
T getParameter(std::string const &) const
static unsigned int partIdx(const InputGenJetsParticleSelector::ParticleVector &p, const reco::Candidate *particle)
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
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.
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > m_fieldToken
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
ParameterDescriptionBase * add(U const &iLabel, T const &value)
HepPDT::ParticleData ParticleData
~CloseByParticleGunProducer() override
XYZVectorD XYZVector
spatial vector with cartesian internal representation
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::vector< int > fPartIDs
Power< A, B >::type pow(const A &a, const B &b)