//file stime.C #include #include #include "TFile.h" #include "TH1.h" #include "TTree.h" #include "TString.h" #include "TDatime.h" #include "TCanvas.h" #include "TPad.h" #include "TStyle.h" using namespace std; void testPlots() { // TString nameRootFile = "Data_Runs_May_4MeVPerFiber_ALL.root"; TFile f(nameRootFile); TTree *t_per_run = (TTree*)f.Get("t_per_run"); TDatime zeit_of_run; int time_of_run; int run_number; int events_of_run; int events_of_run_HE; int neutrons_of_run; float pressure_of_run, pressure_of_runStdDev; t_per_run -> SetBranchAddress("pressure_of_run",&pressure_of_run); t_per_run -> SetBranchAddress("run_number",&run_number); t_per_run -> SetBranchAddress("pressure_of_runStdDev",&pressure_of_runStdDev); t_per_run -> SetBranchAddress("events_of_run",&events_of_run); t_per_run -> SetBranchAddress("events_of_run_HE",&events_of_run_HE); t_per_run -> SetBranchAddress("neutrons_of_run",&neutrons_of_run); //t_per_run -> SetBranchAddress("zeit_of_run",&zeit_of_run(2018,05,05,00,00,00)); t_per_run -> SetBranchAddress("time_of_run",&time_of_run); Int_t total_runs = t_per_run ->GetEntries(); cout<<" total_runs "<SetTimeOffset(0); TDatime T1(2018,05,05,00,00,00); int X1 = T1.Convert(); // Define the highest histogram limit as 2003, March 7th TDatime T2(2018,05,30,00,00,00); int X2 = T2.Convert(); int nBins = (X2-X1)/7200; cout<<" nBins "< GetEntry(run); h_runs_bin -> Fill(time_of_run*1.0,1.); } for(Int_t run = 0; run < total_runs; run++){ t_per_run -> GetEntry(run); TAxis *xaxis = h_runs_bin->GetXaxis(); Int_t binx = xaxis->FindBin(time_of_run*1.0); Float_t nRuns = h_runs_bin -> GetBinContent(binx); //for safety if(nRuns>0){ h_pressure -> Fill(time_of_run,pressure_of_run/nRuns); h_evts -> Fill(time_of_run,events_of_run/nRuns); h_evts_he -> Fill(time_of_run,events_of_run_HE/nRuns); h_neutrons -> Fill(time_of_run,neutrons_of_run/nRuns); } //cout<<" y_axis_events[run] "<SetBinContent(bin_i+1,h_pressure->GetBinContent(bin_i+1)); h_evts_t->SetBinContent(bin_i+1,h_evts->GetBinContent(bin_i+1)); h_evts_he_t->SetBinContent(bin_i+1,h_evts_he->GetBinContent(bin_i+1)); double n_content = h_neutrons->GetBinContent(bin_i+1); //h_neutrons_t->SetBinContent(bin_i+1,n_content); h_neutrons_t->Fill(bin_i); //cout<<" h_neutrons->GetBinContent(bin_i+1) "<GetBinContent(bin_i+1)<Draw(); t_per_run->Draw("time_of_run"); TCanvas *c_evts_he = new TCanvas("c_evts_he","Rates per two hours",1000,1100); c_evts_he->Divide(1,4,0.0001,0.001); c_evts_he->cd(1); gPad->SetGrid(); h_pressure->SetLineColor(4); h_pressure->SetMarkerColor(4); h_pressure->SetMarkerStyle(24); h_pressure->Draw("HIST P"); gPad->Modified(); h_pressure->GetXaxis()->SetTimeDisplay(1); h_pressure->GetXaxis()->SetNdivisions(10); h_pressure->GetXaxis()->SetTimeFormat("%Y/%m/%d"); h_pressure->GetXaxis()->SetTimeOffset(0); //t_per_run->Draw("time_of_run"); c_evts_he->cd(2); gPad->SetGrid(); h_evts->SetLineColor(2); h_evts->SetMarkerColor(2); h_evts->SetMarkerStyle(24); h_evts->Draw("HIST P"); gPad->Modified(); h_evts->GetXaxis()->SetTimeDisplay(1); h_evts->GetXaxis()->SetNdivisions(10); h_evts->GetXaxis()->SetTimeFormat("%Y/%m/%d"); h_evts->GetXaxis()->SetTimeOffset(0); c_evts_he->cd(3); gPad->SetGrid(); h_evts_he->SetLineColor(2); h_evts_he->SetMarkerColor(2); h_evts_he->SetMarkerStyle(24); h_evts_he->Draw("HIST P"); gPad->Modified(); h_evts_he->GetXaxis()->SetTimeDisplay(1); h_evts_he->GetXaxis()->SetNdivisions(10); h_evts_he->GetXaxis()->SetTimeFormat("%Y/%m/%d"); h_evts_he->GetXaxis()->SetTimeOffset(0); c_evts_he->cd(4); gPad->SetGrid(); h_neutrons->SetLineColor(6); h_neutrons->SetMarkerColor(6); h_neutrons->SetMarkerStyle(24); h_neutrons->Draw("HIST P"); gPad->Modified(); h_neutrons->GetXaxis()->SetTimeDisplay(1); h_neutrons->GetXaxis()->SetNdivisions(10); h_neutrons->GetXaxis()->SetTimeFormat("%Y/%m/%d"); h_neutrons->GetXaxis()->SetTimeOffset(0); TCanvas *c_evts_he_t = new TCanvas("c_evts_he_t","Rates per two hours",1000,1100); c_evts_he_t->Divide(1,4,0.0001,0.001); c_evts_he_t->cd(1); gPad->SetGrid(); h_pressure_t->SetLineColor(4); h_pressure_t->SetMarkerColor(4); h_pressure_t->SetMarkerStyle(24); h_pressure_t->Draw("HIST P"); c_evts_he_t->cd(2); gPad->SetGrid(); h_evts_t->SetLineColor(2); h_evts_t->SetMarkerColor(2); h_evts_t->SetMarkerStyle(24); h_evts_t->Draw("HIST P"); c_evts_he_t->cd(3); gPad->SetGrid(); h_evts_he_t->SetLineColor(2); h_evts_he_t->SetMarkerColor(2); h_evts_he_t->SetMarkerStyle(24); h_evts_he_t->Draw("HIST P"); c_evts_he_t->cd(4); gPad->SetGrid(); h_neutrons_t->SetLineColor(6); h_neutrons_t->SetMarkerColor(6); h_neutrons_t->SetMarkerStyle(24); h_neutrons_t->Draw("HIST P"); }