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"))
87 bool digiMuon =
false;
88 bool digiElec =
false;
89 for (edm::PSimHitContainer::const_iterator
hit = simHits.begin();
hit != simHits.end(); ++
hit)
94 double partMom =
hit->pabs();
95 double checkMuonEff = CLHEP::RandFlat::shoot(engine, 0., 1.);
96 double checkElecEff = CLHEP::RandFlat::shoot(engine, 0., 1.);
101 if (partMom <= 1.95
e-03)
102 elecEff = 1.7e-05 * TMath::Exp(2.1 * partMom * 1000.);
103 if (partMom > 1.95
e-03 && partMom < 10.
e-03)
104 elecEff = 1.34 *
log(7.96
e-01 * partMom * 1000. - 5.75
e-01)
105 / (1.34 +
log(7.96
e-01 * partMom * 1000. - 5.75
e-01));
106 if (partMom > 10.
e-03)
108 if (checkElecEff < elecEff)
111 if (!(digiMuon || digiElec))
115 for (
auto & digi : cluster)
129 float randomJitterTime = CLHEP::RandGaussQ::shoot(engine, 0.,
timeJitter_);
134 throw cms::Exception(
"Geometry")<<
"GEMSimpleModel::getSimHitBx() - GEM simhit id does not match any GEM roll id: " <<
id <<
"\n";
137 if (roll->id().region() == 0)
139 throw cms::Exception(
"Geometry") <<
"GEMSimpleModel::getSimHitBx() - this GEM id is from barrel, which cannot happen: " << roll->id() <<
"\n";
141 const double cspeed = 299792458;
142 const int nstrips = roll->nstrips();
143 float middleStrip = nstrips/2.;
144 LocalPoint middleOfRoll = roll->centreOfStrip(middleStrip);
145 GlobalPoint globMiddleRol = roll->toGlobal(middleOfRoll);
146 double muRadius =
sqrt(globMiddleRol.
x()*globMiddleRol.
x() + globMiddleRol.
y()*globMiddleRol.
y() +globMiddleRol.
z()*globMiddleRol.
z());
147 double timeCalibrationOffset_ = (muRadius *1
e+9)/(cspeed*1
e+2);
150 const float halfStripLength(0.5 * top->stripLength());
151 const float distanceFromEdge(halfStripLength - simHitPos.y());
157 const float averagePropagationTime(distanceFromEdge / signalPropagationSpeedTrue);
159 float randomResolutionTime = CLHEP::RandGaussQ::shoot(engine, 0.,
timeResolution_);
160 const float simhitTime(tof +
averageShapingTime_ + randomResolutionTime + averagePropagationTime + randomJitterTime);
161 float referenceTime = 0.;
162 referenceTime = timeCalibrationOffset_ + halfStripLength / signalPropagationSpeedTrue +
averageShapingTime_;
163 const float timeDifference(
cosmics_ ? (simhitTime - referenceTime) / COSMIC_PAR : simhitTime - referenceTime);
165 bx =
static_cast<int> (std::round((timeDifference) /
bxwidth_));
168 const bool debug(
false);
171 std::cout <<
"checktime " <<
"bx = " << bx <<
"\tdeltaT = " << timeDifference <<
"\tsimT = " << simhitTime
172 <<
"\trefT = " << referenceTime <<
"\ttof = " << tof <<
"\tavePropT = " << averagePropagationTime
173 <<
"\taveRefPropT = " << halfStripLength / signalPropagationSpeedTrue << std::endl;
184 const int nstrips(roll->
nstrips());
186 double trStripArea(0.0);
187 if (gemId.region() == 0)
190 <<
"GEMSynchronizer::simulateNoise() - this GEM id is from barrel, which cannot happen.";
193 const float striplength(top_->stripLength());
194 trStripArea = (roll->
pitch()) * striplength;
195 trArea = trStripArea * nstrips;
198 top_->radius() + CLHEP::RandFlat::shoot(engine, -1.*top_->stripLength()/2., top_->stripLength()/2.));
201 double averageNeutralNoiseRatePerRoll = 0.;
202 double averageNoiseElectronRatePerRoll = 0.;
203 double averageNoiseRatePerRoll = 0.;
204 if (gemId.station() == 1)
217 averageNoiseRatePerRoll = averageNeutralNoiseRatePerRoll + averageNoiseElectronRatePerRoll;
219 if (gemId.station() == 2 || gemId.station() == 3)
228 +
GE21NeuBkgParam5 * rollRadius * rollRadius * rollRadius * rollRadius * rollRadius;
239 averageNoiseRatePerRoll = averageNeutralNoiseRatePerRoll + averageNoiseElectronRatePerRoll;
245 for(
int j = 0;
j < nstrips; ++
j)
247 CLHEP::RandPoissonQ randPoissonQ(*engine, aveIntrinsicNoisePerStrip);
248 const int n_intrHits(randPoissonQ.fire());
250 for (
int k = 0;
k < n_intrHits;
k++ )
252 const int time_hit(static_cast<int>(CLHEP::RandFlat::shoot(engine, nBxing)) +
minBunch_);
253 std::pair<int, int> digi(
k+1,time_hit);
259 const double averageNoise(averageNoiseRatePerRoll * nBxing *
bxwidth_ * trArea * 1.0
e-9);
260 CLHEP::RandPoissonQ randPoissonQ(*engine, averageNoise);
261 const int n_hits(randPoissonQ.fire());
262 for (
int i = 0;
i < n_hits; ++
i)
264 const int centralStrip(static_cast<int> (CLHEP::RandFlat::shoot(engine, 1, nstrips)));
265 const int time_hit(static_cast<int>(CLHEP::RandFlat::shoot(engine, nBxing)) +
minBunch_);
268 std::vector < std::pair<int, int> > cluster_;
270 cluster_.push_back(std::pair<int, int>(centralStrip, time_hit));
271 int clusterSize((CLHEP::RandFlat::shoot(engine)) <= 0.53 ? 1 : 2);
272 if (clusterSize == 2)
274 if(CLHEP::RandFlat::shoot(engine) < 0.5)
277 cluster_.push_back(std::pair<int, int>(centralStrip - 1, time_hit));
281 if (CLHEP::RandFlat::shoot(engine) <
averageEfficiency_ && (centralStrip + 1 <= nstrips))
282 cluster_.push_back(std::pair<int, int>(centralStrip + 1, time_hit));
285 for (
auto & digi : cluster_)
292 std::pair<int, int> digi(centralStrip, time_hit);
300 const PSimHit* simHit,
const int bx, CLHEP::HepRandomEngine* engine)
304 const int nstrips(roll->
nstrips());
305 int centralStrip = 0;
306 if (!(topology.
channel(hit_position) + 1 > nstrips))
307 centralStrip = topology.
channel(hit_position) + 1;
309 centralStrip = topology.
channel(hit_position);
312 double deltaX = pointSimHit.
x() - pointDigiHit.
x();
314 std::vector < std::pair<int, int> > cluster_;
316 cluster_.push_back(std::pair<int, int>(centralStrip, bx));
318 int clusterSize((CLHEP::RandFlat::shoot(engine)) <= 0.53 ? 1 : 2);
319 if (clusterSize == 2)
324 cluster_.push_back(std::pair<int, int>(centralStrip - 1, bx));
328 if (CLHEP::RandFlat::shoot(engine) <
averageEfficiency_ && (centralStrip + 1 <= nstrips))
329 cluster_.push_back(std::pair<int, int>(centralStrip + 1, bx));
double GE21ModNeuBkgParam1
double signalPropagationSpeed_
double GE21ModNeuBkgParam4
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 *)
const GEMEtaPartition * etaPartition(GEMDetId id) const
Return a GEMEtaPartition given its id.
double GE21ModNeuBkgParam5
uint32_t rawId() const
get the raw id
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
virtual int channel(const LocalPoint &p) const =0
bool simulateLowNeutralRate_
GEMSimpleModel(const edm::ParameterSet &)
Container::value_type value_type
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