BOSS 7.1.1
BESIII Offline Software System
Loading...
Searching...
No Matches
FirstRung/draw_plots.cxx
Go to the documentation of this file.
1/************* draw some plots for validate the dE/dx calibration
2Gain (Bhabha) plots:
3-- gain constant vs. run #
4-- mean dE/dx vs run# (with new constants applied)
5-- gain constant vs. wire #
6-- mean dE/dx vs wire# (with new constants applied)
7-- distribution of new wire gain - old wire gain (to see how stable they are)
8 (one 1-D plot of difference for all wires)
9***************************/
10//==== 20191129 ====
11// add a function to output the number of runs
12//==================
13
14const int run_begin = 59163;
15
16const int run_end = 62823;
17
18const int max_len = 10000;
19bool m_debug = false;
20
22// const TString old_path = "/afs/ihep.ac.cn/bes3/offline/CalibConst/dedx/6.6.3/";
23 const TString old_path = "./";
24 const TString file_name = Form("DedxConst_%d-%d_705.root", run_begin, run_end);
25 const TString str_eps = Form("figs/gain_vs_run_%d-%d.eps", run_begin, run_end);
26 const TString str_eps2 = Form("figs/resol_vs_run_%d-%d.eps", run_begin, run_end);
27 const TString str_eps3 = Form("figs/rel_resol_vs_run_%d-%d.eps", run_begin, run_end);
28
29 gStyle->SetOptStat(0);
30 Double_t x[max_len], y[max_len], yy[max_len], yyy[max_len];
31 // gain constant vs. run
32 TFile o_file(old_path + file_name);
33 TTree *o_tree_run = (TTree*)o_file.Get("runcalib");
34 Int_t o_run, n_run;
35 Double_t o_gain, o_resol, o_wireg, n_mean, n_wireg;
36 o_tree_run->SetBranchAddress("runno", &o_run);
37 o_tree_run->SetBranchAddress("rungain", &o_gain);
38 o_tree_run->SetBranchAddress("runresol", &o_resol);
39 Int_t m_len = o_tree_run->GetEntries();
40 Int_t m_count(0), p_run(-1);
41 for(int i=0; i<m_len; i++){
42 o_tree_run->GetEntry(i);
43 x[i] = o_run;
44 y[i] = o_gain;
45 if(o_run != p_run){
46 p_run = o_run;
47 m_count ++;
48 }
49 if(m_debug) cout << "x " << x[i] << " y " << y[i] << endl;
50 }
51 TGraph *gr = new TGraph(m_len, x, y);
52 gr->SetTitle("gain constant vs. run");
53 TCanvas *c1 = new TCanvas("c1", "c1", 10, 10, 800, 642);
54 gr->Draw("a*");
55 c1->SaveAs(str_eps);
56
57 c1->Clear();
58 for(int i=0; i<m_len; i++){
59 o_tree_run->GetEntry(i);
60 yy[i] = o_resol;
61 if(y[i]) yyy[i] = 100.*(yy[i]/y[i]/550.);
62 if(m_debug) cout << "x " << x[i] << " y " << yy[i] << endl;
63 }
64 gr = new TGraph(m_len, x, yy);
65 gr->SetTitle("resolution vs. run");
66 gr->Draw("a*");
67 c1->SaveAs(str_eps2);
68
69 c1->Clear();
70 gr = new TGraph(m_len, x, yyy);
71 gr->SetTitle("relative resolution vs. run (%)");
72 gr->Draw("a*");
73 c1->SaveAs(str_eps3);
74
75 cout << "There are total " << m_count << " runs (not entries)." << endl;
76}
77
78
79
Double_t x[10]
TGraph * gr
const int run_end
const int run_begin
void draw_plots()
bool m_debug
const int max_len
double y[1000]