00001 #ifndef CastorSim_CastorDigiStatistics_h 00002 #define CastorSim_CastorDigiStatistics_h 00003 00004 #include "CalibFormats/CaloObjects/interface/CaloSamples.h" 00005 #include "SimCalorimetry/CaloSimAlgos/interface/CaloValidationStatistics.h" 00006 #include "SimCalorimetry/CaloSimAlgos/interface/CaloHitAnalyzer.h" 00007 #include <string> 00008 00009 class CastorDigiStatistics 00010 { 00011 public: 00012 CastorDigiStatistics(std::string name, 00013 int maxBin, 00014 float amplitudeThreshold, 00015 float expectedPedestal, 00016 float binPrevToBinMax, 00017 float binNextToBinMax, 00018 CaloHitAnalyzer & amplitudeAnalyzer) 00019 : maxBin_(maxBin), 00020 amplitudeThreshold_(amplitudeThreshold), 00021 pedestal_(name+" pedestal", expectedPedestal, 0.), 00022 binPrevToBinMax_(name+" binPrevToBinMax", binPrevToBinMax, 0.), 00023 binNextToBinMax_(name+" binNextToBinMax", binNextToBinMax, 0.), 00024 amplitudeAnalyzer_(amplitudeAnalyzer) 00025 { 00026 } 00027 00028 template<class Digi> 00029 void analyze(const Digi & digi); 00030 00031 private: 00032 int maxBin_; 00033 float amplitudeThreshold_; 00034 CaloValidationStatistics pedestal_; 00035 CaloValidationStatistics binPrevToBinMax_; 00036 CaloValidationStatistics binNextToBinMax_; 00037 CaloHitAnalyzer & amplitudeAnalyzer_; 00038 }; 00039 00040 00041 template<class Digi> 00042 void CastorDigiStatistics::analyze(const Digi & digi) { 00043 pedestal_.addEntry(digi[0].adc()); 00044 pedestal_.addEntry(digi[1].adc()); 00045 00046 00047 double pedestal_fC = 0.5*(digi[0].nominal_fC() + digi[1].nominal_fC()); 00048 00049 00050 double maxAmplitude = digi[maxBin_].nominal_fC() - pedestal_fC; 00051 00052 if(maxAmplitude > amplitudeThreshold_) { 00053 00054 double binPrevToBinMax = (digi[maxBin_-1].nominal_fC() - pedestal_fC) 00055 / maxAmplitude; 00056 binPrevToBinMax_.addEntry(binPrevToBinMax); 00057 00058 00059 double binNextToBinMax = (digi[maxBin_+1].nominal_fC() - pedestal_fC) 00060 / maxAmplitude; 00061 binNextToBinMax_.addEntry(binNextToBinMax); 00062 00063 double amplitude = digi[maxBin_].nominal_fC() 00064 + digi[maxBin_+1].nominal_fC() 00065 - 2*pedestal_fC; 00066 00067 00068 amplitudeAnalyzer_.analyze(digi.id().rawId(), amplitude); 00069 00070 } 00071 } 00072 00073 #endif 00074