17 #include <CLHEP/Random/RandFlat.h> 18 #include <CLHEP/Units/SystemOfUnits.h> 19 #include <CLHEP/Units/GlobalPhysicalConstants.h> 20 #include <CLHEP/Random/RandFlat.h> 34 LogError(
"CloseByParticleGunProducer") <<
" Please choose a minimum energy greater than 1 GeV, otherwise time " 35 "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";
55 LogError(
"CloseByParticleGunProducer")
56 <<
" Can't generate non pointing FlatPt samples; please disable FlatPt generation or generate pointing sample";
66 LogError(
"CloseByParticleGunProducer") <<
" Please fix TMin and TMax values in the configuration";
70 produces<HepMCProduct>(
"unsmeared");
71 produces<GenEventInfoProduct>();
80 desc.add<
bool>(
"AddAntiParticle",
false);
83 psd0.
add<
bool>(
"ControlledByEta",
false);
84 psd0.
add<
double>(
"Delta", 10);
85 psd0.
add<
double>(
"VarMax", 200.0);
86 psd0.
add<
double>(
"VarMin", 25.0);
87 psd0.
add<
bool>(
"MaxVarSpread",
false);
88 psd0.
add<
bool>(
"FlatPtGeneration",
false);
89 psd0.
add<
double>(
"MaxEta", 2.7);
90 psd0.
add<
double>(
"MaxPhi", 3.14159265359);
91 psd0.
add<
double>(
"MinEta", 1.7);
92 psd0.
add<
double>(
"MinPhi", -3.14159265359);
93 psd0.
add<
int>(
"NParticles", 2);
94 psd0.
add<
bool>(
"Overlapping",
false);
95 psd0.
add<std::vector<int>>(
"PartID",
99 psd0.
add<
bool>(
"Pointing",
true);
100 psd0.
add<
double>(
"RMax", 120);
101 psd0.
add<
double>(
"RMin", 60);
102 psd0.
add<
bool>(
"RandomShoot",
false);
103 psd0.
add<
double>(
"ZMax", 321);
104 psd0.
add<
double>(
"ZMin", 320);
105 psd0.
add<
bool>(
"UseDeltaT",
false);
106 psd0.
add<
double>(
"TMin", 0.);
107 psd0.
add<
double>(
"TMax", 0.05);
108 psd0.
add<
double>(
"OffsetFirst", 0.);
111 desc.addUntracked<
int>(
"Verbosity", 0);
112 desc.addUntracked<
unsigned int>(
"firstRun", 1);
113 desc.add<
std::string>(
"psethack",
"random particles in phi and r windows");
114 descriptions.
add(
"CloseByParticleGunProducer",
desc);
119 CLHEP::HepRandomEngine* engine = &rng->
getEngine(
e.streamID());
122 LogDebug(
"CloseByParticleGunProducer") <<
" CloseByParticleGunProducer : Begin New Event Generation" << endl;
132 double fZ = CLHEP::RandFlat::shoot(engine,
fZMin,
fZMax);
154 for (
unsigned int ip = 0; ip < numParticles; ++ip) {
156 fR = CLHEP::RandFlat::shoot(engine, tmpR -
fDelta, tmpR +
fDelta);
157 phi = CLHEP::RandFlat::shoot(engine, tmpPhi -
fDelta /
fR, tmpPhi +
fDelta /
fR);
170 double mass = PData->mass().value();
172 double mom,
px,
py, pz;
176 double mom2 = fVar * fVar -
mass *
mass;
188 px = fVar *
cos(phi);
189 py = fVar *
sin(phi);
191 double energy2 = mom * mom +
mass *
mass;
196 double y =
fR *
sin(phi);
203 p.setX(momentum.x());
204 p.setY(momentum.y());
205 p.setZ(momentum.z());
209 double pathLength = 0.;
210 const double speed =
p.pz() /
p.e() * c_light / CLHEP::cm;
211 if (PData->charge()) {
214 (c_light * field.inTesla({0.f, 0.f, 0.f}).z());
216 pathLength =
std::sqrt(arc * arc + fZ * fZ);
225 HepMC::GenVertex* Vtx =
226 new HepMC::GenVertex(HepMC::FourVector(
x * CLHEP::cm, y * CLHEP::cm, fZ * CLHEP::cm,
timeOffset));
229 Part->suggest_barcode(barcode);
232 Vtx->add_particle_out(Part);
238 fEvt->add_vertex(Vtx);
241 fEvt->set_event_number(
e.id().event());
242 fEvt->set_signal_process_id(20);
249 BProduct->addHepMCData(
fEvt);
256 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
Geom::Theta< T > theta() const
Power< A, B >::type pow(const A &a, const B &b)