00001 00009 #include "CondFormats/HcalObjects/interface/HcalQIEShape.h" 00010 00011 HcalQIEShape::HcalQIEShape() 00012 :nbins_(0) 00013 { 00014 } 00015 00016 HcalQIEShape::~HcalQIEShape() {} 00017 00018 void HcalQIEShape::expand () { 00019 int scale = 1; 00020 for (unsigned range = 1; range < 4; range++) { 00021 int factor = nbins_ == 32 ? 5 : 8; // QIE8/QIE10 -> 5/8 00022 scale *= factor; 00023 unsigned index = range * nbins_; 00024 mValues [index] = mValues [index - 2]; // link to previous range 00025 for (unsigned i = 1; i < nbins_; i++) { 00026 mValues [index + i] = mValues [index + i - 1] + scale * (mValues [i] - mValues [i - 1]); 00027 } 00028 } 00029 mValues [nbins_*4] = 2 * mValues [nbins_*4-1] - mValues [nbins_*4-2]; // extrapolate 00030 } 00031 00032 float HcalQIEShape::lowEdge (unsigned fAdc) const { 00033 if (fAdc < 4*nbins_) return mValues [fAdc]; 00034 return 0.; 00035 } 00036 00037 float HcalQIEShape::center (unsigned fAdc) const { 00038 if (fAdc < 4*nbins_) { 00039 if (fAdc % nbins_ == nbins_-1) return 0.5 * (3 * mValues [fAdc] - mValues [fAdc - 1]); // extrapolate 00040 else return 0.5 * (mValues [fAdc] + mValues [fAdc + 1]); // interpolate 00041 } 00042 return 0.; 00043 } 00044 00045 float HcalQIEShape::highEdge (unsigned fAdc) const { 00046 if (fAdc < 4*nbins_) return mValues [fAdc+1]; 00047 return 0.; 00048 } 00049 00050 bool HcalQIEShape::setLowEdge (float fValue, unsigned fAdc) { 00051 if (fAdc >= nbins_) return false; 00052 mValues [fAdc] = fValue; 00053 return true; 00054 } 00055 00056 bool HcalQIEShape::setLowEdges (unsigned int nbins, const float *fValue) { 00057 nbins_=nbins; 00058 mValues.clear(); 00059 mValues.resize(4*nbins_+1); 00060 bool result = true; 00061 for (unsigned int adc = 0; adc < nbins_; adc++) result = result && setLowEdge (fValue [adc], adc); 00062 expand (); 00063 return result; 00064 } 00065