#include "TCanvas.h" #include "TGraph.h" #include "TF1.h" #include "TFile.h" #include "TH1.h" #include "TStyle.h" #include "TROOT.h" #include "TStyle.h" #include "TAxis.h" #include "TMath.h" #include "TAxis.h" #include "TGraph.h" #include "TPad.h" #include "TLatex.h" #include "TApplication.h" void average() { gStyle->SetOptStat(1); char data_dir[512]; int input_offset = 2; sprintf(data_dir,"./data/QDC/%s",gApplication->Argv(input_offset)); int save_flag = atoi(gApplication->Argv(1+input_offset)); cout<<"Reading data in "<SetTitle("Voltage History; Time(s); Bias Voltage(V)"); gr_i->SetTitle("Current History; Time(s); Draw Current(nA)"); gr_c->SetTitle("Temperature History; Time(s); Temperature(C)"); gr_v->SetLineColor(kRed); gr_i->SetLineColor(kGreen+2); gr_c->SetLineColor(kBlue); gr_v->SetLineWidth(2); gr_i->SetLineWidth(2); gr_c->SetLineWidth(2); // TLatex = ltext; TCanvas* c1 = new TCanvas("c1","History Plots",600,800); c1->Divide(1,3); c1->cd(1); gr_v->Draw("Al"); c1->cd(2); gr_i->Draw("Al"); c1->cd(3); gr_c->Draw("Al"); // sprintf(text,"%.2f #pm %.1f%%",gr_gain->GetMean(2),gr_gain->GetRMS(2)*100./gr_gain->GetMean(2)); // ltext.DrawLatex(nch*0.3,gr_gain->GetMaximum()*0.88,text); // save results if(save_flag) { char tmpchar[512]; double norm_voltage = 0; sprintf(fname,"%s/History.png",data_dir); c1->Print(fname); sprintf(fname,"%s/Settings.txt",data_dir); FILE* setting = fopen(fname,"r"); if(!setting) { cout<<"Can not find "<GetMean(2), gr_v->GetRMS(2)); fprintf(result, "Average Current:\t%.6f\t+-\t%.6f\n", gr_i->GetMean(2), gr_i->GetRMS(2)); fprintf(result, "Average Temperature:\t%.6f\t+-\t%.6f\n", gr_c->GetMean(2), gr_c->GetRMS(2)); fprintf(result, "Bias at 25C:\t%.6f\n", norm_voltage); } }