test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 
8 PedestalSub::PedestalSub() : fMethod(AvgWithThresh),fThreshold(2.7),fQuantile(0.0),fCondition(0){
9 }
10 
12 }
13 
14 void PedestalSub::init(Method method=AvgWithThresh, int runCond=0, float threshold=0.0, float quantile=0.0) {
17  fQuantile=quantile;
18  fCondition=runCond;
19 }
20 
21 void PedestalSub::calculate(const std::vector<double> & inputCharge, const std::vector<double> & inputPedestal, std::vector<double> & corrCharge) const {
22 
23  double bseCorr=PedestalSub::getCorrection(inputCharge, inputPedestal);
24  for (auto i=0; i<10; i++) {
26  corrCharge.push_back(inputCharge[i]-inputPedestal[i]-bseCorr);
27  }
28  else {
29  corrCharge.push_back(inputCharge[i]-bseCorr);
30  }
31  }
32 }
33 
34 double PedestalSub::getCorrection(const std::vector<double> & inputCharge, const std::vector<double> & inputPedestal) const {
35 
36  double baseline=0;
37 
38  if (fMethod==DoNothing) {
39  baseline=0;
40  }
41  else if (fMethod==AvgWithThresh) {
42  for (auto i=0; i<10; i++) {
43  if (i==4||i==5) continue;
44  if ( (inputCharge[i]-inputPedestal[i])<fThreshold) {
45  baseline+=(inputCharge[i]-inputPedestal[i]);
46  }
47  else {
48  baseline+=fThreshold;
49  }
50  }
51  baseline/=8;
52  }
53  else if (fMethod==AvgWithoutThresh) {
54  for (auto i=0; i<10; i++) {
55  if (i==4||i==5) continue;
56  baseline+=(inputCharge[i]-inputPedestal[i]);
57  }
58  baseline/=8;
59  }
61  for (auto i=0; i<10; i++) {
62  if (i==4||i==5) continue;
63  if ( (inputCharge[i])<fThreshold) {
64  baseline+=(inputCharge[i]);
65  }
66  else baseline+=fThreshold;
67  }
68  baseline/=8;
69  }
70  return baseline;
71 
72 }
int i
Definition: DBlmapReader.cc:9
double getCorrection(const std::vector< double > &inputCharge, const std::vector< double > &inputPedestal) const
Definition: PedestalSub.cc:34
float fCondition
Definition: PedestalSub.h:26
Method fMethod
Definition: PedestalSub.h:23
void calculate(const std::vector< double > &inputCharge, const std::vector< double > &inputPedestal, std::vector< double > &corrCharge) const
Definition: PedestalSub.cc:21
float fQuantile
Definition: PedestalSub.h:25
float fThreshold
Definition: PedestalSub.h:24
void init(Method method, int runCond, float threshold, float quantile)
Definition: PedestalSub.cc:14