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 , GE11ElecBkgParam0_(config.getParameter<double>(
"GE11ElecBkgParam0"))
33 , GE11ElecBkgParam1_(config.getParameter<double>(
"GE11ElecBkgParam1"))
34 , GE11ElecBkgParam2_(config.getParameter<double>(
"GE11ElecBkgParam2"))
35 , GE21ElecBkgParam0_(config.getParameter<double>(
"GE21ElecBkgParam0"))
36 , GE21ElecBkgParam1_(config.getParameter<double>(
"GE21ElecBkgParam1"))
37 , GE21ElecBkgParam2_(config.getParameter<double>(
"GE21ElecBkgParam2"))
38 , GE11ModNeuBkgParam0_(config.getParameter<double>(
"GE11ModNeuBkgParam0"))
39 , GE11ModNeuBkgParam1_(config.getParameter<double>(
"GE11ModNeuBkgParam1"))
40 , GE11ModNeuBkgParam2_(config.getParameter<double>(
"GE11ModNeuBkgParam2"))
41 , GE21ModNeuBkgParam0_(config.getParameter<double>(
"GE11ModNeuBkgParam0"))
42 , GE21ModNeuBkgParam1_(config.getParameter<double>(
"GE11ModNeuBkgParam1"))
43 , GE21ModNeuBkgParam2_(config.getParameter<double>(
"GE11ModNeuBkgParam2"))
63 bool digiMuon =
false;
64 bool digiElec =
false;
65 for (
const auto&
hit : simHits)
70 double partMom =
hit.pabs();
71 double checkMuonEff = CLHEP::RandFlat::shoot(engine, 0., 1.);
72 double checkElecEff = CLHEP::RandFlat::shoot(engine, 0., 1.);
77 if (partMom <= 1.95
e-03)
78 elecEff = 1.7e-05 *
std::exp(2.1 * partMom * 1000.);
79 if (partMom > 1.95
e-03 && partMom < 10.
e-03)
80 elecEff = 1.34 *
log(7.96
e-01 * partMom * 1000. - 5.75
e-01)
81 / (1.34 +
log(7.96
e-01 * partMom * 1000. - 5.75
e-01));
82 if (partMom > 10.
e-03)
84 if (checkElecEff < elecEff)
87 if (!(digiMuon || digiElec))
91 for (
const auto & digi : cluster)
105 float randomJitterTime = CLHEP::RandGaussQ::shoot(engine, 0.,
timeJitter_);
110 throw cms::Exception(
"Geometry")<<
"GEMSimpleModel::getSimHitBx() - GEM simhit id does not match any GEM roll id: " <<
id <<
"\n";
113 if (roll->id().region() == 0)
115 throw cms::Exception(
"Geometry") <<
"GEMSimpleModel::getSimHitBx() - this GEM id is from barrel, which cannot happen: " << roll->id() <<
"\n";
117 const double cspeed = 299792458;
118 const int nstrips = roll->nstrips();
119 float middleStrip = nstrips/2.;
120 const LocalPoint& middleOfRoll = roll->centreOfStrip(middleStrip);
121 const GlobalPoint& globMiddleRol = roll->toGlobal(middleOfRoll);
122 double muRadius =
sqrt(globMiddleRol.
x()*globMiddleRol.
x() + globMiddleRol.
y()*globMiddleRol.
y() +globMiddleRol.
z()*globMiddleRol.
z());
123 double timeCalibrationOffset_ = (muRadius *1
e+9)/(cspeed*1
e+2);
126 const float halfStripLength(0.5 * top->stripLength());
127 const float distanceFromEdge(halfStripLength - simHitPos.y());
133 const float averagePropagationTime(distanceFromEdge / signalPropagationSpeedTrue);
135 float randomResolutionTime = CLHEP::RandGaussQ::shoot(engine, 0.,
timeResolution_);
136 const float simhitTime(tof +
averageShapingTime_ + randomResolutionTime + averagePropagationTime + randomJitterTime);
137 float referenceTime = 0.;
138 referenceTime = timeCalibrationOffset_ + halfStripLength / signalPropagationSpeedTrue +
averageShapingTime_;
139 const float timeDifference(simhitTime - referenceTime);
141 bx =
static_cast<int> (std::round((timeDifference) /
bxwidth_));
144 const bool debug(
false);
147 std::cout <<
"checktime " <<
"bx = " << bx <<
"\tdeltaT = " << timeDifference <<
"\tsimT = " << simhitTime
148 <<
"\trefT = " << referenceTime <<
"\ttof = " << tof <<
"\tavePropT = " << averagePropagationTime
149 <<
"\taveRefPropT = " << halfStripLength / signalPropagationSpeedTrue << std::endl;
159 const int nstrips(roll->
nstrips());
161 double trStripArea(0.0);
162 if (gemId.region() == 0)
165 <<
"GEMSynchronizer::simulateNoise() - this GEM id is from barrel, which cannot happen.";
168 const float striplength(top_->stripLength());
169 trStripArea = (roll->
pitch()) * striplength;
170 trArea = trStripArea * nstrips;
173 top_->radius() + CLHEP::RandFlat::shoot(engine, -1.*top_->stripLength()/2., top_->stripLength()/2.));
176 double averageNeutralNoiseRatePerRoll = 0.;
177 double averageNoiseElectronRatePerRoll = 0.;
178 double averageNoiseRatePerRoll = 0.;
179 if (gemId.station() == 1)
191 averageNoiseRatePerRoll = averageNeutralNoiseRatePerRoll + averageNoiseElectronRatePerRoll;
194 if (gemId.station() == 2)
207 averageNoiseRatePerRoll = averageNeutralNoiseRatePerRoll + averageNoiseElectronRatePerRoll;
215 for(
int j = 0; j < nstrips; ++j)
217 CLHEP::RandPoissonQ randPoissonQ(*engine, aveIntrinsicNoisePerStrip);
218 const int n_intrHits(randPoissonQ.fire());
220 for (
int k = 0;
k < n_intrHits;
k++ )
222 const int time_hit(static_cast<int>(CLHEP::RandFlat::shoot(engine, nBxing)) +
minBunch_);
223 std::pair<int, int> digi(
k+1,time_hit);
230 const double averageNoise(averageNoiseRatePerRoll * nBxing *
bxwidth_ * trArea * 1.0
e-9);
231 CLHEP::RandPoissonQ randPoissonQ(*engine, averageNoise);
232 const int n_hits(randPoissonQ.fire());
233 for (
int i = 0;
i < n_hits; ++
i)
235 const int centralStrip(static_cast<int> (CLHEP::RandFlat::shoot(engine, 1, nstrips)));
236 const int time_hit(static_cast<int>(CLHEP::RandFlat::shoot(engine, nBxing)) +
minBunch_);
239 std::vector < std::pair<int, int> > cluster_;
241 cluster_.emplace_back(centralStrip, time_hit);
242 int clusterSize((CLHEP::RandFlat::shoot(engine)) <= 0.53 ? 1 : 2);
243 if (clusterSize == 2)
245 if(CLHEP::RandFlat::shoot(engine) < 0.5)
248 cluster_.emplace_back(centralStrip - 1, time_hit);
252 if (CLHEP::RandFlat::shoot(engine) <
averageEfficiency_ && (centralStrip + 1 <= nstrips))
253 cluster_.emplace_back(centralStrip + 1, time_hit);
256 for (
const auto& digi : cluster_)
263 strips_.emplace(centralStrip, time_hit);
271 CLHEP::HepRandomEngine* engine)
275 const int nstrips(roll->
nstrips());
276 int centralStrip = 0;
277 if (!(topology.
channel(hit_position) + 1 > nstrips))
278 centralStrip = topology.
channel(hit_position) + 1;
280 centralStrip = topology.
channel(hit_position);
283 double deltaX = pointSimHit.
x() - pointDigiHit.
x();
286 std::vector < std::pair<int, int> > cluster_;
288 cluster_.emplace_back(centralStrip, bx);
291 int clusterSize((CLHEP::RandFlat::shoot(engine)) <= 0.53 ? 1 : 2);
292 if (clusterSize == 2)
297 cluster_.emplace_back(centralStrip - 1, bx);
301 if (CLHEP::RandFlat::shoot(engine) <
averageEfficiency_ && (centralStrip + 1 <= nstrips))
302 cluster_.emplace_back(centralStrip + 1, bx);
double signalPropagationSpeed_
double GE21ElecBkgParam1_
double GE11ModNeuBkgParam2_
edm::DetSet< GEMDigiSimLink > GEMDigiSimLinks
double GE11ElecBkgParam2_
CaloTopology const * topology(0)
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
int getSimHitBx(const PSimHit *, CLHEP::HepRandomEngine *)
double GE11ElecBkgParam0_
GEMDigiSimLinks theGemDigiSimLinks_
const GEMEtaPartition * etaPartition(GEMDetId id) const
Return a GEMEtaPartition given its id.
uint32_t rawId() const
get the raw id
double GE21ElecBkgParam2_
float timeOfFlight() const
bool simulateIntrinsicNoise_
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 &)
virtual int channel(const LocalPoint &p) const =0
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
void simulateSignal(const GEMEtaPartition *, const edm::PSimHitContainer &, CLHEP::HepRandomEngine *) override
unsigned int detUnitId() const