6 #include "CLHEP/Random/RandFlat.h" 7 #include "CLHEP/Random/RandPoissonQ.h" 8 #include "CLHEP/Random/RandGaussQ.h" 15 , averageEfficiency_(config.getParameter<double> (
"averageEfficiency"))
16 , averageShapingTime_(config.getParameter<double> (
"averageShapingTime"))
17 , timeResolution_(config.getParameter<double> (
"timeResolution"))
18 , timeJitter_(config.getParameter<double> (
"timeJitter"))
19 , averageNoiseRate_(config.getParameter<double> (
"averageNoiseRate"))
20 , signalPropagationSpeed_(config.getParameter<double> (
"signalPropagationSpeed"))
21 , bxwidth_(config.getParameter<
int> (
"bxwidth"))
22 , minBunch_(config.getParameter<
int> (
"minBunch"))
23 , maxBunch_(config.getParameter<
int> (
"maxBunch"))
24 , digitizeOnlyMuons_(config.getParameter<
bool> (
"digitizeOnlyMuons"))
25 , doBkgNoise_(config.getParameter<
bool> (
"doBkgNoise"))
26 , doNoiseCLS_(config.getParameter<
bool> (
"doNoiseCLS"))
27 , fixedRollRadius_(config.getParameter<
bool> (
"fixedRollRadius"))
28 , simulateElectronBkg_(config.getParameter<
bool> (
"simulateElectronBkg"))
29 , instLumi_(config.getParameter<double>(
"instLumi"))
30 , rateFact_(config.getParameter<double>(
"rateFact"))
31 , referenceInstLumi_(config.getParameter<double>(
"referenceInstLumi"))
32 , resolutionX_(config.getParameter<double>(
"resolutionX"))
33 , GE11ElecBkgParam0_(config.getParameter<double>(
"GE11ElecBkgParam0"))
34 , GE11ElecBkgParam1_(config.getParameter<double>(
"GE11ElecBkgParam1"))
35 , GE11ElecBkgParam2_(config.getParameter<double>(
"GE11ElecBkgParam2"))
36 , GE21ElecBkgParam0_(config.getParameter<double>(
"GE21ElecBkgParam0"))
37 , GE21ElecBkgParam1_(config.getParameter<double>(
"GE21ElecBkgParam1"))
38 , GE21ElecBkgParam2_(config.getParameter<double>(
"GE21ElecBkgParam2"))
39 , GE11ModNeuBkgParam0_(config.getParameter<double>(
"GE11ModNeuBkgParam0"))
40 , GE11ModNeuBkgParam1_(config.getParameter<double>(
"GE11ModNeuBkgParam1"))
41 , GE11ModNeuBkgParam2_(config.getParameter<double>(
"GE11ModNeuBkgParam2"))
42 , GE21ModNeuBkgParam0_(config.getParameter<double>(
"GE11ModNeuBkgParam0"))
43 , GE21ModNeuBkgParam1_(config.getParameter<double>(
"GE11ModNeuBkgParam1"))
44 , GE21ModNeuBkgParam2_(config.getParameter<double>(
"GE11ModNeuBkgParam2"))
64 bool digiMuon =
false;
65 bool digiElec =
false;
66 for (
const auto&
hit : simHits)
71 double partMom =
hit.pabs();
72 double checkMuonEff = CLHEP::RandFlat::shoot(engine, 0., 1.);
73 double checkElecEff = CLHEP::RandFlat::shoot(engine, 0., 1.);
78 if (partMom <= 1.95
e-03)
79 elecEff = 1.7e-05 *
std::exp(2.1 * partMom * 1000.);
80 if (partMom > 1.95
e-03 && partMom < 10.
e-03)
81 elecEff = 1.34 *
log(7.96
e-01 * partMom * 1000. - 5.75
e-01)
82 / (1.34 +
log(7.96
e-01 * partMom * 1000. - 5.75
e-01));
83 if (partMom > 10.
e-03)
85 if (checkElecEff < elecEff)
88 if (!(digiMuon || digiElec))
92 for (
const auto & digi : cluster)
106 float randomJitterTime = CLHEP::RandGaussQ::shoot(engine, 0.,
timeJitter_);
111 throw cms::Exception(
"Geometry")<<
"GEMSimpleModel::getSimHitBx() - GEM simhit id does not match any GEM roll id: " <<
id <<
"\n";
114 if (roll->id().region() == 0)
116 throw cms::Exception(
"Geometry") <<
"GEMSimpleModel::getSimHitBx() - this GEM id is from barrel, which cannot happen: " << roll->id() <<
"\n";
118 const double cspeed = 299792458;
119 const int nstrips = roll->nstrips();
120 float middleStrip = nstrips/2.;
121 const LocalPoint& middleOfRoll = roll->centreOfStrip(middleStrip);
122 const GlobalPoint& globMiddleRol = roll->toGlobal(middleOfRoll);
123 double muRadius =
sqrt(globMiddleRol.
x()*globMiddleRol.
x() + globMiddleRol.
y()*globMiddleRol.
y() +globMiddleRol.
z()*globMiddleRol.
z());
124 double timeCalibrationOffset_ = (muRadius *1
e+9)/(cspeed*1
e+2);
127 const float halfStripLength(0.5 * top->stripLength());
128 const float distanceFromEdge(halfStripLength - simHitPos.y());
134 const float averagePropagationTime(distanceFromEdge / signalPropagationSpeedTrue);
136 float randomResolutionTime = CLHEP::RandGaussQ::shoot(engine, 0.,
timeResolution_);
137 const float simhitTime(tof +
averageShapingTime_ + randomResolutionTime + averagePropagationTime + randomJitterTime);
138 float referenceTime = 0.;
139 referenceTime = timeCalibrationOffset_ + halfStripLength / signalPropagationSpeedTrue +
averageShapingTime_;
140 const float timeDifference(simhitTime - referenceTime);
142 bx =
static_cast<int> (std::round((timeDifference) /
bxwidth_));
145 const bool debug(
false);
148 std::cout <<
"checktime " <<
"bx = " << bx <<
"\tdeltaT = " << timeDifference <<
"\tsimT = " << simhitTime
149 <<
"\trefT = " << referenceTime <<
"\ttof = " << tof <<
"\tavePropT = " << averagePropagationTime
150 <<
"\taveRefPropT = " << halfStripLength / signalPropagationSpeedTrue << std::endl;
160 const int nstrips(roll->
nstrips());
162 double trStripArea(0.0);
163 if (gemId.region() == 0)
166 <<
"GEMSynchronizer::simulateNoise() - this GEM id is from barrel, which cannot happen.";
169 const float striplength(top_->stripLength());
170 trStripArea = (roll->
pitch()) * striplength;
171 trArea = trStripArea * nstrips;
174 top_->radius() + CLHEP::RandFlat::shoot(engine, -1.*top_->stripLength()/2., top_->stripLength()/2.));
177 double averageNeutralNoiseRatePerRoll = 0.;
178 double averageNoiseElectronRatePerRoll = 0.;
179 double averageNoiseRatePerRoll = 0.;
180 if (gemId.station() == 1)
192 averageNoiseRatePerRoll = averageNeutralNoiseRatePerRoll + averageNoiseElectronRatePerRoll;
195 if (gemId.station() == 2)
208 averageNoiseRatePerRoll = averageNeutralNoiseRatePerRoll + averageNoiseElectronRatePerRoll;
216 for(
int j = 0; j < nstrips; ++j)
218 CLHEP::RandPoissonQ randPoissonQ(*engine, aveIntrinsicNoisePerStrip);
219 const int n_intrHits(randPoissonQ.fire());
221 for (
int k = 0;
k < n_intrHits;
k++ )
223 const int time_hit(static_cast<int>(CLHEP::RandFlat::shoot(engine, nBxing)) +
minBunch_);
224 std::pair<int, int> digi(
k+1,time_hit);
231 const double averageNoise(averageNoiseRatePerRoll * nBxing *
bxwidth_ * trArea * 1.0
e-9);
232 CLHEP::RandPoissonQ randPoissonQ(*engine, averageNoise);
233 const int n_hits(randPoissonQ.fire());
234 for (
int i = 0;
i < n_hits; ++
i)
236 const int centralStrip(static_cast<int> (CLHEP::RandFlat::shoot(engine, 1, nstrips)));
237 const int time_hit(static_cast<int>(CLHEP::RandFlat::shoot(engine, nBxing)) +
minBunch_);
240 std::vector < std::pair<int, int> > cluster_;
242 cluster_.emplace_back(centralStrip, time_hit);
243 int clusterSize((CLHEP::RandFlat::shoot(engine)) <= 0.53 ? 1 : 2);
244 if (clusterSize == 2)
246 if(CLHEP::RandFlat::shoot(engine) < 0.5)
249 cluster_.emplace_back(centralStrip - 1, time_hit);
253 if (CLHEP::RandFlat::shoot(engine) <
averageEfficiency_ && (centralStrip + 1 <= nstrips))
254 cluster_.emplace_back(centralStrip + 1, time_hit);
257 for (
const auto& digi : cluster_)
264 strips_.emplace(centralStrip, time_hit);
272 CLHEP::HepRandomEngine* engine)
277 float hit_entry_smeardX;
278 float hit_exit_smeardX;
279 if (hit_entry.x()>hit_exit.x()) {
288 LocalPoint inPoint(hit_entry_smeardX, hit_entry.y(), hit_entry.z());
289 LocalPoint outPoint(hit_exit_smeardX, hit_exit.y(), hit_exit.z());
291 int clusterStart = roll->
strip(inPoint);
292 int clusterEnd = roll->
strip(outPoint);
294 std::vector < std::pair<int, int> > cluster_;
296 for (
int i = clusterStart;
i<= clusterEnd ;
i++) {
297 cluster_.emplace_back(
i, bx);
double signalPropagationSpeed_
double GE21ElecBkgParam1_
double GE11ModNeuBkgParam2_
edm::DetSet< GEMDigiSimLink > GEMDigiSimLinks
double GE11ElecBkgParam2_
constexpr uint32_t rawId() const
get the raw id
int getSimHitBx(const PSimHit *, CLHEP::HepRandomEngine *)
double GE11ElecBkgParam0_
GEMDigiSimLinks theGemDigiSimLinks_
const GEMEtaPartition * etaPartition(GEMDetId id) const
Return a GEMEtaPartition given its id.
double GE21ElecBkgParam2_
Local3DPoint exitPoint() const
Exit point in the local Det frame.
float timeOfFlight() const
bool simulateIntrinsicNoise_
~GEMSimpleModel() override
Local3DPoint localPosition() const
double GE21ModNeuBkgParam1_
double averageEfficiency_
double GE21ModNeuBkgParam2_
double GE11ModNeuBkgParam1_
Abs< T >::type abs(const T &t)
std::vector< std::pair< int, int > > simulateClustering(const GEMEtaPartition *, const PSimHit *, const int, CLHEP::HepRandomEngine *) override
double GE21ModNeuBkgParam0_
double GE11ModNeuBkgParam0_
GEMSimpleModel(const edm::ParameterSet &)
double GE21ElecBkgParam0_
const double referenceInstLumi_
bool simulateElectronBkg_
double GE11ElecBkgParam1_
void simulateNoise(const GEMEtaPartition *, CLHEP::HepRandomEngine *) override
const GEMGeometry * geometry_
double averageShapingTime_
std::set< std::pair< int, int > > strips_
DetectorHitMap detectorHitMap_
std::vector< PSimHit > PSimHitContainer
StripDigiSimLinks stripDigiSimLinks_
edm::DetSet< StripDigiSimLink > StripDigiSimLinks
Local3DPoint entryPoint() const
Entry point in the local Det frame.
void simulateSignal(const GEMEtaPartition *, const edm::PSimHitContainer &, CLHEP::HepRandomEngine *) override
unsigned int detUnitId() const