7 #include "CLHEP/Random/RandFlat.h"
8 #include "CLHEP/Random/RandPoissonQ.h"
9 #include "CLHEP/Random/RandGaussQ.h"
10 #include "CLHEP/Units/GlobalPhysicalConstants.h"
18 averageEfficiency_(config.getParameter<double>(
"averageEfficiency")),
19 averageShapingTime_(config.getParameter<double>(
"averageShapingTime")),
20 timeResolution_(config.getParameter<double>(
"timeResolution")),
21 timeJitter_(config.getParameter<double>(
"timeJitter")),
22 signalPropagationSpeed_(config.getParameter<double>(
"signalPropagationSpeed")),
23 bx0filter_(config.getParameter<bool>(
"bx0filter")),
24 digitizeOnlyMuons_(config.getParameter<bool>(
"digitizeOnlyMuons")),
25 resolutionX_(config.getParameter<double>(
"resolutionX")),
27 cspeed(geant_units::operators::
convertMmToCm(CLHEP::c_light)),
29 elecMomCut1(1.96
e-03),
31 elecEffLowCoeff(1.7
e-05),
32 elecEffLowParam0(2.1),
33 elecEffMidCoeff(1.34),
34 elecEffMidParam0(-5.75
e-01),
35 elecEffMidParam1(7.96
e-01) {}
41 CLHEP::HepRandomEngine* engine,
44 bool digiMuon =
false;
45 bool digiElec =
false;
47 for (
const auto&
hit : simHits) {
51 double partMom =
hit.pabs();
52 double checkMuonEff = CLHEP::RandFlat::shoot(engine, 0., 1.);
53 double checkElecEff = CLHEP::RandFlat::shoot(engine, 0., 1.);
65 if (checkElecEff < elecEff)
68 if (!(digiMuon || digiElec))
74 for (
const auto& digi : cluster) {
75 detectorHitMap_.emplace(digi, &
hit);
76 strips_.emplace(digi);
86 float randomJitterTime = CLHEP::RandGaussQ::shoot(engine, 0.,
timeJitter_);
90 throw cms::Exception(
"Geometry") <<
"GEMSignalModel::getSimHitBx() - GEM simhit id does not match any GEM roll id: "
94 if (roll->id().region() == 0) {
96 <<
"GEMSignalModel::getSimHitBx() - this GEM id is from barrel, which cannot happen: " << roll->id() <<
"\n";
98 const int nstrips = roll->nstrips();
99 float middleStrip = nstrips / 2.;
100 const LocalPoint& middleOfRoll = roll->centreOfStrip(middleStrip);
101 const GlobalPoint& globMiddleRol = roll->toGlobal(middleOfRoll);
102 double muRadius =
sqrt(globMiddleRol.
x() * globMiddleRol.
x() + globMiddleRol.
y() * globMiddleRol.
y() +
103 globMiddleRol.
z() * globMiddleRol.
z());
104 double timeCalibrationOffset_ = muRadius /
cspeed;
106 const GEMStripTopology* top(dynamic_cast<const GEMStripTopology*>(&(roll->topology())));
107 const float halfStripLength(0.5 * top->stripLength());
108 const float distanceFromEdge(halfStripLength - simHitPos.y());
114 const float averagePropagationTime(distanceFromEdge / signalPropagationSpeedTrue);
116 float randomResolutionTime = CLHEP::RandGaussQ::shoot(engine, 0.,
timeResolution_);
117 const float simhitTime(tof +
averageShapingTime_ + randomResolutionTime + averagePropagationTime + randomJitterTime);
118 float referenceTime = 0.;
119 referenceTime = timeCalibrationOffset_ + halfStripLength / signalPropagationSpeedTrue +
averageShapingTime_;
120 const float timeDifference(simhitTime - referenceTime);
122 bx =
static_cast<int>(std::round((timeDifference) / 25.));
125 LogDebug(
"GEMDigiProducer") <<
"checktime "
126 <<
"bx = " << bx <<
"\tdeltaT = " << timeDifference <<
"\tsimT = " << simhitTime
127 <<
"\trefT = " << referenceTime <<
"\ttof = " << tof
128 <<
"\tavePropT = " << averagePropagationTime
129 <<
"\taveRefPropT = " << halfStripLength / signalPropagationSpeedTrue <<
"\n";
136 CLHEP::HepRandomEngine* engine) {
141 if (hit_entry.x() < hit_exit.x()) {
142 start_point = hit_entry;
143 end_point = hit_exit;
145 start_point = hit_exit;
146 end_point = hit_entry;
150 float smeared_start_x = start_point.
x() -
std::abs(CLHEP::RandGaussQ::shoot(engine, 0,
resolutionX_));
151 float smeared_end_x = end_point.x() +
std::abs(CLHEP::RandGaussQ::shoot(engine, 0,
resolutionX_));
153 LocalPoint smeared_start_point(smeared_start_x, start_point.y(), start_point.z());
154 LocalPoint smeared_end_point(smeared_end_x, end_point.y(), end_point.z());
156 int cluster_start = top->
channel(smeared_start_point);
157 int cluster_end = top->
channel(smeared_end_point);
159 std::vector<std::pair<int, int> > cluster;
161 cluster.emplace_back(
strip, bx);
static std::vector< std::string > checklist log
double averageEfficiency_
const double elecEffMidParam1
uint16_t *__restrict__ id
const double elecEffMidCoeff
std::vector< std::pair< int, int > > simulateClustering(const GEMStripTopology *, const PSimHit *, const int, CLHEP::HepRandomEngine *)
int channel(const LocalPoint &) const override
Exp< T >::type exp(const T &t)
const GEMEtaPartition * etaPartition(GEMDetId id) const
Return a GEMEtaPartition given its id.
double signalPropagationSpeed_
const double elecEffLowCoeff
Local3DPoint exitPoint() const
Exit point in the local Det frame.
float timeOfFlight() const
Local3DPoint localPosition() const
const double elecEffLowParam0
Abs< T >::type abs(const T &t)
void simulate(const GEMEtaPartition *, const edm::PSimHitContainer &, CLHEP::HepRandomEngine *, Strips &, DetectorHitMap &) override
const double elecEffMidParam0
int getSimHitBx(const PSimHit *, CLHEP::HepRandomEngine *)
std::multimap< std::pair< unsigned int, int >, const PSimHit *, std::less< std::pair< unsigned int, int > > > DetectorHitMap
std::set< std::pair< int, int > > Strips
const GEMGeometry * geometry_
tuple config
parse the configuration file
constexpr NumType convertMmToCm(NumType millimeters)
std::vector< PSimHit > PSimHitContainer
~GEMSignalModel() override
double averageShapingTime_
GEMSignalModel(const edm::ParameterSet &)
Local3DPoint entryPoint() const
Entry point in the local Det frame.
unsigned int detUnitId() const