CMS 3D CMS Logo

PedestalSub.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <cmath>
3 #include <climits>
5 
6 using namespace std;
7 
8 PedestalSub::PedestalSub() : fThreshold(2.7),fQuantile(0.0),fCondition(0){
9 }
10 
12 }
13 
14 void PedestalSub::init(int runCond=0, float threshold=0.0, float quantile=0.0) {
16  fQuantile=quantile;
17  fCondition=runCond;
18 }
19 
20 void PedestalSub::calculate(const std::vector<double> & inputCharge, const std::vector<double> & inputPedestal, const std::vector<double> & inputNoise, std::vector<double> & corrCharge, int soi, int nTS) const {
21 
22  double bseCorr=PedestalSub::getCorrection(inputCharge, inputPedestal, inputNoise, soi, nTS);
23  for (auto i=0; i<nTS; i++) {
24  corrCharge.push_back(inputCharge[i]-inputPedestal[i]-bseCorr);
25  }
26 }
27 
28 double PedestalSub::getCorrection(const std::vector<double> & inputCharge, const std::vector<double> & inputPedestal, const std::vector<double> & inputNoise, int soi, int nTS) const {
29 
30  double baseline=0;
31 
32  for (auto i=0; i<nTS; i++) {
33  if (i==soi || i==(soi+1)) continue;
34  if ( (inputCharge[i]-inputPedestal[i])<3*inputNoise[i]) {
35  baseline+=(inputCharge[i]-inputPedestal[i]);
36  }
37  else {
38  baseline+=3*inputNoise[i];
39  }
40  }
41  baseline/=(nTS-2);
42  return baseline;
43 
44 }
void init(int runCond, float threshold, float quantile)
Definition: PedestalSub.cc:14
float fCondition
Definition: PedestalSub.h:24
float fQuantile
Definition: PedestalSub.h:23
double getCorrection(const std::vector< double > &inputCharge, const std::vector< double > &inputPedestal, const std::vector< double > &inputNoise, int soi, int nSample) const
Definition: PedestalSub.cc:28
float fThreshold
Definition: PedestalSub.h:22
void calculate(const std::vector< double > &inputCharge, const std::vector< double > &inputPedestal, const std::vector< double > &inputNoise, std::vector< double > &corrCharge, int soi, int nSample) const
Definition: PedestalSub.cc:20