17 #include <CLHEP/Random/RandFlat.h> 18 #include <CLHEP/Units/SystemOfUnits.h> 19 #include <CLHEP/Units/GlobalPhysicalConstants.h> 20 #include <CLHEP/Random/RandFlat.h> 32 <<
" Conflicting configuration, cannot have both ControlledByEta and ControlledByREta ";
41 <<
" Please choose a minimum energy greater than 1 GeV, otherwise time " 42 "information may be invalid or not reliable";
44 throw cms::Exception(
"CloseByParticleGunProducer") <<
" Minimum energy must be greater than zero for log spacing";
54 throw cms::Exception(
"CloseByParticleGunProducer") <<
" Please fix MinEta and MaxEta values in the configuration";
59 throw cms::Exception(
"CloseByParticleGunProducer") <<
" Please fix RMin and RMax values in the configuration";
66 throw cms::Exception(
"CloseByParticleGunProducer") <<
" Please fix ZMin and ZMax values in the configuration";
75 <<
" Can't generate non pointing FlatPt samples; please disable FlatPt generation or generate pointing sample";
85 throw cms::Exception(
"CloseByParticleGunProducer") <<
" Please fix TMin and TMax values in the configuration";
89 produces<HepMCProduct>(
"unsmeared");
90 produces<GenEventInfoProduct>();
99 desc.add<
bool>(
"AddAntiParticle",
false);
102 psd0.
add<
bool>(
"ControlledByEta",
false);
103 psd0.
add<
bool>(
"ControlledByREta",
false);
104 psd0.
add<
double>(
"Delta", 10);
105 psd0.
add<
double>(
"VarMax", 200.0);
106 psd0.
add<
double>(
"VarMin", 25.0);
107 psd0.
add<
bool>(
"MaxVarSpread",
false);
108 psd0.
add<
bool>(
"LogSpacedVar",
false);
109 psd0.
add<
bool>(
"FlatPtGeneration",
false);
110 psd0.
add<
double>(
"MaxEta", 2.7);
111 psd0.
add<
double>(
"MaxPhi", 3.14159265359);
112 psd0.
add<
double>(
"MinEta", 1.7);
113 psd0.
add<
double>(
"MinPhi", -3.14159265359);
114 psd0.
add<
int>(
"NParticles", 2);
115 psd0.
add<
bool>(
"Overlapping",
false);
116 psd0.
add<std::vector<int>>(
"PartID",
120 psd0.
add<
bool>(
"Pointing",
true);
121 psd0.
add<
double>(
"RMax", 120);
122 psd0.
add<
double>(
"RMin", 60);
123 psd0.
add<
bool>(
"RandomShoot",
false);
124 psd0.
add<
double>(
"ZMax", 321);
125 psd0.
add<
double>(
"ZMin", 320);
126 psd0.
add<
bool>(
"UseDeltaT",
false);
127 psd0.
add<
double>(
"TMin", 0.);
128 psd0.
add<
double>(
"TMax", 0.05);
129 psd0.
add<
double>(
"OffsetFirst", 0.);
132 desc.addUntracked<
int>(
"Verbosity", 0);
133 desc.addUntracked<
unsigned int>(
"firstRun", 1);
134 desc.add<
std::string>(
"psethack",
"random particles in phi and r windows");
135 descriptions.
add(
"CloseByParticleGunProducer",
desc);
140 CLHEP::HepRandomEngine* engine = &rng->
getEngine(
e.streamID());
143 LogDebug(
"CloseByParticleGunProducer") <<
" CloseByParticleGunProducer : Begin New Event Generation" << endl;
158 fZ = CLHEP::RandFlat::shoot(engine,
fZMin,
fZMax);
183 for (
unsigned int ip = 0; ip < numParticles; ++ip) {
185 fR = CLHEP::RandFlat::shoot(engine, tmpR -
fDelta, tmpR +
fDelta);
186 phi = CLHEP::RandFlat::shoot(engine, tmpPhi -
fDelta /
fR, tmpPhi +
fDelta /
fR);
204 double mass = PData->mass().value();
206 double mom,
px,
py, pz;
210 double mom2 = fVar * fVar -
mass *
mass;
222 px = fVar *
cos(phi);
223 py = fVar *
sin(phi);
225 double energy2 = mom * mom +
mass *
mass;
230 double y =
fR *
sin(phi);
237 p.setX(momentum.x());
238 p.setY(momentum.y());
239 p.setZ(momentum.z());
243 double pathLength = 0.;
244 const double speed =
p.pz() /
p.e() * c_light / CLHEP::cm;
245 if (PData->charge()) {
248 (c_light * field.inTesla({0.f, 0.f, 0.f}).z());
250 pathLength =
std::sqrt(arc * arc + fZ * fZ);
259 HepMC::GenVertex* Vtx =
260 new HepMC::GenVertex(HepMC::FourVector(
x * CLHEP::cm, y * CLHEP::cm, fZ * CLHEP::cm,
timeOffset));
263 Part->suggest_barcode(barcode);
266 Vtx->add_particle_out(Part);
272 fEvt->add_vertex(Vtx);
275 fEvt->set_event_number(
e.id().event());
276 fEvt->set_signal_process_id(20);
283 BProduct->addHepMCData(
fEvt);
290 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)
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)