1 #include "CLHEP/Units/defs.h" 2 #include "CLHEP/Units/SystemOfUnits.h" 3 #include "CLHEP/Units/GlobalPhysicalConstants.h" 10 #include "CLHEP/Random/RandFlat.h" 11 #include "CLHEP/Random/RandPoissonQ.h" 12 #include "CLHEP/Random/RandGaussQ.h" 19 averageEfficiency_(
config.getParameter<double>(
"averageEfficiency")),
20 averageShapingTime_(
config.getParameter<double>(
"averageShapingTime")),
21 timeResolution_(
config.getParameter<double>(
"timeResolution")),
22 timeJitter_(
config.getParameter<double>(
"timeJitter")),
23 averageNoiseRate_(
config.getParameter<double>(
"averageNoiseRate")),
24 signalPropagationSpeed_(
config.getParameter<double>(
"signalPropagationSpeed")),
25 bxwidth_(
config.getParameter<
int>(
"bxwidth")),
26 minBunch_(
config.getParameter<
int>(
"minBunch")),
27 maxBunch_(
config.getParameter<
int>(
"maxBunch")),
28 digitizeOnlyMuons_(
config.getParameter<
bool>(
"digitizeOnlyMuons")),
29 doBkgNoise_(
config.getParameter<
bool>(
"doBkgNoise")),
30 doNoiseCLS_(
config.getParameter<
bool>(
"doNoiseCLS")),
31 fixedRollRadius_(
config.getParameter<
bool>(
"fixedRollRadius")),
32 simulateElectronBkg_(
config.getParameter<
bool>(
"simulateElectronBkg")),
33 instLumi_(
config.getParameter<double>(
"instLumi")),
34 rateFact_(
config.getParameter<double>(
"rateFact")),
35 referenceInstLumi_(
config.getParameter<double>(
"referenceInstLumi")),
36 ME0ElecBkgParam0_(
config.getParameter<double>(
"ME0ElecBkgParam0")),
37 ME0ElecBkgParam1_(
config.getParameter<double>(
"ME0ElecBkgParam1")),
38 ME0ElecBkgParam2_(
config.getParameter<double>(
"ME0ElecBkgParam2")),
39 ME0ElecBkgParam3_(
config.getParameter<double>(
"ME0ElecBkgParam3")),
40 ME0NeuBkgParam0_(
config.getParameter<double>(
"ME0NeuBkgParam0")),
41 ME0NeuBkgParam1_(
config.getParameter<double>(
"ME0NeuBkgParam1")),
42 ME0NeuBkgParam2_(
config.getParameter<double>(
"ME0NeuBkgParam2")),
43 ME0NeuBkgParam3_(
config.getParameter<double>(
"ME0NeuBkgParam3")) {}
51 CLHEP::HepRandomEngine* engine) {
58 bool digiMuon =
false;
59 bool digiElec =
false;
64 double partMom =
hit.pabs();
65 double checkMuonEff = CLHEP::RandFlat::shoot(engine, 0., 1.);
66 double checkElecEff = CLHEP::RandFlat::shoot(engine, 0., 1.);
71 if (partMom <= 1.95
e-03)
72 elecEff = 1.7e-05 *
std::exp(2.1 * partMom * 1000.);
73 if (partMom > 1.95
e-03 && partMom < 10.
e-03)
75 1.34 *
log(7.96
e-01 * partMom * 1000. - 5.75
e-01) / (1.34 +
log(7.96
e-01 * partMom * 1000. - 5.75
e-01));
76 if (partMom > 10.
e-03)
78 if (checkElecEff < elecEff)
81 if (!(digiMuon || digiElec))
85 for (
const auto& digi : cluster) {
97 float randomJitterTime = CLHEP::RandGaussQ::shoot(engine, 0.,
timeJitter_);
101 throw cms::Exception(
"Geometry") <<
"ME0SimpleModel::getSimHitBx() - ME0 simhit id does not match any ME0 roll id: " 105 if (
roll->id().region() == 0) {
107 <<
"ME0SimpleModel::getSimHitBx() - this ME0 id is from barrel, which cannot happen: " <<
roll->id() <<
"\n";
109 const int nstrips =
roll->nstrips();
110 float middleStrip = nstrips / 2.;
111 const LocalPoint& middleOfRoll =
roll->centreOfStrip(middleStrip);
113 double muRadius =
sqrt(globMiddleRol.
x() * globMiddleRol.
x() + globMiddleRol.
y() * globMiddleRol.
y() +
114 globMiddleRol.
z() * globMiddleRol.
z());
115 double timeCalibrationOffset_ = (muRadius * CLHEP::ns * CLHEP::cm) / (CLHEP::c_light);
117 const float halfStripLength(0.5 * top->stripLength());
118 const float distanceFromEdge(halfStripLength - simHitPos.y());
123 const float averagePropagationTime(distanceFromEdge / signalPropagationSpeedTrue);
125 float randomResolutionTime = CLHEP::RandGaussQ::shoot(engine, 0.,
timeResolution_);
126 const float simhitTime(tof +
averageShapingTime_ + randomResolutionTime + averagePropagationTime + randomJitterTime);
127 float referenceTime = 0.;
128 referenceTime = timeCalibrationOffset_ + halfStripLength / signalPropagationSpeedTrue +
averageShapingTime_;
129 const float timeDifference(simhitTime - referenceTime);
131 bx =
static_cast<int>(std::round((timeDifference) /
bxwidth_));
134 const bool debug(
false);
136 LogDebug(
"ME0SimpleModel") <<
"checktime " 137 <<
"bx = " <<
bx <<
"\tdeltaT = " << timeDifference <<
"\tsimT = " << simhitTime
138 <<
"\trefT = " << referenceTime <<
"\ttof = " << tof
139 <<
"\tavePropT = " << averagePropagationTime
140 <<
"\taveRefPropT = " << halfStripLength / signalPropagationSpeedTrue << std::endl;
149 const int nstrips(
roll->nstrips());
151 double trStripArea(0.0);
153 if (me0Id.region() == 0) {
155 <<
"ME0Synchronizer::simulateNoise() - this ME0 id is from barrel, which cannot happen.";
158 const float striplength(top_->stripLength());
159 trStripArea = (
roll->pitch()) * striplength;
160 trArea = trStripArea * nstrips;
162 const float rollRadius(
165 : top_->radius() + CLHEP::RandFlat::shoot(engine, -1. * top_->stripLength() / 2., top_->stripLength() / 2.));
167 const float rSqrtR = rollRadius *
sqrt(rollRadius);
170 double averageNeutralNoiseRatePerRoll = 0.;
171 double averageNoiseElectronRatePerRoll = 0.;
172 double averageNoiseRatePerRoll = 0.;
173 if (me0Id.station() != 1) {
175 <<
"ME0SimpleModel::simulateNoise() - this ME0 id is from station 1, which cannot happen: " <<
roll->id()
184 averageNoiseRatePerRoll = averageNeutralNoiseRatePerRoll + averageNoiseElectronRatePerRoll;
191 for (
int j = 0;
j < nstrips; ++
j) {
192 int randPoissonQ = CLHEP::RandPoissonQ::shoot(engine, aveIntrinsicNoisePerStrip);
194 for (
int k = 0;
k < randPoissonQ;
k++) {
195 const int time_hit(static_cast<int>(CLHEP::RandFlat::shoot(engine, nBxing)) +
minBunch_);
202 const double averageNoise(averageNoiseRatePerRoll * nBxing *
bxwidth_ * trArea * 1.0
e-9);
203 int randPoissonQ = CLHEP::RandPoissonQ::shoot(engine, averageNoise);
205 for (
int i = 0;
i < randPoissonQ; ++
i) {
206 const int centralStrip(static_cast<int>(CLHEP::RandFlat::shoot(engine, 1, nstrips)));
207 const int time_hit(static_cast<int>(CLHEP::RandFlat::shoot(engine, nBxing)) +
minBunch_);
209 std::vector<std::pair<int, int> > cluster;
210 cluster.emplace_back(centralStrip, time_hit);
211 int clusterSize((CLHEP::RandFlat::shoot(engine)) <= 0.53 ? 1 : 2);
213 if (CLHEP::RandFlat::shoot(engine) < 0.5) {
215 cluster.emplace_back(centralStrip - 1, time_hit);
217 if (CLHEP::RandFlat::shoot(engine) <
averageEfficiency_ && (centralStrip + 1 <= nstrips))
218 cluster.emplace_back(centralStrip + 1, time_hit);
221 for (
const auto& digi : cluster) {
226 strips_.emplace(centralStrip, time_hit);
235 CLHEP::HepRandomEngine* engine) {
238 const int nstrips(
roll->nstrips());
239 int centralStrip = 0;
240 if (!(
topology.channel(hit_position) + 1 > nstrips))
241 centralStrip =
topology.channel(hit_position) + 1;
243 centralStrip =
topology.channel(hit_position);
246 double deltaX = pointSimHit.
x() - pointDigiHit.
x();
249 std::vector<std::pair<int, int> > cluster;
251 cluster.emplace_back(centralStrip,
bx);
254 int clusterSize((CLHEP::RandFlat::shoot(engine)) <= 0.53 ? 1 : 2);
258 cluster.emplace_back(centralStrip - 1,
bx);
260 if (CLHEP::RandFlat::shoot(engine) <
averageEfficiency_ && (centralStrip + 1 <= nstrips))
261 cluster.emplace_back(centralStrip + 1,
bx);
double averageShapingTime_
unsigned int detUnitId() const
ME0SimpleModel(const edm::ParameterSet &)
edm::DetSet< ME0DigiSimLink > ME0DigiSimLinks
double averageEfficiency_
bool simulateElectronBkg_
StripDigiSimLinks stripDigiSimLinks_
int getSimHitBx(const PSimHit *, CLHEP::HepRandomEngine *)
const ME0Geometry * geometry_
Abs< T >::type abs(const T &t)
double referenceInstLumi_
ME0DigiSimLinks theME0DigiSimLinks_
std::set< std::pair< int, int > > strips_
Local3DPoint localPosition() const
double signalPropagationSpeed_
void simulateNoise(const ME0EtaPartition *, CLHEP::HepRandomEngine *) override
std::vector< std::pair< int, int > > simulateClustering(const ME0EtaPartition *, const PSimHit *, const int, CLHEP::HepRandomEngine *) override
const ME0EtaPartition * etaPartition(ME0DetId id) const
Return a etaPartition given its id.
~ME0SimpleModel() override
bool simulateIntrinsicNoise_
DetectorHitMap detectorHitMap_
edm::DetSet< StripDigiSimLink > StripDigiSimLinks
float timeOfFlight() const
std::vector< PSimHit > PSimHitContainer
void simulateSignal(const ME0EtaPartition *, const edm::PSimHitContainer &, CLHEP::HepRandomEngine *) override