BOSS 7.0.5
BESIII Offline Software System
Loading...
Searching...
No Matches
T0/dEdxVsP.cxx File Reference
#include "TStyle.h"
#include "TString.h"
#include <vector>
#include <string>

Go to the source code of this file.

Functions

void pushNo ()
 
void dEdxVsP ()
 

Variables

vector< string > file
 
vector< string > str_name
 
const int no = 6
 
const int nbins = 50
 
const double pMin = 0.1
 
const double pMax = 2.2
 
const double chiMin = -1
 
const double chiMax = 1
 
const double chiSigmaMin = 0.5
 
const double chiSigmaMax = 1.5
 
const double fitMeanMin = 520
 
const double fitMeanMax = 560
 
const double fitSigmaMin = 25
 
const double fitSigmaMax = 50
 
const double hitsMeanMin = 10
 
const double hitsMeanMax = 30
 
const double hitsSigmaMin = 0
 
const double hitsSigmaMax = 10
 

Function Documentation

◆ dEdxVsP()

void dEdxVsP ( )

Definition at line 39 of file T0/dEdxVsP.cxx.

40{
41 pushNo();
42 const int FileNo = file.size();
43 string branchheader[FileNo] = {"pos_","neg_"};
44 TH2F** h = new TH2F*[no];
45 TCanvas** c = new TCanvas*[no];
46 TLegend** lgd = new TLegend*[no];
47 TGraphErrors*** gr = new TGraphErrors[no][FileNo];
48 for(int i =0;i<no;i++) gr[i] = new TGraphErrors*[FileNo];
49 gStyle->SetOptStat(0);
50 gStyle->SetCanvasColor(10);
51
52 TFile* f;
53 TTree* tree;
54
55 double chimean[FileNo][nbins],chimeanerr[FileNo][nbins],chisigma[FileNo][nbins];
56 double fitmean[FileNo][nbins],fitmeanerr[FileNo][nbins],fitsigma[FileNo][nbins];
57 double hits_mean[FileNo][nbins],hits_sigma[FileNo][nbins];
58 double pBin[FileNo][nbins];
59
60 stringstream ss;
61 stringstream branch;
62 for(int i=0;i<FileNo;i++)
63 {
64 ss.str("");
65 ss<<file[i];
66 f = new TFile(ss.str().c_str());
67 tree = (TTree*) f->Get("momInfor");
68 branch.str("");
69 branch<<branchheader[i]<<"chimean";
70 //cout<<branch.str().c_str()<<endl;
71 tree -> SetBranchAddress(branch.str().c_str(),chimean[i]);
72 branch.str("");
73 //cout<<branch.str().c_str()<<endl;
74 branch<<branchheader[i]<<"chimeanerr";
75 tree -> SetBranchAddress(branch.str().c_str(),chimeanerr[i]);
76 branch.str("");
77 branch<<branchheader[i]<<"chisigma";
78 tree -> SetBranchAddress(branch.str().c_str(),chisigma[i]);
79 branch.str("");
80 branch<<branchheader[i]<<"fitmean";
81 tree -> SetBranchAddress(branch.str().c_str(),fitmean[i]);
82 branch.str("");
83 branch<<branchheader[i]<<"fitmeanerr";
84 tree -> SetBranchAddress(branch.str().c_str(),fitmeanerr[i]);
85 branch.str("");
86 branch<<branchheader[i]<<"fitsigma";
87 tree -> SetBranchAddress(branch.str().c_str(),fitsigma[i]);
88 branch.str("");
89 branch<<"hits_mean";
90 tree -> SetBranchAddress(branch.str().c_str(),hits_mean[i]);
91 branch.str("");
92 branch<<"hits_sigma";
93 tree -> SetBranchAddress(branch.str().c_str(),hits_sigma[i]);
94 branch.str("");
95 branch<<"pBin";
96 tree -> SetBranchAddress(branch.str().c_str(),pBin[i]);
97 tree -> GetEntry(0);
98 }
99
100 //--------------------- chimean ------------------------------//
101 c[0] = new TCanvas("chimean","chimean",800,600);
102 c[0] -> SetGridx();
103 c[0] -> SetGridy();
104 h[0] = new TH2F("chimean","chimean",100,pMin,pMax,100,chiMin,chiMax);
105 h[0] -> GetYaxis()->SetTitle("#chi_{mean}");
106 //h[0] -> GetYaxis()->SetTitleOffset(.9);
107 h[0] -> GetXaxis()->SetTitle("momentum");
108 h[0] -> Draw();
109 lgd[0] = new TLegend(.65, .75, .89, .89);
110 lgd[0]->SetFillColor(10);
111 lgd[0]->SetBorderSize(1);
112
113 for(int i=0;i<FileNo;i++)
114 {
115 gr[0][i] = new TGraphErrors(nbins,pBin[i],chimean[i],0,chimeanerr[i]);
116 gr[0][i] -> SetMarkerStyle(20+i);
117 gr[0][i] -> SetMarkerColor(i+1);
118 gr[0][i] -> Draw("Psame");
119 lgd[0] -> AddEntry(gr[0][i], str_name[i].c_str() , "p");
120 }
121 lgd[0] -> Draw();
122
123 //--------------------- chisigma -----------------------------//
124 c[1] = new TCanvas("chisigma","chisigma",800,600);
125 c[1] -> SetGridx();
126 c[1] -> SetGridy();
127 h[1] = new TH2F("chisigma","chisigma",100,pMin,pMax,100,chiSigmaMin,chiSigmaMax);
128 h[1] -> GetYaxis()->SetTitle("#chi_{#sigma}");
129 //h[1] -> GetYaxis()->SetTitleOffset(.9);
130 h[1] -> GetXaxis()->SetTitle("momentum");
131 h[1] -> Draw();
132 lgd[1] = new TLegend(.65, .75, .89, .89);
133 lgd[1]->SetFillColor(10);
134 lgd[1]->SetBorderSize(1);
135
136 for(int i=0;i<FileNo;i++)
137 {
138 gr[1][i] = new TGraphErrors(nbins,pBin[i],chisigma[i],0,0);
139 gr[1][i] -> SetMarkerStyle(20+i);
140 gr[1][i] -> SetMarkerColor(i+1);
141 gr[1][i] -> Draw("Psame");
142 lgd[1] -> AddEntry(gr[1][i], str_name[i].c_str() , "p");
143 }
144 lgd[1] -> Draw();
145
146 //--------------------- fitmean -----------------------------//
147 c[2] = new TCanvas("fitmean","fitmean",800,600);
148 c[2] -> SetGridx();
149 c[2] -> SetGridy();
150 h[2] = new TH2F("fitmean","fitmean",100,pMin,pMax,100,fitMeanMin,fitMeanMax);
151 h[2] -> GetYaxis()->SetTitle("fitmean");
152 //h[2] -> GetYaxis()->SetTitleOffset(.9);
153 h[2] -> GetXaxis()->SetTitle("momentum");
154 h[2] -> Draw();
155 lgd[2] = new TLegend(.65, .75, .89, .89);
156 lgd[2]->SetFillColor(10);
157 lgd[2]->SetBorderSize(1);
158
159 for(int i=0;i<FileNo;i++)
160 {
161 gr[2][i] = new TGraphErrors(nbins,pBin[i],fitmean[i],0,0);
162 gr[2][i] -> SetMarkerStyle(20+i);
163 gr[2][i] -> SetMarkerColor(i+1);
164 gr[2][i] -> Draw("Psame");
165 lgd[2] -> AddEntry(gr[2][i], str_name[i].c_str() , "p");
166 }
167 lgd[2] -> Draw();
168
169 //--------------------- fitsigma -----------------------------//
170 c[3] = new TCanvas("fitsigma","fitsigma",800,600);
171 c[3] -> SetGridx();
172 c[3] -> SetGridy();
173 h[3] = new TH2F("fitsigma","fitsigma",100,pMin,pMax,100,fitSigmaMin,fitSigmaMax);
174 h[3] -> GetYaxis()->SetTitle("fitsigma");
175 //h[3] -> GetYaxis()->SetTitleOffset(.9);
176 h[3] -> GetXaxis()->SetTitle("momentum");
177 h[3] -> Draw();
178 lgd[3] = new TLegend(.65, .75, .89, .89);
179 lgd[3]->SetFillColor(10);
180 lgd[3]->SetBorderSize(1);
181
182 for(int i=0;i<FileNo;i++)
183 {
184 gr[3][i] = new TGraphErrors(nbins,pBin[i],fitsigma[i],0,0);
185 gr[3][i] -> SetMarkerStyle(20+i);
186 gr[3][i] -> SetMarkerColor(i+1);
187 gr[3][i] -> Draw("Psame");
188 lgd[3] -> AddEntry(gr[3][i], str_name[i].c_str() , "p");
189 }
190 lgd[3] -> Draw();
191
192 //---------------------used hits for dE/dx calculation -----------------------------//
193 c[4] = new TCanvas("hits_mean","hits_mean",800,600);
194 c[4] -> SetGridx();
195 c[4] -> SetGridy();
196 h[4] = new TH2F("hits_mean","hits_mean",100,pMin,pMax,100,hitsMeanMin,hitsMeanMax);
197 h[4] -> GetYaxis()->SetTitle("hits_mean");
198 //h[4] -> GetYaxis()->SetTitleOffset(.9);
199 h[4] -> GetXaxis()->SetTitle("momentum");
200 h[4] -> Draw();
201 lgd[4] = new TLegend(.65, .75, .89, .89);
202 lgd[4]->SetFillColor(10);
203 lgd[4]->SetBorderSize(1);
204
205 for(int i=0;i<FileNo;i++)
206 {
207 gr[4][i] = new TGraphErrors(nbins,pBin[i],hits_mean[i],0,0);
208 gr[4][i] -> SetMarkerStyle(20+i);
209 gr[4][i] -> SetMarkerColor(i+1);
210 gr[4][i] -> Draw("Psame");
211 lgd[4] -> AddEntry(gr[4][i], str_name[i].c_str() , "p");
212 }
213 lgd[4] -> Draw();
214
215 //---------------------sigma of used hits for dE/dx calculation -------------------------//
216 c[5] = new TCanvas("hits_sigma","hits_sigma",800,600);
217 c[5] -> SetGridx();
218 c[5] -> SetGridy();
219 h[5] = new TH2F("hits_sigma","hits_sigma",100,pMin,pMax,100,hitsSigmaMin,hitsSigmaMax);
220 h[5] -> GetYaxis()->SetTitle("hits_sigma");
221 //h[5] -> GetYaxis()->SetTitleOffset(.9);
222 h[5] -> GetXaxis()->SetTitle("momentum");
223 h[5] -> Draw();
224 lgd[5] = new TLegend(.65, .75, .89, .89);
225 lgd[5]->SetFillColor(10);
226 lgd[5]->SetBorderSize(1);
227
228 for(int i=0;i<FileNo;i++)
229 {
230 gr[5][i] = new TGraphErrors(nbins,pBin[i],hits_sigma[i],0,0);
231 gr[5][i] -> SetMarkerStyle(20+i);
232 gr[5][i] -> SetMarkerColor(i+1);
233 gr[5][i] -> Draw("Psame");
234 lgd[5] -> AddEntry(gr[5][i], str_name[i].c_str() , "p");
235 }
236 lgd[5] -> Draw();
237
238 TFile* g = new TFile("dEdxVsP_show.root","recreate");
239 for(int i=0;i<no;i++)
240 {
241 c[i]->Write();
242 }
243 g->Close();
244}
data GetEntry(0)
data SetBranchAddress("time",&time)
TGraph * gr
const double hitsMeanMin
Definition: T0/dEdxVsP.cxx:34
const double chiSigmaMin
Definition: T0/dEdxVsP.cxx:28
const double hitsSigmaMax
Definition: T0/dEdxVsP.cxx:37
vector< string > file
Definition: T0/dEdxVsP.cxx:10
const double hitsMeanMax
Definition: T0/dEdxVsP.cxx:35
const double chiSigmaMax
Definition: T0/dEdxVsP.cxx:29
const int nbins
Definition: T0/dEdxVsP.cxx:23
const double fitMeanMax
Definition: T0/dEdxVsP.cxx:31
const double hitsSigmaMin
Definition: T0/dEdxVsP.cxx:36
void pushNo()
Definition: T0/dEdxVsP.cxx:12
const double fitSigmaMin
Definition: T0/dEdxVsP.cxx:32
const double chiMin
Definition: T0/dEdxVsP.cxx:26
const double chiMax
Definition: T0/dEdxVsP.cxx:27
const int no
Definition: T0/dEdxVsP.cxx:22
const double fitMeanMin
Definition: T0/dEdxVsP.cxx:30
const double pMin
Definition: T0/dEdxVsP.cxx:24
const double fitSigmaMax
Definition: T0/dEdxVsP.cxx:33
vector< string > str_name
Definition: T0/dEdxVsP.cxx:11
const double pMax
Definition: T0/dEdxVsP.cxx:25
legend Draw()
mg GetYaxis() -> SetRangeUser(0.8, 1.02)
mg GetXaxis() -> SetRangeUser(0.5, 1.9)
gr1 SetMarkerStyle(8)
legend AddEntry(gr3,"e+ Data oldPat","p")
TFile f("ana_bhabha660a_dqa_mcPat_zy_old.root")
gr1 SetMarkerColor(1)
char * c_str(Index i)
Definition: EvtCyclic3.cc:252

