BOSS 7.0.9
BESIII Offline Software System
Loading...
Searching...
No Matches
CosthetaSec/dEdxVsCos.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("check/costheta.root");
15}
16
17const int no = 4; //The number of graphs you want to draw
18const int nbins = 80; //The number of cos(theta) bins
19const double cosMin = -0.93; //histogram range for cos(theta)
20const double cosMax = 0.93;
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;
25const double fitMeanMin = 400;
26const double fitMeanMax = 700;
27const double fitSigmaMin = 20;
28const double fitSigmaMax = 50;
29
31{
32 pushNo();
33 const int FileNo = file.size();
34 string branchheader[FileNo] = {"pos_","neg_"};
35 TH2F** h = new TH2F*[no];
36 TCanvas** c = new TCanvas*[no];
37 TLegend** lgd = new TLegend*[no];
38 TGraphErrors*** gr = new TGraphErrors[no][FileNo];
39 for(int i =0;i<no;i++) gr[i] = new TGraphErrors*[FileNo];
40 gStyle->SetOptStat(0);
41 gStyle->SetCanvasColor(10);
42
43 TFile* f;
44 TTree* tree;
45
46 double chimean[FileNo][nbins],chimeanerr[FileNo][nbins],chisigma[FileNo][nbins];
47 double fitmean[FileNo][nbins],fitmeanerr[FileNo][nbins],fitsigma[FileNo][nbins];
48 double cosBin[FileNo][nbins];
49
50 stringstream ss;
51 stringstream branch;
52 for(int i=0;i<FileNo;i++)
53 {
54 ss.str("");
55 ss<<file[i];
56 f = new TFile(ss.str().c_str());
57 tree = (TTree*) f->Get("costhetacalib");
58 branch.str("");
59 branch<<branchheader[i]<<"chimean";
60 tree -> SetBranchAddress(branch.str().c_str(),chimean[i]);
61 branch.str("");
62 branch<<branchheader[i]<<"chimeanerr";
63 tree -> SetBranchAddress(branch.str().c_str(),chimeanerr[i]);
64 branch.str("");
65 branch<<branchheader[i]<<"chisigma";
66 tree -> SetBranchAddress(branch.str().c_str(),chisigma[i]);
67 branch.str("");
68 branch<<branchheader[i]<<"fitmean";
69 tree -> SetBranchAddress(branch.str().c_str(),fitmean[i]);
70 branch.str("");
71 branch<<branchheader[i]<<"fitmeanerr";
72 tree -> SetBranchAddress(branch.str().c_str(),fitmeanerr[i]);
73 branch.str("");
74 branch<<branchheader[i]<<"fitsigma";
75 tree -> SetBranchAddress(branch.str().c_str(),fitsigma[i]);
76 branch.str("");
77 branch<<"cosBin";
78 tree -> SetBranchAddress(branch.str().c_str(),cosBin[i]);
79 tree -> GetEntry(0);
80 }
81
82 //--------------------- chimean ------------------------------//
83 c[0] = new TCanvas("chimean","chimean",800,600);
84 c[0] -> SetGridx();
85 c[0] -> SetGridy();
86 h[0] = new TH2F("chimean","chimean",100,cosMin,cosMax,100,chiMin,chiMax);
87 h[0] -> GetYaxis()->SetTitle("#chi_{mean}");
88 //h[0] -> GetYaxis()->SetTitleOffset(.9);
89 h[0] -> GetXaxis()->SetTitle("cos(#theta)");
90 h[0] -> Draw();
91 lgd[0] = new TLegend(.65, .75, .89, .89);
92 lgd[0]->SetFillColor(10);
93 lgd[0]->SetBorderSize(1);
94
95 for(int i=0;i<FileNo;i++)
96 {
97 gr[0][i] = new TGraphErrors(nbins,cosBin[i],chimean[i],0,chimeanerr[i]);
98 gr[0][i] -> SetMarkerStyle(20+i);
99 gr[0][i] -> SetMarkerColor(i+1);
100 gr[0][i] -> Draw("Psame");
101 lgd[0] -> AddEntry(gr[0][i], file[i].c_str() , "p");
102 }
103 lgd[0] -> Draw();
104
105 //--------------------- chisigma -----------------------------//
106 c[1] = new TCanvas("chisigma","chisigma",800,600);
107 c[1] -> SetGridx();
108 c[1] -> SetGridy();
109 h[1] = new TH2F("chisigma","chisigma",100,cosMin,cosMax,100,chiSigmaMin,chiSigmaMax);
110 h[1] -> GetYaxis()->SetTitle("#chi_{#sigma}");
111 //h[1] -> GetYaxis()->SetTitleOffset(.9);
112 h[1] -> GetXaxis()->SetTitle("cos(#theta)");
113 h[1] -> Draw();
114 lgd[1] = new TLegend(.65, .75, .89, .89);
115 lgd[1]->SetFillColor(10);
116 lgd[1]->SetBorderSize(1);
117
118 for(int i=0;i<FileNo;i++)
119 {
120 gr[1][i] = new TGraphErrors(nbins,cosBin[i],chisigma[i],0,0);
121 gr[1][i] -> SetMarkerStyle(20+i);
122 gr[1][i] -> SetMarkerColor(i+1);
123 gr[1][i] -> Draw("Psame");
124 lgd[1] -> AddEntry(gr[1][i], file[i].c_str() , "p");
125 }
126 lgd[1] -> Draw();
127
128 //--------------------- fitmean -----------------------------//
129 c[2] = new TCanvas("fitmean","fitmean",800,600);
130 c[2] -> SetGridx();
131 c[2] -> SetGridy();
132 h[2] = new TH2F("fitmean","fitmean",100,cosMin,cosMax,100,fitMeanMin,fitMeanMax);
133 h[2] -> GetYaxis()->SetTitle("fitmean");
134 //h[2] -> GetYaxis()->SetTitleOffset(.9);
135 h[2] -> GetXaxis()->SetTitle("cos(#theta)");
136 h[2] -> Draw();
137 lgd[2] = new TLegend(.65, .75, .89, .89);
138 lgd[2]->SetFillColor(10);
139 lgd[2]->SetBorderSize(1);
140
141 for(int i=0;i<FileNo;i++)
142 {
143 gr[2][i] = new TGraphErrors(nbins,cosBin[i],fitmean[i],0,0);
144 gr[2][i] -> SetMarkerStyle(20+i);
145 gr[2][i] -> SetMarkerColor(i+1);
146 gr[2][i] -> Draw("Psame");
147 lgd[2] -> AddEntry(gr[2][i], file[i].c_str() , "p");
148 }
149 lgd[2] -> Draw();
150
151 //--------------------- fitsigma -----------------------------//
152 c[3] = new TCanvas("fitsigma","fitsigma",800,600);
153 c[3] -> SetGridx();
154 c[3] -> SetGridy();
155 h[3] = new TH2F("fitsigma","fitsigma",100,cosMin,cosMax,100,fitSigmaMin,fitSigmaMax);
156 h[3] -> GetYaxis()->SetTitle("fitsigma");
157 //h[3] -> GetYaxis()->SetTitleOffset(.9);
158 h[3] -> GetXaxis()->SetTitle("cos(#theta)");
159 h[3] -> Draw();
160 lgd[3] = new TLegend(.65, .75, .89, .89);
161 lgd[3]->SetFillColor(10);
162 lgd[3]->SetBorderSize(1);
163
164 for(int i=0;i<FileNo;i++)
165 {
166 gr[3][i] = new TGraphErrors(nbins,cosBin[i],fitsigma[i],0,0);
167 gr[3][i] -> SetMarkerStyle(20+i);
168 gr[3][i] -> SetMarkerColor(i+1);
169 gr[3][i] -> Draw("Psame");
170 lgd[3] -> AddEntry(gr[3][i], file[i].c_str() , "p");
171 }
172 lgd[3] -> Draw();
173
174 TFile* g = new TFile("dEdxVsCostheta.root","recreate");
175 for(int i=0;i<no;i++)
176 {
177 c[i]->Write();
178 }
179 g->Close();
180}
const double chiSigmaMin
const double cosMax
const double cosMin
vector< string > file
const double chiSigmaMax
const int nbins
const double fitMeanMax
void pushNo()
const double fitSigmaMin
const double chiMin
void dEdxVsCos()
const double chiMax
const int no
const double fitMeanMin
const double fitSigmaMax
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