/* * analyzer.h * * Created on: Jan 8, 2013 * Author: yqiang */ #ifndef ANALYZER_H_ #define ANALYZER_H_ #include #include #include #include #include #include #include #include #include #include #include #include #include #include struct Scale { Double_t coeff; TString unit; }; const Int_t ch_vtt = 16; // Voltage Tabs +/-10V const Int_t ch_vtts = 3; // Voltage Tabs +/-10V splice const Int_t ch_vttb = 7; // Voltage Tabs +/-100V const Int_t ch_pickup = 8; // Pick up coils const Int_t ch_lead = 3; // current leads const Int_t ch_acc = 8; // accelerometers const TString name_epics = "halld-pxi:array:"; const TString name_current = "i_sol"; const TString name_shunt = "i_shunt"; const TString name_shunt_old = "I_SHUNT"; const TString name_field = "b_field"; const TString name_voltage = "v_mps"; const TString name_qd_old = "qd_err"; const TString name_qd = "det_qd"; const TString name_gfd = "det_gfd"; const TString name_vtt[ch_vtt] = { "vtt4", "vtt5", "vtt6", "vtt7", "vtt8", "vtt9", "vtt10", "vtt11", "vtt12", "vtt13", "vtt14", "vtt15", "vtt16", "vtt17", "vtt18", "vtt19" }; const TString name_vtts[ch_vtts] = { "vtt7s", "vtt12s", "vtt16s" }; const TString name_vttb[ch_vttb] = { "vtt4b", "vtt7b", "vtt8b", "vtt12b", "vtt14b", "vtt18b", "vtt19b" }; //const TString name_pickup[ch_pickup] = { "v_pc1u", "v_pc1d", "v_pc2u", "v_pc2d", const TString name_pickup[ch_pickup] = { "v_pc2u", "v_pc2d", "v_pc1u", "v_pc1d", "v_pc3u", "v_pc3d", "v_pc4u", "v_pc4d" }; const TString name_lead[ch_lead] = { "vtt3", "vtt20", "vtt21" }; const TString name_acc[ch_acc] = {"Coil1_Accel_Top","Coil1_Accel_Bot","Coil2_Accel_Top","Coil2_Accel_Bot", "Coil3_Accel_Top","Coil3_Accel_Bot","Coil4_Accel_Top","Coil4_Accel_Bot"}; const Color_t col_current = kRed + 1; const Color_t col_shunt = kAzure - 3; const Color_t col_field = kGreen + 2; const Color_t col_voltage = kBlue - 4; const Color_t col_softvol = kOrange - 2; const Color_t col_qd = kRed + 1; const Color_t col_gfd = kBlue - 4; const Color_t col_vtt[ch_vtt] = { kRed + 1, kOrange + 1, kOrange - 2, kSpring - 1, kCyan + 1, kAzure - 3, kBlue + 2, kViolet + 1, kMagenta + 1, kRed - 4, kOrange - 3, kGreen - 2, kAzure + 1, kBlue + 1, kViolet + 2, kMagenta - 3 }; const Color_t col_vtts[ch_vtts] = { kRed - 2 , kRed - 4, kRed - 6}; const Color_t col_vttb[ch_vttb] = { kBlue - 2 , kBlue - 4, kBlue - 6, kGreen - 2 , kGreen - 4, kGreen - 6, kMagenta}; const Color_t col_pickup[ch_pickup] = { kRed + 1, kOrange + 1, kOrange - 2, kSpring - 1, kCyan + 1, kAzure - 3, kViolet + 1, kMagenta + 1 }; const Color_t col_lead[ch_lead] = { kRed + 1, kBlue + 2, kGreen - 2 }; const Color_t col_acc[ch_acc] = { kRed + 1, kBlue + 1, kRed +1, kBlue + 1 , kRed + 1, kBlue + 1, kRed +1, kBlue + 1}; const Scale scale_current = { 299.495, "Current (A)" }; const Scale scale_shunt = { 15127.9, "Current (A)" }; const Scale scale_voltage = { 1.033, "Voltage (V)" }; const Scale scale_field = { 1., "Field (T)" }; const Scale scale_pickupfield = { 1. / 54., "Field (T)" }; const Scale scale_ratio = { 1000., "Field/Current (T/kA)" }; const Scale scale_qd = { 2.081, "Voltage (V)" }; const Scale scale_gfd = { 1., "Voltage(V)" }; const Scale scale_vtt[ch_vtt] = { { 1., "Voltage (V)" }, { 1., "Voltage (V)" }, { 1., "Voltage (V)" }, { 1., "Voltage (V)" }, { 1.167, "Voltage (V)" }, { 1., "Voltage (V)" }, { 1., "Voltage (V)" }, { 1., "Voltage (V)" }, { 1.167, "Voltage (V)" }, { 1., "Voltage (V)" }, { 1.,"Voltage (V)" }, { 1., "Voltage (V)" }, { 1., "Voltage (V)" }, { 1., "Voltage (V)" }, { 1.093, "Voltage (V)" }, { 1.073,"Voltage (V)" } }; const Scale scale_vtts[ch_vtts] = { { 1., "Voltage (V)" }, { 1., "Voltage (V)" },{ 1., "Voltage (V)" }}; const Scale scale_vttb[ch_vttb] = { { 1., "Voltage (V)" }, { 1., "Voltage (V)" }, { 1., "Voltage (V)" }, { 1., "Voltage (V)" }, { 1., "Voltage (V)" }, { 1., "Voltage (V)" }, { 1., "Voltage (V)" }}; /* const Scale scale_pickup[ch_pickup] = { { 1., "Voltage (V)" }, { 1., */ /* "Voltage (V)" }, { 1., "Voltage (V)" }, { 1., "Voltage (V)" }, { 1., */ /* "Voltage (V)" }, { 1., "Voltage (V)" }, { 1., "Voltage (V)" }, { 1., */ /* "Voltage (V)" } }; */ const Scale scale_pickup[ch_pickup] = { { 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_lead[ch_lead] = { { 1., "Voltage (V)" }, { 1., "Voltage (V)" }, { 1., "Voltage (V)" } }; const Scale scale_acc[ch_acc] = { { 1., "Voltage (V)" }, { 1., "Voltage (V)" }, { 1., "Voltage (V)" }, { 1., "Voltage (V)" }, { 1., "Voltage (V)" }, { 1., "Voltage (V)" }, { 1., "Voltage (V)" }, { 1., "Voltage (V)" } }; const Double_t Inductance[ch_vtt] = { 1.302, 0.743, 0.8521, 1.212, 2.777, 0.5078, 0.3392, 1.275, 2.392, 1.662, 1.775, 0.2423, 0.3411, 1.237, 4.552, 3.821 }; const Double_t Resistance[ch_vtt] = { 1.037, 0.571, 0.598, 0.877, 1.887, 0.399, 0.266, 0.718, 1.488, 1.037, 1.090, 0.146, 0.292, 0.718, 2.233, 1.954 }; //const Double_t pickup_pol_corr[ch_pickup] = { 1, -1, -1, -1, 1, -1, -1, 1 }; const Double_t pickup_pol_corr[ch_pickup] = { -1, -1, 1, -1, 1, -1, -1, 1 }; class MyMainFrame: public TGMainFrame { private: TRootEmbeddedCanvas *canvas_history; TRootEmbeddedCanvas *canvas_misc; TGStatusBar *fStatusBar; TGLabel *label_dir; TGLabel *label_offset; TGNumberEntryField *field_delay; TGNumberEntryField *field_resample; TGNumberEntryField *field_window; TGCheckButton *check_legend; TGCheckButton *check_error; TGCheckButton *check_mean; TGCheckButton *check_fit; TGCheckButton *check_ZFCT; TGCheckButton *check_denoise; TFile *datafiles[100]; Int_t nfile; TTree *datatree; TTimeStamp starttime; TString workingdir; TString basename; TH1F *h_history; TH1F *h_current; TH1F *h_shunt; TH1F *h_field; TH1F *h_voltage; TH1F *h_qd; TH1F *h_gfd; TH1F *h_vtt[ch_vtt]; TH1F *h_vtts[ch_vtts]; TH1F *h_vttb[ch_vttb]; TH1F *h_pickup[ch_pickup]; TH1F *h_lead[ch_lead]; TH1F *h_acc[ch_acc]; Double_t offset_current, offset_shunt, offset_field, offset_voltage, offset_qd, offset_gfd, offset_vtt[ch_vtt], offset_vtts[ch_vtts], offset_vttb[ch_vttb], offset_pickup[ch_pickup], offset_lead[ch_lead], offset_acc[ch_acc]; 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 DoPlotField(); void DoPlotRatio(); void DoPlotVoltage(); void DoPlotVoltageC12(); void DoPlotVoltageC34(); void DoPlotVoltageLeads(); void DoPlotInductance(); void DoPlotQD(); void DoPlotResistance(); void DoPlotTemperature(); void DoPlotAccelerometers(); void DoRoot(); void DoPrint();ClassDef(MyMainFrame, 0) void SetStatusText(const char *txt, Int_t pi); void EventInfo(Int_t event, Int_t px, Int_t py, TObject *selected); }; 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); Double_t Temperature(Double_t ratio); #endif /* ANALYZER_H_ */