forked from gavalian/instarec
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExampleClass1.java
More file actions
613 lines (517 loc) · 21.9 KB
/
ExampleClass1.java
File metadata and controls
613 lines (517 loc) · 21.9 KB
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
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
import j4np.hipo5.data.Bank;
import j4np.hipo5.data.Event;
import j4np.hipo5.io.HipoReader;
import j4np.hipo5.data.Leaf
import java.lang.Math;
import twig.data.TDirectory;
import twig.data.GraphErrors;
import twig.data.H1F;
import twig.graphics.TGCanvas;
public class ExampleClass1 {
public ExampleClass1(){}
public static void main(String[] args) {
// Variable to hold the highest momentum
int pid;
float StartTime;
short maxPRow = -1;
String filePath2 = "w.h5";
H1F htmaster = new H1F("Event Start time from Data", 500, 0, 200);
htmaster.attr().setLineColor(4);
//ht.attr().setFillColor(2);
htmaster.attr().setLineWidth(1);
htmaster.attr().setTitleX("T from data [ns]");
H2F hPaddleTime1 = new H2F("hPaddleTime1", 10, -100, 70, 10, 100, 110);
//hPaddle.attr().setLineColor(4);
//ht.attr().setFillColor(2);
//hPaddle.attr().setLineWidth(1);
hPaddleTime1.attr().setTitleX("Paddle");
hPaddleTime1.attr().setTitleY("Time");
H2F hPaddleTime2 = new H2F("hPaddleTime2", 100, -40000, 40000, 100, 60, 110);
//hPaddle.attr().setLineColor(4);
//ht.attr().setFillColor(2);
//hPaddle.attr().setLineWidth(1);
hPaddleTime2.attr().setTitleX("Paddle");
hPaddleTime2.attr().setTitleY("Time");
H2F hPaddleTime3 = new H2F("hPaddleTime3", 100, -40000, 40000, 100, 60, 110);
//hPaddle.attr().setLineColor(4);
//ht.attr().setFillColor(2);
//hPaddle.attr().setLineWidth(1);
hPaddleTime3.attr().setTitleX("Paddle");
hPaddleTime3.attr().setTitleY("Time");
H2F hPaddleTime4 = new H2F("hPaddleTime4", 100, -40000, 40000, 100, 60, 110);
//hPaddle.attr().setLineColor(4);
//ht.attr().setFillColor(2);
//hPaddle.attr().setLineWidth(1);
hPaddleTime4.attr().setTitleX("Paddle");
hPaddleTime4.attr().setTitleY("Time");
H2F hPaddleTime5 = new H2F("hPaddleTime5", 100, -40000, 40000, 100, 60, 110);
//hPaddle.attr().setLineColor(4);
//ht.attr().setFillColor(2);
//hPaddle.attr().setLineWidth(1);
hPaddleTime5.attr().setTitleX("Paddle");
hPaddleTime5.attr().setTitleY("Time");
H2F hPaddleTime6 = new H2F("hPaddleTime6", 100, -40000, 40000, 100, 60, 110);
//hPaddle.attr().setLineColor(4);
//ht.attr().setFillColor(2);
//hPaddle.attr().setLineWidth(1);
hPaddleTime6.attr().setTitleX("Paddle");
hPaddleTime6.attr().setTitleY("Time");
H2F hMomentumTime1 = new H2F("hMomentumTime1", 500, 0, 10, 500, 60, 110);
//hPaddle.attr().setLineColor(4);
//ht.attr().setFillColor(2);
//hPaddle.attr().setLineWidth(1);
hMomentumTime1.attr().setTitleX("Momentum");
hMomentumTime1.attr().setTitleY("Time");
H2F hMomentumTime2 = new H2F("hMomentumTime2", 500, 0, 10, 500, 60, 110);
//hPaddle.attr().setLineColor(4);
//ht.attr().setFillColor(2);
//hPaddle.attr().setLineWidth(1);
hMomentumTime2.attr().setTitleX("Momentum");
hMomentumTime2.attr().setTitleY("Time");
H2F hMomentumTime3 = new H2F("hMomentumTime3", 500, 0, 10, 500, 60, 110);
//hPaddle.attr().setLineColor(4);
//ht.attr().setFillColor(2);
//hPaddle.attr().setLineWidth(1);
hMomentumTime3.attr().setTitleX("Momentum");
hMomentumTime3.attr().setTitleY("Time");
H2F hMomentumTime4 = new H2F("hMomentumTime4", 500, 0, 10, 500, 60, 110);
//hPaddle.attr().setLineColor(4);
//ht.attr().setFillColor(2);
//hPaddle.attr().setLineWidth(1);
hMomentumTime4.attr().setTitleX("Momentum");
hMomentumTime4.attr().setTitleY("Time");
H2F hMomentumTime5 = new H2F("hMomentumTime5", 500, 0, 10, 500, 60, 110);
//hPaddle.attr().setLineColor(4);
//ht.attr().setFillColor(2);
//hPaddle.attr().setLineWidth(1);
hMomentumTime5.attr().setTitleX("Momentum");
hMomentumTime5.attr().setTitleY("Time");
H2F hMomentumTime6 = new H2F("hMomentumTime6", 500, 0, 10, 500, 60, 110);
//hPaddle.attr().setLineColor(4);
//ht.attr().setFillColor(2);
//hPaddle.attr().setLineWidth(1);
hMomentumTime6.attr().setTitleX("Momentum");
hMomentumTime6.attr().setTitleY("Time");
H1F ht = new H1F("Event Start time (Momentum below 4 GeV)", 250, 80, 110);
ht.attr().setLineColor(2);
//ht.attr().setFillColor(2);
ht.attr().setLineWidth(1);
ht.attr().setTitleX("T from data [ns]");
H1F ht2 = new H1F("Event Start time (Momentum between 4-7 GeV)", 250, 80, 110);
ht2.attr().setLineColor(3);
//ht2.attr().setFillColor(2);
ht2.attr().setLineWidth(1);
ht2.attr().setTitleX("T from data [ns]");
H1F ht3 = new H1F("Event Start time (Momentum above 7 GeV)", 250, 80, 110);
ht3.attr().setLineColor(4);
//ht3.attr().setFillColor(2);
ht3.attr().setLineWidth(1);
ht3.attr().setTitleX("T from data [ns]");
H1F htpredmaster = new H1F("Sector 1", 500, 0, 200);
htpredmaster.attr().setLineColor(2);
//htpred.attr().setFillColor(2);
htpredmaster.attr().setLineWidth(1);
htpredmaster.attr().setTitleX("T pred [ns]");
H1F htpredmaster2 = new H1F("Sector 2", 500, 0, 200);
htpredmaster2.attr().setLineColor(3);
//htpred.attr().setFillColor(2);
htpredmaster2.attr().setLineWidth(1);
htpredmaster2.attr().setTitleX("T pred [ns]");
H1F htpredmaster3 = new H1F("Predicted Event Start time", 500, 0, 200);
htpredmaster3.attr().setLineColor(4);
//htpred.attr().setFillColor(2);
htpredmaster3.attr().setLineWidth(1);
htpredmaster3.attr().setTitleX("T pred [ns]");
H1F htpredmaster4 = new H1F("Predicted Event Start time", 500, 0, 200);
htpredmaster4.attr().setLineColor(5);
//htpred.attr().setFillColor(2);
htpredmaster4.attr().setLineWidth(1);
htpredmaster4.attr().setTitleX("T pred [ns]");
H1F htpredmaster5 = new H1F("Predicted Event Start time", 500, 0, 200);
htpredmaster5.attr().setLineColor(6);
//htpred.attr().setFillColor(2);
htpredmaster5.attr().setLineWidth(1);
htpredmaster5.attr().setTitleX("T pred [ns]");
H1F htpredmaster6 = new H1F("Predicted Event Start time", 500, 0, 200);
htpredmaster6.attr().setLineColor(7);
//htpred.attr().setFillColor(2);
htpredmaster6.attr().setLineWidth(1);
htpredmaster6.attr().setTitleX("T pred [ns]");
H1F ht1pred1 = new H1F("ht1pred", 250, 80, 110);
ht1pred1.attr().setLineColor(2);
//htpred.attr().setFillColor(2);
ht1pred1.attr().setLineWidth(1);
ht1pred1.attr().setTitleX("T pred [ns]");
H1F ht1pred2 = new H1F("ht1pred2", 250, 80, 110);
ht1pred2.attr().setLineColor(8);
//htpred2.attr().setFillColor(2);
ht1pred2.attr().setLineWidth(1);
ht1pred2.attr().setTitleX("T pred [ns]");
H1F ht1pred3 = new H1F("ht1pred3", 250, 80, 110);
ht1pred3.attr().setLineColor(4);
//htpred3.attr().setFillColor(2);
ht1pred3.attr().setLineWidth(1);
ht1pred3.attr().setTitleX("T pred [ns]");
H1F ht2pred1 = new H1F("ht2pred1", 250, 80, 110);
ht2pred1.attr().setLineColor(2);
//htpred3.attr().setFillColor(2);
ht2pred1.attr().setLineWidth(1);
ht2pred1.attr().setTitleX("T pred [ns]");
H1F ht2pred2 = new H1F("ht2pred2", 250, 80, 110);
ht2pred2.attr().setLineColor(8);
//htpred3.attr().setFillColor(2);
ht2pred2.attr().setLineWidth(1);
ht2pred2.attr().setTitleX("T pred [ns]");
H1F ht2pred3 = new H1F("ht2pred3", 250, 80, 110);
ht2pred3.attr().setLineColor(4);
//htpred3.attr().setFillColor(2);
ht2pred3.attr().setLineWidth(1);
ht2pred3.attr().setTitleX("T pred [ns]");
H1F ht3pred1 = new H1F("ht3pred1", 250, 80, 110);
ht3pred1.attr().setLineColor(2);
//htpred3.attr().setFillColor(2);
ht3pred1.attr().setLineWidth(1);
ht3pred1.attr().setTitleX("T pred [ns]");
H1F ht3pred2 = new H1F("ht3pred2", 250, 80, 110);
ht3pred2.attr().setLineColor(8);
//htpred3.attr().setFillColor(2);
ht3pred2.attr().setLineWidth(1);
ht3pred2.attr().setTitleX("T pred [ns]");
H1F ht3pred3 = new H1F("ht3pred3", 250, 80, 110);
ht3pred3.attr().setLineColor(4);
//htpred3.attr().setFillColor(2);
ht3pred3.attr().setLineWidth(1);
ht3pred3.attr().setTitleX("T pred [ns]");
H1F ht4pred1 = new H1F("ht4pred1", 250, 80, 110);
ht4pred1.attr().setLineColor(2);
//htpred3.attr().setFillColor(2);
ht4pred1.attr().setLineWidth(1);
ht4pred1.attr().setTitleX("T pred [ns]");
H1F ht4pred2 = new H1F("ht4pred2", 250, 80, 110);
ht4pred2.attr().setLineColor(8);
//htpred3.attr().setFillColor(2);
ht4pred2.attr().setLineWidth(1);
ht4pred2.attr().setTitleX("T pred [ns]");
H1F ht4pred3 = new H1F("ht4pred3", 250, 80, 110);
ht4pred3.attr().setLineColor(4);
//htpred3.attr().setFillColor(2);
ht4pred3.attr().setLineWidth(1);
ht4pred3.attr().setTitleX("T pred [ns]");
H1F ht5pred1 = new H1F("ht5pred1", 250, 80, 110);
ht5pred1.attr().setLineColor(2);
//htpred3.attr().setFillColor(2);
ht5pred1.attr().setLineWidth(1);
ht5pred1.attr().setTitleX("T pred [ns]");
H1F ht5pred2 = new H1F("ht5pred2", 250, 80, 110);
ht5pred2.attr().setLineColor(8);
//htpred3.attr().setFillColor(2);
ht5pred2.attr().setLineWidth(1);
ht5pred2.attr().setTitleX("T pred [ns]");
H1F ht5pred3 = new H1F("ht5pred3", 250, 80, 110);
ht5pred3.attr().setLineColor(4);
//htpred3.attr().setFillColor(2);
ht5pred3.attr().setLineWidth(1);
ht5pred3.attr().setTitleX("T pred [ns]");
H1F ht6pred1 = new H1F("ht6pred1", 250, 80, 110);
ht6pred1.attr().setLineColor(2);
//htpred3.attr().setFillColor(2);
ht6pred1.attr().setLineWidth(1);
ht6pred1.attr().setTitleX("T pred [ns]");
H1F ht6pred2 = new H1F("ht6pred2", 250, 80, 110);
ht6pred2.attr().setLineColor(8);
//htpred3.attr().setFillColor(2);
ht6pred2.attr().setLineWidth(1);
ht6pred2.attr().setTitleX("T pred [ns]");
H1F ht6pred3 = new H1F("ht6pred3", 250, 80, 110);
ht6pred3.attr().setLineColor(4);
//htpred3.attr().setFillColor(2);
ht6pred3.attr().setLineWidth(1);
ht6pred3.attr().setTitleX("T pred [ns]");
H1F hmomP = new H1F("First Particle in REC::Particle Momentum (REC bank)", 1000, 0, 10);
hmomP.attr().setLineColor(2);
hmomP.attr().setFillColor(2);
hmomP.attr().setLineWidth(3);
hmomP.attr().setTitleX("P [GeV]");
H1F hmom = new H1F("Highest Electron Momentum (partout leaf)", 1000, 0, 10);
hmom.attr().setLineColor(2);
hmom.attr().setFillColor(2);
hmom.attr().setLineWidth(3);
hmom.attr().setTitleX("P [GeV]");
H1F htdiff = new H1F("Difference between Start times", 100, 0, 200);
htdiff.attr().setLineColor(2);
htdiff.attr().setFillColor(2);
htdiff.attr().setLineWidth(3);
htdiff.attr().setTitleX("T predicted [ns]");
HipoReader r = new HipoReader(filePath2);
Event e = new Event();
//show the list of schemas
// r.getSchemaFactory().show();
Bank[] banks = r.getBanks("REC::Particle", "REC::Event", "REC::Track");
Leaf partout = new Leaf(32200, 1, "sifssf3f3f6f9f3ffff", 4096);
Leaf Startout = new Leaf(32200, 4, "d", 4096);
Leaf trackbank = new Leaf(32000,1,"i",4096);
Leaf FTOFclusters = new Leaf(32200,3,"i",4096);
int nEvs=0;
//double maxP = 0;
while (r.hasNext()) {
r.nextEvent(e);
e.read(banks);
e.read(Startout, 32200, 4);
e.read(partout, 32200, 1);
e.read(trackbank, 32000, 1);
e.read(FTOFclusters, 32200, 3);
double maxP = 0;
int electron_no=0;
short sector = -1;
short component = -1;
short status = 0;
short pindex = -1;
double time = -1;
//show contents of rec particle
if(nEvs==0){
banks[0].show();
banks[1].show();
}
// If there is an electron, fill the histogram with the event start time.
for (short i = 0; i < banks[0].getRows(); i++) {
pid = banks[0].getInt("pid", i);
if (pid == 11) {
electron_no += 1;
}
}
if(electron_no>0){
float px = banks[0].getFloat("px", 0);
float py = banks[0].getFloat("py", 0);
float pz = banks[0].getFloat("pz", 0);
float momentum = (float) Math.sqrt(px * px + py * py + pz * pz);
//short component = banks[2].getInt("component", j);
//double status = banks[2].getInt("status", j);
//double sector = banks[2].getInt("sector", j);
//System.out.println("Momentum of first particle in event " + momentum);
hmomP.fill(momentum);
for (short j = 0; j < banks[1].getRows(); j++) {
// Get momentum information (using px, py, pz for 3D momentum)
//System.out.println("Momentum in part bank" + momentum);
StartTime = banks[1].getFloat("startTime", j);
htmaster.fill(StartTime);
if (momentum < 4) {
ht.fill(StartTime);
} else if (momentum > 4 && momentum < 7) {
ht2.fill(StartTime);
} else {
ht3.fill(StartTime);
}
}
}
for (short i = 0; i < partout.getRows(); i++) {
if (partout.getInt(1, i) == 11 && partout.getInt(4, i) == -1) {
double px = partout.getDouble(6, i);
double py = partout.getDouble(7, i);
double pz = partout.getDouble(8, i);
//Calculate absolute value of 3-momentum:
double rho = (double) Math.sqrt(px * px + py * py + pz * pz);
pindex = partout.getShort(0, i);
status = trackbank.getShort(0, pindex);
component = partout.getShort(29, i);
time = partout.getDouble(28, i);
sector = FTOFclusters.getShort(1, pindex);
//System.out.println("Time= " + time);
System.out.println("component = " + component);
//Update electron with max momentum dynamically:
if (rho > maxP && status>0 && component>-1) {
maxP = rho;
//System.out.println("Max Electron momentum = " + maxP);
}
}
}
if (maxP > 0) {
hmom.fill((float) maxP); // Add the momentum to the histogram
//hPaddle.fill((float) component);
}
for (short i = 0; i < Startout.getRows(); i++) {
//System.out.println("maxP = " + maxP);
double t = Startout.getDouble(0, i);
if (t>0 && maxP>0 && status>0 && sector==1 && component>-1) {
htpredmaster.fill(t);
hMomentumTime1.fill(maxP, t);
hPaddleTime1.fill(component, t);
//System.out.println("Max El momentum: " + maxP);
if(maxP<4){
//System.out.println("Start Time: " + t);
ht1pred1.fill(t);}
else if(maxP>4 && maxP<7){
ht1pred2.fill(t);}
else{ht1pred3.fill(t);}
}
if (t>0 && maxP>0 && status>0 && sector==2 && component>-1) {
htpredmaster2.fill(t);
hMomentumTime2.fill(maxP, t);
hPaddleTime2.fill(component, t);
if(maxP<4){
//System.out.println("Start Time: " + t);
ht2pred1.fill(t);}
else if(maxP>4 && maxP<7){
ht2pred2.fill(t);}
else{ht2pred3.fill(t);}
}
if (t>0 && maxP>0 && status>0 && sector==3 && component>-1) {
htpredmaster3.fill(t);
hPaddleTime3.fill(component, t);
hMomentumTime3.fill(maxP, t);
if(maxP<4){
//System.out.println("Start Time: " + t);
ht3pred1.fill(t);}
else if(maxP>4 && maxP<7){
ht3pred2.fill(t);}
else{ht3pred3.fill(t);}
}
if (t>0 && maxP>0 && status>0 && sector==4 && component>-1) {
htpredmaster4.fill(t);
hPaddleTime4.fill(component, t);
hMomentumTime4.fill(maxP, t);
if(maxP<4){
//System.out.println("Start Time: " + t);
ht4pred1.fill(t);}
else if(maxP>4 && maxP<7){
ht4pred2.fill(t);}
else{ht4pred3.fill(t);}
}
if (t>0 && maxP>0 && status>0 && sector==5 && component>-1) {
htpredmaster5.fill(t);
hPaddleTime5.fill(component, t);
hMomentumTime5.fill(maxP, t);
if(maxP<4){
//System.out.println("Start Time: " + t);
ht5pred1.fill(t);}
else if(maxP>4 && maxP<7){
ht5pred2.fill(t);}
else{ht5pred3.fill(t);}
}
if (t>0 && maxP>0 && status>0 && sector==6 && component>-1) {
htpredmaster6.fill(t);
hPaddleTime6.fill(component, t);
hMomentumTime6.fill(maxP, t);
if(maxP<4){
//System.out.println("Start Time: " + t);
ht6pred1.fill(t);}
else if(maxP>4 && maxP<7){
ht6pred2.fill(t);}
else{ht6pred3.fill(t);}
}
}
nEvs++;
}
double entries = hmom.getEntries();
//double entries2 = htpred.getEntries();
//double entries3 = htpred2.getEntries();
//double entries4 = htpred3.getEntries();
double entries5 = hmomP.getEntries();
double entries6 = ht.getEntries();
double entries7 = ht2.getEntries();
double entries8 = ht3.getEntries();
TGCanvas canvas = new TGCanvas();
canvas.setTitle("Multiple Histograms");
canvas.view().region().draw(hPaddleTime1);
canvas.repaint();
/*
TGCanvas canvas = new TGCanvas();
canvas.setTitle("Multiple Histograms");
canvas.view().region().draw(htpredmaster);
canvas.repaint();
TGCanvas canvas = new TGCanvas();
canvas.view().divide(3,2);
canvas.setTitle("Multiple Histograms");
canvas.view().cd(0).region().draw(htpredmaster);
canvas.view().cd(1).region().draw(htpredmaster2);
canvas.view().cd(2).region().draw(htpredmaster3);
canvas.view().cd(3).region().draw(htpredmaster4);
canvas.view().cd(4).region().draw(htpredmaster5);
canvas.view().cd(5).region().draw(htpredmaster6);
htpredmaster.attr().setLegend("Sector 1");
htpredmaster2.attr().setLegend("Sector 2");
htpredmaster3.attr().setLegend("Sector 3");
htpredmaster4.attr().setLegend("Sector 4");
htpredmaster5.attr().setLegend("Sector 5");
htpredmaster6.attr().setLegend("Sector 6");
canvas.cd(0).view().region().showLegend(0.5,0.98);
canvas.cd(1).view().region().showLegend(0.5,0.98);
canvas.cd(2).view().region().showLegend(0.5,0.98);
canvas.cd(3).view().region().showLegend(0.5,0.98);
canvas.cd(4).view().region().showLegend(0.5,0.98);
canvas.cd(5).view().region().showLegend(0.5,0.98);
canvas.repaint();
*/
/*
ht1pred1.attr().setLegend("Sector 1 P<4");
ht1pred2.attr().setLegend("Sector 1 4<P<7");
ht1pred3.attr().setLegend("Sector 1 P>7");
TGCanvas canvas = new TGCanvas();
canvas.view().divide(3,2);
canvas.setTitle("Multiple Histograms");
canvas.cd(0).view().region().draw(ht1pred1).draw(ht1pred2,"same").draw(ht1pred3,"same");
canvas.cd(0).view().region().showLegend(0.5,0.98);
canvas.cd(0).repaint();
ht2pred1.attr().setLegend("Sector 2 P<4");
ht2pred2.attr().setLegend("Sector 2 4<P<7");
ht2pred3.attr().setLegend("Sector 2 P>7");
canvas.cd(1).view().region().draw(ht2pred1).draw(ht2pred2,"same").draw(ht2pred3,"same");
canvas.cd(1).view().region().showLegend(0.,0.98);
canvas.cd(1).repaint();
ht3pred1.attr().setLegend("Sector 3 P<4");
ht3pred2.attr().setLegend("Sector 3 4<P<7");
ht3pred3.attr().setLegend("Sector 3 P>7");
canvas.cd(2).view().region().draw(ht3pred1).draw(ht3pred2,"same").draw(ht3pred3,"same");
canvas.cd(2).view().region().showLegend(0,0.98);
canvas.cd(2).repaint();
ht4pred1.attr().setLegend("Sector 4 P<4");
ht4pred2.attr().setLegend("Sector 4 4<P<7");
ht4pred3.attr().setLegend("Sector 4 P>7");
canvas.cd(3).view().region().draw(ht4pred1).draw(ht4pred2,"same").draw(ht4pred3,"same");
canvas.cd(3).view().region().showLegend(0.,0.98);
canvas.cd(3).repaint();
ht5pred1.attr().setLegend("Sector 5 P<4");
ht5pred2.attr().setLegend("Sector 5 4<P<7");
ht5pred3.attr().setLegend("Sector 5 P>7");
canvas.cd(4).view().region().draw(ht5pred1).draw(ht5pred2,"same").draw(ht5pred3,"same");
canvas.cd(4).view().region().showLegend(0.,0.98);
canvas.cd(4).repaint();
ht6pred1.attr().setLegend("Sector 6 P<4");
ht6pred2.attr().setLegend("Sector 6 4<P<7");
ht6pred3.attr().setLegend("Sector 6 P>7");
canvas.cd(5).view().region().draw(ht6pred1).draw(ht6pred2,"same").draw(ht6pred3,"same");
canvas.cd(5).view().region().showLegend(0,0.98);
canvas.cd(5).repaint();
*/
/*
ht.attr().setLegend("P<4 (data)");
ht2.attr().setLegend("4<P<7 (data)");
ht3.attr().setLegend("P>7 (data)");
canvas.cd(1).view().region().draw(ht).draw(ht2,"same").draw(ht3,"same");
canvas.cd(1).view().region().showLegend(0.5,0.98);
canvas.cd(1).repaint();
TGCanvas canvas2 = new TGCanvas();
canvas2.setTitle("Multiple Histograms");
htmaster.attr().setLegend("Data");
htpredmaster.attr().setLegend("Prediction");
canvas2.view().region().draw(htpredmaster,"same").draw(htmaster,"same");
canvas2.view().region().showLegend(0.5,0.98);
canvas2.repaint();
*/
//System.out.println("entries in mom:" + entries);
//System.out.println("entries in mom from REC Bank:" + entries5);
//System.out.println("entries in tpred:" + entries2 + entries3 + entries4);
//System.out.println("entries in t:" + entries6 + entries7 + entries8);
// Save histogram using `TDirectory.export()`
TDirectory.export("start_time_Exp1.twig", "/plots/StartTime", ht);
TDirectory.export("start_time_Exp2.twig", "/plots/StartTime", ht2);
TDirectory.export("start_time_Exp3.twig", "/plots/StartTime", ht3);
//TDirectory.export("start_time_Pred1.twig", "/plots/StartTime", htpred);
//TDirectory.export("start_time_Pred2.twig", "/plots/StartTime", htpred2);
//TDirectory.export("start_time_Pred3.twig", "/plots/StartTime", htpred3);
TDirectory.export("start_time_MomentumExp.twig", "/plots/StartTime", hmomP);
TDirectory.export("start_time_MomentumPred.twig", "/plots/StartTime", hmom);
TDirectory.export("start_time_MomentumPred.twig", "/plots/StartTime", hmom);
System.out.println("Histogram saved as start_time_New.twig");
System.out.println("Histogram saved as start_time_Exp1.twig");
}
}