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  for (int isample = 0; isample < digi.size(); ++isample) {
45  int gainId = digi[isample].gainId();
46  //int gainId = 1;
47 
48  if (gainId == 1) {
49  result[isample] = float(digi[isample].adc()) / 1000. / peToA; // special coding
50  } else if (gainId > 1) {
51  result[isample] = float(digi[isample].adc()) * LSB[gainId - 1] * icalconst / peToA;
52  } // gain = 0
53  else {
54  result[isample] = float(digi[isample].adc()) * LSB[gainId] * icalconst / peToA;
55  }
56 
57  // old version:
58  //result[isample] = float(digi[isample].adc())*LSB[gainId]*icalconst/peToA;
59  }
60 
61  //std::cout << " EcalSignalGenerator:EB noise input " << digi << std::endl;
62 
63  //std::cout << " converted noise sample " << std::endl;
64  //for(int isample = 0; isample<digi.size(); ++isample){
65  // std::cout << " " << result[isample] ;
66  //}
67  //std::cout << std::endl;
68 
69  return result;
70 }
71 
72 template <>
74  // calibration, for future reference: (same block for all Ecal types)
75  //EcalDetId cell = digi.id();
76  // const EcalCalibrations& calibrations=conditions->getEcalCalibrations(cell);
77  //const EcalQIECoder* channelCoder = theConditions->getEcalCoder (cell);
78  //const EcalQIEShape* channelShape = theConditions->getEcalShape (cell);
79  //EcalCoderDb coder (*channelCoder, *channelShape);
80  //CaloSamples result;
81  //coder.adc2fC(digi, result);
82  //fC2pe(result);
83 
84  DetId detId = digi.id();
85 
86  double Emax = fullScaleEnergy(detId);
87  double LSB[NGAINS + 1];
88 
89  double icalconst = 1.; //findIntercalibConstant( detId );
90 
91  const EcalIntercalibConstantMCMap &icalMap = ical->getMap();
92  EcalIntercalibConstantMCMap::const_iterator icalit = icalMap.find(detId);
93  if (icalit != icalMap.end()) {
94  icalconst = (*icalit);
95  }
96 
97  double peToA = peToAConversion(detId);
98 
99  const std::vector<float> gainRatios = GetGainRatios(detId);
100 
101  for (unsigned int igain(0); igain <= NGAINS; ++igain) {
102  LSB[igain] = 0.;
103  if (igain > 0)
104  LSB[igain] = Emax / (MAXADC * gainRatios[igain]);
105  }
106 
107  // std::cout << " intercal, LSBs, egains " << icalconst << " " << LSB[0] << " " << LSB[1] << " " << gainRatios[0] << " " << gainRatios[1] << " " << Emax << std::endl;
108 
109  CaloSamples result(detId, digi.size());
110 
111  for (int isample = 0; isample < digi.size(); ++isample) {
112  int gainId = digi[isample].gainId();
113  //int gainId = 1;
114 
115  if (gainId == 1) {
116  result[isample] = float(digi[isample].adc()) / 1000. / peToA; // special coding
117  } else if (gainId > 1) {
118  result[isample] = float(digi[isample].adc()) * LSB[gainId - 1] * icalconst / peToA;
119  } // gain = 0
120  else {
121  result[isample] = float(digi[isample].adc()) * LSB[gainId] * icalconst / peToA;
122  }
123 
124  // old version
125  //result[isample] = float(digi[isample].adc())*LSB[gainId]*icalconst/peToA;
126  }
127 
128  //std::cout << " EcalSignalGenerator:EE noise input " << digi << std::endl;
129 
130  //std::cout << " converted noise sample " << std::endl;
131  //for(int isample = 0; isample<digi.size(); ++isample){
132  // std::cout << " " << result[isample] ;
133  // }
134  //std::cout << std::endl;
135 
136  return result;
137 }
138 
139 template <>
141  // calibration, for future reference: (same block for all Ecal types)
142  //EcalDetId cell = digi.id();
143  // const EcalCalibrations& calibrations=conditions->getEcalCalibrations(cell);
144  //const EcalQIECoder* channelCoder = theConditions->getEcalCoder (cell);
145  //const EcalQIEShape* channelShape = theConditions->getEcalShape (cell);
146  //EcalCoderDb coder (*channelCoder, *channelShape);
147  //CaloSamples result;
148  //coder.adc2fC(digi, result);
149  //fC2pe(result);
150 
151  DetId detId = digi.id();
152 
153  double icalconst = 1.; //findIntercalibConstant( detId );
154 
155  const ESIntercalibConstantMap &icalMap = esmips->getMap();
156  ESIntercalibConstantMap::const_iterator icalit = icalMap.find(detId);
157  if (icalit != icalMap.end()) {
158  icalconst = double(*icalit);
159  }
160 
161  CaloSamples result(detId, digi.size());
162 
163  for (int isample = 0; isample < digi.size(); ++isample) {
164  result[isample] = float(digi[isample].adc()) / icalconst * ESMIPToGeV;
165  }
166 
167  //std::cout << " EcalSignalGenerator:ES noise input " << digi << std::endl;
168 
169  //std::cout << " converted noise sample " << std::endl;
170  //for(int isample = 0; isample<digi.size(); ++isample){
171  // std::cout << " " << result[isample] ;
172  //}
173  //std::cout << std::endl;
174 
175  return result;
176 }
key_type id() const
Definition: EBDataFrame.h:31
const self & getMap() const
const ESDetId & id() const
Definition: ESDataFrame.h:21
const_iterator end() const
const self & getMap() const
const std::vector< float > GetGainRatios(const DetId &detid)
int size() const
Definition: ESDataFrame.h:23
double fullScaleEnergy(const DetId &detId) const
int size() const
Definition: EcalDataFrame.h:26
const EcalIntercalibConstantsMC * ical
const_iterator find(uint32_t rawId) const
constexpr int adc(sample_type sample)
get the ADC sample (12 bits)
key_type id() const
Definition: EEDataFrame.h:28
Definition: DetId.h:18
CaloSamples samplesInPE(const DIGI &digi)
std::vector< Item >::const_iterator const_iterator
std::vector< Item >::const_iterator const_iterator
constexpr int gainId(sample_type sample)
get the gainId (2 bits)
double peToAConversion(const DetId &detId) const
const_iterator find(uint32_t rawId) const
const_iterator end() const
const ESIntercalibConstants * esmips