test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalSimParameters.cc
Go to the documentation of this file.
9 #include "CLHEP/Random/RandGaussQ.h"
10 using namespace std;
11 
12 HcalSimParameters::HcalSimParameters(double simHitToPhotoelectrons,
13  const std::vector<double> & photoelectronsToAnalog,
14  double samplingFactor, double timePhase,
15  int readoutFrameSize, int binOfMaximum,
16  bool doPhotostatistics, bool syncPhase,
17  int firstRing, const std::vector<double> & samplingFactors,
18  double sipmTau
19  )
20 : CaloSimParameters(simHitToPhotoelectrons, photoelectronsToAnalog[0], samplingFactor, timePhase,
21  readoutFrameSize, binOfMaximum, doPhotostatistics, syncPhase),
22  theDbService(0),
23  theSiPMcharacteristics(0),
24  theFirstRing(firstRing),
25  theSamplingFactors(samplingFactors),
26  thePE2fCByRing(photoelectronsToAnalog),
27  theSiPMSmearing(false),
28  doTimeSmear_(true),
29  theSiPMTau(sipmTau)
30 {
32 
33  edm::LogInfo("HcalSimParameters:") << " doSiPMsmearing = " << theSiPMSmearing;
34 }
35 
38  theDbService(0),
39  theFirstRing( p.getParameter<int>("firstRing") ),
40  theSamplingFactors( p.getParameter<std::vector<double> >("samplingFactors") ),
41  thePE2fCByRing( p.getParameter<std::vector<double> >("photoelectronsToAnalog") ),
42  theSiPMSmearing( p.getParameter<bool>("doSiPMSmearing") ),
43  doTimeSmear_( p.getParameter<bool>("timeSmearing") ),
44  theSiPMTau( p.getParameter<double>("sipmTau") )
45 {
47 
48  edm::LogInfo("HcalSimParameters:") << " doSiPMsmearing = " << theSiPMSmearing;
49 }
50 
52 {
53  assert(service);
54  theDbService = service;
57 }
58 
60 {
61  // the gain is in units of GeV/fC. We want a constant with pe/dGeV
62  // pe/dGeV = (GeV/dGeV) / (GeV/fC) / (fC/pe)
64  if(HcalGenericDetId(detId).genericSubdet() != HcalGenericDetId::HcalGenForward
65  || HcalGenericDetId(detId).genericSubdet() != HcalGenericDetId::HcalGenZDC)
66  {
67  result = samplingFactor(detId) / fCtoGeV(detId) / photoelectronsToAnalog(detId);
68  }
69  return result;
70 }
71 
72 
73 double HcalSimParameters::fCtoGeV(const DetId & detId) const
74 {
75  assert(theDbService != 0);
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  {
82  edm::LogError("HcalAmplifier") << "Could not fetch HCAL conditions for channel " << hcalGenDetId;
83  }
84  else
85  {
86  // only one gain will be recorded per channel, so just use capID 0 for now
87  result = gains->getValue(0);
88 // if(doNoise_)
90 // result += CLHEP::RandGaussQ::shoot(0., gwidths->getValue(0));
91 // }
92  }
93  return result;
94 }
95 
96 double HcalSimParameters::samplingFactor(const DetId & detId) const
97 {
98  HcalDetId hcalDetId(detId);
99  return theSamplingFactors.at(hcalDetId.ietaAbs()-theFirstRing);
100 }
101 
102 
104 {
107  if (type == HcalNoSiPM) {
108  HcalDetId hcalDetId(detId);
109  return thePE2fCByRing.at(hcalDetId.ietaAbs()-theFirstRing);
110  }
111  return theDbService->getHcalSiPMParameter(detId)->getFCByPE();
112 }
113 
114 
115 //static const double GeV2fC = 1.0/0.145;
116 static const double GeV2fC = 1.0/0.4;
117 
119  // GeV->ampl (fC), time (ns)
120  theSmearSettings.emplace_back( 4.00*GeV2fC, 4.050);
121  theSmearSettings.emplace_back( 20.00*GeV2fC, 3.300);
122  theSmearSettings.emplace_back( 25.00*GeV2fC, 2.925);
123  theSmearSettings.emplace_back( 30.00*GeV2fC, 2.714);
124  theSmearSettings.emplace_back( 37.00*GeV2fC, 2.496);
125  theSmearSettings.emplace_back( 44.50*GeV2fC, 2.278);
126  theSmearSettings.emplace_back( 56.00*GeV2fC, 2.138);
127  theSmearSettings.emplace_back( 63.50*GeV2fC, 2.022);
128  theSmearSettings.emplace_back( 81.00*GeV2fC, 1.788);
129  theSmearSettings.emplace_back( 88.50*GeV2fC, 1.695);
130  theSmearSettings.emplace_back(114.50*GeV2fC, 1.716);
131  theSmearSettings.emplace_back(175.50*GeV2fC, 1.070);
132  theSmearSettings.emplace_back(350.00*GeV2fC, 1.564);
133  theSmearSettings.emplace_back(99999.00*GeV2fC, 1.564);
134 }
135 
136 double HcalSimParameters::timeSmearRMS(double ampl) const {
138  double smearsigma=0;
139 
140  for (i=0; i<theSmearSettings.size(); i++)
141  if (theSmearSettings[i].first > ampl)
142  break;
143 
144  // Smearing occurs only within the envelope definitions.
145  if (i!=0 && (i < theSmearSettings.size())) {
146  double energy1 = theSmearSettings[i-1].first;
147  double sigma1 = theSmearSettings[i-1].second;
148  double energy2 = theSmearSettings[i].first;
149  double sigma2 = theSmearSettings[i].second;
150 
151  if (energy2 != energy1)
152  smearsigma = sigma1 + ((sigma2-sigma1)*(ampl-energy1)/(energy2-energy1));
153  else
154  smearsigma = (sigma2+sigma1)/2.;
155  }
156 
157  return smearsigma;
158 
159 }
160 
161 int HcalSimParameters::pixels(const DetId & detId) const {
164  return theSiPMcharacteristics->getPixels(type);
165 }
166 
167 double HcalSimParameters::sipmDarkCurrentuA(const DetId & detId) const
168 {
171 }
172 
173 double HcalSimParameters::sipmCrossTalk(const DetId & detId) const
174 {
177  return theSiPMcharacteristics->getCrossTalk(type);
178 }
179 std::vector<float> HcalSimParameters::sipmNonlinearity(const DetId & detId) const
180 {
184 }
185 
186 unsigned int HcalSimParameters::signalShape(const DetId & detId) const {
188  return theDbService->getHcalMCParam(detId)->signalShape();
189 }
std::vector< float > sipmNonlinearity(const DetId &detId) const
const HcalSiPMCharacteristics * theSiPMcharacteristics
type
Definition: HCALResponse.h:21
const HcalGainWidth * getGainWidth(const HcalGenericDetId &fId) const
int i
Definition: DBlmapReader.cc:9
HcalSimParameters(double simHitToPhotoelectrons, const std::vector< double > &photoelectronsToAnalog, double samplingFactor, double timePhase, int readoutFrameSize, int binOfMaximum, bool doPhotostatistics, bool syncPhase, int firstRing, const std::vector< double > &samplingFactors, double sipmTau)
assert(m_qm.get())
double fCtoGeV(const DetId &detId) const
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:22
uint16_t size_type
Main class for Parameters in different subdetectors.
float getCrossTalk(int type) const
get cross talk
tuple result
Definition: mps_fire.py:84
static const double GeV2fC
HcalTimeSmearSettings theSmearSettings
std::vector< double > thePE2fCByRing
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.cc:98
Definition: DetId.h:18
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:40
void setDbService(const HcalDbService *service)
double sipmCrossTalk(const DetId &detId) const
const HcalDbService * theDbService
volatile std::atomic< bool > shutdown_flag false
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