CMS 3D CMS Logo

HcalSimParameters.cc
Go to the documentation of this file.
9 #include "CLHEP/Random/RandGaussQ.h"
10 using namespace std;
11 
13  double samplingFactor,
14  double timePhase,
15  int readoutFrameSize,
16  int binOfMaximum,
17  bool doPhotostatistics,
18  bool syncPhase,
19  int firstRing,
20  const std::vector<double>& samplingFactors,
21  double sipmTau)
22  : CaloSimParameters(simHitToPhotoelectrons,
23  0.0,
24  samplingFactor,
25  timePhase,
26  readoutFrameSize,
27  binOfMaximum,
28  doPhotostatistics,
29  syncPhase),
30  theDbService(nullptr),
31  theSiPMcharacteristics(nullptr),
32  theFirstRing(firstRing),
33  theSamplingFactors(samplingFactors),
34  theSiPMSmearing(false),
35  doTimeSmear_(true),
36  theSiPMTau(sipmTau) {
38 
39  edm::LogInfo("HcalSimParameters:") << " doSiPMsmearing = " << theSiPMSmearing;
40 }
41 
43  : CaloSimParameters(p, true),
45  theFirstRing(p.getParameter<int>("firstRing")),
46  theSamplingFactors(p.getParameter<std::vector<double> >("samplingFactors")),
47  theSiPMSmearing(p.getParameter<bool>("doSiPMSmearing")),
48  doTimeSmear_(p.getParameter<bool>("timeSmearing")),
49  theSiPMTau(p.getParameter<double>("sipmTau")),
50  threshold_currentTDC_(p.getParameter<double>("threshold_currentTDC")) {
52 
53  edm::LogInfo("HcalSimParameters:") << " doSiPMsmearing = " << theSiPMSmearing;
54 }
55 
57  assert(service);
58  theDbService = service;
60  assert(theSiPMcharacteristics);
61 }
62 
64  // the gain is in units of GeV/fC. We want a constant with pe/dGeV
65  // pe/dGeV = (GeV/dGeV) / (GeV/fC) / (fC/pe)
67  if (HcalGenericDetId(detId).genericSubdet() != HcalGenericDetId::HcalGenForward ||
68  HcalGenericDetId(detId).genericSubdet() != HcalGenericDetId::HcalGenZDC) {
69  result = samplingFactor(detId) / fCtoGeV(detId) / photoelectronsToAnalog(detId);
70  }
71  return result;
72 }
73 
74 double HcalSimParameters::fCtoGeV(const DetId& detId) const {
75  assert(theDbService != nullptr);
76  HcalGenericDetId hcalGenDetId(detId);
77  const HcalGain* gains = theDbService->getGain(hcalGenDetId);
78  const HcalGainWidth* gwidths = theDbService->getGainWidth(hcalGenDetId);
79  double result = 0.0;
80  if (!gains || !gwidths) {
81  edm::LogError("HcalAmplifier") << "Could not fetch HCAL conditions for channel " << hcalGenDetId;
82  } else {
83  // only one gain will be recorded per channel, so just use capID 0 for now
84  result = gains->getValue(0);
85  // if(doNoise_)
87  // result += CLHEP::RandGaussQ::shoot(0., gwidths->getValue(0));
88  // }
89  }
90  return result;
91 }
92 
93 double HcalSimParameters::samplingFactor(const DetId& detId) const {
94  HcalDetId hcalDetId(detId);
95  return theSamplingFactors.at(hcalDetId.ietaAbs() - theFirstRing);
96 }
97 
99  //now always taken from database for HPDs or SiPMs (HB, HE, HO)
100  assert(theDbService);
101  return theDbService->getHcalSiPMParameter(detId)->getFCByPE();
102 }
103 
104 //static const double GeV2fC = 1.0/0.145;
105 static const double GeV2fC = 1.0 / 0.4;
106 
108  // GeV->ampl (fC), time (ns)
109  theSmearSettings.emplace_back(4.00 * GeV2fC, 4.050);
110  theSmearSettings.emplace_back(20.00 * GeV2fC, 3.300);
111  theSmearSettings.emplace_back(25.00 * GeV2fC, 2.925);
112  theSmearSettings.emplace_back(30.00 * GeV2fC, 2.714);
113  theSmearSettings.emplace_back(37.00 * GeV2fC, 2.496);
114  theSmearSettings.emplace_back(44.50 * GeV2fC, 2.278);
115  theSmearSettings.emplace_back(56.00 * GeV2fC, 2.138);
116  theSmearSettings.emplace_back(63.50 * GeV2fC, 2.022);
117  theSmearSettings.emplace_back(81.00 * GeV2fC, 1.788);
118  theSmearSettings.emplace_back(88.50 * GeV2fC, 1.695);
119  theSmearSettings.emplace_back(114.50 * GeV2fC, 1.716);
120  theSmearSettings.emplace_back(175.50 * GeV2fC, 1.070);
121  theSmearSettings.emplace_back(350.00 * GeV2fC, 1.564);
122  theSmearSettings.emplace_back(99999.00 * GeV2fC, 1.564);
123 }
124 
125 double HcalSimParameters::timeSmearRMS(double ampl) const {
127  double smearsigma = 0;
128 
129  for (i = 0; i < theSmearSettings.size(); i++)
130  if (theSmearSettings[i].first > ampl)
131  break;
132 
133  // Smearing occurs only within the envelope definitions.
134  if (i != 0 && (i < theSmearSettings.size())) {
135  double energy1 = theSmearSettings[i - 1].first;
136  double sigma1 = theSmearSettings[i - 1].second;
137  double energy2 = theSmearSettings[i].first;
138  double sigma2 = theSmearSettings[i].second;
139 
140  if (energy2 != energy1)
141  smearsigma = sigma1 + ((sigma2 - sigma1) * (ampl - energy1) / (energy2 - energy1));
142  else
143  smearsigma = (sigma2 + sigma1) / 2.;
144  }
145 
146  return smearsigma;
147 }
148 
149 int HcalSimParameters::pixels(const DetId& detId) const {
150  assert(theDbService);
152  return theSiPMcharacteristics->getPixels(type);
153 }
154 
155 double HcalSimParameters::sipmDarkCurrentuA(const DetId& detId) const {
156  assert(theDbService);
158 }
159 
160 double HcalSimParameters::sipmCrossTalk(const DetId& detId) const {
161  assert(theDbService);
163  return theSiPMcharacteristics->getCrossTalk(type);
164 }
165 std::vector<float> HcalSimParameters::sipmNonlinearity(const DetId& detId) const {
166  assert(theDbService);
169 }
170 
171 unsigned int HcalSimParameters::signalShape(const DetId& detId) const {
172  assert(theDbService);
173  return theDbService->getHcalMCParam(detId)->signalShape();
174 }
std::vector< float > sipmNonlinearity(const DetId &detId) const
const HcalSiPMCharacteristics * theSiPMcharacteristics
type
Definition: HCALResponse.h:21
const HcalGainWidth * getGainWidth(const HcalGenericDetId &fId) const
double fCtoGeV(const DetId &detId) const
#define nullptr
int getType() const
get SiPM type
int pixels(const DetId &detId) const
float getValue(int fCapId) const
get value for capId = 0..3
Definition: HcalGain.h:21
uint16_t size_type
Main class for Parameters in different subdetectors.
float getCrossTalk(int type) const
get cross talk
static const double GeV2fC
HcalTimeSmearSettings theSmearSettings
unsigned int signalShape(const DetId &detId) const
double timeSmearRMS(double ampl) const
double simHitToPhotoelectrons() const
const HcalMCParam * getHcalMCParam(const HcalGenericDetId &fId) const
std::vector< double > theSamplingFactors
virtual double samplingFactor(const DetId &detId) const
float getDarkCurrent() const
get dark current
int ietaAbs() const
get the absolute value of the cell ieta
Definition: HcalDetId.h:148
Definition: DetId.h:17
HcalSimParameters(double simHitToPhotoelectrons, double samplingFactor, double timePhase, int readoutFrameSize, int binOfMaximum, bool doPhotostatistics, bool syncPhase, int firstRing, const std::vector< double > &samplingFactors, double sipmTau)
double sipmDarkCurrentuA(const DetId &detId) const
const HcalGain * getGain(const HcalGenericDetId &fId) const
const HcalSiPMCharacteristics * getHcalSiPMCharacteristics() const
std::vector< float > getNonLinearities(int type) const
get nonlinearity constants
unsigned int signalShape() const
Definition: HcalMCParam.h:38
void setDbService(const HcalDbService *service)
double sipmCrossTalk(const DetId &detId) const
const HcalDbService * theDbService
int getPixels(int type) const
get # of pixels
const HcalSiPMParameter * getHcalSiPMParameter(const HcalGenericDetId &fId) const
float getFCByPE() const
get fcByPE
double photoelectronsToAnalog() const
the factor which goes from photoelectrons to whatever gets read by ADCs