CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/CondFormats/CastorObjects/src/CastorCalibrationQIECoder.cc

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