-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlotExtractor.C
325 lines (272 loc) · 14.3 KB
/
PlotExtractor.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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
#include <iostream>
#include <TString.h>
#include <math.h>
void scint_pes()
{
std::ifstream rfiles("files.dat");
std::string line;
TFile *file;
TH1D *hst, *tmp;
while(std::getline(rfiles, line)){
file = TFile::Open(line.data());
for(int det=1; det<9; det++){
//PE spectrum of each detector with scintillator cuts (must hit the upstream and at least one downstream scintillator)
tmp = (TH1D*)file->Get(Form("R%i_CathodeEventsDistrHist",det));
hst = (TH1D*)tmp->Clone(Form("R%i_PEs",det));
hst->SetTitle(Form("R%i Photoelectron Distribution",det));
hst->GetXaxis()->SetTitle("Photoelectrons");
hst->GetYaxis()->SetTitle("Events");
hst->GetXaxis()->SetRangeUser(0,100);
hst->SetDirectory(0);
hst->SaveAs(Form("plots/R%i_scintcut_pes.root",det));
//PE spectrum for beams that hit only one quartz tile (ring cut) and passes scintillator cut
tmp = (TH1D*)file->Get(Form("R%iOnly_CathodeEventsDistrHist",det));
hst = (TH1D*)tmp->Clone(Form("R%i_Solo_PEs",det));
hst->SetTitle(Form("R%i Photoelectron Distribution",det));
hst->GetXaxis()->SetTitle("Photoelectrons");
hst->GetYaxis()->SetTitle("Events");
hst->GetXaxis()->SetRangeUser(0,100);
hst->SetDirectory(0);
hst->SaveAs(Form("plots/R%i_ringcut_pes.root",det));
//Distribution of initial beam angles for scintillator cuts
tmp = (TH1D*)file->Get(Form("R%i_InitialBeamAngleHist",det));
hst = (TH1D*)tmp->Clone(Form("R%i_angle",det));
hst->SetTitle(Form("R%i Initial Beam Angle Distribution",det));
hst->GetXaxis()->SetTitle("Angle from Z-axis [deg]");
hst->GetYaxis()->SetTitle("Events");
hst->GetXaxis()->SetRangeUser(0,20);
hst->SetDirectory(0);
hst->SaveAs(Form("plots/R%i_scintcut_angle.root",det));
//Distribution of initial beam angles for ring+scintillator cuts
tmp = (TH1D*)file->Get(Form("R%iOnly_InitialBeamAngleHist",det));
hst = (TH1D*)tmp->Clone(Form("R%iOnly_angle",det));
hst->SetTitle(Form("R%i Initial Beam Angle Distribution",det));
hst->GetXaxis()->SetTitle("Angle from Z-axis [deg]");
hst->GetYaxis()->SetTitle("Events");
hst->GetXaxis()->SetRangeUser(0,20);
hst->SetDirectory(0);
hst->SaveAs(Form("plots/R%i_ringcut_angle.root",det));
}
file->Close("R");
}
}
void gem1_pes()
{
std::ifstream rfiles("files.dat");
std::string line;
TFile *file;
TH1D *hst, *tmp;
while(std::getline(rfiles, line)){
file = TFile::Open(line.data());
for(int det=1; det<9; det++){
tmp = (TH1D*)file->Get(Form("R%i_GEM1_CathodeEventsDistrHist",det));
hst = (TH1D*)tmp->Clone(Form("R%i_PEs",det));
hst->SetTitle(Form("R%i Photoelectron Distribution",det));
hst->GetXaxis()->SetTitle("Photoelectrons");
hst->GetYaxis()->SetTitle("Events");
hst->GetXaxis()->SetRangeUser(0,100);
hst->SetDirectory(0);
hst->SaveAs(Form("plots/R%i_gem1_scintcut_pes.root",det));
tmp = (TH1D*)file->Get(Form("R%iOnly_GEM1_CathodeEventsDistrHist",det));
hst = (TH1D*)tmp->Clone(Form("R%i_Solo_PEs",det));
hst->SetTitle(Form("R%i Photoelectron Distribution",det));
hst->GetXaxis()->SetTitle("Photoelectrons");
hst->GetYaxis()->SetTitle("Events");
hst->GetXaxis()->SetRangeUser(0,100);
hst->SetDirectory(0);
hst->SaveAs(Form("plots/R%i_gem1_ringcut_pes.root",det));
tmp = (TH1D*)file->Get(Form("R%i_GEM1_InitialBeamAngleHist",det));
hst = (TH1D*)tmp->Clone(Form("R%i_angle",det));
hst->SetTitle(Form("R%i Initial Beam Angle Distribution",det));
hst->GetXaxis()->SetTitle("Angle from Z-axis [deg]");
hst->GetYaxis()->SetTitle("Events");
hst->GetXaxis()->SetRangeUser(0,20);
hst->SetDirectory(0);
hst->SaveAs(Form("plots/R%i_gem1_scintcut_angle.root",det));
tmp = (TH1D*)file->Get(Form("R%iOnly_GEM1_InitialBeamAngleHist",det));
hst = (TH1D*)tmp->Clone(Form("R%iOnly_angle",det));
hst->SetTitle(Form("R%i Initial Beam Angle Distribution",det));
hst->GetXaxis()->SetTitle("Angle from Z-axis [deg]");
hst->GetYaxis()->SetTitle("Events");
hst->GetXaxis()->SetRangeUser(0,20);
hst->SetDirectory(0);
hst->SaveAs(Form("plots/R%i_gem1_ringcut_angle.root",det));
}
file->Close("R");
}
}
void gem2_pes()
{
std::ifstream rfiles("files.dat");
std::string line;
TFile *file;
TH1D *hst, *tmp;
while(std::getline(rfiles, line)){
file = TFile::Open(line.data());
for(int det=1; det<9; det++){
tmp = (TH1D*)file->Get(Form("R%i_GEM2_CathodeEventsDistrHist",det));
hst = (TH1D*)tmp->Clone(Form("R%i_PEs",det));
hst->SetTitle(Form("R%i Photoelectron Distribution",det));
hst->GetXaxis()->SetTitle("Photoelectrons");
hst->GetYaxis()->SetTitle("Events");
hst->GetXaxis()->SetRangeUser(0,100);
hst->SetDirectory(0);
hst->SaveAs(Form("plots/R%i_gem2_scintcut_pes.root",det));
tmp = (TH1D*)file->Get(Form("R%iOnly_GEM2_CathodeEventsDistrHist",det));
hst = (TH1D*)tmp->Clone(Form("R%i_Solo_PEs",det));
hst->SetTitle(Form("R%i Photoelectron Distribution",det));
hst->GetXaxis()->SetTitle("Photoelectrons");
hst->GetYaxis()->SetTitle("Events");
hst->GetXaxis()->SetRangeUser(0,100);
hst->SetDirectory(0);
hst->SaveAs(Form("plots/R%i_gem2_ringcut_pes.root",det));
tmp = (TH1D*)file->Get(Form("R%i_GEM2_InitialBeamAngleHist",det));
hst = (TH1D*)tmp->Clone(Form("R%i_angle",det));
hst->SetTitle(Form("R%i Initial Beam Angle Distribution",det));
hst->GetXaxis()->SetTitle("Angle from Z-axis [deg]");
hst->GetYaxis()->SetTitle("Events");
hst->GetXaxis()->SetRangeUser(0,20);
hst->SetDirectory(0);
hst->SaveAs(Form("plots/R%i_gem2_scintcut_angle.root",det));
tmp = (TH1D*)file->Get(Form("R%iOnly_GEM2_InitialBeamAngleHist",det));
hst = (TH1D*)tmp->Clone(Form("R%iOnly_angle",det));
hst->SetTitle(Form("R%i Initial Beam Angle Distribution",det));
hst->GetXaxis()->SetTitle("Angle from Z-axis [deg]");
hst->GetYaxis()->SetTitle("Events");
hst->GetXaxis()->SetRangeUser(0,20);
hst->SetDirectory(0);
hst->SaveAs(Form("plots/R%i_gem2_ringcut_angle.root",det));
}
file->Close("R");
}
}
//This object performs cuts over the quartz in the x-direction. Goal is to see position dependence of PE yield, among other things
void quartz_pos(){
std::ifstream rfiles("files.dat");
std::string line;
TFile *file;
TH1D *hst, *tmp;
int pos, file_open = 0;
while(std::getline(rfiles, line)){
file = TFile::Open(line.data());
file_open++;
for(int det=4; det<5; det++){
pos = -11;
while(pos <= 1){
pos++;
pos++;
TTree *tree = (TTree*)file->Get("MOLLEROptTree");
TCanvas *canvas_pes = new TCanvas("canvas_pes","canvas_pes");
tree->Draw(Form("MOLLEROptData.MOLLERDetectorEvent.R%iSoloPEs",det),Form("(MOLLEROptData.MOLLERDetectorEvent.R%iTileHitY <= %i) && (MOLLEROptData.MOLLERDetectorEvent.R%iTileHitY > %i-2)",det,pos,det,pos));
canvas_pes->SaveAs(Form("plots/r%i/file%i_pes_pos_%i.root",det,file_open,pos));
/*TCanvas *canvas_pos = new TCanvas("canvas_pos","canvas_pos");
tree->Draw(Form("MOLLEROptData.MOLLERDetectorEvent.R%iTileHitY:MOLLEROptData.MOLLERDetectorEvent.R%iTileHitX",det,det),Form("(MOLLEROptData.MOLLERDetectorEvent.R%iTileHitY <= %i) && (MOLLEROptData.MOLLERDetectorEvent.R%iTileHitY > %i-2)",det,pos,det,pos),"colz");
canvas_pos->SaveAs(Form("plots/r%i/file%i_quartz_pos_%i.root",det,file_open,pos));*/
}
}
file->Close("R");
}
}
void scint_hit_tracker(){
std::ifstream rfiles("files.dat");
std::string line;
TFile *file;
TH1D *hst, *tmp;
int pos, file_open = 0;
char ext[] = "MOLLEROptData.MOLLERDetectorEvent.";
while(std::getline(rfiles, line)){
file = TFile::Open(line.data());
file_open++;
TTree *tree = (TTree*)file->Get("MOLLEROptTree");
TCanvas *canvas_scint12 = new TCanvas("canvas_scint12","canvas_scint12");
tree->Draw(Form("%sScint1TrackHit",ext),Form("%sScint2TrackHit == 1",ext));
canvas_scint12->SaveAs("plots/scint12_gems.root");
TCanvas *canvas_scint123 = new TCanvas("canvas_scint123","canvas_scint123");
tree->Draw(Form("%sScint1TrackHit",ext),Form("(%sScint2TrackHit == 1) && (%sScint3TrackHit == 1)",ext,ext));
canvas_scint123->SaveAs("plots/scint123_gems.root");
TCanvas *canvas_scint124 = new TCanvas("canvas_scint124","canvas_scint124");
tree->Draw(Form("%sScint1TrackHit",ext),Form("(%sScint2TrackHit == 1) && (%sScint4TrackHit == 1)",ext,ext));
canvas_scint124->SaveAs("plots/scint124_gems.root");
TCanvas *canvas_scint1234 = new TCanvas("canvas_scint1234","canvas_scint1234");
tree->Draw(Form("%sScint1TrackHit",ext),Form("(%sScint2TrackHit == 1) && (%sScint3TrackHit == 1) && (%sScint4TrackHit == 1)",ext,ext,ext));
canvas_scint1234->SaveAs("plots/scint1234_gems.root");
file->Close("R");
}
}
void scint_angle_tracker(){
std::ifstream rfiles("files.dat");
std::string line;
TFile *file;
TH1D *hst, *tmp;
int pos, file_open = 0;
char ext[] = "MOLLEROptData.MOLLERDetectorEvent.";
while(std::getline(rfiles, line)){
file = TFile::Open(line.data());
file_open++;
TTree *tree = (TTree*)file->Get("MOLLEROptTree");
TCanvas *canvas_scint12_angles = new TCanvas("canvas_scint12_angles","canvas_scint12_angles");
tree->Draw(Form("%sInitialBeamAngle",ext),Form("(%sScint1TrackHit == 1) & (%sScint2TrackHit == 1)",ext,ext));
canvas_scint12_angles->SaveAs("plots/scint12_angles.root");
TCanvas *canvas_scint123_angles = new TCanvas("canvas_scint123_angles","canvas_scint123_angles");
tree->Draw(Form("%sInitialBeamAngle",ext),Form("(%sScint1TrackHit == 1) & (%sScint2TrackHit == 1) & (%sScint3TrackHit == 1)",ext,ext,ext));
canvas_scint123_angles->SaveAs("plots/scint123_angles.root");
TCanvas *canvas_scint124_angles = new TCanvas("canvas_scint124_angles","canvas_scint124_angles");
tree->Draw(Form("%sInitialBeamAngle",ext),Form("(%sScint1TrackHit == 1) & (%sScint2TrackHit == 1) & (%sScint4TrackHit == 1)",ext,ext,ext));
canvas_scint124_angles->SaveAs("plots/scint124_angles.root");
TCanvas *canvas_scint1234_angles = new TCanvas("canvas_scint1234_angles","canvas_scint1234_angles");
tree->Draw(Form("%sInitialBeamAngle",ext),Form("(%sScint1TrackHit == 1) & (%sScint2TrackHit == 1) & (%sScint3TrackHit == 1) & (%sScint4TrackHit == 1) ",ext,ext,ext,ext));
canvas_scint1234_angles->SaveAs("plots/scint1234_angles.root");
file->Close("R");
}
}
void scint_hitpos_tracker(){
std::ifstream rfiles("files.dat");
std::string line;
TFile *file;
TH1D *hst, *tmp;
int pos, file_open = 0;
char ext[] = "MOLLEROptData.MOLLERDetectorEvent.";
while(std::getline(rfiles, line)){
file = TFile::Open(line.data());
file_open++;
TTree *tree = (TTree*)file->Get("MOLLEROptTree");
TCanvas *canvas_scint123 = new TCanvas("canvas_scint123","canvas_scint123");
tree->Draw(Form("%sScint3HitY:%sScint3HitX",ext,ext),Form("(%sScint1TrackHit == 1) & (%sScint2TrackHit == 1)",ext,ext),"colz");
canvas_scint123->SaveAs("plots/scint12_gem1_hitpos.root");
TCanvas *canvas_scint124 = new TCanvas("canvas_scint124","canvas_scint124");
tree->Draw(Form("%sScint4HitY:%sScint4HitX",ext,ext),Form("(%sScint1TrackHit == 1) & (%sScint2TrackHit == 1)",ext,ext),"colz");
canvas_scint124->SaveAs("plots/scint12_gem2_hitpos.root");
TCanvas *canvas_scint1234_gem1 = new TCanvas("canvas_scint1234_gem1","canvas_scint1234_gem1");
tree->Draw(Form("%sScint3HitY:%sScint3HitX",ext,ext),Form("(%sScint1TrackHit == 1) & (%sScint2TrackHit == 1) & (%sScint4TrackHit == 1)",ext,ext,ext),"colz");
canvas_scint1234_gem1->SaveAs("plots/scint1234_gem1_hitpos.root");
TCanvas *canvas_scint1234_gem2 = new TCanvas("canvas_scint1234_gem2","canvas_scint1234_gem2");
tree->Draw(Form("%sScint4HitY:%sScint4HitX",ext,ext),Form("(%sScint1TrackHit == 1) & (%sScint2TrackHit == 1) & (%sScint3TrackHit == 1)",ext,ext,ext),"colz");
canvas_scint1234_gem2->SaveAs("plots/scint1234_gem2_hitpos.root");
file->Close("R");
}
}
void scint_slope_calc(){
std::ifstream rfiles("files.dat");
std::string line;
TFile *file;
TH1D *hst, *tmp;
int pos, file_open = 0;
float pi = TMath::Pi();
char ext[] = "MOLLEROptData.MOLLERDetectorEvent.";
while(std::getline(rfiles, line)){
file = TFile::Open(line.data());
file_open++;
TTree *tree = (TTree*)file->Get("MOLLEROptTree");
// No conditions are used since slopex/y require hits on all scints+gems to store data
TCanvas *canvas_scint1234_slope = new TCanvas("canvas_scint1234_slope","canvas_scint1234_slope");
tree->Draw(Form("%sslopey:%sslopex",ext,ext),"","colz");
canvas_scint1234_slope->SaveAs("plots/scint1234_slope_hitpos.root");
TCanvas *canvas_scint1234_slopex = new TCanvas("canvas_scint1234_slopex","canvas_scint1234_slopex");
tree->Draw(Form("%sslopex",ext),"");
canvas_scint1234_slopex->SaveAs("plots/scint1234_slopex.root");
TCanvas *canvas_scint1234_slopey = new TCanvas("canvas_scint1234_slopey","canvas_scint1234_slopey");
tree->Draw(Form("%sslopey",ext),"");
canvas_scint1234_slopey->SaveAs("plots/scint1234_slopey.root");
file->Close("R");
}
}