ATTPCROOT  0.3.0-alpha
A ROOT-based framework for analyzing data from active target detectors
AtPedestal.cxx
Go to the documentation of this file.
1 // =================================================
2 // AtPedestal Class
3 //
4 // Description:
5 // This class is used for calculating or finding
6 // pedestal value and sigma corresponding to
7 // user-input padRow and padLayer.
8 //
9 // Genie Jhang ( geniejhang@majimak.com )
10 // Modified by Y. Ayyad for the AtTPCROOT
11 // =================================================
12 
13 #include "AtPedestal.h"
14 
15 #include <Rtypes.h>
16 
17 #include "GETMath2.h"
18 
19 #include <iostream>
20 
22 
23 AtPedestal::AtPedestal() : fMath(std::make_unique<GETMath2>()) {}
24 
25 Bool_t AtPedestal::SubtractPedestal(Int_t numTbs, Int_t *fpn, Int_t *rawADC, Double_t *dest, Double_t rmsCut,
26  Bool_t signalNegativePolarity, Int_t startTb, Int_t averageTbs)
27 {
28  while (true) {
29  fMath->Reset();
30  for (Int_t iTb = startTb; iTb < startTb + averageTbs; iTb++)
31  fMath->Add(rawADC[iTb]);
32 
33  if (fMath->GetRMS() < rmsCut)
34  break;
35 
36  startTb += averageTbs;
37 
38  if (startTb > numTbs - averageTbs - 3) {
39  std::cout << "= [STPedestal] There's no part satisfying sigma threshold " << rmsCut << "!" << std::endl;
40 
41  return kFALSE;
42  }
43  }
44 
45  Double_t baselineDiff = -fMath->GetMean();
46 
47  fMath->Reset();
48  for (Int_t iTb = startTb; iTb < startTb + averageTbs; iTb++)
49  fMath->Add(fpn[iTb]);
50 
51  baselineDiff += fMath->GetMean();
52 
53  for (Int_t iTb = 0; iTb < numTbs; iTb++) {
54  Double_t adc = 0;
55  if (signalNegativePolarity == kTRUE)
56  adc = (fpn[iTb] - baselineDiff) - rawADC[iTb];
57  else
58  adc = rawADC[iTb] - (fpn[iTb] - baselineDiff);
59 
60  dest[iTb] = adc;
61  }
62 
63  return kTRUE;
64 }
GETMath2.h
AtPedestal.h
AtPedestal
Definition: AtPedestal.h:27
AtPedestal::AtPedestal
AtPedestal()
Definition: AtPedestal.cxx:23
GETMath2
Definition: GETMath2.h:29
ClassImp
ClassImp(AtPedestal)
AtPedestal::SubtractPedestal
Bool_t SubtractPedestal(Int_t numTbs, Int_t *fpn, Int_t *rawADC, Double_t *dest, Double_t rmsCut=5, Bool_t signalNegativePolarity=kFALSE, Int_t startTb=3, Int_t averageTbs=10)
Definition: AtPedestal.cxx:25