File indexing completed on 2023-03-17 10:46:36
0001
0002
0003
0004
0005
0006 #include "CondFormats/CastorObjects/interface/CastorQIEShape.h"
0007
0008 namespace {
0009 const float binMin[32] = {-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
0010 16, 18, 20, 22, 24, 26, 28, 31, 34, 37, 40, 44, 48, 52, 57, 62};
0011 }
0012
0013 CastorQIEShape::CastorQIEShape() {
0014 for (int i = 0; i < 32; i++)
0015 mValues[i] = binMin[i];
0016 expand();
0017 }
0018
0019 CastorQIEShape::~CastorQIEShape() {}
0020
0021 void CastorQIEShape::expand() {
0022 int scale = 1;
0023 for (unsigned range = 1; range < 4; range++) {
0024 scale = scale * 5;
0025 unsigned index = range * 32;
0026 mValues[index] = mValues[index - 2];
0027 for (unsigned i = 1; i < 32; i++) {
0028 mValues[index + i] = mValues[index + i - 1] + scale * (mValues[i] - mValues[i - 1]);
0029 }
0030 }
0031 mValues[128] = 2 * mValues[127] - mValues[126];
0032 }
0033
0034 float CastorQIEShape::lowEdge(unsigned fAdc) const {
0035 if (fAdc < 128)
0036 return mValues[fAdc];
0037 return 0.;
0038 }
0039
0040 float CastorQIEShape::center(unsigned fAdc) const {
0041 if (fAdc < 128) {
0042 if (fAdc % 32 == 31)
0043 return 0.5 * (3 * mValues[fAdc] - mValues[fAdc - 1]);
0044 else
0045 return 0.5 * (mValues[fAdc] + mValues[fAdc + 1]);
0046 }
0047 return 0.;
0048 }
0049
0050 float CastorQIEShape::highEdge(unsigned fAdc) const {
0051 if (fAdc >= 128)
0052 return 0;
0053 if (fAdc == 127)
0054 return mValues[fAdc + 1];
0055 if (fAdc % 32 == 31)
0056 return mValues[fAdc + 3];
0057 return mValues[fAdc + 1];
0058 }
0059
0060 bool CastorQIEShape::setLowEdge(float fValue, unsigned fAdc) {
0061 if (fAdc >= 32)
0062 return false;
0063 mValues[fAdc] = fValue;
0064 return true;
0065 }
0066
0067 bool CastorQIEShape::setLowEdges(const float fValue[32]) {
0068 bool result = true;
0069 for (int adc = 0; adc < 32; adc++)
0070 result = result && setLowEdge(fValue[adc], adc);
0071 expand();
0072 return result;
0073 }