File indexing completed on 2024-04-06 12:02:16
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include "CondFormats/HcalObjects/interface/HcalQIEShape.h"
0010
0011 HcalQIEShape::HcalQIEShape() : nbins_(0) {}
0012
0013 HcalQIEShape::~HcalQIEShape() {}
0014
0015 void HcalQIEShape::expand() {
0016 int scale = 1;
0017 for (unsigned range = 1; range < 4; range++) {
0018 int factor = nbins_ == 32 ? 5 : 8;
0019 scale *= factor;
0020 unsigned index = range * nbins_;
0021 unsigned overlap = (nbins_ == 32) ? 2 : 3;
0022 mValues[index] = mValues[index - overlap];
0023 for (unsigned i = 1; i < nbins_; i++) {
0024 mValues[index + i] = mValues[index + i - 1] + scale * (mValues[i] - mValues[i - 1]);
0025 }
0026 }
0027 mValues[nbins_ * 4] = 2 * mValues[nbins_ * 4 - 1] - mValues[nbins_ * 4 - 2];
0028 }
0029
0030 float HcalQIEShape::lowEdge(unsigned fAdc) const {
0031 if (fAdc < 4 * nbins_)
0032 return mValues[fAdc];
0033 return 0.;
0034 }
0035
0036 float HcalQIEShape::center(unsigned fAdc) const {
0037 if (fAdc < 4 * nbins_) {
0038 if (fAdc % nbins_ == nbins_ - 1)
0039 return 0.5 * (3 * mValues[fAdc] - mValues[fAdc - 1]);
0040 else
0041 return 0.5 * (mValues[fAdc] + mValues[fAdc + 1]);
0042 }
0043 return 0.;
0044 }
0045
0046 float HcalQIEShape::highEdge(unsigned fAdc) const {
0047 if (fAdc < 4 * nbins_)
0048 return mValues[fAdc + 1];
0049 return 0.;
0050 }
0051
0052 bool HcalQIEShape::setLowEdge(float fValue, unsigned fAdc) {
0053 if (fAdc >= nbins_)
0054 return false;
0055 mValues[fAdc] = fValue;
0056 return true;
0057 }
0058
0059 bool HcalQIEShape::setLowEdges(unsigned int nbins, const float *fValue) {
0060 nbins_ = nbins;
0061 mValues.clear();
0062 mValues.resize(4 * nbins_ + 1);
0063 bool result = true;
0064 for (unsigned int adc = 0; adc < nbins_; adc++)
0065 result = result && setLowEdge(fValue[adc], adc);
0066 expand();
0067 return result;
0068 }