CMS 3D CMS Logo

EcalSignalGenerator.cc
Go to the documentation of this file.
2 
3 template <>
5  // calibration, for future reference: (same block for all Ecal types)
6  //EcalDetId cell = digi.id();
7  // const EcalCalibrations& calibrations=conditions->getEcalCalibrations(cell);
8  //const EcalQIECoder* channelCoder = theConditions->getEcalCoder (cell);
9  //const EcalQIEShape* channelShape = theConditions->getEcalShape (cell);
10  //EcalCoderDb coder (*channelCoder, *channelShape);
11  //CaloSamples result;
12  //coder.adc2fC(digi, result);
13  //fC2pe(result);
14 
15  DetId detId = digi.id();
16 
17  double Emax = fullScaleEnergy(detId);
18  double LSB[NGAINS + 1];
19 
20  //double icalconst = findIntercalibConstant( detId );
21 
22  double icalconst = 1.; // find the correct value.
23 
24  const EcalIntercalibConstantMCMap &icalMap = ical->getMap();
25  EcalIntercalibConstantMCMap::const_iterator icalit = icalMap.find(detId);
26  if (icalit != icalMap.end()) {
27  icalconst = (*icalit);
28  }
29 
30  double peToA = peToAConversion(detId);
31 
32  const std::vector<float> gainRatios = GetGainRatios(detId);
33 
34  for (unsigned int igain(0); igain <= NGAINS; ++igain) {
35  LSB[igain] = 0.;
36  if (igain > 0)
37  LSB[igain] = Emax / (MAXADC * gainRatios[igain]);
38  }
39 
40  // std::cout << " intercal, LSBs, egains " << icalconst << " " << LSB[0] << " " << LSB[1] << " " << gainRatios[0] << " " << gainRatios[1] << " " << Emax << std::endl;
41 
42  CaloSamples result(detId, digi.size());
43 
44  // correction factor for premixed sample: ratio of laser corrections
45  double correction_factor_for_premixed_sample_transparency = 1.0;
46  double value_LC = 1.;
47  if (m_timeDependent) {
49  auto cache = m_valueLCCache_LC.find(detId);
50  if (cache != m_valueLCCache_LC.end()) {
51  value_LC = cache->second;
52  } else {
53  value_LC = findLaserConstant_LC(detId);
54  m_valueLCCache_LC.emplace(detId, value_LC);
55  }
56  }
57  }
58 
59  double value_LC_prime = 1.;
60 
61  if (m_timeDependent) {
63  auto cache = m_valueLCCache_LC_prime.find(detId);
64  if (cache != m_valueLCCache_LC_prime.end()) {
65  value_LC_prime = cache->second;
66  } else {
67  value_LC_prime = findLaserConstant_LC_prime(detId);
68  m_valueLCCache_LC_prime.emplace(detId, value_LC_prime);
69  }
70  }
71  }
72 
73  correction_factor_for_premixed_sample_transparency = value_LC_prime / value_LC;
74  //
75  // LC' / LC (see formula)
76  //
77 
78  for (int isample = 0; isample < digi.size(); ++isample) {
79  int gainId = digi[isample].gainId();
80  //int gainId = 1;
81 
82  if (gainId == 1) {
83  result[isample] = float(digi[isample].adc()) / 1000. / peToA *
84  correction_factor_for_premixed_sample_transparency; // special coding, save low level info
85  } else if (gainId > 1) {
86  result[isample] =
87  float(digi[isample].adc()) * LSB[gainId - 1] * icalconst / peToA *
88  correction_factor_for_premixed_sample_transparency; // bet that no pileup hit has an energy over Emax/2
89  } // gain = 0
90  else {
91  result[isample] =
92  float(digi[isample].adc()) * LSB[gainId] * icalconst / peToA *
93  correction_factor_for_premixed_sample_transparency; //not sure we ever get here at gain=0, but hit wil be saturated anyway
94  // in EcalCoder.cc it is actually "LSB[3]" -> grrr
95  }
96 
97  // old version:
98  //result[isample] = float(digi[isample].adc())*LSB[gainId]*icalconst/peToA;
99  }
100 
101  //std::cout << " EcalSignalGenerator:EB noise input " << digi << std::endl;
102 
103  //std::cout << " converted noise sample " << std::endl;
104  //for(int isample = 0; isample<digi.size(); ++isample){
105  // std::cout << " " << result[isample] ;
106  //}
107  //std::cout << std::endl;
108 
109  return result;
110 }
111 
112 template <>
114  // calibration, for future reference: (same block for all Ecal types)
115  //EcalDetId cell = digi.id();
116  // const EcalCalibrations& calibrations=conditions->getEcalCalibrations(cell);
117  //const EcalQIECoder* channelCoder = theConditions->getEcalCoder (cell);
118  //const EcalQIEShape* channelShape = theConditions->getEcalShape (cell);
119  //EcalCoderDb coder (*channelCoder, *channelShape);
120  //CaloSamples result;
121  //coder.adc2fC(digi, result);
122  //fC2pe(result);
123 
124  DetId detId = digi.id();
125 
126  double Emax = fullScaleEnergy(detId);
127  double LSB[NGAINS + 1];
128 
129  double icalconst = 1.; //findIntercalibConstant( detId );
130 
131  const EcalIntercalibConstantMCMap &icalMap = ical->getMap();
132  EcalIntercalibConstantMCMap::const_iterator icalit = icalMap.find(detId);
133  if (icalit != icalMap.end()) {
134  icalconst = (*icalit);
135  }
136 
137  double peToA = peToAConversion(detId);
138 
139  const std::vector<float> gainRatios = GetGainRatios(detId);
140 
141  for (unsigned int igain(0); igain <= NGAINS; ++igain) {
142  LSB[igain] = 0.;
143  if (igain > 0)
144  LSB[igain] = Emax / (MAXADC * gainRatios[igain]);
145  }
146 
147  // std::cout << " intercal, LSBs, egains " << icalconst << " " << LSB[0] << " " << LSB[1] << " " << gainRatios[0] << " " << gainRatios[1] << " " << Emax << std::endl;
148 
149  CaloSamples result(detId, digi.size());
150 
151  // correction facotr for premixed sample: ratio of laser corrections
152  double correction_factor_for_premixed_sample_transparency = 1.0;
153  double value_LC = 1.;
154 
155  if (m_timeDependent) {
156  if (detId.subdetId() != EcalSubdetector::EcalPreshower) {
157  auto cache = m_valueLCCache_LC.find(detId);
158  if (cache != m_valueLCCache_LC.end()) {
159  value_LC = cache->second;
160  } else {
161  value_LC = findLaserConstant_LC(detId);
162  m_valueLCCache_LC.emplace(detId, value_LC);
163  }
164  }
165  }
166 
167  double value_LC_prime = 1.;
168  if (m_timeDependent) {
169  if (detId.subdetId() != EcalSubdetector::EcalPreshower) {
170  auto cache = m_valueLCCache_LC_prime.find(detId);
171  if (cache != m_valueLCCache_LC_prime.end()) {
172  value_LC_prime = cache->second;
173  } else {
174  value_LC_prime = findLaserConstant_LC_prime(detId);
175  m_valueLCCache_LC_prime.emplace(detId, value_LC_prime);
176  }
177  }
178  }
179 
180  correction_factor_for_premixed_sample_transparency = value_LC_prime / value_LC;
181  //
182  // LC' / LC (see formula)
183  //
184 
185  for (int isample = 0; isample < digi.size(); ++isample) {
186  int gainId = digi[isample].gainId();
187  //int gainId = 1;
188 
189  if (gainId == 1) {
190  result[isample] = float(digi[isample].adc()) / 1000. / peToA *
191  correction_factor_for_premixed_sample_transparency; // special coding
192  } else if (gainId > 1) {
193  result[isample] = float(digi[isample].adc()) * LSB[gainId - 1] * icalconst / peToA *
194  correction_factor_for_premixed_sample_transparency;
195  } // gain = 0
196  else {
197  result[isample] = float(digi[isample].adc()) * LSB[gainId] * icalconst / peToA *
198  correction_factor_for_premixed_sample_transparency;
199  }
200 
201  // old version
202  //result[isample] = float(digi[isample].adc())*LSB[gainId]*icalconst/peToA;
203  }
204 
205  //std::cout << " EcalSignalGenerator:EE noise input " << digi << std::endl;
206 
207  //std::cout << " converted noise sample " << std::endl;
208  //for(int isample = 0; isample<digi.size(); ++isample){
209  // std::cout << " " << result[isample] ;
210  // }
211  //std::cout << std::endl;
212 
213  return result;
214 }
215 
216 template <>
218  // calibration, for future reference: (same block for all Ecal types)
219  //EcalDetId cell = digi.id();
220  // const EcalCalibrations& calibrations=conditions->getEcalCalibrations(cell);
221  //const EcalQIECoder* channelCoder = theConditions->getEcalCoder (cell);
222  //const EcalQIEShape* channelShape = theConditions->getEcalShape (cell);
223  //EcalCoderDb coder (*channelCoder, *channelShape);
224  //CaloSamples result;
225  //coder.adc2fC(digi, result);
226  //fC2pe(result);
227 
228  DetId detId = digi.id();
229 
230  double icalconst = 1.; //findIntercalibConstant( detId );
231 
232  const ESIntercalibConstantMap &icalMap = esmips->getMap();
233  ESIntercalibConstantMap::const_iterator icalit = icalMap.find(detId);
234  if (icalit != icalMap.end()) {
235  icalconst = double(*icalit);
236  }
237 
238  CaloSamples result(detId, digi.size());
239 
240  for (int isample = 0; isample < digi.size(); ++isample) {
241  result[isample] = float(digi[isample].adc()) / icalconst * ESMIPToGeV;
242  }
243 
244  //std::cout << " EcalSignalGenerator:ES noise input " << digi << std::endl;
245 
246  //std::cout << " converted noise sample " << std::endl;
247  //for(int isample = 0; isample<digi.size(); ++isample){
248  // std::cout << " " << result[isample] ;
249  //}
250  //std::cout << std::endl;
251 
252  return result;
253 }
CalibCache m_valueLCCache_LC_prime
double findLaserConstant_LC(const DetId &detId) const
const std::vector< float > GetGainRatios(const DetId &detid)
const_iterator find(uint32_t rawId) const
const EcalIntercalibConstantsMC * ical
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
const_iterator find(uint32_t rawId) const
Definition: DetId.h:17
constexpr int gainId(sample_type sample)
get the gainId (2 bits)
CaloSamples samplesInPE(const DIGI &digi)
std::vector< Item >::const_iterator const_iterator
double findLaserConstant_LC_prime(const DetId &detId) const
const_iterator end() const
std::vector< Item >::const_iterator const_iterator
def cache(function)
Definition: utilities.py:3
const_iterator end() const
const self & getMap() const
const ESIntercalibConstants * esmips
double fullScaleEnergy(const DetId &detId) const
double peToAConversion(const DetId &detId) const
uint16_t *__restrict__ uint16_t const *__restrict__ adc