16 #include "CLHEP/Random/RandomEngine.h"
17 #include "CLHEP/Random/RandGauss.h"
18 #include "CLHEP/Random/RandExponential.h"
60 std::vector<unsigned int>
RPs_;
87 void Generate(CLHEP::HepRandomEngine &rndEng,
double &
x,
double &
y);
104 CLHEP::HepRandomEngine &rndEng,
120 using namespace CLHEP;
121 using namespace HepMC;
130 else if (!
typeName.compare(
"gauss"))
132 else if (!
typeName.compare(
"gauss-limit"))
133 type_ = dtGaussLimit;
153 x = x_mean_ + x_width_ * (rndEng.flat() - 0.5);
154 y = y_mean_ + y_width_ * (rndEng.flat() - 0.5);
158 x = x_mean_ + RandGauss::shoot(&rndEng) * x_width_;
159 y = y_mean_ + RandGauss::shoot(&rndEng) * y_width_;
163 const double u_x = rndEng.flat(), u_y = rndEng.flat();
165 const double cdf_x_min = (1. + TMath::Erf((x_min_ - x_mean_) / x_width_ /
sqrt(2.))) / 2.;
166 const double cdf_x_max = (1. + TMath::Erf((x_max_ - x_mean_) / x_width_ /
sqrt(2.))) / 2.;
167 const double a_x = cdf_x_max - cdf_x_min, b_x = cdf_x_min;
169 const double cdf_y_min = (1. + TMath::Erf((y_min_ - y_mean_) / y_width_ /
sqrt(2.))) / 2.;
170 const double cdf_y_max = (1. + TMath::Erf((y_max_ - y_mean_) / y_width_ /
sqrt(2.))) / 2.;
171 const double a_y = cdf_y_max - cdf_y_min, b_y = cdf_y_min;
173 x = x_mean_ + x_width_ *
sqrt(2.) * TMath::ErfInverse(2. * (a_x * u_x + b_x) - 1.);
174 y = y_mean_ + y_width_ *
sqrt(2.) * TMath::ErfInverse(2. * (a_y * u_y + b_y) - 1.);
187 : verbosity_(ps.getUntrackedParameter<unsigned
int>(
"verbosity", 0)),
189 makeHepMC_(ps.getParameter<
bool>(
"makeHepMC")),
190 makeHits_(ps.getParameter<
bool>(
"makeHits")),
192 RPs_(ps.getParameter<
vector<unsigned
int>>(
"RPs")),
194 particlesPerEvent_(ps.getParameter<unsigned
int>(
"particlesPerEvent")),
195 particle_E_(ps.getParameter<double>(
"particle_E")),
196 particle_p_(ps.getParameter<double>(
"particle_p")),
197 z0_(ps.getParameter<double>(
"z0")),
199 roundToPitch_(ps.getParameter<
bool>(
"roundToPitch")),
200 pitchStrips_(ps.getParameter<double>(
"pitchStrips")),
201 pitchDiamonds_(ps.getParameter<double>(
"pitchDiamonds")),
202 pitchPixels_(ps.getParameter<double>(
"pitchPixels")),
204 insensitiveMarginStrips_(ps.getParameter<double>(
"insensitiveMarginStrips")),
216 produces<HepMCProduct>();
219 produces<DetSetVector<TotemRPRecHit>>();
220 produces<DetSetVector<CTPPSDiamondRecHit>>();
221 produces<DetSetVector<CTPPSPixelRecHit>>();
232 CLHEP::HepRandomEngine &rndEng,
239 double bx = 0., by = 0., ax = 0., ay = 0.;
244 printf(
"\tax = %.3f mrad, bx = %.3f mm, ay = %.3f mrad, by = %.3f mm, z0 = %.3f m\n",
253 GenVertex *gVx =
new GenVertex(HepMC::FourVector(
bx, by,
z0_, 0.));
254 gEv->add_vertex(gVx);
257 double az =
sqrt(1. - ax * ax - ay * ay);
261 gPe->suggest_barcode(
idx + 1);
262 gVx->add_particle_out(gPe);
267 for (CTPPSGeometry::mapType::const_iterator it =
geometry.beginSensor(); it !=
geometry.endSensor(); ++it) {
298 A(0, 1) = -gl_a1.x();
299 A(0, 2) = -gl_a2.x();
300 B(0) = gl_o.x() -
bx;
302 A(1, 1) = -gl_a1.y();
303 A(1, 2) = -gl_a2.y();
304 B(1) = gl_o.y() - by;
306 A(2, 1) = -gl_a1.z();
307 A(2, 2) = -gl_a2.z();
308 B(2) = gl_o.z() -
z0_;
322 double u = h_loc.x();
323 double v = h_loc.y();
326 printf(
" u=%+8.4f, v=%+8.4f", u,
v);
331 printf(
" | no hit\n");
343 printf(
" | strip=%+4i",
strip);
349 printf(
" | m=%+8.4f, sigma=%+8.4f\n",
v, sigma);
352 hits.emplace_back(
v, sigma);
362 printf(
" m = %.3f\n", h_loc.x());
367 hits.emplace_back(h_loc.x(),
width, 0., 0., 0., 0., 0., 0., 0., 0,
HPTDCErrorFlags(),
false);
378 printf(
" m1 = %.3f, m2 = %.3f\n", h_loc.x(), h_loc.y());
382 const LocalPoint lp(h_loc.x(), h_loc.y(), h_loc.z());
386 hits.emplace_back(lp, le);
396 printf(
">> PPSFastLocalSimulation::produce > event %llu\n",
event.id().event());
402 printf(
"\tseed = %li\n", rndEng.getSeed());
409 gEv->set_event_number(
event.id().event());
418 printf(
" generating track %u\n",
pi);
425 unique_ptr<HepMCProduct> hepMCoutput(
new HepMCProduct());
426 hepMCoutput->addHepMCData(gEv);
427 event.put(
move(hepMCoutput));
431 event.put(
move(stripHitColl));
432 event.put(
move(diamondHitColl));
433 event.put(
move(pixelHitColl));