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.
8 #include "CLHEP/Random/RandGaussQ.h"
9 using namespace std;
10 
11 HcalSimParameters::HcalSimParameters(double simHitToPhotoelectrons, const std::vector<double> & photoelectronsToAnalog,
12  double samplingFactor, double timePhase,
13  int readoutFrameSize, int binOfMaximum,
14  bool doPhotostatistics, bool syncPhase,
15  int firstRing, const std::vector<double> & samplingFactors)
16 : CaloSimParameters(simHitToPhotoelectrons, photoelectronsToAnalog[0], samplingFactor, timePhase,
17  readoutFrameSize, binOfMaximum, doPhotostatistics, syncPhase),
18  theDbService(0),
19  theFirstRing(firstRing),
20  theSamplingFactors(samplingFactors),
21  thePE2fCByRing(photoelectronsToAnalog),
22  thePixels(0),
23  doTimeSmear_(true)
24 {
26 }
27 
30  theDbService(0),
31  theFirstRing( p.getParameter<int>("firstRing") ),
32  theSamplingFactors( p.getParameter<std::vector<double> >("samplingFactors") ),
33  thePE2fCByRing( p.getParameter<std::vector<double> >("photoelectronsToAnalog") ),
34  thePixels(0),
35  doTimeSmear_( p.getParameter<bool>("timeSmearing"))
36 {
37  if(p.exists("pixels"))
38  {
39  thePixels = p.getParameter<int>("pixels");
40  }
42 }
43 
45 {
46  // the gain is in units of GeV/fC. We want a constant with pe/dGeV
47  // pe/dGeV = (GeV/dGeV) / (GeV/fC) / (fC/pe)
49  if(HcalGenericDetId(detId).genericSubdet() != HcalGenericDetId::HcalGenForward
50  || HcalGenericDetId(detId).genericSubdet() != HcalGenericDetId::HcalGenZDC)
51  {
52  result = samplingFactor(detId) / fCtoGeV(detId) / photoelectronsToAnalog(detId);
53  }
54  return result;
55 }
56 
57 
58 double HcalSimParameters::fCtoGeV(const DetId & detId) const
59 {
60  assert(theDbService != 0);
61  HcalGenericDetId hcalGenDetId(detId);
62  const HcalGain* gains = theDbService->getGain(hcalGenDetId);
63  const HcalGainWidth* gwidths = theDbService->getGainWidth(hcalGenDetId);
64  if (!gains || !gwidths )
65  {
66  edm::LogError("HcalAmplifier") << "Could not fetch HCAL conditions for channel " << hcalGenDetId;
67  }
68  // only one gain will be recorded per channel, so just use capID 0 for now
69  double result = gains->getValue(0);
70 // if(doNoise_)
72 // result += CLHEP::RandGaussQ::shoot(0., gwidths->getValue(0));
73 // }
74  return result;
75 }
76 
77 double HcalSimParameters::samplingFactor(const DetId & detId) const
78 {
79  HcalDetId hcalDetId(detId);
80  return theSamplingFactors.at(hcalDetId.ietaAbs()-theFirstRing);
81 }
82 
83 
85 {
86  HcalDetId hcalDetId(detId);
87  return thePE2fCByRing.at(hcalDetId.ietaAbs()-theFirstRing);
88 }
89 
90 
91 //static const double GeV2fC = 1.0/0.145;
92 static const double GeV2fC = 1.0/0.4;
93 
95  // GeV->ampl (fC), time (ns)
96  theSmearSettings.emplace_back( 4.00*GeV2fC, 4.050);
97  theSmearSettings.emplace_back( 20.00*GeV2fC, 3.300);
98  theSmearSettings.emplace_back( 25.00*GeV2fC, 2.925);
99  theSmearSettings.emplace_back( 30.00*GeV2fC, 2.714);
100  theSmearSettings.emplace_back( 37.00*GeV2fC, 2.496);
101  theSmearSettings.emplace_back( 44.50*GeV2fC, 2.278);
102  theSmearSettings.emplace_back( 56.00*GeV2fC, 2.138);
103  theSmearSettings.emplace_back( 63.50*GeV2fC, 2.022);
104  theSmearSettings.emplace_back( 81.00*GeV2fC, 1.788);
105  theSmearSettings.emplace_back( 88.50*GeV2fC, 1.695);
106  theSmearSettings.emplace_back(114.50*GeV2fC, 1.716);
107  theSmearSettings.emplace_back(175.50*GeV2fC, 1.070);
108  theSmearSettings.emplace_back(350.00*GeV2fC, 1.564);
109  theSmearSettings.emplace_back(99999.00*GeV2fC, 1.564);
110 }
111 
112 double HcalSimParameters::timeSmearRMS(double ampl) const {
114  double smearsigma=0;
115 
116  for (i=0; i<theSmearSettings.size(); i++)
117  if (theSmearSettings[i].first > ampl)
118  break;
119 
120  // Smearing occurs only within the envelope definitions.
121  if (i!=0 && (i < theSmearSettings.size())) {
122  double energy1 = theSmearSettings[i-1].first;
123  double sigma1 = theSmearSettings[i-1].second;
124  double energy2 = theSmearSettings[i].first;
125  double sigma2 = theSmearSettings[i].second;
126 
127  if (energy2 != energy1)
128  smearsigma = sigma1 + ((sigma2-sigma1)*(ampl-energy1)/(energy2-energy1));
129  else
130  smearsigma = (sigma2+sigma1)/2.;
131  }
132 
133  return smearsigma;
134 
135 }
T getParameter(std::string const &) const
const HcalGainWidth * getGainWidth(const HcalGenericDetId &fId) const
int i
Definition: DBlmapReader.cc:9
double fCtoGeV(const DetId &detId) const
bool exists(std::string const &parameterName) const
checks if a parameter exists
float getValue(int fCapId) const
get value for capId = 0..3
Definition: HcalGain.h:20
uint16_t size_type
Main class for Parameters in different subdetectors.
static const double GeV2fC
HcalTimeSmearSettings theSmearSettings
std::vector< double > thePE2fCByRing
double timeSmearRMS(double ampl) const
tuple result
Definition: query.py:137
double simHitToPhotoelectrons() const
std::vector< double > theSamplingFactors
virtual double samplingFactor(const DetId &detId) const
bool first
Definition: L1TdeRCT.cc:94
int ietaAbs() const
get the absolute value of the cell ieta
Definition: HcalDetId.h:36
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)
Definition: DetId.h:20
const HcalGain * getGain(const HcalGenericDetId &fId) const
const HcalDbService * theDbService
double photoelectronsToAnalog() const
the factor which goes from photoelectrons to whatever gets read by ADCs