◆ pushNo()

void pushNo ( )

Definition at line 12 of file T0/dEdxVsP.cxx.

13{
14 file.push_back("dEdxVsP.root");
15 file.push_back("dEdxVsP.root");
16 str_name.push_back("positron");
17 str_name.push_back("electron");
18}

Referenced by dEdxVsP().

Variable Documentation

◆ chiMax

const double chiMax = 1

Definition at line 27 of file T0/dEdxVsP.cxx.

Referenced by dEdxVsP().

◆ chiMin

const double chiMin = -1

Definition at line 26 of file T0/dEdxVsP.cxx.

Referenced by dEdxVsP().

◆ chiSigmaMax

const double chiSigmaMax = 1.5

Definition at line 29 of file T0/dEdxVsP.cxx.

Referenced by dEdxVsP().

◆ chiSigmaMin

const double chiSigmaMin = 0.5

Definition at line 28 of file T0/dEdxVsP.cxx.

Referenced by dEdxVsP().

◆ file

vector<string> file

Definition at line 10 of file T0/dEdxVsP.cxx.

Referenced by dEdxVsP(), and pushNo().

◆ fitMeanMax

const double fitMeanMax = 560

Definition at line 31 of file T0/dEdxVsP.cxx.

Referenced by dEdxVsP().

