CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_8_patch3/src/CondFormats/CastorObjects/src/CastorQIEShape.cc

Go to the documentation of this file.
00001 
00006 #include "CondFormats/CastorObjects/interface/CastorQIEShape.h"
00007 
00008 namespace {
00009   const float binMin [32] = {-1,  0,  1,  2,  3,  4,  5,  6,  7,  8,
00010                              9, 10, 11, 12, 13, 14, 16, 18, 20, 22,
00011                              24, 26, 28, 31, 34, 37, 40, 44, 48, 52,
00012                              57, 62};
00013 }
00014 
00015 CastorQIEShape::CastorQIEShape() 
00016 {
00017   for (int i = 0; i < 32; i++) mValues [i] = binMin [i];
00018   expand ();
00019 }
00020 
00021 CastorQIEShape::~CastorQIEShape() {}
00022 
00023 void CastorQIEShape::expand () {
00024   int scale = 1;
00025   for (unsigned range = 1; range < 4; range++) {
00026     scale = scale * 5;
00027     unsigned index = range * 32;
00028     mValues [index] = mValues [index - 2]; // link to previous range
00029     for (unsigned i = 1; i < 32; i++) {
00030       mValues [index + i] =  mValues [index + i - 1] + scale * (mValues [i] - mValues [i - 1]);
00031     }
00032   }
00033   mValues [128] = 2 * mValues [127] - mValues [126]; // extrapolate
00034 }
00035 
00036 float CastorQIEShape::lowEdge (unsigned fAdc) const {
00037   if (fAdc < 128) return mValues [fAdc];
00038   return 0.;
00039 }
00040 
00041 float CastorQIEShape::center (unsigned fAdc) const {
00042   if (fAdc < 128) {
00043     if (fAdc % 32 == 31) return 0.5 * (3 * mValues [fAdc] - mValues [fAdc - 1]); // extrapolate
00044     else       return 0.5 * (mValues [fAdc] + mValues [fAdc + 1]); // interpolate
00045   }
00046   return 0.;
00047 }
00048 
00049 float CastorQIEShape::highEdge (unsigned fAdc) const {
00050   if (fAdc >= 128 ) return 0;
00051   if (fAdc == 127 ) return mValues [fAdc+1];
00052   if (fAdc % 32 == 31) return mValues [fAdc+3];
00053   return mValues [fAdc+1];
00054 }
00055 
00056 bool CastorQIEShape::setLowEdge (float fValue, unsigned fAdc) {
00057   if (fAdc >= 32) return false; 
00058   mValues [fAdc] = fValue;
00059   return true;
00060 }
00061 
00062 bool CastorQIEShape::setLowEdges (const float fValue [32]) {
00063   bool result = true;
00064   for (int adc = 0; adc < 32; adc++) result = result && setLowEdge (fValue [adc], adc);
00065   expand ();
00066   return result;
00067 }