BOSS 7.1.0
BESIII Offline Software System
Loading...
Searching...
No Matches
draw_charge_space_coarse_II.cxx
Go to the documentation of this file.
1#include <fstream>
2TString rootfilelist("rootfile_list.txt");
3bool m_debug = false;
4const double m_err_standard = 0.005;
5const double m_diff_standard = 0.02;
6int m_num_in_bin = 100;
7int m_num_hists = 0;
8double x[1000], xerr[1000], y[1000], yerr[1000];
9
10double f_real_work(){
11 // read input file
12 ifstream input_file(rootfilelist);
13 if(!input_file){
14 cout << "cannot read input file correctly!" << endl;
15 exit();
16 }
17 TString rootfilename("begin");
18 TH1F *hx[1000];
19 TH1F *h[1000];
20 for(int j=0; j<1000; j++){
21 h[j] = new TH1F(Form("h%d",j), "h", 3000, 0, 1000);
22 hx[j] = new TH1F(Form("hx%d",j), "hx", 100000, 0, 100000);
23 }
24
25 while(rootfilename!=""){
26 input_file >> rootfilename;
27 if(m_debug) cout << rootfilename << endl;
28 else if(m_num_hists%50==0){
29 cout << rootfilename << endl;
30 cout << "num of hists " << m_num_hists+1 << endl;
31 }
32 if(rootfilename=="") continue;
33 TFile *f = new TFile(rootfilename);
34 if(!f) continue;
35 TTree *t = f->Get("n103");
36 float runno(0);
37 float dedx(0), costheta(0);
38 t->SetBranchAddress("runNO", &runno);
39 t->SetBranchAddress("dEdx_meas", &dedx);
40 t->SetBranchAddress("costheta", &costheta);
41 for(int i=0; i<t->GetEntries(); i++){
42 t->GetEntry(i);
43 if(i==0) hx[m_num_hists]->Fill(runno);
44 if(fabs(costheta)<0.15) h[m_num_hists]->Fill(dedx);
45 }
46 if(h[m_num_hists]->GetEntries()>m_num_in_bin) m_num_hists ++;
47 delete t;
48 delete f;
49 }
50 double m_ave_err(0);
51 for(int k=0; k<m_num_hists; k++){
52 x[k] = hx[k]->GetMean();
53 xerr[k] = hx[k]->GetRMS();
54 y[k] = h[k]->GetMean();
55 yerr[k] = h[k]->GetMeanError();
56 m_ave_err += yerr[k]/y[k];
57 }
58 m_ave_err = m_ave_err/m_num_hists;
59 return m_ave_err;
60}
61
62
64 double m_error = f_real_work();
65 if(m_error>m_err_standard){
66 m_num_hists = 0;
67 m_num_in_bin = (int)pow(m_error/m_err_standard,2)*m_num_in_bin;
68 cout << "new num of bin: " << m_num_in_bin << endl;
69 m_error = f_real_work();
70 }
71 cout << "average error: " << m_error << endl;
72
73 TGraphErrors *g = new TGraphErrors(m_num_hists, x, y ,xerr, yerr);
74 TCanvas *c1 = new TCanvas("c1", "c1", 10, 10, 800, 642);
75 g->Draw("AP");
76 for(int k=0; k<m_num_hists; k++){
77 if(fabs(y[k+1]-y[k])/y[k]>m_diff_standard){
78 TLine *l = new TLine(x[k+1]-xerr[k+1], y[k+1]-5*(yerr[k+1]), x[k+1]-xerr[k+1], y[k+1]+5*(yerr[k+1]));
79 l->SetLineColor(2);
80 l->Draw();
81 }
82 }
83 c1->SaveAs("figs/charge_space_via_run_coarse_II.eps");
84 c1->SaveAs("figs/charge_space_via_run_coarse_II.root");
85
86}
TFile f("ana_bhabha660a_dqa_mcPat_zy_old.root")
TTree * t
Definition: binning.cxx:23
void draw_charge_space_coarse_II()
TString rootfilelist("rootfile_list.txt")
double y[1000]
double x[1000]
const double m_err_standard
const double m_diff_standard
double xerr[1000]
double yerr[1000]
double f_real_work()
float costheta