BOSS 7.0.6
BESIII Offline Software System
Loading...
Searching...
No Matches
drawmom.cxx
Go to the documentation of this file.
1#include "betagamma.cxx"
2TString str_base = "../hadron_track/";
3TString str_vec[5] = {"electron","muon","pion","kaon","proton"};
4const double mom_max_vec[5] = {1.843, 2.0, 1.5, 1.8, 1.2};
5double bg_max_vec[5];
6const double masses[5] = {0.511e-3, 105.658e-3, 139.570e-3, 493.677e-3, 938.272e-3};
7const double dedx_max_vec[5] = {1000, 1000, 1000, 1500, 7000};
8double bg_matrix[5][2];
9double mom_matrix[5][2];
10const double y_matrix[5][2] = {{1.0,1.0},{2.0,2.0},{3.0,3.0},{4.0,4.0},{5.0,5.0}};
11bool m_debug = false;
12const TCut vec_cut[5]={"","","","","dEdx_meas>500"};
13
14void drawmom(){
15 for(int i=0; i<5; i++) bg_max_vec[i]=mom_max_vec[i]/masses[i];
16 cout << "begin of drawmom()" << endl;
17 TTree *t[5];
18 TFile *f[5];
19 TH1F *h[5];
20 TGraph *g[5];
21 TMultiGraph *mg = new TMultiGraph();
22 TLatex *l[5];
23 TCanvas *c1 = new TCanvas("momentum","momentum",10,10,1200,642);
24 c1->Divide(3,2);
25 // draw momentum histograms
26 for(int i=0; i<5; i++){
27 f[i] = new TFile(str_base + str_vec[i] + "/" + str_vec[i] + ".root");
28 t[i] = (TTree*)f[i]->Get("n103");
29 h[i] = new TH1F(str_vec[i], str_vec[i], (int)((mom_max_vec[i]-0.0)/0.001), 0.0, mom_max_vec[i]);
30 c1->cd(i+1);
31 t[i]->Project(str_vec[i], "ptrk", vec_cut[i], "", 100000);
32 h[i]->Draw();
33 mom_matrix[i][0] = h[i]->GetBinCenter(h[i]->FindFirstBinAbove(6.0));
34 mom_matrix[i][1] = h[i]->GetBinCenter(h[i]->FindLastBinAbove(6.0));
35 bg_matrix[i][0] = bg(i,mom_matrix[i][0]);
36 bg_matrix[i][1] = bg(i,mom_matrix[i][1]);
37 g[i] = new TGraph(2, bg_matrix[i], y_matrix[i]);
38 mg->Add(g[i]);
39 l[i] = new TLatex(bg_matrix[i][1], y_matrix[i][1], str_vec[i]);
40 }
41 c1->SaveAs("figs/mom.eps");
42
43 // draw beta-gamma histograms
44 delete c1;
45 TCanvas *c1 = new TCanvas("#beta#gamma","#beta#gamma",10,10,1200,642);
46 c1->Divide(3,2);
47 for(int i=0; i<5; i++){
48 delete h[i];
49 h[i] = new TH1F(str_vec[i], str_vec[i], (int)((bg_max_vec[i]-0.0)/0.001), 0.0, bg_max_vec[i]);
50 c1->cd(i+1);
51 t[i]->Project(str_vec[i], Form("ptrk/%f",masses[i]), vec_cut[i], "", 100000);
52 if(i) h[i]->Draw();
53 }
54 c1->SaveAs("figs/bg_hists.eps");
55
56 TCanvas *c2 = new TCanvas("betagamma","betagamma",10,10,800,642);
57 c2->SetLogx();
58 mg->Draw("al");
59 mg->GetXaxis()->SetTitle("#beta#gamma range");
60 for(int j=0; j<5; j++) l[j]->Draw();
61 c2->SaveAs("figs/bg.eps");
62 // output information
63 if(m_debug){
64 for(int i=0; i<5; i++){
65 cout << str_vec[i] << " bins " << h[i]->GetNbinsX() << endl;
66 cout << "mom low: " << mom_matrix[i][0] << " high: " << mom_matrix[i][1] << endl;
67 cout << "bg low: " << bg_matrix[i][0] << " high: " << bg_matrix[i][1] << endl;
68 }
69 }
70
71 TCanvas *c3 = new TCanvas("dedx vs momentum","dedx vs momentum",10,10,1200,642);
72 c3->Divide(3,2);
73 for(int i=0; i<5; i++){
74 c3->cd(i+1);
75 if(i==4) t[i]->Draw("dEdx_meas:ptrk", Form("ptrk<%f & dEdx_meas<%f & dEdx_meas>500", mom_max_vec[i], dedx_max_vec[i]), "", 100000);
76 else t[i]->Draw("dEdx_meas:ptrk", Form("ptrk<%f & dEdx_meas<%f", mom_max_vec[i], dedx_max_vec[i]), "", 100000);
77 }
78 c3->SaveAs("figs/dedx_vs_mom.eps");
79
80}
81
82const double input_bg[5][2] = {{421.97,3187.82}, {10.98,115.6}, {0.74,10.98}, {0.64,0.74}, {0.26,0.64}};
84 double output_mom[5][2];
85 for(int i=0; i<5; i++){
86 output_mom[i][0] = rebg(i,input_bg[i][0]);
87 output_mom[i][1] = rebg(i,input_bg[i][1]);
88 cout << str_vec[i] << endl;
89 }
90 for(int j=0; j<5; j++) cout << "low " << output_mom[j][0] << " high " << output_mom[j][1] << " virtual bins for 1MeV width:" << (output_mom[j][1]-output_mom[j][0])/0.001 << endl << endl;
91
92}
TTree * t
Definition: binning.cxx:23
void drawmom()
Definition: drawmom.cxx:14
const double input_bg[5][2]
Definition: drawmom.cxx:82
double bg_matrix[5][2]
Definition: drawmom.cxx:8
double bg_max_vec[5]
Definition: drawmom.cxx:5
const double dedx_max_vec[5]
Definition: drawmom.cxx:7
TString str_vec[5]
Definition: drawmom.cxx:3
TString str_base
Definition: drawmom.cxx:2
bool m_debug
Definition: drawmom.cxx:11
const double y_matrix[5][2]
Definition: drawmom.cxx:10
const double mom_max_vec[5]
Definition: drawmom.cxx:4
double mom_matrix[5][2]
Definition: drawmom.cxx:9
const TCut vec_cut[5]
Definition: drawmom.cxx:12
const double masses[5]
Definition: drawmom.cxx:6
void banch_rebg()
Definition: drawmom.cxx:83
legend Draw()
TFile f("ana_bhabha660a_dqa_mcPat_zy_old.root")
float bg
void rebg(int i, double bg)