CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/src/CondFormats/HcalObjects/src/HcalCalibrationQIECoder.cc

Go to the documentation of this file.
00001 
00008 #include <iostream>
00009 
00010 #include "CondFormats/HcalObjects/interface/HcalCalibrationQIECoder.h"
00011 
00012 float HcalCalibrationQIECoder::charge (unsigned fAdc) const {
00013   const float* data = base ();
00014   if (fAdc >= 31) return (3*data[31]-data[30])/2.; // extrapolation
00015   return (data[fAdc]+data[fAdc+1])/2;
00016 }
00017 
00018 unsigned HcalCalibrationQIECoder::adc (float fCharge) const {
00019   const float* data = base ();
00020   unsigned adc = 1;
00021   for (; adc < 32; adc++) {
00022     if (fCharge < data[adc]) return adc-1;
00023   }
00024   return 31; // overflow
00025 }
00026 
00027 float HcalCalibrationQIECoder::minCharge (unsigned fBin) const {
00028   const float* data = base ();
00029   return fBin < 32 ? data[fBin] : data[31];
00030 }
00031 
00032 const float* HcalCalibrationQIECoder::minCharges () const {
00033   const float* data = base ();
00034   return data;
00035 }
00036 
00037 
00038 void HcalCalibrationQIECoder::setMinCharge (unsigned fBin, float fValue) {
00039   float* data = base ();
00040   if (fBin < 32) data [fBin] = fValue;
00041 }
00042 
00043 void HcalCalibrationQIECoder::setMinCharges (const float fValue [32]) {
00044   float* data = base ();
00045   for (int i = 0; i < 32; i++) data[i] = fValue[i];
00046 }