CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalDbService.cc
Go to the documentation of this file.
1 //
2 // F.Ratnikov (UMd), Aug. 9, 2005
3 //
4 
6 
11 
13 
14 #include <cmath>
15 
17  mPedestals (0), mPedestalWidths (0),
18  mGains (0), mGainWidths (0),
19  mQieShapeCache (0), mQIEData(0),
20  mElectronicsMap(0),
21  mRespCorrs(0),
22  mL1TriggerObjects(0),
23  mTimeCorrs(0),
24  mLUTCorrs(0),
25  mPFCorrs(0),
26  mLutMetadata(0),
27  mUpdateCalibrations (true), mUpdateCalibWidths(true)
28  {}
29 
31  if (mPedestals && mPedestals->topo()) return mPedestals->topo();
32  if (mGains && mGains->topo()) return mGains->topo();
33  if (mRespCorrs && mRespCorrs->topo()) return mRespCorrs->topo();
35  if (mLutMetadata && mLutMetadata->topo()) return mLutMetadata->topo();
36  return 0;
37 }
38 
39 
41 {
43  {
45  mUpdateCalibrations = false;
46  }
47  return mCalibSet.getCalibrations(fId);
48 }
49 
51 {
52  if (mUpdateCalibWidths)
53  {
55  mUpdateCalibWidths = false;
56  }
58 }
59 
61  // we use the set of ids for pedestals as the master list
62  if ((!mPedestals) || (!mGains) || (!mQIEData) || (!mRespCorrs) || (!mTimeCorrs) || (!mLUTCorrs) ) return;
63 
64  std::vector<DetId> ids=mPedestals->getAllChannels();
65  bool pedsInADC = mPedestals->isADC();
66  // clear the calibrations set
67  mCalibSet.clear();
68  // loop!
69  HcalCalibrations tool;
70 
71  // std::cout << " length of id-vector: " << ids.size() << std::endl;
72  for (std::vector<DetId>::const_iterator id=ids.begin(); id!=ids.end(); ++id) {
73  // make
74  bool ok=makeHcalCalibration(*id,&tool,pedsInADC);
75  // store
76  if (ok) mCalibSet.setCalibrations(*id,tool);
77  // std::cout << "Hcal calibrations built... detid no. " << HcalGenericDetId(*id) << std::endl;
78  }
79  mCalibSet.sort();
80 }
81 
83  // we use the set of ids for pedestal widths as the master list
84  if ((!mPedestalWidths) || (!mGainWidths) || (!mQIEData) ) return;
85 
86  std::vector<DetId> ids=mPedestalWidths->getAllChannels();
87  bool pedsInADC = mPedestalWidths->isADC();
88  // clear the calibrations set
90  // loop!
92 
93  // std::cout << " length of id-vector: " << ids.size() << std::endl;
94  for (std::vector<DetId>::const_iterator id=ids.begin(); id!=ids.end(); ++id) {
95  // make
96  bool ok=makeHcalCalibrationWidth(*id,&tool,pedsInADC);
97  // store
98  if (ok) mCalibWidthSet.setCalibrationWidths(*id,tool);
99  // std::cout << "Hcal calibrations built... detid no. " << HcalGenericDetId(*id) << std::endl;
100  }
102 }
103 
104 bool HcalDbService::makeHcalCalibration (const HcalGenericDetId& fId, HcalCalibrations* fObject, bool pedestalInADC) const {
105  if (fObject) {
106  const HcalPedestal* pedestal = getPedestal (fId);
107  const HcalGain* gain = getGain (fId);
108  const HcalRespCorr* respcorr = getHcalRespCorr (fId);
109  const HcalTimeCorr* timecorr = getHcalTimeCorr (fId);
110  const HcalLUTCorr* lutcorr = getHcalLUTCorr (fId);
111 
112  if (pedestalInADC) {
113  const HcalQIECoder* coder=getHcalCoder(fId);
114  const HcalQIEShape* shape=getHcalShape(coder);
115  if (pedestal && gain && shape && coder && respcorr && timecorr && lutcorr) {
116  float pedTrue[4];
117  for (int i=0; i<4; i++) {
118  float x=pedestal->getValues()[i];
119  int x1=(int)std::floor(x);
120  int x2=(int)std::floor(x+1);
121  // y = (y2-y1)/(x2-x1) * (x - x1) + y1 [note: x2-x1=1]
122  float y2=coder->charge(*shape,x2,i);
123  float y1=coder->charge(*shape,x1,i);
124  pedTrue[i]=(y2-y1)*(x-x1)+y1;
125  }
126  *fObject = HcalCalibrations (gain->getValues (), pedTrue, respcorr->getValue(), timecorr->getValue(), lutcorr->getValue() );
127  return true;
128  }
129  } else {
130  if (pedestal && gain && respcorr && timecorr && lutcorr) {
131  *fObject = HcalCalibrations (gain->getValues (), pedestal->getValues (), respcorr->getValue(), timecorr->getValue(), lutcorr->getValue() );
132  return true;
133  }
134  }
135  }
136  return false;
137 }
138 
140  HcalCalibrationWidths* fObject, bool pedestalInADC) const {
141  if (fObject) {
142  const HcalPedestalWidth* pedestalwidth = getPedestalWidth (fId);
143  const HcalGainWidth* gainwidth = getGainWidth (fId);
144  if (pedestalInADC) {
145  const HcalQIECoder* coder=getHcalCoder(fId);
146  const HcalQIEShape* shape=getHcalShape(coder);
147  if (pedestalwidth && gainwidth && shape && coder) {
148  float pedTrueWidth[4];
149  for (int i=0; i<4; i++) {
150  float x=pedestalwidth->getWidth(i);
151  // assume QIE is linear in low range and use x1=0 and x2=1
152  // y = (y2-y1) * (x) [do not add any constant, only scale!]
153  float y2=coder->charge(*shape,1,i);
154  float y1=coder->charge(*shape,0,i);
155  pedTrueWidth[i]=(y2-y1)*x;
156  }
157  *fObject = HcalCalibrationWidths (gainwidth->getValues (), pedTrueWidth);
158  return true;
159  }
160  } else {
161  if (pedestalwidth && gainwidth) {
162  float pedestalWidth [4];
163  for (int i = 0; i < 4; i++) pedestalWidth [i] = pedestalwidth->getWidth (i);
164  *fObject = HcalCalibrationWidths (gainwidth->getValues (), pedestalWidth);
165  return true;
166  }
167  }
168  }
169  return false;
170 }
171 
172 
174  if (mRespCorrs) {
175  return mRespCorrs->getValues (fId);
176  }
177  return 0;
178 }
179 
181  if (mPedestals) {
182  return mPedestals->getValues (fId);
183  }
184  return 0;
185 }
186 
188  if (mPedestalWidths) {
189  return mPedestalWidths->getValues (fId);
190  }
191  return 0;
192 }
193 
195  if (mGains) {
196  return mGains->getValues(fId);
197  }
198  return 0;
199 }
200 
202  if (mGainWidths) {
203  return mGainWidths->getValues (fId);
204  }
205  return 0;
206 }
207 
209  if (mQIEData) {
210  return mQIEData->getCoder (fId);
211  }
212  return 0;
213 }
214 
216  if (mQIEData) {
217  return &mQIEData->getShape (fId);
218  }
219  return 0;
220 }
221 
223  if (mQIEData) {
224  return &mQIEData->getShape(coder);
225  }
226  return 0;
227 }
228 
229 
231  return mElectronicsMap;
232 }
233 
235 {
236  return mL1TriggerObjects->getValues (fId);
237 }
238 
240 {
241  return mChannelQuality->getValues (fId);
242 }
243 
245 {
246  return mZSThresholds->getValues (fId);
247 }
248 
250  if (mTimeCorrs) {
251  return mTimeCorrs->getValues (fId);
252  }
253  return 0;
254 }
255 
257  if (mLUTCorrs) {
258  return mLUTCorrs->getValues (fId);
259  }
260  return 0;
261 }
262 
264  if (mPFCorrs) {
265  return mPFCorrs->getValues (fId);
266  }
267  return 0;
268 }
269 
271  return mLutMetadata;
272 }
273 
const HcalLUTCorrs * mLUTCorrs
Definition: HcalDbService.h:88
const HcalGainWidth * getGainWidth(const HcalGenericDetId &fId) const
int i
Definition: DBlmapReader.cc:9
bool mUpdateCalibWidths
Definition: HcalDbService.h:94
bool isADC() const
Definition: HcalPedestals.h:26
bool mUpdateCalibrations
Definition: HcalDbService.h:94
const HcalQIECoder * getCoder(DetId fId) const
get QIE parameters
Definition: HcalQIEData.h:38
const HcalChannelStatus * getHcalChannelStatus(const HcalGenericDetId &fId) const
const HcalL1TriggerObjects * mL1TriggerObjects
Definition: HcalDbService.h:86
const HcalPFCorrs * mPFCorrs
Definition: HcalDbService.h:89
const Item * getValues(DetId fId, bool throwOnFail=true) const
const HcalGains * mGains
Definition: HcalDbService.h:78
const HcalChannelQuality * mChannelQuality
Definition: HcalDbService.h:82
const HcalLutMetadata * mLutMetadata
Definition: HcalDbService.h:90
const float * getValues() const
get value for all capId = 0..3
Definition: HcalGainWidth.h:17
const HcalPedestalWidth * getPedestalWidth(const HcalGenericDetId &fId) const
const HcalRespCorr * getHcalRespCorr(const HcalGenericDetId &fId) const
const HcalLUTCorr * getHcalLUTCorr(const HcalGenericDetId &fId) const
const HcalTimeCorr * getHcalTimeCorr(const HcalGenericDetId &fId) const
void buildCalibWidths() const
HcalCalibrationsSet mCalibSet
Definition: HcalDbService.h:92
std::vector< DetId > getAllChannels() const
const HcalL1TriggerObject * getHcalL1TriggerObject(const HcalGenericDetId &fId) const
bool makeHcalCalibration(const HcalGenericDetId &fId, HcalCalibrations *fObject, bool pedestalInADC) const
const HcalQIEShape & getShape(DetId fId) const
get basic shape
Definition: HcalQIEData.h:35
const HcalLutMetadata * getHcalLutMetadata() const
bool makeHcalCalibrationWidth(const HcalGenericDetId &fId, HcalCalibrationWidths *fObject, bool pedestalInADC) const
void setCalibrationWidths(const DetId id, const HcalCalibrationWidths &ca)
const float * getValues() const
get value for all capId = 0..3
Definition: HcalGain.h:18
const HcalPedestalWidths * mPedestalWidths
Definition: HcalDbService.h:77
const HcalRespCorrs * mRespCorrs
Definition: HcalDbService.h:84
const HcalCalibrationWidths & getHcalCalibrationWidths(const HcalGenericDetId &fId) const
HcalDbService(const edm::ParameterSet &)
const HcalZSThreshold * getHcalZSThreshold(const HcalGenericDetId &fId) const
const HcalElectronicsMap * mElectronicsMap
Definition: HcalDbService.h:83
const HcalGainWidths * mGainWidths
Definition: HcalDbService.h:79
const HcalTimeCorrs * mTimeCorrs
Definition: HcalDbService.h:87
#define TYPELOOKUP_DATA_REG(_dataclass_)
Definition: typelookup.h:97
const HcalCalibrationWidths & getCalibrationWidths(const DetId id) const
float getValue() const
Definition: HcalLUTCorr.h:18
HcalCalibrationWidthsSet mCalibWidthSet
Definition: HcalDbService.h:93
const HcalPFCorr * getHcalPFCorr(const HcalGenericDetId &fId) const
const HcalTopology * getTopologyUsed() const
const HcalZSThresholds * mZSThresholds
Definition: HcalDbService.h:85
float getValue() const
Definition: HcalTimeCorr.h:18
const HcalQIEData * mQIEData
Definition: HcalDbService.h:81
const HcalCalibrations & getCalibrations(const DetId id) const
const HcalGain * getGain(const HcalGenericDetId &fId) const
float getWidth(int fCapId) const
get width (sqrt(sigma_i_i)) for capId = 0..3
const HcalQIECoder * getHcalCoder(const HcalGenericDetId &fId) const
const HcalQIEShape * getHcalShape(const HcalGenericDetId &fId) const
void buildCalibrations() const
float getValue() const
Definition: HcalRespCorr.h:18
void setCalibrations(const DetId id, const HcalCalibrations &ca)
const HcalElectronicsMap * getHcalMapping() const
const float * getValues() const
get value for all capId = 0..3
Definition: HcalPedestal.h:17
const HcalPedestals * mPedestals
Definition: HcalDbService.h:76
Definition: DDAxes.h:10
const HcalCalibrations & getHcalCalibrations(const HcalGenericDetId &fId) const
const HcalPedestal * getPedestal(const HcalGenericDetId &fId) const
const HcalTopology * topo() const
float charge(const HcalQIEShape &fShape, unsigned fAdc, unsigned fCapId) const
ADC [0..127] + capid [0..3] -&gt; fC conversion.
Definition: HcalQIECoder.cc:22