CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch13/src/CondFormats/HcalObjects/src/HcalQIEShape.cc

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