BOSS 7.1.0
BESIII Offline Software System
Loading...
Searching...
No Matches
CheckRung/check/dEdxVsCosNP.cxx
Go to the documentation of this file.
1//This code can display dE/dx from two or more files vs costheta on one pad
2
3#include <vector>
4#include <string>
5#include "TStyle.h"
6#include "TString.h"
7
8using namespace std;
9
10vector<string>file;
11void pushNo()
12{
13 file.push_back("costheta.root");
14 file.push_back("costheta.root");
15}
16
17const int no = 5; //The number of graphs you want to draw
18const int nbins = 80; //The number of cos(theta) bins
19const double cosMin = -1.0; //histogram range for cos(theta)
20const double cosMax = 1.0;
21const double chiMin = -30; //histogram range for chi mean
22const double chiMax = 30;
23const double chiSigmaMin = 0.5; //histogram range for chi sigma
24const double chiSigmaMax = 6.5;
25//const double fitMeanMin = 530;
26//const double fitMeanMax = 585;
27const double fitMeanMin = 30;
28const double fitMeanMax = 2585;
29const double fitSigmaMin = 20;
30const double fitSigmaMax = 50;
31const double slopeMin = 0.8;
32const double slopeMax = 1.2;
33
35{
36 pushNo();
37 const int FileNo = file.size();
38 string branchheader[FileNo] = {"pos_","neg_"};
39 string str_names[FileNo] = {"positron","electron"};
40 TH2F** h = new TH2F*[no];
41 TCanvas** c = new TCanvas*[no];
42 TLegend** lgd = new TLegend*[no];
43 TGraphErrors*** gr = new TGraphErrors[no][FileNo];
44 for(int i =0;i<no;i++) gr[i] = new TGraphErrors*[FileNo];
45 gStyle->SetOptStat(0);
46 gStyle->SetCanvasColor(10);
47
48 TFile* f;
49 TTree* tree;
50
51 double chimean[FileNo][nbins],chimeanerr[FileNo][nbins],chisigma[FileNo][nbins];
52 double fitmean[FileNo][nbins],fitmeanerr[FileNo][nbins],fitsigma[FileNo][nbins];
53 double cosBin[FileNo][nbins], slope[FileNo][nbins];
54
55 stringstream ss;
56 stringstream branch;
57 for(int i=0;i<FileNo;i++)
58 {
59 ss.str("");
60 ss<<file[i];
61 f = new TFile(ss.str().c_str());
62 tree = (TTree*) f->Get("costhetacalib");
63 branch.str("");
64 branch<<branchheader[i]<<"chimean";
65 tree -> SetBranchAddress(branch.str().c_str(),chimean[i]);
66 branch.str("");
67 branch<<branchheader[i]<<"chimeanerr";
68 tree -> SetBranchAddress(branch.str().c_str(),chimeanerr[i]);
69 branch.str("");
70 branch<<branchheader[i]<<"chisigma";
71 tree -> SetBranchAddress(branch.str().c_str(),chisigma[i]);
72 branch.str("");
73 branch<<branchheader[i]<<"fitmean";
74 tree -> SetBranchAddress(branch.str().c_str(),fitmean[i]);
75 branch.str("");
76 branch<<branchheader[i]<<"fitmeanerr";
77 tree -> SetBranchAddress(branch.str().c_str(),fitmeanerr[i]);
78 branch.str("");
79 branch<<branchheader[i]<<"fitsigma";
80 tree -> SetBranchAddress(branch.str().c_str(),fitsigma[i]);
81 branch.str("");
82 branch<<"cosBin";
83 tree -> SetBranchAddress(branch.str().c_str(),cosBin[i]);
84 tree -> GetEntry(0);
85 }
86
87 //--------------------- chimean ------------------------------//
88 c[0] = new TCanvas("chimean","chimean",800,600);
89 c[0] -> SetGridx();
90 c[0] -> SetGridy();
91 h[0] = new TH2F("chimean","chimean",100,cosMin,cosMax,100,chiMin,chiMax);
92 h[0] -> GetYaxis()->SetTitle("#chi_{mean}");
93 //h[0] -> GetYaxis()->SetTitleOffset(.9);
94 h[0] -> GetXaxis()->SetTitle("cos(#theta)");
95 h[0] -> Draw();
96 lgd[0] = new TLegend(.65, .75, .89, .89);
97 lgd[0]->SetFillColor(10);
98 lgd[0]->SetBorderSize(1);
99
100 for(int i=0;i<FileNo;i++)
101 {
102 gr[0][i] = new TGraphErrors(nbins,cosBin[i],chimean[i],0,chimeanerr[i]);
103 gr[0][i] -> SetMarkerStyle(20+i);
104 gr[0][i] -> SetMarkerColor(i+1);
105 gr[0][i] -> Draw("Psame");
106 lgd[0] -> AddEntry(gr[0][i], str_names[i].c_str() , "p");
107 }
108 lgd[0] -> Draw();
109
110 //--------------------- chisigma -----------------------------//
111 c[1] = new TCanvas("chisigma","chisigma",800,600);
112 c[1] -> SetGridx();
113 c[1] -> SetGridy();
114 h[1] = new TH2F("chisigma","chisigma",100,cosMin,cosMax,100,chiSigmaMin,chiSigmaMax);
115 h[1] -> GetYaxis()->SetTitle("#chi_{#sigma}");
116 //h[1] -> GetYaxis()->SetTitleOffset(.9);
117 h[1] -> GetXaxis()->SetTitle("cos(#theta)");
118 h[1] -> Draw();
119 lgd[1] = new TLegend(.65, .75, .89, .89);
120 lgd[1]->SetFillColor(10);
121 lgd[1]->SetBorderSize(1);
122
123 for(int i=0;i<FileNo;i++)
124 {
125 gr[1][i] = new TGraphErrors(nbins,cosBin[i],chisigma[i],0,0);
126 gr[1][i] -> SetMarkerStyle(20+i);
127 gr[1][i] -> SetMarkerColor(i+1);
128 gr[1][i] -> Draw("Psame");
129 lgd[1] -> AddEntry(gr[1][i], str_names[i].c_str() , "p");
130 }
131 lgd[1] -> Draw();
132
133 //--------------------- fitmean -----------------------------//
134 c[2] = new TCanvas("fitmean","fitmean",800,600);
135 c[2] -> SetGridx();
136 c[2] -> SetGridy();
137 h[2] = new TH2F("fitmean","fitmean",100,cosMin,cosMax,100,fitMeanMin,fitMeanMax);
138 h[2] -> GetYaxis()->SetTitle("fitmean");
139 //h[2] -> GetYaxis()->SetTitleOffset(.9);
140 h[2] -> GetXaxis()->SetTitle("cos(#theta)");
141 h[2] -> Draw();
142 lgd[2] = new TLegend(.65, .75, .89, .89);
143 lgd[2]->SetFillColor(10);
144 lgd[2]->SetBorderSize(1);
145
146 for(int i=0;i<FileNo;i++){
147 gr[2][i] = new TGraphErrors(nbins,cosBin[i],fitmean[i],0,0);
148 gr[2][i] -> SetMarkerStyle(20+i);
149 gr[2][i] -> SetMarkerColor(i+1);
150 gr[2][i] -> Draw("Psame");
151 lgd[2] -> AddEntry(gr[2][i], str_names[i].c_str() , "p");
152 }
153 lgd[2] -> Draw();
154
155 //--------------------- fitsigma -----------------------------//
156 c[3] = new TCanvas("fitsigma","fitsigma",800,600);
157 c[3] -> SetGridx();
158 c[3] -> SetGridy();
159 h[3] = new TH2F("fitsigma","fitsigma",100,cosMin,cosMax,100,fitSigmaMin,fitSigmaMax);
160 h[3] -> GetYaxis()->SetTitle("fitsigma");
161 //h[3] -> GetYaxis()->SetTitleOffset(.9);
162 h[3] -> GetXaxis()->SetTitle("cos(#theta)");
163 h[3] -> Draw();
164 lgd[3] = new TLegend(.65, .75, .89, .89);
165 lgd[3]->SetFillColor(10);
166 lgd[3]->SetBorderSize(1);
167
168 for(int i=0;i<FileNo;i++)
169 {
170 gr[3][i] = new TGraphErrors(nbins,cosBin[i],fitsigma[i],0,0);
171 gr[3][i] -> SetMarkerStyle(20+i);
172 gr[3][i] -> SetMarkerColor(i+1);
173 gr[3][i] -> Draw("Psame");
174 lgd[3] -> AddEntry(gr[3][i], str_names[i].c_str() , "p");
175 }
176 lgd[3] -> Draw();
177
178 //--------------------- slope -----------------------------//
179 c[4] = new TCanvas("slope","slope",800,600);
180 c[4] -> SetGridx();
181 c[4] -> SetGridy();
182 h[4] = new TH2F("slope","slope",100,cosMin,cosMax,100,slopeMin,slopeMax);
183 h[4] -> GetYaxis()->SetTitle("slope");
184 //h[4] -> GetYaxis()->SetTitleOffset(.9);
185 h[4] -> GetXaxis()->SetTitle("cos(#theta)");
186 h[4] -> Draw();
187 lgd[4] = new TLegend(.65, .75, .89, .89);
188 lgd[4]->SetFillColor(10);
189 lgd[4]->SetBorderSize(1);
190
191
192 for(int j=0; j<FileNo; j++){
193 for(int k=0; k<nbins; k++){
194 if(fitmean[j][k]) slope[j][k] = fitmean[j][k]/fitmean[j][nbins-k-1];
195 else slope[j][k] = 0;
196 }
197 }
198
199 for(int i=0;i<FileNo;i++)
200 {
201 gr[4][i] = new TGraphErrors(nbins/2,cosBin[i],slope[i],0,0);
202 gr[4][i] -> SetMarkerStyle(20+i);
203 gr[4][i] -> SetMarkerColor(i+1);
204 gr[4][i] -> Draw("Psame");
205 lgd[4] -> AddEntry(gr[4][i], str_names[i].c_str() , "p");
206 }
207 lgd[4] -> Draw();
208
209 // output file
210 TFile* g = new TFile("dEdxVsCosNP.root","recreate");
211 for(int i=0;i<no;i++)
212 {
213 c[i]->Write();
214 }
215 g->Close();
216}
void dEdxVsCosNP()
const double chiSigmaMin
const double cosMax
const double cosMin
vector< string > file
const double chiSigmaMax
const int nbins
const double fitMeanMax
const double fitSigmaMin
const double chiMin
const double chiMax
const double slopeMax
const int no
const double fitMeanMin
const double fitSigmaMax
const double slopeMin
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)
data GetEntry(0)
data SetBranchAddress("time",&time)
TGraph * gr
void slope()
Definition: slope.cxx:12