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  result[isample] = float(digi[isample].adc())*LSB[gainId]*icalconst/peToA;
53  }
54 
55  //std::cout << " EcalSignalGenerator:EB noise input " << digi << std::endl;
56 
57  //std::cout << " converted noise sample " << std::endl;
58  //for(int isample = 0; isample<digi.size(); ++isample){
59  // std::cout << " " << result[isample] ;
60  //}
61  //std::cout << std::endl;
62 
63  return result;
64  }
65 
66 
67  template <>
69  {
70  // calibration, for future reference: (same block for all Ecal types)
71  //EcalDetId cell = digi.id();
72  // const EcalCalibrations& calibrations=conditions->getEcalCalibrations(cell);
73  //const EcalQIECoder* channelCoder = theConditions->getEcalCoder (cell);
74  //const EcalQIEShape* channelShape = theConditions->getEcalShape (cell);
75  //EcalCoderDb coder (*channelCoder, *channelShape);
76  //CaloSamples result;
77  //coder.adc2fC(digi, result);
78  //fC2pe(result);
79 
80  DetId detId = digi.id();
81 
82  double Emax = fullScaleEnergy(detId);
83  double LSB[NGAINS+1];
84 
85  double icalconst = 1.; //findIntercalibConstant( detId );
86 
87  const EcalIntercalibConstantMCMap &icalMap = ical->getMap();
88  EcalIntercalibConstantMCMap::const_iterator icalit = icalMap.find(detId);
89  if( icalit!=icalMap.end() )
90  {
91  icalconst = (*icalit);
92  }
93 
94 
95  double peToA = peToAConversion ( detId ) ;
96 
97  const std::vector<float> gainRatios = GetGainRatios(detId);
98 
99  for( unsigned int igain ( 0 ); igain <= NGAINS ; ++igain )
100  {
101  LSB[igain] = 0.;
102  if ( igain > 0 ) LSB[igain]= Emax/(MAXADC*gainRatios[igain]);
103  }
104 
105  // std::cout << " intercal, LSBs, egains " << icalconst << " " << LSB[0] << " " << LSB[1] << " " << gainRatios[0] << " " << gainRatios[1] << " " << Emax << std::endl;
106 
107  CaloSamples result(detId, digi.size());
108 
109  for(int isample = 0; isample<digi.size(); ++isample){
110 
111  int gainId = digi[isample].gainId();
112  //int gainId = 1;
113 
114  result[isample] = float(digi[isample].adc())*LSB[gainId]*icalconst/peToA;
115  }
116 
117  //std::cout << " EcalSignalGenerator:EE noise input " << digi << std::endl;
118 
119  //std::cout << " converted noise sample " << std::endl;
120  //for(int isample = 0; isample<digi.size(); ++isample){
121  // std::cout << " " << result[isample] ;
122  // }
123  //std::cout << std::endl;
124 
125  return result;
126  }
127 
128  template <>
130  {
131  // calibration, for future reference: (same block for all Ecal types)
132  //EcalDetId cell = digi.id();
133  // const EcalCalibrations& calibrations=conditions->getEcalCalibrations(cell);
134  //const EcalQIECoder* channelCoder = theConditions->getEcalCoder (cell);
135  //const EcalQIEShape* channelShape = theConditions->getEcalShape (cell);
136  //EcalCoderDb coder (*channelCoder, *channelShape);
137  //CaloSamples result;
138  //coder.adc2fC(digi, result);
139  //fC2pe(result);
140 
141  DetId detId = digi.id();
142 
143  double icalconst = 1.; //findIntercalibConstant( detId );
144 
145  const ESIntercalibConstantMap &icalMap = esmips->getMap();
146  ESIntercalibConstantMap::const_iterator icalit = icalMap.find(detId);
147  if( icalit!=icalMap.end() )
148  {
149  icalconst = double (*icalit);
150  }
151 
152  CaloSamples result(detId, digi.size());
153 
154  for(int isample = 0; isample<digi.size(); ++isample){
155  result[isample] = float(digi[isample].adc())/icalconst*ESMIPToGeV;
156  }
157 
158  //std::cout << " EcalSignalGenerator:ES noise input " << digi << std::endl;
159 
160  //std::cout << " converted noise sample " << std::endl;
161  //for(int isample = 0; isample<digi.size(); ++isample){
162  // std::cout << " " << result[isample] ;
163  //}
164  //std::cout << std::endl;
165 
166  return result;
167  }
168 
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
const EcalIntercalibConstantsMC * ical
tuple result
Definition: query.py:137
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