CMS 3D CMS Logo

CastorDigiStatistics.h
Go to the documentation of this file.
1 #ifndef CastorSim_CastorDigiStatistics_h
2 #define CastorSim_CastorDigiStatistics_h
3 
7 #include <string>
8 
10 public:
12  int maxBin,
13  float amplitudeThreshold,
14  float expectedPedestal,
15  float binPrevToBinMax,
16  float binNextToBinMax,
17  CaloHitAnalyzer &amplitudeAnalyzer)
18  : maxBin_(maxBin),
19  amplitudeThreshold_(amplitudeThreshold),
20  pedestal_(name + " pedestal", expectedPedestal, 0.),
21  binPrevToBinMax_(name + " binPrevToBinMax", binPrevToBinMax, 0.),
22  binNextToBinMax_(name + " binNextToBinMax", binNextToBinMax, 0.),
23  amplitudeAnalyzer_(amplitudeAnalyzer) {}
24 
25  template <class Digi>
26  void analyze(const Digi &digi);
27 
28 private:
29  int maxBin_;
35 };
36 
37 template <class Digi>
39  pedestal_.addEntry(digi[0].adc());
40  pedestal_.addEntry(digi[1].adc());
41 
42  double pedestal_fC = 0.5 * (digi[0].nominal_fC() + digi[1].nominal_fC());
43 
44  double maxAmplitude = digi[maxBin_].nominal_fC() - pedestal_fC;
45 
46  if (maxAmplitude > amplitudeThreshold_) {
47  double binPrevToBinMax = (digi[maxBin_ - 1].nominal_fC() - pedestal_fC) / maxAmplitude;
48  binPrevToBinMax_.addEntry(binPrevToBinMax);
49 
50  double binNextToBinMax = (digi[maxBin_ + 1].nominal_fC() - pedestal_fC) / maxAmplitude;
51  binNextToBinMax_.addEntry(binNextToBinMax);
52 
53  double amplitude = digi[maxBin_].nominal_fC() + digi[maxBin_ + 1].nominal_fC() - 2 * pedestal_fC;
54 
55  amplitudeAnalyzer_.analyze(digi.id().rawId(), amplitude);
56  }
57 }
58 
59 #endif
void analyze(int detId, double recEnergy)
to be called for each RecHit
CaloValidationStatistics binPrevToBinMax_
std::tuple< unsigned int, int, int, DigiType, int, int, int, float > Digi
Definition: GenericDigi.h:40
CaloHitAnalyzer & amplitudeAnalyzer_
constexpr int adc(sample_type sample)
get the ADC sample (12 bits)
CaloValidationStatistics pedestal_
void addEntry(float value, float weight=1.)
CastorDigiStatistics(std::string name, int maxBin, float amplitudeThreshold, float expectedPedestal, float binPrevToBinMax, float binNextToBinMax, CaloHitAnalyzer &amplitudeAnalyzer)
void analyze(const Digi &digi)
CaloValidationStatistics binNextToBinMax_