6 #include "CLHEP/Random/RandFlat.h"
7 #include "CLHEP/Random/RandPoissonQ.h"
8 #include "CLHEP/Random/RandGaussQ.h"
16 averageEfficiency_(
config.getParameter<double>(
"averageEfficiency")),
17 minBunch_(
config.getParameter<
int>(
"minBunch")),
18 maxBunch_(
config.getParameter<
int>(
"maxBunch")),
19 simulateNoiseCLS_(
config.getParameter<
bool>(
"simulateNoiseCLS")),
20 fixedRollRadius_(
config.getParameter<
bool>(
"fixedRollRadius")),
21 simulateElectronBkg_(
config.getParameter<
bool>(
"simulateElectronBkg")),
22 instLumi_(
config.getParameter<double>(
"instLumi")),
23 rateFact_(
config.getParameter<double>(
"rateFact")),
24 bxWidth_(
config.getParameter<double>(
"bxWidth")),
25 referenceInstLumi_(
config.getParameter<double>(
"referenceInstLumi")),
26 GE11ElecBkgParam0_(
config.getParameter<double>(
"GE11ElecBkgParam0")),
27 GE11ElecBkgParam1_(
config.getParameter<double>(
"GE11ElecBkgParam1")),
28 GE11ElecBkgParam2_(
config.getParameter<double>(
"GE11ElecBkgParam2")),
29 GE21ElecBkgParam0_(
config.getParameter<double>(
"GE21ElecBkgParam0")),
30 GE21ElecBkgParam1_(
config.getParameter<double>(
"GE21ElecBkgParam1")),
31 GE21ElecBkgParam2_(
config.getParameter<double>(
"GE21ElecBkgParam2")),
32 GE11ModNeuBkgParam0_(
config.getParameter<double>(
"GE11ModNeuBkgParam0")),
33 GE11ModNeuBkgParam1_(
config.getParameter<double>(
"GE11ModNeuBkgParam1")),
34 GE11ModNeuBkgParam2_(
config.getParameter<double>(
"GE11ModNeuBkgParam2")),
35 GE21ModNeuBkgParam0_(
config.getParameter<double>(
"GE11ModNeuBkgParam0")),
36 GE21ModNeuBkgParam1_(
config.getParameter<double>(
"GE11ModNeuBkgParam1")),
37 GE21ModNeuBkgParam2_(
config.getParameter<double>(
"GE11ModNeuBkgParam2")) {}
43 CLHEP::HepRandomEngine* engine,
47 const int nstrips(roll->
nstrips());
49 double trStripArea(0.0);
50 if (gemId.region() == 0) {
51 throw cms::Exception(
"Geometry") <<
"GEMBkgModel::simulate() - this GEM id is from barrel, which cannot happen.";
54 const float striplength(top_->stripLength());
55 trStripArea = (roll->
pitch()) * striplength;
56 trArea = trStripArea * nstrips;
58 const float rollRadius(
61 : top_->radius() + CLHEP::RandFlat::shoot(engine, -1. * top_->stripLength() / 2., top_->stripLength() / 2.));
64 double averageNeutralNoiseRatePerRoll = 0.;
65 double averageNoiseElectronRatePerRoll = 0.;
66 double averageNoiseRatePerRoll = 0.;
67 if (gemId.station() == 1) {
69 averageNeutralNoiseRatePerRoll =
73 averageNoiseElectronRatePerRoll =
77 averageNoiseRatePerRoll = averageNeutralNoiseRatePerRoll + averageNoiseElectronRatePerRoll;
79 }
else if (gemId.station() == 2) {
81 averageNeutralNoiseRatePerRoll =
85 averageNoiseElectronRatePerRoll =
89 averageNoiseRatePerRoll = averageNeutralNoiseRatePerRoll + averageNoiseElectronRatePerRoll;
94 const double averageNoise(averageNoiseRatePerRoll * nBxing * trArea *
bxWidth_);
95 CLHEP::RandPoissonQ randPoissonQ(*engine, averageNoise);
96 const int n_hits(randPoissonQ.fire());
97 for (
int i = 0;
i < n_hits; ++
i) {
98 const int centralStrip(static_cast<int>(CLHEP::RandFlat::shoot(engine, 1, nstrips)));
99 const int time_hit(static_cast<int>(CLHEP::RandFlat::shoot(engine, nBxing)) +
minBunch_);
101 std::vector<std::pair<int, int> > cluster_;
103 cluster_.emplace_back(centralStrip, time_hit);
104 int clusterSize((CLHEP::RandFlat::shoot(engine)) <=
clusterSizeCut ? 1 : 2);
105 if (clusterSize == 2) {
106 if (CLHEP::RandFlat::shoot(engine) < 0.5) {
108 cluster_.emplace_back(centralStrip - 1, time_hit);
110 if (CLHEP::RandFlat::shoot(engine) <
averageEfficiency_ && (centralStrip + 1 <= nstrips))
111 cluster_.emplace_back(centralStrip + 1, time_hit);
114 for (
const auto& digi : cluster_) {
115 strips_.emplace(digi);
119 strips_.emplace(centralStrip, time_hit);