/* * analyzer.h * * Created on: Jan 8, 2013 * Author: yqiang * * Modified: Oct 14, 2014 by yqiang for Active Collimator * */ #ifndef ANALYZER_H_ #define ANALYZER_H_ #include #include #include #include #include #include #include #include #include #include #include #include #include struct Scale { Double_t coeff; TString unit; }; const Int_t ch_voltage = 8; const TString name_voltage[ch_voltage] = { "N9.raw_XP", "N9.raw_XM", "N9.raw_YP", "N9.raw_YM", "N10.raw_XP", "N10.raw_XM", "N10.raw_YP", "N10.raw_YM" }; const TString name_current = "current"; const Color_t col_voltage[ch_voltage] = { kRed + 1, kOrange + 1, kOrange - 2, kSpring - 1, kCyan + 1, kAzure - 3, kViolet + 1, kMagenta + 1 }; const Scale scale_voltage[ch_voltage] = { { 1., "Voltage (V)" }, { 0.87, "Voltage (V)" }, { 0.78, "Voltage (V)" }, { 0.74, "Voltage (V)" }, { 0.63, "Voltage (V)" }, { 0.67, "Voltage (V)" }, { 0.65, "Voltage (V)" }, { 0.66, "Voltage (V)" } }; const Scale scale_current = { 1., "Current (nA)" }; class MyMainFrame: public TGMainFrame { private: TRootEmbeddedCanvas *canvas_history; TRootEmbeddedCanvas *canvas_misc; TGLabel *label_dir; TGLabel *label_offset; TGNumberEntryField *field_resample; TGCheckButton *check_legend; TGCheckButton *check_error; TGCheckButton *check_mean; TGCheckButton *check_fit; TGCheckButton *check_denoise; TFile *datafiles[100]; Int_t nfile; TTree *datatree; TTimeStamp starttime; TString workingdir; TString basename; TH1F *h_history; TH1F *h_voltage[ch_voltage]; TH1F *h_current; Double_t offset_voltage[ch_voltage]; Int_t version; Bool_t isTree; public: MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h); virtual ~MyMainFrame(); void DoOpen(); void DoZeroOffset(); void DoResetOffset(); void DoSaveOffset(); void DoLoadOffset(); void DoPlotVoltage(); void DoRoot(); void DoPrint();ClassDef(MyMainFrame, 0) }; class TObjTimeStamp: public TObject { private: TTimeStamp fTimeStamp; public: TObjTimeStamp(const TTimeStamp ts = TTimeStamp()) : fTimeStamp(ts) { } TObjTimeStamp(const TObjTimeStamp &ts) : TObject(), fTimeStamp(ts.fTimeStamp) { } virtual ~TObjTimeStamp() { } inline void Print() const { fTimeStamp.Print(); } inline void SetTime(const TTimeStamp ts) { fTimeStamp = ts; } inline TTimeStamp GetTime() const { return fTimeStamp; } ClassDef(TObjTimeStamp,1) }; Scale CreateScale(Double_t coeff, TString unit); TH1F *Resample(TH1F *h1, Double_t freq, Double_t offset = 0, Double_t delay = 0, Bool_t denoise = kFALSE, Bool_t cut = kFALSE, Double_t xmin = 0, Double_t xmax = 10000., Color_t color = kBlack, struct Scale scale = CreateScale(1., "Voltage (V)")); TH1F *IntHist(TH1F *h1, struct Scale scale = CreateScale(1., "Integral (V.s)")); TH1F *Ratio(TH1F *h1, TH1F *h2, struct Scale scale = CreateScale(1., "Ratio")); void ComboPlot(TVirtualPad *pp, TH1F **hh, Int_t nh, TString title = "", Bool_t legend = kFALSE, Bool_t error = kFALSE, Bool_t mean = kFALSE, Bool_t fit = kFALSE, Bool_t manual = kFALSE, Double_t min = -10., Double_t max = 10.); Double_t Average(TH1F *hh, Double_t &error); TH1F *AddHist(TH1F **h1, Int_t nhist, TString hname, TString htitle = "", Color_t color = kBlack); TH1F *CorrHist(TH1F *h1, TH1F *h2, Int_t nbin = 100, Bool_t manual = kFALSE, Double_t min = 0, Double_t max = 1500); TH1F *Derivative(TH1F *h1, Double_t window = 1); TH1F *ReadTree(TTree *tree, TString branchname, Double_t scale = 1); TH1F *DeNoise(TH1F *h1); #endif /* ANALYZER_H_ */