CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
PedestalSub.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <cmath>
3 #include <climits>
5 
6 using namespace std;
7 
9 
11 
12 void PedestalSub::calculate(const std::vector<double>& inputCharge,
13  const std::vector<double>& inputPedestal,
14  const std::vector<double>& inputNoise,
15  std::vector<double>& corrCharge,
16  int soi,
17  int nTS) const {
18  double bseCorr = PedestalSub::getCorrection(inputCharge, inputPedestal, inputNoise, soi, nTS);
19  for (auto i = 0; i < nTS; i++) {
20  corrCharge.push_back(inputCharge[i] - inputPedestal[i] - bseCorr);
21  }
22 }
23 
24 double PedestalSub::getCorrection(const std::vector<double>& inputCharge,
25  const std::vector<double>& inputPedestal,
26  const std::vector<double>& inputNoise,
27  int soi,
28  int nTS) const {
29  double baseline = 0;
30 
31  for (auto i = 0; i < nTS; i++) {
32  if (i == soi || i == (soi + 1))
33  continue;
34  if ((inputCharge[i] - inputPedestal[i]) < 3 * inputNoise[i]) {
35  baseline += (inputCharge[i] - inputPedestal[i]);
36  } else {
37  baseline += 3 * inputNoise[i];
38  }
39  }
40  baseline /= (nTS - 2);
41  return baseline;
42 }
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:24
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:12