test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EcalSignalGenerator.cc
Go to the documentation of this file.
2 
3 
4  template <>
6  {
7  // calibration, for future reference: (same block for all Ecal types)
8  //EcalDetId cell = digi.id();
9  // const EcalCalibrations& calibrations=conditions->getEcalCalibrations(cell);
10  //const EcalQIECoder* channelCoder = theConditions->getEcalCoder (cell);
11  //const EcalQIEShape* channelShape = theConditions->getEcalShape (cell);
12  //EcalCoderDb coder (*channelCoder, *channelShape);
13  //CaloSamples result;
14  //coder.adc2fC(digi, result);
15  //fC2pe(result);
16 
17  DetId detId = digi.id();
18 
19  double Emax = fullScaleEnergy(detId);
20  double LSB[NGAINS+1];
21 
22  //double icalconst = findIntercalibConstant( detId );
23 
24  double icalconst = 1.; // find the correct value.
25 
26  const EcalIntercalibConstantMCMap &icalMap = ical->getMap();
27  EcalIntercalibConstantMCMap::const_iterator icalit = icalMap.find(detId);
28  if( icalit!=icalMap.end() )
29  {
30  icalconst = (*icalit);
31  }
32 
33  double peToA = peToAConversion ( detId ) ;
34 
35  const std::vector<float> gainRatios = GetGainRatios(detId);
36 
37  for( unsigned int igain ( 0 ); igain <= NGAINS ; ++igain )
38  {
39  LSB[igain] = 0.;
40  if ( igain > 0 ) LSB[igain]= Emax/(MAXADC*gainRatios[igain]);
41  }
42 
43  // std::cout << " intercal, LSBs, egains " << icalconst << " " << LSB[0] << " " << LSB[1] << " " << gainRatios[0] << " " << gainRatios[1] << " " << Emax << std::endl;
44 
45  CaloSamples result(detId, digi.size());
46 
47  for(int isample = 0; isample<digi.size(); ++isample){
48 
49  int gainId = digi[isample].gainId();
50  //int gainId = 1;
51 
52  if(gainId == 1) {
53  result[isample] = float(digi[isample].adc())/1000./peToA; // special coding
54  }
55  else if(gainId > 1) {
56  result[isample] = float(digi[isample].adc())*LSB[gainId-1]*icalconst/peToA;
57  } // gain = 0
58  else { result[isample] = float(digi[isample].adc())*LSB[gainId]*icalconst/peToA;}
59 
60  // old version:
61  //result[isample] = float(digi[isample].adc())*LSB[gainId]*icalconst/peToA;
62  }
63 
64  //std::cout << " EcalSignalGenerator:EB noise input " << digi << std::endl;
65 
66  //std::cout << " converted noise sample " << std::endl;
67  //for(int isample = 0; isample<digi.size(); ++isample){
68  // std::cout << " " << result[isample] ;
69  //}
70  //std::cout << std::endl;
71 
72  return result;
73  }
74 
75 
76  template <>
78  {
79  // calibration, for future reference: (same block for all Ecal types)
80  //EcalDetId cell = digi.id();
81  // const EcalCalibrations& calibrations=conditions->getEcalCalibrations(cell);
82  //const EcalQIECoder* channelCoder = theConditions->getEcalCoder (cell);
83  //const EcalQIEShape* channelShape = theConditions->getEcalShape (cell);
84  //EcalCoderDb coder (*channelCoder, *channelShape);
85  //CaloSamples result;
86  //coder.adc2fC(digi, result);
87  //fC2pe(result);
88 
89  DetId detId = digi.id();
90 
91  double Emax = fullScaleEnergy(detId);
92  double LSB[NGAINS+1];
93 
94  double icalconst = 1.; //findIntercalibConstant( detId );
95 
96  const EcalIntercalibConstantMCMap &icalMap = ical->getMap();
97  EcalIntercalibConstantMCMap::const_iterator icalit = icalMap.find(detId);
98  if( icalit!=icalMap.end() )
99  {
100  icalconst = (*icalit);
101  }
102 
103 
104  double peToA = peToAConversion ( detId ) ;
105 
106  const std::vector<float> gainRatios = GetGainRatios(detId);
107 
108  for( unsigned int igain ( 0 ); igain <= NGAINS ; ++igain )
109  {
110  LSB[igain] = 0.;
111  if ( igain > 0 ) LSB[igain]= Emax/(MAXADC*gainRatios[igain]);
112  }
113 
114  // std::cout << " intercal, LSBs, egains " << icalconst << " " << LSB[0] << " " << LSB[1] << " " << gainRatios[0] << " " << gainRatios[1] << " " << Emax << std::endl;
115 
116  CaloSamples result(detId, digi.size());
117 
118  for(int isample = 0; isample<digi.size(); ++isample){
119 
120  int gainId = digi[isample].gainId();
121  //int gainId = 1;
122 
123  if(gainId == 1) {
124  result[isample] = float(digi[isample].adc())/1000./peToA; // special coding
125  }
126  else if(gainId > 1) {
127  result[isample] = float(digi[isample].adc())*LSB[gainId-1]*icalconst/peToA;
128  } // gain = 0
129  else { result[isample] = float(digi[isample].adc())*LSB[gainId]*icalconst/peToA;}
130 
131  // old version
132  //result[isample] = float(digi[isample].adc())*LSB[gainId]*icalconst/peToA;
133  }
134 
135  //std::cout << " EcalSignalGenerator:EE noise input " << digi << std::endl;
136 
137  //std::cout << " converted noise sample " << std::endl;
138  //for(int isample = 0; isample<digi.size(); ++isample){
139  // std::cout << " " << result[isample] ;
140  // }
141  //std::cout << std::endl;
142 
143  return result;
144  }
145 
146  template <>
148  {
149  // calibration, for future reference: (same block for all Ecal types)
150  //EcalDetId cell = digi.id();
151  // const EcalCalibrations& calibrations=conditions->getEcalCalibrations(cell);
152  //const EcalQIECoder* channelCoder = theConditions->getEcalCoder (cell);
153  //const EcalQIEShape* channelShape = theConditions->getEcalShape (cell);
154  //EcalCoderDb coder (*channelCoder, *channelShape);
155  //CaloSamples result;
156  //coder.adc2fC(digi, result);
157  //fC2pe(result);
158 
159  DetId detId = digi.id();
160 
161  double icalconst = 1.; //findIntercalibConstant( detId );
162 
163  const ESIntercalibConstantMap &icalMap = esmips->getMap();
164  ESIntercalibConstantMap::const_iterator icalit = icalMap.find(detId);
165  if( icalit!=icalMap.end() )
166  {
167  icalconst = double (*icalit);
168  }
169 
170  CaloSamples result(detId, digi.size());
171 
172  for(int isample = 0; isample<digi.size(); ++isample){
173  result[isample] = float(digi[isample].adc())/icalconst*ESMIPToGeV;
174  }
175 
176  //std::cout << " EcalSignalGenerator:ES noise input " << digi << std::endl;
177 
178  //std::cout << " converted noise sample " << std::endl;
179  //for(int isample = 0; isample<digi.size(); ++isample){
180  // std::cout << " " << result[isample] ;
181  //}
182  //std::cout << std::endl;
183 
184  return result;
185  }
186 
int adc(sample_type sample)
get the ADC sample (12 bits)
key_type id() const
Definition: EBDataFrame.h:31
int gainId(sample_type sample)
get the gainId (2 bits)
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
tuple result
Definition: mps_fire.py:83
const EcalIntercalibConstantsMC * ical
const_iterator find(uint32_t rawId) const
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
double peToAConversion(const DetId &detId) const
const_iterator find(uint32_t rawId) const
const_iterator end() const
const ESIntercalibConstants * esmips