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));
T getParameter(std::string const &) const
Distribution(const edm::ParameterSet &)
void produce(edm::Event &, const edm::EventSetup &) override
#define DEFINE_FWK_MODULE(type)
unsigned int verbosity_
verbosity level
Distribution position_dist_
position parameters in mm
bool makeHits_
whether the hits of the proton shall be calculated and saved
static bool IsHit(double u, double v, double insensitiveMargin=0)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
std::unique_ptr< T, impl::DeviceDeleter > unique_ptr
static const unsigned short no_of_strips_
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
double z0_
the "origin" of tracks, in mm
DetGeomDesc::Translation Vector
Fast (no G4) proton simulation in within one station. Uses misaligned geometry.
static const double y_width_
bool makeHepMC_
whether a HepMC description of the proton shall be saved in the event
Distribution angular_dist_
angular parameters in rad
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
bool getData(T &iHolder) const
void Generate(CLHEP::HepRandomEngine &rndEng, double &x, double &y)
bool roundToPitch_
whether measurement values shall be rounded to the nearest strip
The manager class for TOTEM RP geometry.
void printId(unsigned int id)
static const double last_strip_to_border_dist_
unsigned int particlesPerEvent_
number of particles to generate per event
void GenerateTrack(unsigned int pi, CLHEP::HepRandomEngine &rndEng, HepMC::GenEvent *gEv, std::unique_ptr< edm::DetSetVector< TotemRPRecHit >> &stripHitColl, std::unique_ptr< edm::DetSetVector< CTPPSDiamondRecHit >> &diamondHitColl, std::unique_ptr< edm::DetSetVector< CTPPSPixelRecHit >> &pixelHitColl, const CTPPSGeometry &geometry)
~PPSFastLocalSimulation() override
double particle_E_
particle energy and momentum
std::vector< unsigned int > RPs_
the list of RPs to simulate
std::pair< OmniClusterRef, TrackingParticleRef > P
Base class for CTPPS detector IDs.
ParameterSet const & getParameterSet(ParameterSetID const &id)
double stripZeroPosition_
v position of strip 0, in mm
static const double pitch_
Detector ID class for CTPPS Timing Diamond detectors. Bits [19:31] : Assigend in CTPPSDetId Calss Bit...
PPSFastLocalSimulation(const edm::ParameterSet &)
double insensitiveMarginStrips_
size of insensitive margin at sensor's edge facing the beam, in mm
enum PPSFastLocalSimulation::Distribution::Type type_
edm::ESGetToken< CTPPSGeometry, VeryForwardMisalignedGeometryRecord > esTokenGeometry_