1 #include "CLHEP/Units/defs.h" 2 #include "CLHEP/Units/SystemOfUnits.h" 3 #include "CLHEP/Units/GlobalPhysicalConstants.h" 9 #include "CLHEP/Random/RandFlat.h" 10 #include "CLHEP/Random/RandPoissonQ.h" 11 #include "CLHEP/Random/RandGaussQ.h" 18 averageEfficiency_(config.getParameter<double>(
"averageEfficiency")),
19 averageShapingTime_(config.getParameter<double>(
"averageShapingTime")),
20 timeResolution_(config.getParameter<double>(
"timeResolution")),
21 timeJitter_(config.getParameter<double>(
"timeJitter")),
22 averageNoiseRate_(config.getParameter<double>(
"averageNoiseRate")),
23 signalPropagationSpeed_(config.getParameter<double>(
"signalPropagationSpeed")),
24 bxwidth_(config.getParameter<
int>(
"bxwidth")),
25 minBunch_(config.getParameter<
int>(
"minBunch")),
26 maxBunch_(config.getParameter<
int>(
"maxBunch")),
27 digitizeOnlyMuons_(config.getParameter<
bool>(
"digitizeOnlyMuons")),
28 doBkgNoise_(config.getParameter<
bool>(
"doBkgNoise")),
29 doNoiseCLS_(config.getParameter<
bool>(
"doNoiseCLS")),
30 fixedRollRadius_(config.getParameter<
bool>(
"fixedRollRadius")),
31 simulateElectronBkg_(config.getParameter<
bool>(
"simulateElectronBkg")),
32 instLumi_(config.getParameter<double>(
"instLumi")),
33 rateFact_(config.getParameter<double>(
"rateFact")),
34 referenceInstLumi_(config.getParameter<double>(
"referenceInstLumi")),
35 ME0ElecBkgParam0_(config.getParameter<double>(
"ME0ElecBkgParam0")),
36 ME0ElecBkgParam1_(config.getParameter<double>(
"ME0ElecBkgParam1")),
37 ME0ElecBkgParam2_(config.getParameter<double>(
"ME0ElecBkgParam2")),
38 ME0ElecBkgParam3_(config.getParameter<double>(
"ME0ElecBkgParam3")),
39 ME0NeuBkgParam0_(config.getParameter<double>(
"ME0NeuBkgParam0")),
40 ME0NeuBkgParam1_(config.getParameter<double>(
"ME0NeuBkgParam1")),
41 ME0NeuBkgParam2_(config.getParameter<double>(
"ME0NeuBkgParam2")),
42 ME0NeuBkgParam3_(config.getParameter<double>(
"ME0NeuBkgParam3")) {}
50 CLHEP::HepRandomEngine* engine) {
57 bool digiMuon =
false;
58 bool digiElec =
false;
59 for (
const auto&
hit : simHits) {
63 double partMom =
hit.pabs();
64 double checkMuonEff = CLHEP::RandFlat::shoot(engine, 0., 1.);
65 double checkElecEff = CLHEP::RandFlat::shoot(engine, 0., 1.);
70 if (partMom <= 1.95
e-03)
71 elecEff = 1.7e-05 *
std::exp(2.1 * partMom * 1000.);
72 if (partMom > 1.95
e-03 && partMom < 10.
e-03)
74 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));
75 if (partMom > 10.
e-03)
77 if (checkElecEff < elecEff)
80 if (!(digiMuon || digiElec))
84 for (
const auto& digi : cluster) {
96 float randomJitterTime = CLHEP::RandGaussQ::shoot(engine, 0.,
timeJitter_);
100 throw cms::Exception(
"Geometry") <<
"ME0SimpleModel::getSimHitBx() - ME0 simhit id does not match any ME0 roll id: " 104 if (roll->id().region() == 0) {
106 <<
"ME0SimpleModel::getSimHitBx() - this ME0 id is from barrel, which cannot happen: " << roll->id() <<
"\n";
108 const int nstrips = roll->nstrips();
109 float middleStrip = nstrips / 2.;
110 const LocalPoint& middleOfRoll = roll->centreOfStrip(middleStrip);
111 const GlobalPoint& globMiddleRol = roll->toGlobal(middleOfRoll);
112 double muRadius =
sqrt(globMiddleRol.
x() * globMiddleRol.
x() + globMiddleRol.
y() * globMiddleRol.
y() +
113 globMiddleRol.
z() * globMiddleRol.
z());
114 double timeCalibrationOffset_ = (muRadius * CLHEP::ns * CLHEP::cm) / (CLHEP::c_light);
116 const float halfStripLength(0.5 * top->stripLength());
117 const float distanceFromEdge(halfStripLength - simHitPos.y());
122 const float averagePropagationTime(distanceFromEdge / signalPropagationSpeedTrue);
124 float randomResolutionTime = CLHEP::RandGaussQ::shoot(engine, 0.,
timeResolution_);
125 const float simhitTime(tof +
averageShapingTime_ + randomResolutionTime + averagePropagationTime + randomJitterTime);
126 float referenceTime = 0.;
127 referenceTime = timeCalibrationOffset_ + halfStripLength / signalPropagationSpeedTrue +
averageShapingTime_;
128 const float timeDifference(simhitTime - referenceTime);
130 bx =
static_cast<int>(std::round((timeDifference) /
bxwidth_));
133 const bool debug(
false);
135 LogDebug(
"ME0SimpleModel") <<
"checktime " 136 <<
"bx = " << bx <<
"\tdeltaT = " << timeDifference <<
"\tsimT = " << simhitTime
137 <<
"\trefT = " << referenceTime <<
"\ttof = " << tof
138 <<
"\tavePropT = " << averagePropagationTime
139 <<
"\taveRefPropT = " << halfStripLength / signalPropagationSpeedTrue << std::endl;
148 const int nstrips(roll->
nstrips());
150 double trStripArea(0.0);
152 if (me0Id.region() == 0) {
154 <<
"ME0Synchronizer::simulateNoise() - this ME0 id is from barrel, which cannot happen.";
157 const float striplength(top_->stripLength());
158 trStripArea = (roll->
pitch()) * striplength;
159 trArea = trStripArea * nstrips;
161 const float rollRadius(
164 : top_->radius() + CLHEP::RandFlat::shoot(engine, -1. * top_->stripLength() / 2., top_->stripLength() / 2.));
166 const float rSqrtR = rollRadius *
sqrt(rollRadius);
169 double averageNeutralNoiseRatePerRoll = 0.;
170 double averageNoiseElectronRatePerRoll = 0.;
171 double averageNoiseRatePerRoll = 0.;
172 if (me0Id.station() != 1) {
174 <<
"ME0SimpleModel::simulateNoise() - this ME0 id is from station 1, which cannot happen: " << roll->
id()
183 averageNoiseRatePerRoll = averageNeutralNoiseRatePerRoll + averageNoiseElectronRatePerRoll;
190 for (
int j = 0;
j < nstrips; ++
j) {
191 int randPoissonQ = CLHEP::RandPoissonQ::shoot(engine, aveIntrinsicNoisePerStrip);
193 for (
int k = 0;
k < randPoissonQ;
k++) {
194 const int time_hit(static_cast<int>(CLHEP::RandFlat::shoot(engine, nBxing)) +
minBunch_);
201 const double averageNoise(averageNoiseRatePerRoll * nBxing *
bxwidth_ * trArea * 1.0
e-9);
202 int randPoissonQ = CLHEP::RandPoissonQ::shoot(engine, averageNoise);
204 for (
int i = 0;
i < randPoissonQ; ++
i) {
205 const int centralStrip(static_cast<int>(CLHEP::RandFlat::shoot(engine, 1, nstrips)));
206 const int time_hit(static_cast<int>(CLHEP::RandFlat::shoot(engine, nBxing)) +
minBunch_);
208 std::vector<std::pair<int, int> > cluster;
209 cluster.emplace_back(centralStrip, time_hit);
210 int clusterSize((CLHEP::RandFlat::shoot(engine)) <= 0.53 ? 1 : 2);
211 if (clusterSize == 2) {
212 if (CLHEP::RandFlat::shoot(engine) < 0.5) {
214 cluster.emplace_back(centralStrip - 1, time_hit);
216 if (CLHEP::RandFlat::shoot(engine) <
averageEfficiency_ && (centralStrip + 1 <= nstrips))
217 cluster.emplace_back(centralStrip + 1, time_hit);
220 for (
const auto& digi : cluster) {
225 strips_.emplace(centralStrip, time_hit);
234 CLHEP::HepRandomEngine* engine) {
237 const int nstrips(roll->
nstrips());
238 int centralStrip = 0;
239 if (!(topology.
channel(hit_position) + 1 > nstrips))
240 centralStrip = topology.
channel(hit_position) + 1;
242 centralStrip = topology.
channel(hit_position);
245 double deltaX = pointSimHit.
x() - pointDigiHit.
x();
248 std::vector<std::pair<int, int> > cluster;
250 cluster.emplace_back(centralStrip, bx);
253 int clusterSize((CLHEP::RandFlat::shoot(engine)) <= 0.53 ? 1 : 2);
254 if (clusterSize == 2) {
257 cluster.emplace_back(centralStrip - 1, bx);
259 if (CLHEP::RandFlat::shoot(engine) <
averageEfficiency_ && (centralStrip + 1 <= nstrips))
260 cluster.emplace_back(centralStrip + 1, bx);
const StripTopology & specificTopology() const
double averageShapingTime_
ME0SimpleModel(const edm::ParameterSet &)
edm::DetSet< ME0DigiSimLink > ME0DigiSimLinks
CaloTopology const * topology(0)
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
double averageEfficiency_
bool simulateElectronBkg_
constexpr uint32_t rawId() const
get the raw id
StripDigiSimLinks stripDigiSimLinks_
LocalPoint centreOfStrip(int strip) const
const ME0EtaPartition * etaPartition(ME0DetId id) const
Return a etaPartition given its id.
int getSimHitBx(const PSimHit *, CLHEP::HepRandomEngine *)
const ME0Geometry * geometry_
float timeOfFlight() const
Local3DPoint localPosition() const
Abs< T >::type abs(const T &t)
double referenceInstLumi_
virtual int channel(const LocalPoint &p) const =0
int nstrips() const
Return the chamber this roll belongs to.
ME0DigiSimLinks theME0DigiSimLinks_
std::set< std::pair< int, int > > strips_
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
~ME0SimpleModel() override
bool simulateIntrinsicNoise_
DetectorHitMap detectorHitMap_
edm::DetSet< StripDigiSimLink > StripDigiSimLinks
std::vector< PSimHit > PSimHitContainer
void simulateSignal(const ME0EtaPartition *, const edm::PSimHitContainer &, CLHEP::HepRandomEngine *) override
const Topology & topology() const override
unsigned int detUnitId() const