Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:01:57

0001 /** 
0002 \class CastorQIEData
0003 \author Panos Katsas (UoA)
0004 POOL object to store calibration mode QIE coder parameters for one channel
0005 $Id
0006 */
0007 
0008 #include <iostream>
0009 
0010 #include "CondFormats/CastorObjects/interface/CastorQIEShape.h"
0011 #include "CondFormats/CastorObjects/interface/CastorCalibrationQIECoder.h"
0012 
0013 float CastorCalibrationQIECoder::charge(unsigned fAdc) const {
0014   const float* data = base();
0015   if (fAdc >= 31)
0016     return (3 * data[31] - data[30]) / 2.;  // extrapolation
0017   return (data[fAdc] + data[fAdc + 1]) / 2;
0018 }
0019 
0020 unsigned CastorCalibrationQIECoder::adc(float fCharge) const {
0021   const float* data = base();
0022   unsigned adc = 1;
0023   for (; adc < 32; adc++) {
0024     if (fCharge < data[adc])
0025       return adc - 1;
0026   }
0027   return 31;  // overflow
0028 }
0029 
0030 float CastorCalibrationQIECoder::minCharge(unsigned fBin) const {
0031   const float* data = base();
0032   return fBin < 32 ? data[fBin] : data[31];
0033 }
0034 
0035 const float* CastorCalibrationQIECoder::minCharges() const {
0036   const float* data = base();
0037   return data;
0038 }
0039 
0040 void CastorCalibrationQIECoder::setMinCharge(unsigned fBin, float fValue) {
0041   float* data = base();
0042   if (fBin < 32)
0043     data[fBin] = fValue;
0044 }
0045 
0046 void CastorCalibrationQIECoder::setMinCharges(const float fValue[32]) {
0047   float* data = base();
0048   for (int i = 0; i < 32; i++)
0049     data[i] = fValue[i];
0050 }