-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOverlay.C
265 lines (221 loc) · 5.63 KB
/
Overlay.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
//This will overlay E2 vs E1 profile plots obtained for different runs.
#include<iostream>
#include<string>
#include<vector>
#include<fstream>
#include"TH1.h"
#include"TROOT.h"
#include"TH2.h"
#include"TFile.h"
#include"TDirectory.h"
#include"TTree.h"
#include"TBrowser.h"
#include"TF1.h"
#include<iomanip>
#include"TGraphErrors.h"
#include"TGraph.h"
#include"TCanvas.h"
#include"TPaveStats.h"
using namespace std;
int nietaHF=26,niphiHF=36;
const int nfiles=3;
TFile *f[nfiles];
TCanvas *c_ieta[8];
int canvasIdx=0,padIdx=0;
float p_x1,p_y1,p_x2,p_y2,p=0.15;
//void movestat(TPavestats*);
void Overlay(const char* iDirName){
int pad=0;
TFile *f[nfiles];
char name[100];
/* f[0]=new TFile("fit_251244_E2E1Hists.root");
f[1]=new TFile("fit_251251_E2E1Hists.root");
f[2]=new TFile("fit_251252_E2E1Hists.root");
f[4]=new TFile("fit_251562_E2E1Hists.root");
f[3]=new TFile("fit_251561_E2E1Hists.root");*/
/*
f[0]=new TFile("fit_254833_E2E1Hists.root");
f[1]=new TFile("fit_251721_E2E1Hists.root");
f[2]=new TFile("fit_251883_E2E1Hists.root");
f[3]=new TFile("fit_251643_E2E1Hists.root");*/
f[0]=new TFile("fit_254833_E2E1HistsVtx.root");
f[1]=new TFile("fit_2015B_E2E1HistsVtx.root");
f[2]=new TFile("fit_2012D_E2E1HistsVtx.root");
/*f[0]=new TFile("fit_254833_E2E1HistsTrg1.root");
f[1]=new TFile("fit_MC_E2E1HistsTrg_1000to1400.root");
f[2]=new TFile("fit_2012D_E2E1HistsVtx.root");*/
for(int i=0;i<8;i++){
sprintf(name,"IetaSet_%i",i);
c_ieta[i]= new TCanvas(name,name,1500,500);
c_ieta[i]->Divide(4,1);
}
TFile *fout = new TFile("Overlayed.root","RECREATE");
TObjArray Hlist(0);
for(int i=0;i<nfiles;i++){
TDirectory *dir1 = (TDirectory*) f[i]->FindObjectAny(iDirName);
for(int j=0;j<nietaHF/2;j++){
sprintf(name,"Graph;%d",j+1);
dir1->cd();
TGraphErrors *g1=(TGraphErrors*)dir1->FindObjectAny(name);
TPaveStats *st1 = (TPaveStats*)g1->FindObject("stats");
if(st1){
st1->SetTextSize(0.03);
st1->SetLineColor(g1->GetLineColor());
st1->SetTextColor(g1->GetLineColor());
if(i==0){
st1->SetX1NDC(0.15);
st1->SetX2NDC(0.4);
st1->SetY1NDC(0.9);
st1->SetY2NDC(0.8);
}
if(i==1){
st1->SetX1NDC(0.4);
st1->SetX2NDC(0.65);
st1->SetY1NDC(0.9);
st1->SetY2NDC(0.8);
}
if(i==2){
st1->SetX1NDC(0.15);
st1->SetX2NDC(0.4);
st1->SetY1NDC(0.7);
st1->SetY2NDC(0.8);
}
if(i==3){
st1->SetX1NDC(0.65);
st1->SetX2NDC(0.9);
st1->SetY1NDC(0.4);
st1->SetY2NDC(0.5);
}
if(i==4){
st1->SetX1NDC(0.65);
st1->SetX2NDC(0.9);
st1->SetY1NDC(0.3);
st1->SetY2NDC(0.4);
}
}
// movestat(st1);
/* TLegend *legend=new TLegend(0.75,0.8,.98,.9);
sprintf(name,"Data%i",i);
legend->AddEntry(g1,f[i]->GetName(),"L");
legend->SetTextSize(0.04);
legend->Draw();*/
if(j!=((nietaHF/2)-1)){
canvasIdx=(j/4);
padIdx=(j%4);
c_ieta[canvasIdx]->cd(1+padIdx);
// cout<<"j:"<<j<<" canvasIdx:"<<canvasIdx<<" padIdx:"<<padIdx<<endl;
}
else{
c_ieta[7]->cd(1);
}
if(i==0){
g1->Draw("AP");
}
else{
g1->Draw("sames");
}
}
for(int j=(nietaHF/2);j<nietaHF;j++){
sprintf(name,"Graph;%d",j+1);
dir1->cd();
TGraphErrors *g1=(TGraphErrors*)dir1->FindObjectAny(name);
TPaveStats *st2 = (TPaveStats*)g1->FindObject("stats");
if(st2){
st2->SetTextSize(0.03);
st2->SetLineColor(g1->GetLineColor());
st2->SetTextColor(g1->GetLineColor());
if(i==0){
st2->SetX1NDC(0.15);
st2->SetX2NDC(0.4);
st2->SetY1NDC(0.9);
st2->SetY2NDC(0.8);
}
if(i==1){
st2->SetX1NDC(0.4);
st2->SetX2NDC(0.65);
st2->SetY1NDC(0.9);
st2->SetY2NDC(0.8);
}
if(i==2){
st2->SetX1NDC(0.15);
st2->SetX2NDC(0.4);
st2->SetY1NDC(0.7);
st2->SetY2NDC(0.8);
}
if(i==3){
st2->SetX1NDC(0.65);
st2->SetX2NDC(0.9);
st2->SetY1NDC(0.4);
st2->SetY2NDC(0.5);
}
if(i==4){
st2->SetX1NDC(0.65);
st2->SetX2NDC(0.9);
st2->SetY1NDC(0.3);
st2->SetY2NDC(0.4);
}
}
/* TLegend *legend=new TLegend(0.75,0.8,.98,.9);
sprintf(name,"Data%i",i);
legend->AddEntry(g1,f[i]->GetName(),"L");
legend->SetTextSize(0.05);
legend->Draw();*/
if(j!=nietaHF-1){
canvasIdx=((j-1)/4)+1;
padIdx=((j-1)%4)+1;
c_ieta[canvasIdx]->cd(padIdx);
//cout<<"j:"<<j<<" canvasIdx:"<<canvasIdx<<" padIdx:"<<padIdx<<endl;
}
else{
c_ieta[7]->cd(2);
}
if(i==0){
g1->Draw("AP");
}
else{
g1->Draw("sames");
}
}
}
}
/*void movestat(TPavestat *st1){
st1->SetX1NDC(0.7);
st1->SetX2NDC(0.95);
st1->SetY1NDC(p-.15);
st1->SetY2NDC(p);
}*/
/*
void Overlay(const char* iDirName){
vector<char*> ipfname;
//------------------------------------
string line;
ifstream myfile ("OverlayHistFiles.txt");
if (myfile.is_open())
{
while ( getline (myfile,line) )
{
ipfname.push_back(line);
}
myfile.close();
}
else cout << "Unable to open file"<<endl;
//-----------------------------------
TObjArray Hlist(0);
TFile *fout = new TFile("Overlayed.root","RECREATE");
for(int i=0;i<ipfname.size();i++){
cout<<"-------"<<ipfname[i]<<"---------";
const char* fname=&(ipfname[i]);
TFile *f=new TFile(fname);
TDirectory *dir1 = (TDirectory*) f->FindObjectAny(iDirName);
for(int j=0;j<nietaHF;j++){
char name[100];
sprintf(name,"Graph;%d",i+1);
dir1->cd();
TGraphErrors *g1=(TGraphErrors*)dir1->FindObjectAny(name);
Hlist.Add(g1);
}
}//loop over all files
fout->cd();
Hlist.Write();
}
*/