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"))
89 bool digiMuon =
false;
90 bool digiElec =
false;
91 for (edm::PSimHitContainer::const_iterator
hit = simHits.begin();
hit != simHits.end(); ++
hit)
96 double partMom =
hit->pabs();
97 double checkMuonEff = CLHEP::RandFlat::shoot(engine, 0., 1.);
98 double checkElecEff = CLHEP::RandFlat::shoot(engine, 0., 1.);
103 if (partMom <= 1.95
e-03)
104 elecEff = 1.7e-05 * TMath::Exp(2.1 * partMom * 1000.);
105 if (partMom > 1.95
e-03 && partMom < 10.
e-03)
106 elecEff = 1.34 *
log(7.96
e-01 * partMom * 1000. - 5.75
e-01)
107 / (1.34 +
log(7.96
e-01 * partMom * 1000. - 5.75
e-01));
108 if (partMom > 10.
e-03)
110 if (checkElecEff < elecEff)
113 if (!(digiMuon || digiElec))
117 for (
auto & digi : cluster)
131 float randomJitterTime = CLHEP::RandGaussQ::shoot(engine, 0.,
timeJitter_);
136 throw cms::Exception(
"Geometry")<<
"GEMSimpleModel::getSimHitBx() - GEM simhit id does not match any GEM roll id: " <<
id <<
"\n";
139 if (roll->id().region() == 0)
141 throw cms::Exception(
"Geometry") <<
"GEMSimpleModel::getSimHitBx() - this GEM id is from barrel, which cannot happen: " << roll->id() <<
"\n";
143 const double cspeed = 299792458;
144 const int nstrips = roll->nstrips();
145 float middleStrip = nstrips/2.;
146 LocalPoint middleOfRoll = roll->centreOfStrip(middleStrip);
147 GlobalPoint globMiddleRol = roll->toGlobal(middleOfRoll);
148 double muRadius =
sqrt(globMiddleRol.
x()*globMiddleRol.
x() + globMiddleRol.
y()*globMiddleRol.
y() +globMiddleRol.
z()*globMiddleRol.
z());
149 double timeCalibrationOffset_ = (muRadius *1
e+9)/(cspeed*1
e+2);
152 const float halfStripLength(0.5 * top->stripLength());
153 const float distanceFromEdge(halfStripLength - simHitPos.y());
159 const float averagePropagationTime(distanceFromEdge / signalPropagationSpeedTrue);
161 float randomResolutionTime = CLHEP::RandGaussQ::shoot(engine, 0.,
timeResolution_);
162 const float simhitTime(tof +
averageShapingTime_ + randomResolutionTime + averagePropagationTime + randomJitterTime);
163 float referenceTime = 0.;
164 referenceTime = timeCalibrationOffset_ + halfStripLength / signalPropagationSpeedTrue +
averageShapingTime_;
165 const float timeDifference(
cosmics_ ? (simhitTime - referenceTime) / COSMIC_PAR : simhitTime - referenceTime);
167 bx =
static_cast<int> (std::round((timeDifference) /
bxwidth_));
170 const bool debug(
false);
173 std::cout <<
"checktime " <<
"bx = " << bx <<
"\tdeltaT = " << timeDifference <<
"\tsimT = " << simhitTime
174 <<
"\trefT = " << referenceTime <<
"\ttof = " << tof <<
"\tavePropT = " << averagePropagationTime
175 <<
"\taveRefPropT = " << halfStripLength / signalPropagationSpeedTrue << std::endl;
186 const int nstrips(roll->
nstrips());
188 double trStripArea(0.0);
189 if (gemId.region() == 0)
192 <<
"GEMSynchronizer::simulateNoise() - this GEM id is from barrel, which cannot happen.";
195 const float striplength(top_->stripLength());
196 trStripArea = (roll->
pitch()) * striplength;
197 trArea = trStripArea * nstrips;
200 top_->radius() + CLHEP::RandFlat::shoot(engine, -1.*top_->stripLength()/2., top_->stripLength()/2.));
203 double averageNeutralNoiseRatePerRoll = 0.;
204 double averageNoiseElectronRatePerRoll = 0.;
205 double averageNoiseRatePerRoll = 0.;
206 if (gemId.station() == 1)
219 averageNoiseRatePerRoll = averageNeutralNoiseRatePerRoll + averageNoiseElectronRatePerRoll;
221 if (gemId.station() == 2)
230 +
GE21NeuBkgParam5 * rollRadius * rollRadius * rollRadius * rollRadius * rollRadius;
241 averageNoiseRatePerRoll = averageNeutralNoiseRatePerRoll + averageNoiseElectronRatePerRoll;
247 for(
int j = 0;
j < nstrips; ++
j)
249 CLHEP::RandPoissonQ randPoissonQ(*engine, aveIntrinsicNoisePerStrip);
250 const int n_intrHits(randPoissonQ.fire());
252 for (
int k = 0;
k < n_intrHits;
k++ )
254 const int time_hit(static_cast<int>(CLHEP::RandFlat::shoot(engine, nBxing)) +
minBunch_);
255 std::pair<int, int> digi(
k+1,time_hit);
261 const double averageNoise(averageNoiseRatePerRoll * nBxing *
bxwidth_ * trArea * 1.0
e-9);
262 CLHEP::RandPoissonQ randPoissonQ(*engine, averageNoise);
263 const int n_hits(randPoissonQ.fire());
264 for (
int i = 0;
i < n_hits; ++
i)
266 const int centralStrip(static_cast<int> (CLHEP::RandFlat::shoot(engine, 1, nstrips)));
267 const int time_hit(static_cast<int>(CLHEP::RandFlat::shoot(engine, nBxing)) +
minBunch_);
270 std::vector < std::pair<int, int> > cluster_;
272 cluster_.push_back(std::pair<int, int>(centralStrip, time_hit));
273 int clusterSize((CLHEP::RandFlat::shoot(engine)) <= 0.53 ? 1 : 2);
274 if (clusterSize == 2)
276 if(CLHEP::RandFlat::shoot(engine) < 0.5)
279 cluster_.push_back(std::pair<int, int>(centralStrip - 1, time_hit));
283 if (CLHEP::RandFlat::shoot(engine) <
averageEfficiency_ && (centralStrip + 1 <= nstrips))
284 cluster_.push_back(std::pair<int, int>(centralStrip + 1, time_hit));
287 for (
auto & digi : cluster_)
294 std::pair<int, int> digi(centralStrip, time_hit);
302 const PSimHit*
simHit,
const int bx, CLHEP::HepRandomEngine* engine)
306 const int nstrips(roll->
nstrips());
307 int centralStrip = 0;
308 if (!(topology.
channel(hit_position) + 1 > nstrips))
309 centralStrip = topology.
channel(hit_position) + 1;
311 centralStrip = topology.
channel(hit_position);
314 double deltaX = pointSimHit.
x() - pointDigiHit.
x();
316 std::vector < std::pair<int, int> > cluster_;
318 cluster_.push_back(std::pair<int, int>(centralStrip, bx));
320 int clusterSize((CLHEP::RandFlat::shoot(engine)) <= 0.53 ? 1 : 2);
321 if (clusterSize == 2)
326 cluster_.push_back(std::pair<int, int>(centralStrip - 1, bx));
330 if (CLHEP::RandFlat::shoot(engine) <
averageEfficiency_ && (centralStrip + 1 <= nstrips))
331 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_
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