CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch13/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 const float binMin [32] = {-3, -0.4,  2.2,  4.8,  7.4,  10,  12.6, 15.2, 
00015                            17.8,  20.4, 23, 25.6, 28.2, 30.8 ,33.4, 36,
00016                            41.2, 46.4, 51.6, 56.8, 62, 67.2, 73, 80.8, 
00017                            88.6, 96.4, 104, 114.4, 124.8, 135, 148, 161}; 
00018                              
00019                            }
00020                            
00021 CastorQIEShape::CastorQIEShape() 
00022 {
00023   for (int i = 0; i < 32; i++) mValues [i] = binMin [i];
00024   expand ();
00025 }
00026 
00027 CastorQIEShape::~CastorQIEShape() {}
00028 
00029 void CastorQIEShape::expand () {
00030   int scale = 1;
00031   for (unsigned range = 1; range < 4; range++) {
00032     scale = scale * 5;
00033     unsigned index = range * 32;
00034     mValues [index] = mValues [index - 2]; // link to previous range
00035     for (unsigned i = 1; i < 32; i++) {
00036       mValues [index + i] =  mValues [index + i - 1] + scale * (mValues [i] - mValues [i - 1]);
00037     }
00038   }
00039   mValues [128] = 2 * mValues [127] - mValues [126]; // extrapolate
00040 }
00041 
00042 float CastorQIEShape::lowEdge (unsigned fAdc) const {
00043   if (fAdc < 128) return mValues [fAdc];
00044   return 0.;
00045 }
00046 
00047 float CastorQIEShape::center (unsigned fAdc) const {
00048   if (fAdc < 128) {
00049     if (fAdc % 32 == 31) return 0.5 * (3 * mValues [fAdc] - mValues [fAdc - 1]); // extrapolate
00050     else       return 0.5 * (mValues [fAdc] + mValues [fAdc + 1]); // interpolate
00051   }
00052   return 0.;
00053 }
00054 
00055 float CastorQIEShape::highEdge (unsigned fAdc) const {
00056   if (fAdc >= 128 ) return 0;
00057   if (fAdc == 127 ) return mValues [fAdc+1];
00058   if (fAdc % 32 == 31) return mValues [fAdc+3];
00059   return mValues [fAdc+1];
00060 }
00061 
00062 bool CastorQIEShape::setLowEdge (float fValue, unsigned fAdc) {
00063   if (fAdc >= 32) return false; 
00064   mValues [fAdc] = fValue;
00065   return true;
00066 }
00067 
00068 bool CastorQIEShape::setLowEdges (const float fValue [32]) {
00069   bool result = true;
00070   for (int adc = 0; adc < 32; adc++) result = result && setLowEdge (fValue [adc], adc);
00071   expand ();
00072   return result;
00073 }