Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MbdSig.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file MbdSig.h
1 #ifndef __MBDSIG_H__
2 #define __MBDSIG_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 MbdSig
23 {
24  public:
25  explicit MbdSig(const int chnum = 0, const int nsamp = 0);
26  // explicit MbdSig(const MbdSig &obj); // never used
27  virtual ~MbdSig();
28 
29  // MbdSig& operator= (const MbdSig& 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  {
57  minped0samp = minsamp;
58  maxped0samp = maxsamp;
59  }
60  void SetEventPed0Range(const Double_t minx, const Double_t maxx)
61  {
62  minped0x = minx;
63  maxped0x = maxx;
64  }
65  void SetEventPed0PreSamp(const Int_t presample, const Int_t nsamps = 1)
66  {
67  ped_presamp = presample;
68  ped_presamp_nsamps = nsamps;
69  }
70  void CalcEventPed0(const Int_t minsamp, const Int_t maxsamp);
71  void CalcEventPed0(const Double_t minx, const Double_t maxx);
72  void CalcEventPed0_PreSamp(const Int_t pre_samp, const Int_t nsamps = 1);
73 
75  Double_t LeadingEdge(const Double_t threshold); // Leading Edge Discriminator Time
76 
78  Double_t dCFD(const Double_t fraction_threshold);
79 
81  Double_t MBD(const Int_t max_samp);
82 
84  Double_t GetSplineAmpl();
85 
87  Double_t Integral(const Double_t xmin, const Double_t xmax);
88 
90  void LocMax(Double_t &x_at_max, Double_t &ymax, Double_t minxrange = 0., Double_t maxxrange = 0.);
91 
93  void LocMin(Double_t &x_at_min, Double_t &ymin, Double_t minxrange = 0., Double_t maxxrange = 0.);
94 
96  Int_t FitTemplate();
97  // Double_t Ampl() { return f_ampl; }
98  // Double_t Time() { return f_time; }
99 
101  void SetTemplateSize(const Int_t nptsx, const Int_t nptsy, const Double_t begt, const Double_t endt);
102  Int_t SetTemplate(const std::vector<float> &shape, const std::vector<float> &sherr);
103 
104  // Double_t FitPulse();
105  void SetTimeOffset(const Double_t o) { f_time_offset = o; }
106  Double_t TemplateFcn(const Double_t *x, const Double_t *par);
107  TF1 *GetTemplateFcn() { return template_fcn; }
108  void SetMinMaxFitTime(const Double_t mintime, const Double_t maxtime);
109 
110  void PadUpdate();
111  void Print();
112  void Verbose(const int v) { verbose = v; }
113 
114  private:
115  void Init();
116 
117  int ch;
118  int nsamples;
119  int _status{0};
120 
122  // should make an array for the different methods
123  Double_t f_ampl;
124  Double_t f_time;
126  Double_t f_time_offset;
128  Double_t f_integral;
130  TH1 *hRawPulse;
131  TH1 *hSubPulse;
132  TH1 *hpulse;
133  TGraphErrors *gRawPulse;
134  TGraphErrors *gSubPulse;
135  TGraphErrors *gpulse;
136 
138  // RunningStats *ped0stats; //!
139  TH1 *hPed0;
140  Double_t ped0;
141  Double_t ped0rms;
142  Int_t use_ped0;
143  Int_t minped0samp;
144  Int_t maxped0samp;
145  Double_t minped0x;
146  Double_t maxped0x;
147  Double_t ped_presamp{};
148  Double_t ped_presamp_nsamps{};
149 
151  // Double_t time_calib;
152 
156 
157  TH1 *hAmpl;
158  TH1 *hTime;
163  // Double_t template_min_good_amplitude; //! for template, in original units of waveform data
164  // Double_t template_max_good_amplitude; //! for template, in original units of waveform data
165  // Double_t template_min_xrange; //! for template, in original units of waveform data
166  // Double_t template_max_xrange; //! for template, in original units of waveform data
167  std::vector<float> template_y;
168  std::vector<float> template_yrms;
170  Double_t fit_min_time{};
171  Double_t fit_max_time{};
172 
173  int verbose;
174 };
175 
176 #endif // __MBDSIG_H__