6 #include "CLHEP/Random/RandFlat.h" 7 #include "CLHEP/Random/RandPoissonQ.h" 8 #include "CLHEP/Random/RandGaussQ.h" 17 const double COSMIC_PAR(37.62);
22 , averageEfficiency_(config.getParameter<double> (
"averageEfficiency"))
23 , averageShapingTime_(config.getParameter<double> (
"averageShapingTime"))
24 , timeResolution_(config.getParameter<double> (
"timeResolution"))
25 , timeJitter_(config.getParameter<double> (
"timeJitter"))
26 , averageNoiseRate_(config.getParameter<double> (
"averageNoiseRate"))
27 , signalPropagationSpeed_(config.getParameter<double> (
"signalPropagationSpeed"))
28 , cosmics_(config.getParameter<bool> (
"cosmics"))
29 , bxwidth_(config.getParameter<
int> (
"bxwidth"))
30 , minBunch_(config.getParameter<
int> (
"minBunch"))
31 , maxBunch_(config.getParameter<
int> (
"maxBunch"))
32 , digitizeOnlyMuons_(config.getParameter<bool> (
"digitizeOnlyMuons"))
33 , doBkgNoise_(config.getParameter<bool> (
"doBkgNoise"))
34 , doNoiseCLS_(config.getParameter<bool> (
"doNoiseCLS"))
35 , fixedRollRadius_(config.getParameter<bool> (
"fixedRollRadius"))
36 , simulateElectronBkg_(config.getParameter<bool> (
"simulateElectronBkg"))
37 , simulateLowNeutralRate_(config.getParameter<bool>(
"simulateLowNeutralRate"))
38 , instLumi_(config.getParameter<double>(
"instLumi"))
39 , rateFact_(config.getParameter<double>(
"rateFact"))
91 bool digiMuon =
false;
92 bool digiElec =
false;
93 for (edm::PSimHitContainer::const_iterator
hit = simHits.begin();
hit != simHits.end(); ++
hit)
98 double partMom =
hit->pabs();
99 double checkMuonEff = CLHEP::RandFlat::shoot(engine, 0., 1.);
100 double checkElecEff = CLHEP::RandFlat::shoot(engine, 0., 1.);
105 if (partMom <= 1.95
e-03)
106 elecEff = 1.7e-05 * TMath::Exp(2.1 * partMom * 1000.);
107 if (partMom > 1.95
e-03 && partMom < 10.
e-03)
108 elecEff = 1.34 *
log(7.96
e-01 * partMom * 1000. - 5.75
e-01)
109 / (1.34 +
log(7.96
e-01 * partMom * 1000. - 5.75
e-01));
110 if (partMom > 10.
e-03)
112 if (checkElecEff < elecEff)
115 if (!(digiMuon || digiElec))
119 for (
auto & digi : cluster)
133 float randomJitterTime = CLHEP::RandGaussQ::shoot(engine, 0.,
timeJitter_);
138 throw cms::Exception(
"Geometry")<<
"GEMSimpleModel::getSimHitBx() - GEM simhit id does not match any GEM roll id: " <<
id <<
"\n";
141 if (roll->id().region() == 0)
143 throw cms::Exception(
"Geometry") <<
"GEMSimpleModel::getSimHitBx() - this GEM id is from barrel, which cannot happen: " << roll->id() <<
"\n";
145 const double cspeed = 299792458;
146 const int nstrips = roll->nstrips();
147 float middleStrip = nstrips/2.;
148 LocalPoint middleOfRoll = roll->centreOfStrip(middleStrip);
149 GlobalPoint globMiddleRol = roll->toGlobal(middleOfRoll);
150 double muRadius =
sqrt(globMiddleRol.
x()*globMiddleRol.
x() + globMiddleRol.
y()*globMiddleRol.
y() +globMiddleRol.
z()*globMiddleRol.
z());
151 double timeCalibrationOffset_ = (muRadius *1
e+9)/(cspeed*1
e+2);
154 const float halfStripLength(0.5 * top->stripLength());
155 const float distanceFromEdge(halfStripLength - simHitPos.y());
161 const float averagePropagationTime(distanceFromEdge / signalPropagationSpeedTrue);
163 float randomResolutionTime = CLHEP::RandGaussQ::shoot(engine, 0.,
timeResolution_);
164 const float simhitTime(tof +
averageShapingTime_ + randomResolutionTime + averagePropagationTime + randomJitterTime);
165 float referenceTime = 0.;
166 referenceTime = timeCalibrationOffset_ + halfStripLength / signalPropagationSpeedTrue +
averageShapingTime_;
167 const float timeDifference(
cosmics_ ? (simhitTime - referenceTime) / COSMIC_PAR : simhitTime - referenceTime);
169 bx =
static_cast<int> (std::round((timeDifference) /
bxwidth_));
172 const bool debug(
false);
175 std::cout <<
"checktime " <<
"bx = " << bx <<
"\tdeltaT = " << timeDifference <<
"\tsimT = " << simhitTime
176 <<
"\trefT = " << referenceTime <<
"\ttof = " << tof <<
"\tavePropT = " << averagePropagationTime
177 <<
"\taveRefPropT = " << halfStripLength / signalPropagationSpeedTrue << std::endl;
188 const int nstrips(roll->
nstrips());
190 double trStripArea(0.0);
191 if (gemId.region() == 0)
194 <<
"GEMSynchronizer::simulateNoise() - this GEM id is from barrel, which cannot happen.";
197 const float striplength(top_->stripLength());
198 trStripArea = (roll->
pitch()) * striplength;
199 trArea = trStripArea * nstrips;
202 top_->radius() + CLHEP::RandFlat::shoot(engine, -1.*top_->stripLength()/2., top_->stripLength()/2.));
205 double averageNeutralNoiseRatePerRoll = 0.;
206 double averageNoiseElectronRatePerRoll = 0.;
207 double averageNoiseRatePerRoll = 0.;
208 if (gemId.station() == 1)
223 averageNoiseRatePerRoll = averageNeutralNoiseRatePerRoll + averageNoiseElectronRatePerRoll;
226 if (gemId.station() == 2)
235 +
GE21NeuBkgParam5 * rollRadius * rollRadius * rollRadius * rollRadius * rollRadius;
247 averageNoiseRatePerRoll = averageNeutralNoiseRatePerRoll + averageNoiseElectronRatePerRoll;
254 for(
int j = 0; j < nstrips; ++j)
256 CLHEP::RandPoissonQ randPoissonQ(*engine, aveIntrinsicNoisePerStrip);
257 const int n_intrHits(randPoissonQ.fire());
259 for (
int k = 0;
k < n_intrHits;
k++ )
261 const int time_hit(static_cast<int>(CLHEP::RandFlat::shoot(engine, nBxing)) +
minBunch_);
262 std::pair<int, int> digi(
k+1,time_hit);
268 const double averageNoise(averageNoiseRatePerRoll * nBxing *
bxwidth_ * trArea * 1.0
e-9);
269 CLHEP::RandPoissonQ randPoissonQ(*engine, averageNoise);
270 const int n_hits(randPoissonQ.fire());
271 for (
int i = 0;
i < n_hits; ++
i)
273 const int centralStrip(static_cast<int> (CLHEP::RandFlat::shoot(engine, 1, nstrips)));
274 const int time_hit(static_cast<int>(CLHEP::RandFlat::shoot(engine, nBxing)) +
minBunch_);
277 std::vector < std::pair<int, int> > cluster_;
279 cluster_.push_back(std::pair<int, int>(centralStrip, time_hit));
280 int clusterSize((CLHEP::RandFlat::shoot(engine)) <= 0.53 ? 1 : 2);
281 if (clusterSize == 2)
283 if(CLHEP::RandFlat::shoot(engine) < 0.5)
286 cluster_.push_back(std::pair<int, int>(centralStrip - 1, time_hit));
290 if (CLHEP::RandFlat::shoot(engine) <
averageEfficiency_ && (centralStrip + 1 <= nstrips))
291 cluster_.push_back(std::pair<int, int>(centralStrip + 1, time_hit));
294 for (
auto & digi : cluster_)
301 std::pair<int, int> digi(centralStrip, time_hit);
309 const PSimHit*
simHit,
const int bx, CLHEP::HepRandomEngine* engine)
313 const int nstrips(roll->
nstrips());
314 int centralStrip = 0;
315 if (!(topology.
channel(hit_position) + 1 > nstrips))
316 centralStrip = topology.
channel(hit_position) + 1;
318 centralStrip = topology.
channel(hit_position);
321 double deltaX = pointSimHit.
x() - pointDigiHit.
x();
323 std::vector < std::pair<int, int> > cluster_;
325 cluster_.push_back(std::pair<int, int>(centralStrip, bx));
327 int clusterSize((CLHEP::RandFlat::shoot(engine)) <= 0.53 ? 1 : 2);
328 if (clusterSize == 2)
333 cluster_.push_back(std::pair<int, int>(centralStrip - 1, bx));
337 if (CLHEP::RandFlat::shoot(engine) <
averageEfficiency_ && (centralStrip + 1 <= nstrips))
338 cluster_.push_back(std::pair<int, int>(centralStrip + 1, bx));
double GE21ModNeuBkgParam1
double signalPropagationSpeed_
double GE21ModNeuBkgParam4
edm::DetSet< GEMDigiSimLink > GEMDigiSimLinks
double slopeNeuGE11_highRate
CaloTopology const * topology(0)
double constNeuGE11_highRate
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 *)
GEMDigiSimLinks theGemDigiSimLinks_
const GEMEtaPartition * etaPartition(GEMDetId id) const
Return a GEMEtaPartition given its id.
double GE21ModNeuBkgParam5
uint32_t rawId() const
get the raw id
Container::value_type value_type
float timeOfFlight() const
bool simulateIntrinsicNoise_
Local3DPoint localPosition() const
double averageEfficiency_
Abs< T >::type abs(const T &t)
std::vector< std::pair< int, int > > simulateClustering(const GEMEtaPartition *, const PSimHit *, const int, CLHEP::HepRandomEngine *) override
bool simulateLowNeutralRate_
GEMSimpleModel(const edm::ParameterSet &)
virtual int channel(const LocalPoint &p) const =0
bool simulateElectronBkg_
double GE21ModNeuBkgParam2
double GE21ModNeuBkgParam0
double GE21ModNeuBkgParam3
void simulateNoise(const GEMEtaPartition *, CLHEP::HepRandomEngine *) override
const GEMGeometry * geometry_
double averageShapingTime_
std::set< std::pair< int, int > > strips_
const double referenceInstLumi
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