◆ fitMeanMin

const double fitMeanMin = 520

Definition at line 30 of file T0/dEdxVsP.cxx.

Referenced by dEdxVsP().

◆ fitSigmaMax

const double fitSigmaMax = 50

Definition at line 33 of file T0/dEdxVsP.cxx.

Referenced by dEdxVsP().

◆ fitSigmaMin

const double fitSigmaMin = 25

Definition at line 32 of file T0/dEdxVsP.cxx.

Referenced by dEdxVsP().

◆ hitsMeanMax

const double hitsMeanMax = 30

Definition at line 35 of file T0/dEdxVsP.cxx.

Referenced by dEdxVsP().

◆ hitsMeanMin

const double hitsMeanMin = 10

Definition at line 34 of file T0/dEdxVsP.cxx.

Referenced by dEdxVsP().

◆ hitsSigmaMax

const double hitsSigmaMax = 10

Definition at line 37 of file T0/dEdxVsP.cxx.

Referenced by dEdxVsP().

◆ hitsSigmaMin

const double hitsSigmaMin = 0

Definition at line 36 of file T0/dEdxVsP.cxx.

Referenced by dEdxVsP().

◆ nbins

const int nbins = 50

Definition at line 23 of file T0/dEdxVsP.cxx.

Referenced by dEdxVsP().

◆ no

const int no = 6

Definition at line 22 of file T0/dEdxVsP.cxx.

Referenced by dEdxVsP().

◆ pMax

const double pMax = 2.2

Definition at line 25 of file T0/dEdxVsP.cxx.

Referenced by dEdxVsP().

◆ pMin

const double pMin = 0.1

Definition at line 24 of file T0/dEdxVsP.cxx.

Referenced by dEdxVsP().

◆ str_name

vector<string> str_name

Definition at line 11 of file T0/dEdxVsP.cxx.

Referenced by dEdxVsP(), and pushNo().