CMS 3D CMS Logo

GEMBkgModel.cc
Go to the documentation of this file.
6 #include "CLHEP/Random/RandFlat.h"
7 #include "CLHEP/Random/RandPoissonQ.h"
8 #include "CLHEP/Random/RandGaussQ.h"
9 #include <cmath>
10 #include <utility>
11 #include <map>
12 
15  clusterSizeCut(0.53),
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")) {}
38 
40 
42  const edm::PSimHitContainer&,
43  CLHEP::HepRandomEngine* engine,
44  Strips& strips_,
45  DetectorHitMap& detectorHitMap_) {
46  const GEMDetId& gemId(roll->id());
47  const int nstrips(roll->nstrips());
48  double trArea(0.0);
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.";
52  }
53  const GEMStripTopology* top_(dynamic_cast<const GEMStripTopology*>(&(roll->topology())));
54  const float striplength(top_->stripLength());
55  trStripArea = (roll->pitch()) * striplength;
56  trArea = trStripArea * nstrips;
57  const int nBxing(maxBunch_ - minBunch_ + 1);
58  const float rollRadius(
60  ? top_->radius()
61  : top_->radius() + CLHEP::RandFlat::shoot(engine, -1. * top_->stripLength() / 2., top_->stripLength() / 2.));
62 
63  //calculate noise from model
64  double averageNeutralNoiseRatePerRoll = 0.;
65  double averageNoiseElectronRatePerRoll = 0.;
66  double averageNoiseRatePerRoll = 0.;
67  if (gemId.station() == 1) {
68  //simulate neutral background for GE1/1
69  averageNeutralNoiseRatePerRoll =
71  GE11ModNeuBkgParam2_ * rollRadius * rollRadius); //simulate electron background for GE1/1
73  averageNoiseElectronRatePerRoll =
74  (GE11ElecBkgParam0_ + GE11ElecBkgParam1_ * rollRadius + GE11ElecBkgParam2_ * rollRadius * rollRadius);
75 
76  // Scale up/down for desired instantaneous lumi (reference is 5E34, double from config is in units of 1E34)
77  averageNoiseRatePerRoll = averageNeutralNoiseRatePerRoll + averageNoiseElectronRatePerRoll;
78  averageNoiseRatePerRoll *= instLumi_ * rateFact_ / referenceInstLumi_;
79  } else if (gemId.station() == 2) {
80  //simulate neutral background for GE2/1
81  averageNeutralNoiseRatePerRoll =
82  (GE21ModNeuBkgParam0_ + GE21ModNeuBkgParam1_ * rollRadius + GE21ModNeuBkgParam2_ * rollRadius * rollRadius);
83  //simulate electron background for GE2/1
85  averageNoiseElectronRatePerRoll =
86  (GE21ElecBkgParam0_ + GE21ElecBkgParam1_ * rollRadius + GE21ElecBkgParam2_ * rollRadius * rollRadius);
87 
88  // Scale up/down for desired instantaneous lumi (reference is 5E34, double from config is in units of 1E34)
89  averageNoiseRatePerRoll = averageNeutralNoiseRatePerRoll + averageNoiseElectronRatePerRoll;
90  averageNoiseRatePerRoll *= instLumi_ * rateFact_ / referenceInstLumi_;
91  }
92 
93  //simulate bkg contribution
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_);
100  if (simulateNoiseCLS_) {
101  std::vector<std::pair<int, int> > cluster_;
102  cluster_.clear();
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) {
107  if (CLHEP::RandFlat::shoot(engine) < averageEfficiency_ && (centralStrip - 1 > 0))
108  cluster_.emplace_back(centralStrip - 1, time_hit);
109  } else {
110  if (CLHEP::RandFlat::shoot(engine) < averageEfficiency_ && (centralStrip + 1 <= nstrips))
111  cluster_.emplace_back(centralStrip + 1, time_hit);
112  }
113  }
114  for (const auto& digi : cluster_) {
115  strips_.emplace(digi);
116  }
117  } //end simulateNoiseCLS_
118  else {
119  strips_.emplace(centralStrip, time_hit);
120  }
121  }
122  return;
123 }
GEMBkgModel(const edm::ParameterSet &)
Definition: GEMBkgModel.cc:13
double GE21ModNeuBkgParam1_
Definition: GEMBkgModel.h:59
double GE21ElecBkgParam2_
Definition: GEMBkgModel.h:53
const double clusterSizeCut
Definition: GEMBkgModel.h:33
double GE11ModNeuBkgParam2_
Definition: GEMBkgModel.h:57
bool simulateElectronBkg_
Definition: GEMBkgModel.h:40
double GE11ModNeuBkgParam0_
Definition: GEMBkgModel.h:55
double GE11ModNeuBkgParam1_
Definition: GEMBkgModel.h:56
double GE21ModNeuBkgParam0_
Definition: GEMBkgModel.h:58
Definition: config.py:1
double bxWidth_
Definition: GEMBkgModel.h:43
GEMDetId id() const
double instLumi_
Definition: GEMBkgModel.h:41
double GE21ElecBkgParam0_
Definition: GEMBkgModel.h:51
double GE21ModNeuBkgParam2_
Definition: GEMBkgModel.h:60
bool fixedRollRadius_
Definition: GEMBkgModel.h:39
const double referenceInstLumi_
Definition: GEMBkgModel.h:44
double GE11ElecBkgParam2_
Definition: GEMBkgModel.h:50
float pitch() const
double GE11ElecBkgParam1_
Definition: GEMBkgModel.h:49
void simulate(const GEMEtaPartition *, const edm::PSimHitContainer &, CLHEP::HepRandomEngine *, Strips &, DetectorHitMap &) override
Definition: GEMBkgModel.cc:41
const Topology & topology() const override
bool simulateNoiseCLS_
Definition: GEMBkgModel.h:38
std::multimap< std::pair< unsigned int, int >, const PSimHit *, std::less< std::pair< unsigned int, int > > > DetectorHitMap
Definition: GEMDigiModel.h:35
std::set< std::pair< int, int > > Strips
Definition: GEMDigiModel.h:31
double GE11ElecBkgParam0_
Definition: GEMBkgModel.h:48
double rateFact_
Definition: GEMBkgModel.h:42
~GEMBkgModel() override
Definition: GEMBkgModel.cc:39
int nstrips() const
number of readout strips in partition
std::vector< PSimHit > PSimHitContainer
double GE21ElecBkgParam1_
Definition: GEMBkgModel.h:52
double averageEfficiency_
Definition: GEMBkgModel.h:34