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 TrapezoidalStripTopology* top_(dynamic_cast<const TrapezoidalStripTopology*>(&(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::GEMBkgModel
GEMBkgModel(const edm::ParameterSet &)
Definition: GEMBkgModel.cc:13
electrons_cff.bool
bool
Definition: electrons_cff.py:372
mps_fire.i
i
Definition: mps_fire.py:355
GEMBkgModel::GE21ElecBkgParam2_
double GE21ElecBkgParam2_
Definition: GEMBkgModel.h:53
GEMEtaPartition::nstrips
int nstrips() const
number of readout strips in partition
Definition: GEMEtaPartition.cc:24
GEMBkgModel::GE21ModNeuBkgParam1_
double GE21ModNeuBkgParam1_
Definition: GEMBkgModel.h:59
GEMBkgModel::clusterSizeCut
const double clusterSizeCut
Definition: GEMBkgModel.h:33
GEMEtaPartition
Definition: GEMEtaPartition.h:12
GEMBkgModel.h
GEMBkgModel::GE11ModNeuBkgParam2_
double GE11ModNeuBkgParam2_
Definition: GEMBkgModel.h:57
GEMBkgModel::GE21ModNeuBkgParam0_
double GE21ModNeuBkgParam0_
Definition: GEMBkgModel.h:58
GEMBkgModel::simulateElectronBkg_
bool simulateElectronBkg_
Definition: GEMBkgModel.h:40
GEMBkgModel::GE11ModNeuBkgParam0_
double GE11ModNeuBkgParam0_
Definition: GEMBkgModel.h:55
GEMDigiModel
Definition: GEMDigiModel.h:37
GEMBkgModel::GE11ModNeuBkgParam1_
double GE11ModNeuBkgParam1_
Definition: GEMBkgModel.h:56
GEMBkgModel::bxWidth_
double bxWidth_
Definition: GEMBkgModel.h:43
config
Definition: config.py:1
GEMBkgModel::minBunch_
int minBunch_
Definition: GEMBkgModel.h:35
TrapezoidalStripTopology
Definition: TrapezoidalStripTopology.h:21
GEMBkgModel::instLumi_
double instLumi_
Definition: GEMBkgModel.h:41
GEMBkgModel::GE21ElecBkgParam0_
double GE21ElecBkgParam0_
Definition: GEMBkgModel.h:51
Strips
std::set< std::pair< int, int > > Strips
Definition: GEMDigiModel.h:31
DetectorHitMap
std::multimap< std::pair< unsigned int, int >, const PSimHit *, std::less< std::pair< unsigned int, int > > > DetectorHitMap
Definition: GEMDigiModel.h:35
GEMBkgModel::GE21ModNeuBkgParam2_
double GE21ModNeuBkgParam2_
Definition: GEMBkgModel.h:60
GEMEtaPartitionSpecs.h
edm::ParameterSet
Definition: ParameterSet.h:36
GEMBkgModel::GE11ElecBkgParam2_
double GE11ElecBkgParam2_
Definition: GEMBkgModel.h:50
GEMBkgModel::fixedRollRadius_
bool fixedRollRadius_
Definition: GEMBkgModel.h:39
GEMDetId
Definition: GEMDetId.h:17
GEMBkgModel::referenceInstLumi_
const double referenceInstLumi_
Definition: GEMBkgModel.h:44
GEMEtaPartition::topology
const Topology & topology() const override
Definition: GEMEtaPartition.cc:14
createfilelist.int
int
Definition: createfilelist.py:10
GEMEtaPartition::id
GEMDetId id() const
Definition: GEMEtaPartition.h:18
GEMBkgModel::GE11ElecBkgParam1_
double GE11ElecBkgParam1_
Definition: GEMBkgModel.h:49
GEMBkgModel::simulate
void simulate(const GEMEtaPartition *, const edm::PSimHitContainer &, CLHEP::HepRandomEngine *, Strips &, DetectorHitMap &) override
Definition: GEMBkgModel.cc:41
GEMBkgModel::simulateNoiseCLS_
bool simulateNoiseCLS_
Definition: GEMBkgModel.h:38
GEMEtaPartition::pitch
float pitch() const
Definition: GEMEtaPartition.cc:41
GEMBkgModel::GE11ElecBkgParam0_
double GE11ElecBkgParam0_
Definition: GEMBkgModel.h:48
GEMGeometry.h
TrapezoidalStripTopology.h
GEMBkgModel::~GEMBkgModel
~GEMBkgModel() override
Definition: GEMBkgModel.cc:39
Exception
Definition: hltDiff.cc:246
GEMBkgModel::rateFact_
double rateFact_
Definition: GEMBkgModel.h:42
GEMBkgModel::maxBunch_
int maxBunch_
Definition: GEMBkgModel.h:36
Exception.h
edm::PSimHitContainer
std::vector< PSimHit > PSimHitContainer
Definition: PSimHitContainer.h:11
GEMBkgModel::GE21ElecBkgParam1_
double GE21ElecBkgParam1_
Definition: GEMBkgModel.h:52
GEMBkgModel::averageEfficiency_
double averageEfficiency_
Definition: GEMBkgModel.h:34