Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OnlBbcSig.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file OnlBbcSig.h
1 #ifndef __ONLBBCSIG_H__
2 #define __ONLBBCSIG_H__
3 
4 #include <TH1.h>
5 //#include <TH2.h>
6 #include <fstream>
7 #include <vector>
8 
9 class TFile;
10 class TTree;
11 class TGraphErrors;
12 class TH2;
13 //class THnSparse;
14 //class RunningStats;
15 
22 class OnlBbcSig
23 {
24 public:
25  explicit OnlBbcSig(const int chnum = 0, const int nsamp = 0);
26  //explicit OnlBbcSig(const OnlBbcSig &obj); // never used
27  virtual ~OnlBbcSig();
28 
29  //OnlBbcSig& operator= (const OnlBbcSig& obj) = delete; // never used
30 
31  void SetY(const Float_t *y, const int invert = 1);
32  void SetXY(const Float_t *x, const Float_t *y, const int invert = 1);
33 
34  TH1 *GetHist() { return hpulse; }
35  TGraphErrors *GetGraph() { return gpulse; }
36  Double_t GetAmpl() { return f_ampl; }
37  Double_t GetTime() { return f_time; }
38  Double_t GetIntegral() { return f_integral; }
39 
45  void FillPed0(const Int_t minsamp, const Int_t maxsamp);
46  void FillPed0(const Double_t minsamp, const Double_t maxsamp);
47 
48  Double_t GetPed0() { return ped0; }
49  Double_t GetPed0RMS() { return ped0rms; }
50 
52  void SetPed0(const Double_t mean, const Double_t rms = 0.);
53 
55  void SetEventPed0Range(const Int_t minsamp, const Int_t maxsamp) {
56  minped0samp = minsamp;
57  maxped0samp = maxsamp;
58  }
59  void SetEventPed0Range(const Double_t minx, const Double_t maxx) {
60  minped0x = minx;
61  maxped0x = maxx;
62  }
63  void CalcEventPed0(const Int_t minsamp, const Int_t maxsamp);
64  void CalcEventPed0(const Double_t minx, const Double_t maxx);
65 
67  Double_t LeadingEdge(const Double_t threshold); // Leading Edge Discriminator Time
68 
70  Double_t dCFD(const Double_t fraction_threshold);
71 
73  Double_t MBD(const Int_t max_samp);
74 
76  Double_t GetSplineAmpl();
77 
79  Double_t Integral(const Double_t xmin, const Double_t xmax);
80 
82  void LocMax(Double_t& x_at_max, Double_t& ymax, Double_t minxrange = 0., Double_t maxxrange = 0.);
83 
85  void LocMin(Double_t& x_at_min, Double_t& ymin, Double_t minxrange = 0., Double_t maxxrange = 0.);
86 
88  Int_t FitTemplate();
89  //Double_t Ampl() { return f_ampl; }
90  //Double_t Time() { return f_time; }
91 
93  void SetTemplateSize(const Int_t nptsx, const Int_t nptsy, const Double_t begt, const Double_t endt);
94  int FillSplineTemplate();
95  void FillFcnTemplate();
96  void MakeAndWriteTemplate(std::ostream& out, std::ostream& oerr);
97  Int_t ReadTemplate(std::ifstream& shapefile, std::ifstream& sherrfile);
98  void SetTemplateMinMaxGoodADC(const Double_t min, const Double_t max); // This is used in making templates only
99  void SetTemplateMinMaxFitRange(const Double_t min, const Double_t max); // This is used in making templates only
100 
101  //Double_t FitPulse();
102  void SetTimeOffset(const Double_t o) { f_time_offset = o; }
103  Double_t TemplateFcn(const Double_t *x, const Double_t *par);
104  TF1* GetTemplateFcn() { return template_fcn; }
105 
106  void PadUpdate();
107  void Print();
108  void Verbose(const int v) { verbose = v; }
109 
110 private:
111  void Init();
112 
113  int ch;
114  int nsamples;
115 
117  // should make an array for the different methods
118  Double_t f_ampl;
119  Double_t f_time;
121  Double_t f_time_offset;
123  Double_t f_integral;
125  TH1 *hRawPulse;
126  TH1 *hSubPulse;
127  TH1 *hpulse;
128  TGraphErrors *gRawPulse;
129  TGraphErrors *gSubPulse;
130  TGraphErrors *gpulse;
131 
133  //RunningStats *ped0stats; //!
134  TH1 *hPed0;
135  Double_t ped0;
136  Double_t ped0rms;
137  Int_t use_ped0;
138  Int_t minped0samp;
139  Int_t maxped0samp;
140  Double_t minped0x;
141  Double_t maxped0x;
142 
144  Double_t time_calib;
145 
149  //THnSparse *h2Template;
150  TH1 *hAmpl;
151  TH1 *hTime;
160  std::vector<Double_t> template_y;
161  std::vector<Double_t> template_yrms;
163 
164  int verbose;
165 };
166 
167 #endif // __OnlBbcSig_H__