CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ME0PreRecoGaussianModel.cc
Go to the documentation of this file.
5 
6 #include "CLHEP/Random/RandFlat.h"
7 #include "CLHEP/Random/RandGaussQ.h"
8 #include "CLHEP/Random/RandPoissonQ.h"
9 
10 #include <cmath>
11 #include <utility>
12 #include <map>
13 
15  ME0DigiPreRecoModel(config)
16 , sigma_t(config.getParameter<double> ("timeResolution"))
17 , sigma_u(config.getParameter<double> ("phiResolution"))
18 , sigma_v(config.getParameter<double> ("etaResolution"))
19 , corr(config.getParameter<bool> ("useCorrelation"))
20 , etaproj(config.getParameter<bool> ("useEtaProjectiveGEO"))
21 , digitizeOnlyMuons_(config.getParameter<bool> ("digitizeOnlyMuons"))
22 , averageEfficiency_(config.getParameter<double> ("averageEfficiency"))
23 , doBkgNoise_(config.getParameter<bool> ("doBkgNoise"))
24 , simulateIntrinsicNoise_(config.getParameter<bool> ("simulateIntrinsicNoise"))
25 , simulateElectronBkg_(config.getParameter<bool>("simulateElectronBkg"))
26 , averageNoiseRate_(config.getParameter<double> ("averageNoiseRate"))
27 , bxwidth_(config.getParameter<int> ("bxwidth"))
28 , minBunch_(config.getParameter<int> ("minBunch"))
29 , maxBunch_(config.getParameter<int> ("maxBunch"))
30 
31 {
32  //params for the simple pol6 model of neutral and electron bkg for ME0:
33  ME0ModNeuBkgParam0 = 5.69e+06;
34  ME0ModNeuBkgParam1 = -293334;
35  ME0ModNeuBkgParam2 = 6279.6;
36  ME0ModNeuBkgParam3 = -71.2928;
37  ME0ModNeuBkgParam4 = 0.452244;
38  ME0ModNeuBkgParam5 = -0.0015191;
39  ME0ModNeuBkgParam6 = 2.1106e-06;
40 
41  ME0ModElecBkgParam0 = 3.77712e+06;
42  ME0ModElecBkgParam1 = -199280;
43  ME0ModElecBkgParam2 = 4340.69;
44  ME0ModElecBkgParam3 = -49.922;
45  ME0ModElecBkgParam4 = 0.319699;
46  ME0ModElecBkgParam5 = -0.00108113;
47  ME0ModElecBkgParam6 = 1.50889e-06;
48 
49 }
50 
52 {
53 }
54 
55 void ME0PreRecoGaussianModel::simulateSignal(const ME0EtaPartition* roll, const edm::PSimHitContainer& simHits, CLHEP::HepRandomEngine* engine)
56 {
57 for (const auto & hit: simHits)
58 {
59  if (std::abs(hit.particleType()) != 13 && digitizeOnlyMuons_) continue;
60  // GEM efficiency
61  if (CLHEP::RandFlat::shoot(engine) > averageEfficiency_) continue;
62 
63  auto entry = hit.entryPoint();
64  float x=CLHEP::RandGaussQ::shoot(engine, entry.x(), sigma_u);
65  float y=CLHEP::RandGaussQ::shoot(engine, entry.y(), sigma_v);
66  float ex=sigma_u;
67  float ey=sigma_v;
68  float corr=0.;
69  float tof=CLHEP::RandGaussQ::shoot(engine, hit.timeOfFlight(), sigma_t);
70  int pdgid = hit.particleType();
71  // please keep hit time always 0 for this model
72  ME0DigiPreReco digi(x,y,ex,ey,corr,tof,pdgid);
73  digi_.insert(digi);
74 }
75 }
76 
77 void ME0PreRecoGaussianModel::simulateNoise(const ME0EtaPartition* roll, CLHEP::HepRandomEngine* engine)
78 {
79  const double cspeed = 299792458;
80  double trArea(0.0);
81  const ME0DetId me0Id(roll->id());
82 
83  if (me0Id.region() == 0)
84  {
85  throw cms::Exception("Geometry")
86  << "GEMSynchronizer::simulateNoise() - this GEM id is from barrel, which cannot happen.";
87  }
88  const TrapezoidalStripTopology* top_(dynamic_cast<const TrapezoidalStripTopology*> (&(roll->topology())));
89 
90  // base_bottom, base_top, height, strips, pads (all half length)
91  auto& parameters(roll->specs()->parameters());
92  float semiBottomEdge(parameters[0]);
93  float semiTopEdge(parameters[1]);
94  float semiHeight(parameters[2]);
95  float myTanPhi = (semiTopEdge - semiBottomEdge) / (semiHeight * 2);
96  double rollRadius = top_->radius();
97  const int nBxing(maxBunch_ - minBunch_ + 1);
98  trArea = 2 * semiHeight * (semiTopEdge + semiBottomEdge);
99 
100  //simulate bkg contribution
101  if (!doBkgNoise_)
102  return;
103 
104  double aveNeutrRateBotRoll = 0.;
105  double averageNoiseElectronRatePerRoll = 0.;
106  int pdgid = 0;
107 
108  float myRand = CLHEP::RandFlat::shoot(engine);
109  float yy_rand = 2 * semiHeight * (myRand - 0.5);
110 
111  double radius_rand = rollRadius + yy_rand;
112 
114  averageNoiseElectronRatePerRoll = ME0ModElecBkgParam0
115  + ME0ModElecBkgParam1 * radius_rand
116  + ME0ModElecBkgParam2 * radius_rand * radius_rand
117  + ME0ModElecBkgParam3 * radius_rand * radius_rand * radius_rand
118  + ME0ModElecBkgParam4 * radius_rand * radius_rand * radius_rand * radius_rand
119  + ME0ModElecBkgParam5 * radius_rand * radius_rand * radius_rand * radius_rand * radius_rand
120  + ME0ModElecBkgParam6 * radius_rand * radius_rand * radius_rand * radius_rand * radius_rand * radius_rand;
121 
122  const double averageNoiseElec(averageNoiseElectronRatePerRoll * nBxing * bxwidth_ * trArea * 1.0e-9);
123  const int n_elechits(CLHEP::RandPoissonQ::shoot(engine, averageNoiseElec));
124 
125  double xMax = semiTopEdge - (semiHeight - yy_rand) * myTanPhi;
126  for (int i = 0; i < n_elechits; ++i)
127  {
128  //calculate xx_rand at a given yy_rand
129  float myRandX = CLHEP::RandFlat::shoot(engine);
130  float xx_rand = 2 * xMax * (myRandX - 0.5);
131 
132  float ex = sigma_u;
133  float ey = sigma_v;
134  float corr = 0.;
135 
136  GlobalPoint pointDigiHit = roll->toGlobal(LocalPoint(xx_rand, yy_rand));
137  //calc tof to the random estimated point
138  double stripRadius = sqrt(pointDigiHit.x() * pointDigiHit.x() + pointDigiHit.y() * pointDigiHit.y()
139  + pointDigiHit.z() * pointDigiHit.z());
140  double timeCalibrationOffset_ = (stripRadius * 1e+9) / (cspeed * 1e+2); //[ns]
141  float tof = CLHEP::RandGaussQ::shoot(engine, timeCalibrationOffset_, sigma_t);
142 
143  float myrand = CLHEP::RandFlat::shoot(engine);
144  if (myrand <= 0.5)
145  pdgid = -11;
146  else
147  pdgid = 11;
148 
149  ME0DigiPreReco digi(xx_rand, yy_rand, ex, ey, corr, tof, pdgid);
150  digi_.insert(digi);
151  }
152 
153  aveNeutrRateBotRoll = ME0ModNeuBkgParam0
154  + ME0ModNeuBkgParam1 * radius_rand
155  + ME0ModNeuBkgParam2 * radius_rand * radius_rand
156  + ME0ModNeuBkgParam3 * radius_rand * radius_rand * radius_rand
157  + ME0ModNeuBkgParam4 * radius_rand * radius_rand * radius_rand * radius_rand
158  + ME0ModNeuBkgParam5 * radius_rand * radius_rand * radius_rand * radius_rand * radius_rand
159  + ME0ModNeuBkgParam6 * radius_rand * radius_rand * radius_rand * radius_rand * radius_rand * radius_rand;
160 
161  const double averageNoiseNeutral(aveNeutrRateBotRoll * nBxing * bxwidth_ * trArea * 1.0e-9);
162  const int n_hits(CLHEP::RandPoissonQ::shoot(engine, averageNoiseNeutral));
163 
164  for (int i = 0; i < n_hits; ++i)
165  {
166  //calculate xx_rand at a given yy_rand
167  float myRandX = CLHEP::RandFlat::shoot(engine);
168  float xx_rand = 2 * xMax * (myRandX - 0.5);
169 
170  float ex = sigma_u;
171  float ey = sigma_v;
172  float corr = 0.;
173 
174  GlobalPoint pointDigiHit = roll->toGlobal(LocalPoint(xx_rand, yy_rand));
175  //calc tof to the random estimated point
176  double stripRadius = sqrt(pointDigiHit.x() * pointDigiHit.x() + pointDigiHit.y() * pointDigiHit.y()
177  + pointDigiHit.z() * pointDigiHit.z());
178  double timeCalibrationOffset_ = (stripRadius * 1e+9) / (cspeed * 1e+2); //[ns]
179  float tof = CLHEP::RandGaussQ::shoot(engine, timeCalibrationOffset_, sigma_t);
180 
181  //distribute bkg between neutrons and gammas
182  float myrand = CLHEP::RandFlat::shoot(engine);
183  if (myrand <= 0.1)
184  pdgid = 2112; // neutrons
185  else
186  pdgid = 22;
187 
188  ME0DigiPreReco digi(xx_rand, yy_rand, ex, ey, corr, tof, pdgid);
189  digi_.insert(digi);
190  }
191 }
192 
const ME0EtaPartitionSpecs * specs() const
int i
Definition: DBlmapReader.cc:9
dictionary parameters
Definition: Parameters.py:2
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:52
T y() const
Definition: PV3DBase.h:63
const ME0Specs & parameters() const
T sqrt(T t)
Definition: SSEVec.h:48
ME0DetId id() const
T z() const
Definition: PV3DBase.h:64
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
JetCorrectorParameters corr
Definition: classes.h:5
void simulateSignal(const ME0EtaPartition *, const edm::PSimHitContainer &, CLHEP::HepRandomEngine *) override
std::set< ME0DigiPreReco > digi_
tuple simHits
Definition: trackerHits.py:16
void simulateNoise(const ME0EtaPartition *, CLHEP::HepRandomEngine *) override
const Topology & topology() const
ME0PreRecoGaussianModel(const edm::ParameterSet &)
Local3DPoint LocalPoint
Definition: LocalPoint.h:11
std::vector< PSimHit > PSimHitContainer
T x() const
Definition: PV3DBase.h:62