/
betterreadmaus.cpp
executable file
·2182 lines (1709 loc) · 85.2 KB
/
betterreadmaus.cpp
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
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "betterreadmaus.h"
#include "JsonCppStreamer/IRStream.hh"
BetterReadMAUS::BetterReadMAUS()
{
tof0_global_x_vs_slab_number = new TH2F("tof0_global_x_vs_slab_number", "TOF0;global x; vertical slab number", 10, -220.0, 220.0, 10, -0.5, 9.5);
tof0_global_y_vs_slab_number = new TH2F("tof0_global_y_vs_slab_number", "TOF0;global y; horizontal slab number", 10, -220.0, 220.0, 10, -0.5, 9.5);
tof1_global_x_vs_slab_number = new TH2F("tof1_global_x_vs_slab_number", "TOF1;global x; vertical slab number", 7, -220.0, 220.0, 7, -0.5, 6.5);
tof1_global_y_vs_slab_number = new TH2F("tof1_global_y_vs_slab_number", "TOF1;global y; horizontal slab number", 7, -220.0, 220.0, 7, -0.5, 6.5);
tof0_x_residual = new TH1F("tof0_x_residual", "TOF0; x recon - x pixel", 100, -220.0, 220.0);
tof1_x_residual = new TH1F("tof1_x_residual", "TOF1; x recon - x pixel", 100, -220.0, 220.0);
tof0_y_residual = new TH1F("tof0_y_residual", "TOF0; y recon - y pixel", 100, -220.0, 220.0);
tof1_y_residual = new TH1F("tof1_y_residual", "TOF1; y recon - y pixel", 100, -220.0, 220.0);
}
void BetterReadMAUS::SetDataType(bool thisIsData, bool thisIsMCRecon, bool thisIsMCTruth){
// This function gets used to determine which PMT is read as being on
// the top/bottom at TOF0 and TOF1 -- in MC recon, PMT0 is at +y, PMT1 is at -y
// in data, PMT1 is at +y, PMT0 is at -y
//
// Rather than changing the geometry and causing lots of confusion about *when* a
// PMT was at +/- y in a MC, we're just going to check to see which way around we
// need to read things.
//
// Check the plots in qualityCheck.pdf that this programme produces. If the y
// residuals look extremely broad (i.e. going well off the horizontal scale)
// then something has happened with the PMT positions.
isData = thisIsData;
isMCRecon = thisIsMCRecon;
isMCTruth = thisIsMCTruth; // this won't do anything, but it makes sense for there to
// be the option in case it's needed in the future
}
void BetterReadMAUS::set_cut_values(){
min_tof = 27.0;
max_tof = 32.0;
min_normalised_tof = 1.0;
max_normalised_tof = 6.0;
max_chindof = 4.0; //2.5;
max_tku_radius = 150.0;
min_tku_radius = 0.0;
max_diffuser = 90.0;
// for tku P vs tof selection:
mean_dP = 20.0; // difference in total momentum at u/s side of TOF1 and TKU station 1
min_dP = mean_dP - 22.0;
max_dP = mean_dP + 22.0;
}
void BetterReadMAUS::print_tof_plots(){
std::string saveAs = "qualityCheck.pdf(";
TCanvas canvas;
tof0_x_residual->Draw("hist");
canvas.Print(saveAs.c_str());
tof0_y_residual->Draw("hist");
canvas.Print(saveAs.c_str());
tof1_x_residual->Draw("hist");
canvas.Print(saveAs.c_str());
tof1_y_residual->Draw("hist");
canvas.Print(saveAs.c_str());
tof0_global_x_vs_slab_number->Draw("colz");
canvas.Print(saveAs.c_str());
tof0_global_y_vs_slab_number->Draw("colz");
canvas.Print(saveAs.c_str());
tof1_global_x_vs_slab_number->Draw("colz");
canvas.Print(saveAs.c_str());
tof1_global_y_vs_slab_number->Draw("colz");
saveAs = "qualityCheck.pdf)";
canvas.Print(saveAs.c_str());
}
void BetterReadMAUS::reset_particle_variables(){
// reset's particle variables
reset_TOF0_variables();
reset_TOF1_variables();
reset_TKU_variables();
reset_diffuser_variables();
reconstructed_event_number = -1;
spill_number = -1;
cut_tof = 0;
cut_normalised_tof = 0;
cut_diffuser = 0;
cut_chindof = 0;
cut_tku_r = 0;
cut_one_tof0 = 0;
cut_one_tof1 = 0;
cut_one_track = 0;
cut_tof_p = 0;
cut_allPassed = 0;
cut_allButDiffuserPassed = 0;
number_of_TOF0_spacepoints = 0;
number_of_TOF1_spacepoints = 0;
number_of_TKU_tracks = 0;
time_of_flight = TMath::Infinity();
normalised_time_of_flight = TMath::Infinity();
}
void BetterReadMAUS::reset_TOF0_variables(){
TOF0_xPixel = TMath::Infinity();
TOF0_yPixel = TMath::Infinity();
TOF0_x = TMath::Infinity();
TOF0_y = TMath::Infinity();
TOF0_z = TMath::Infinity();
TOF0_horizontal_slab = -1;
TOF0_vertical_slab = -1;
TOF0_horizontal_slab_tMinus = TMath::Infinity();
TOF0_horizontal_slab_tPlus = TMath::Infinity();
TOF0_vertical_slab_tMinus = TMath::Infinity();
TOF0_vertical_slab_tPlus = TMath::Infinity();
TOF0_hitTime = TMath::Infinity();
TOF0_px = TMath::Infinity();
TOF0_py = TMath::Infinity();
TOF0_pz = TMath::Infinity();
TOF0_p = TMath::Infinity();
}
void BetterReadMAUS::reset_TOF1_variables(){
TOF1_xPixel = TMath::Infinity();
TOF1_yPixel = TMath::Infinity();
TOF1_x = TMath::Infinity();
TOF1_y = TMath::Infinity();
TOF1_z = TMath::Infinity();
TOF1_horizontal_slab = -1;
TOF1_vertical_slab = -1;
TOF1_horizontal_slab_tMinus = TMath::Infinity();
TOF1_horizontal_slab_tPlus = TMath::Infinity();
TOF1_vertical_slab_tMinus = TMath::Infinity();
TOF1_vertical_slab_tPlus = TMath::Infinity();
TOF1_hitTime = TMath::Infinity();
TOF1_px = TMath::Infinity();
TOF1_py = TMath::Infinity();
TOF1_pz = TMath::Infinity();
TOF1_p = TMath::Infinity();
}
void BetterReadMAUS::reset_TKU_variables(){
TKU_assumed_field = TMath::Infinity();
TKU_plane1_x = TMath::Infinity();
TKU_plane1_y = TMath::Infinity();
TKU_plane1_z = TMath::Infinity();
TKU_plane1_px = TMath::Infinity();
TKU_plane1_py = TMath::Infinity();
TKU_plane1_pz = TMath::Infinity();
TKU_plane1_p = TMath::Infinity();
TKU_plane1_r = TMath::Infinity();
TKU_plane1_pt = TMath::Infinity();
TKU_plane1_x_error = TMath::Infinity();
TKU_plane1_y_error = TMath::Infinity();
TKU_plane1_px_error = TMath::Infinity();
TKU_plane1_py_error = TMath::Infinity();
TKU_plane1_kappa_error = TMath::Infinity();
TKU_plane2_x = TMath::Infinity();
TKU_plane2_y = TMath::Infinity();
TKU_plane2_z = TMath::Infinity();
TKU_plane2_px = TMath::Infinity();
TKU_plane2_py = TMath::Infinity();
TKU_plane2_pz = TMath::Infinity();
TKU_plane2_p = TMath::Infinity();
TKU_plane2_r = TMath::Infinity();
TKU_plane2_pt = TMath::Infinity();
TKU_plane2_x_error = TMath::Infinity();
TKU_plane2_y_error = TMath::Infinity();
TKU_plane2_px_error = TMath::Infinity();
TKU_plane2_py_error = TMath::Infinity();
TKU_plane2_kappa_error = TMath::Infinity();
TKU_plane3_x = TMath::Infinity();
TKU_plane3_y = TMath::Infinity();
TKU_plane3_z = TMath::Infinity();
TKU_plane3_px = TMath::Infinity();
TKU_plane3_py = TMath::Infinity();
TKU_plane3_pz = TMath::Infinity();
TKU_plane3_p = TMath::Infinity();
TKU_plane3_r = TMath::Infinity();
TKU_plane3_pt = TMath::Infinity();
TKU_plane3_x_error = TMath::Infinity();
TKU_plane3_y_error = TMath::Infinity();
TKU_plane3_px_error = TMath::Infinity();
TKU_plane3_py_error = TMath::Infinity();
TKU_plane3_kappa_error = TMath::Infinity();
TKU_plane4_x = TMath::Infinity();
TKU_plane4_y = TMath::Infinity();
TKU_plane4_z = TMath::Infinity();
TKU_plane4_px = TMath::Infinity();
TKU_plane4_py = TMath::Infinity();
TKU_plane4_pz = TMath::Infinity();
TKU_plane4_p = TMath::Infinity();
TKU_plane4_r = TMath::Infinity();
TKU_plane4_pt = TMath::Infinity();
TKU_plane4_x_error = TMath::Infinity();
TKU_plane4_y_error = TMath::Infinity();
TKU_plane4_px_error = TMath::Infinity();
TKU_plane4_py_error = TMath::Infinity();
TKU_plane4_kappa_error = TMath::Infinity();
TKU_plane5_x = TMath::Infinity();
TKU_plane5_y = TMath::Infinity();
TKU_plane5_z = TMath::Infinity();
TKU_plane5_px = TMath::Infinity();
TKU_plane5_py = TMath::Infinity();
TKU_plane5_pz = TMath::Infinity();
TKU_plane5_p = TMath::Infinity();
TKU_plane5_r = TMath::Infinity();
TKU_plane5_pt = TMath::Infinity();
TKU_plane5_x_error = TMath::Infinity();
TKU_plane5_y_error = TMath::Infinity();
TKU_plane5_px_error = TMath::Infinity();
TKU_plane5_py_error = TMath::Infinity();
TKU_plane5_kappa_error = TMath::Infinity();
TKU_chiSquare = TMath::Infinity();
TKU_ndof = -1;
TKU_patternRecognition_dipAngle = TMath::Infinity();
TKU_patternRecognition_R = TMath::Infinity();
TKU_patternRecognition_x0 = TMath::Infinity();
TKU_patternRecognition_y0 = TMath::Infinity();
TKU_plane1_pull = TMath::Infinity();
TKU_plane2_pull = TMath::Infinity();
TKU_plane3_pull = TMath::Infinity();
TKU_plane4_pull = TMath::Infinity();
TKU_plane5_pull = TMath::Infinity();
TKU_charge = -5;
TKU_assumed_field = TMath::Infinity();
}
void BetterReadMAUS::readCalibrationFile(QString calibrationFile){
reading_TOF0 = false;
reading_TOF1 = false;
reading_horizontal = false;
reading_vertical = false;
TOF0_horizontal_calibration.clear();
TOF0_vertical_calibration.clear();
TOF1_horizontal_calibration.clear();
TOF1_vertical_calibration.clear();
QFile file(calibrationFile);
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){
std::cerr << "Failed to read calibration file.\n";
return;
}
QTextStream in(&file);
while(!in.atEnd()){
QString line = in.readLine();
process_line(line);
}
check_calibration();
}
void BetterReadMAUS::process_line(QString line){
if(line.contains("TOF0")){
reading_TOF0 = true;
reading_TOF1 = false;
}
else if(line.contains("TOF1")){
reading_TOF0 = false;
reading_TOF1 = true;
}
else if(line.contains("Horizontal")){
reading_horizontal = true;
reading_vertical = false;
}
else if(line.contains("Vertical")){
reading_horizontal = false;
reading_vertical = true;
}
else{
// the line gives us some calibration info...
QStringList list = line.split("\t");
double delta = list.at(2).toDouble();
if(reading_TOF0 && reading_horizontal && !reading_TOF1 && !reading_vertical){
TOF0_horizontal_calibration << delta;
calibrated_c_eff = list.at(1).toDouble();
}
else if(reading_TOF0 && reading_vertical && !reading_TOF1 && !reading_horizontal){
TOF0_vertical_calibration << delta;
}
else if(reading_TOF1 && reading_horizontal && !reading_TOF0 && !reading_vertical){
TOF1_horizontal_calibration << delta;
}
else if(reading_TOF1 && reading_vertical && !reading_TOF0 && !reading_horizontal){
TOF1_vertical_calibration << delta;
}
}
}
void BetterReadMAUS::check_calibration(){
// print out the calibration constants
std::cerr << "TOF0_horizontal_calibration holds: (slab, delta)\n"
<< "(0, " << TOF0_horizontal_calibration.at(0) << ")\n"
<< "(1, " << TOF0_horizontal_calibration.at(1) << ")\n"
<< "(2, " << TOF0_horizontal_calibration.at(2) << ")\n"
<< "(3, " << TOF0_horizontal_calibration.at(3) << ")\n"
<< "(4, " << TOF0_horizontal_calibration.at(4) << ")\n"
<< "(5, " << TOF0_horizontal_calibration.at(5) << ")\n"
<< "(6, " << TOF0_horizontal_calibration.at(6) << ")\n"
<< "(7, " << TOF0_horizontal_calibration.at(7) << ")\n"
<< "(8, " << TOF0_horizontal_calibration.at(8) << ")\n"
<< "(9, " << TOF0_horizontal_calibration.at(9) << ")\n";
std::cerr << "TOF0_vertical_calibration holds: (slab, delta)\n"
<< "(0, " << TOF0_vertical_calibration.at(0) << ")\n"
<< "(1, " << TOF0_vertical_calibration.at(1) << ")\n"
<< "(2, " << TOF0_vertical_calibration.at(2) << ")\n"
<< "(3, " << TOF0_vertical_calibration.at(3) << ")\n"
<< "(4, " << TOF0_vertical_calibration.at(4) << ")\n"
<< "(5, " << TOF0_vertical_calibration.at(5) << ")\n"
<< "(6, " << TOF0_vertical_calibration.at(6) << ")\n"
<< "(7, " << TOF0_vertical_calibration.at(7) << ")\n"
<< "(8, " << TOF0_vertical_calibration.at(8) << ")\n"
<< "(9, " << TOF0_vertical_calibration.at(9) << ")\n";
std::cerr << "TOF1_horizontal_calibration holds: (slab, delta)\n"
<< "(0, " << TOF1_horizontal_calibration.at(0) << ")\n"
<< "(1, " << TOF1_horizontal_calibration.at(1) << ")\n"
<< "(2, " << TOF1_horizontal_calibration.at(2) << ")\n"
<< "(3, " << TOF1_horizontal_calibration.at(3) << ")\n"
<< "(4, " << TOF1_horizontal_calibration.at(4) << ")\n"
<< "(5, " << TOF1_horizontal_calibration.at(5) << ")\n"
<< "(6, " << TOF1_horizontal_calibration.at(6) << ")\n";
std::cerr << "TOF1_vertical_calibration holds: (slab, delta)\n"
<< "(0, " << TOF1_vertical_calibration.at(0) << ")\n"
<< "(1, " << TOF1_vertical_calibration.at(1) << ")\n"
<< "(2, " << TOF1_vertical_calibration.at(2) << ")\n"
<< "(3, " << TOF1_vertical_calibration.at(3) << ")\n"
<< "(4, " << TOF1_vertical_calibration.at(4) << ")\n"
<< "(5, " << TOF1_vertical_calibration.at(5) << ")\n"
<< "(6, " << TOF1_vertical_calibration.at(6) << ")\n";
}
void BetterReadMAUS::apply_calibration_TOF0(){
double horizontal_delta = TOF0_horizontal_calibration.at(TOF0_horizontal_slab);
double vertical_delta = TOF0_vertical_calibration.at(TOF0_vertical_slab);
double slab_width = 40.0;
double min_x, max_x, min_y, max_y;
bool good_x = false;
bool good_y = false;
tof0_global_x_vs_slab_number->Fill(TOF0_xPixel, TOF0_vertical_slab);
tof0_global_y_vs_slab_number->Fill(TOF0_yPixel, TOF0_horizontal_slab);
if(!std::isnan(horizontal_delta)){
TOF0_x = 0.5*calibrated_c_eff*(TOF0_horizontal_slab_tMinus
- TOF0_horizontal_slab_tPlus + horizontal_delta);
tof0_x_residual->Fill(TOF0_x - TOF0_xPixel);
min_x = TOF0_xPixel - 0.5*slab_width;
max_x = TOF0_xPixel + 0.5*slab_width;
if(TOF0_x >= min_x && TOF0_x <= max_x){
good_x = true;
}
else{
//good_x = false;
good_x = true;
}
}
else{
TOF0_x = TOF0_xPixel;
good_x = false;
}
if(!std::isnan(vertical_delta)){
TOF0_y = 0.5*calibrated_c_eff*(TOF0_vertical_slab_tMinus
- TOF0_vertical_slab_tPlus + vertical_delta);
// test:
//TOF0_y = -1.0*TOF0_y;
tof0_y_residual->Fill(TOF0_y - TOF0_yPixel);
min_y = TOF0_yPixel - 0.5*slab_width;
max_y = TOF0_yPixel + 0.5*slab_width;
if(TOF0_y >= min_y && TOF0_y <= max_x){
good_y = true;
}
else{
//good_y = false;
good_y = true;
}
}
else{
TOF0_y = TOF0_yPixel;
good_y = false;
}
if(good_x && good_y){
TOF0_goodPMTPosition = 1;
}
else{
TOF0_goodPMTPosition = 0;
}
}
void BetterReadMAUS::apply_calibration_TOF1(){
double horizontal_delta = TOF1_horizontal_calibration.at(TOF1_horizontal_slab);
double vertical_delta = TOF1_vertical_calibration.at(TOF1_vertical_slab);
double slab_width = 60.0;
double min_x, max_x, min_y, max_y;
bool good_x = false;
bool good_y = false;
tof1_global_x_vs_slab_number->Fill(TOF1_xPixel, TOF1_vertical_slab);
tof1_global_y_vs_slab_number->Fill(TOF1_yPixel, TOF1_horizontal_slab);
if(!std::isnan(horizontal_delta)){
TOF1_x = 0.5*calibrated_c_eff*(TOF1_horizontal_slab_tMinus
- TOF1_horizontal_slab_tPlus + horizontal_delta);
tof1_x_residual->Fill(TOF1_x - TOF1_xPixel);
min_x = TOF1_xPixel - 0.5*slab_width;
max_x = TOF1_xPixel + 0.5*slab_width;
if(TOF1_x >= min_x && TOF1_x <= max_x){
good_x = true;
}
else{
//good_x = false;
good_x = true;
}
}
else{
TOF1_x = TOF1_xPixel;
good_x = false;
}
if(!std::isnan(vertical_delta)){
TOF1_y = 0.5*calibrated_c_eff*(TOF1_vertical_slab_tMinus
- TOF1_vertical_slab_tPlus + vertical_delta);
// test:
//TOF1_y = -1.0*TOF1_y;
tof1_y_residual->Fill(TOF1_y - TOF1_yPixel);
min_y = TOF1_yPixel - 0.5*slab_width;
max_y = TOF1_yPixel + 0.5*slab_width;
if(TOF1_y >= min_y && TOF1_y <= max_x){
good_y = true;
}
else{
//good_y = false;
good_y = true;
}
}
else{
TOF1_y = TOF1_yPixel;
good_y = false;
}
if(good_x && good_y){
TOF1_goodPMTPosition = 1;
}
else{
TOF1_goodPMTPosition = 0;
}
}
void BetterReadMAUS::define_root_file(QString saveAs){
outputFile = new TFile(saveAs.toStdString().c_str(), "RECREATE");
outputTree = new TTree("T", "T");
outputTree->Branch("SpillNumber", &spill_number, "SpillNumber/I");
outputTree->Branch("ReconstructedEventNumber", &reconstructed_event_number, "ReconstructedEventNumber/I");
outputTree->Branch("num_TOF0_spacepoints", &number_of_TOF0_spacepoints, "num_TOF0_spacepoints/I");
outputTree->Branch("num_TOF1_spacepoints", &number_of_TOF1_spacepoints, "num_TOF1_spacepoints/I");
outputTree->Branch("num_TKU_tracks", &number_of_TKU_tracks, "num_TKU_tracks/I");
// TOF0
outputTree->Branch("TOF0_x", &TOF0_x, "TOF0_x/D");
outputTree->Branch("TOF0_y", &TOF0_y, "TOF0_y/D");
outputTree->Branch("TOF0_z", &TOF0_z, "TOF0_z/D");
outputTree->Branch("TOF0_hitTime", &TOF0_hitTime, "TOF0_hitTime/D");
outputTree->Branch("TOF0_px", &TOF0_px, "TOF0_px/D");
outputTree->Branch("TOF0_py", &TOF0_py, "TOF0_py/D");
outputTree->Branch("TOF0_pz", &TOF0_pz, "TOF0_pz/D");
outputTree->Branch("TOF0_p", &TOF0_p, "TOF0_p/D");
outputTree->Branch("TOF0_xPixel", &TOF0_xPixel, "TOF0_xPixel/D");
outputTree->Branch("TOF0_yPixel", &TOF0_yPixel, "TOF0_yPixel/D");
outputTree->Branch("TOF0_hSlab_tMinus", &TOF0_horizontal_slab_tMinus, "TOF0_hSlab_tMinus/D");
outputTree->Branch("TOF0_hSlab_tPlus", &TOF0_horizontal_slab_tPlus, "TOF0_hSlab_tPlus/D");
outputTree->Branch("TOF0_vSlab_tMinus", &TOF0_vertical_slab_tMinus, "TOF0_vSlab_tMinus/D");
outputTree->Branch("TOF0_vSlab_tPlus", &TOF0_vertical_slab_tPlus, "TOF0_vSlab_tPlus/D");
outputTree->Branch("TOF0_hSlab", &TOF0_horizontal_slab, "TOF0_hSlab/I");
outputTree->Branch("TOF0_vSlab", &TOF0_vertical_slab, "TOF0_vSlab/I");
outputTree->Branch("TOF0_xPrime", &TOF0_xPrime, "TOF0_xPrime/D");
outputTree->Branch("TOF0_yPrime", &TOF0_yPrime, "TOF0_yPrime/D");
// TOF1
outputTree->Branch("TOF1_x", &TOF1_x, "TOF1_x/D");
outputTree->Branch("TOF1_xPixel", &TOF1_xPixel, "TOF1_xPixel/D");
outputTree->Branch("TOF1_y", &TOF1_y, "TOF1_y/D");
outputTree->Branch("TOF1_yPixel", &TOF1_yPixel, "TOF1_yPixel/D");
outputTree->Branch("TOF1_z", &TOF1_z, "TOF1_z/D");
outputTree->Branch("TOF1_hitTime", &TOF1_hitTime, "TOF1_hitTime/D");
outputTree->Branch("TOF1_hSlab_tMinus", &TOF1_horizontal_slab_tMinus, "TOF1_hSlab_tMinus/D");
outputTree->Branch("TOF1_hSlab_tPlus", &TOF1_horizontal_slab_tPlus, "TOF1_hSlab_tPlus/D");
outputTree->Branch("TOF1_vSlab_tMinus", &TOF1_vertical_slab_tMinus, "TOF1_vSlab_tMinus/D");
outputTree->Branch("TOF1_vSlab_tPlus", &TOF1_vertical_slab_tPlus, "TOF1_vSlab_tPlus/D");
outputTree->Branch("TOF1_hSlab", &TOF1_horizontal_slab, "TOF1_hSlab/I");
outputTree->Branch("TOF1_vSlab", &TOF1_vertical_slab, "TOF1_vSlab/I");
outputTree->Branch("TOF1_px", &TOF1_px, "TOF1_px/D");
outputTree->Branch("TOF1_py", &TOF1_py, "TOF1_py/D");
outputTree->Branch("TOF1_pz", &TOF1_pz, "TOF1_pz/D");
outputTree->Branch("TOF1_p", &TOF1_p, "TOF1_p/D");
outputTree->Branch("TOF1_xPrime", &TOF1_xPrime, "TOF1_xPrime/D");
outputTree->Branch("TOF1_yPrime", &TOF1_yPrime, "TOF1_yPrime/D");
// Time of flight
outputTree->Branch("time_of_flight", &time_of_flight, "time_of_flight/D");
outputTree->Branch("normalised_time_of_flight", &normalised_time_of_flight, "normalised_time_of_flight/D");
// Diffuser -- values taken from Globals
outputTree->Branch("diffuser_x", &diffuser_x, "diffuser_x/D");
outputTree->Branch("diffuser_y", &diffuser_y, "diffuser_y/D");
outputTree->Branch("diffuser_r", &diffuser_r, "diffuser_r/D");
outputTree->Branch("diffuser_z", &diffuser_z, "diffuser_z/D");
outputTree->Branch("diffuser_px", &diffuser_px, "diffuser_px/D");
outputTree->Branch("diffuser_py", &diffuser_py, "diffuser_py/D");
outputTree->Branch("diffuser_pz", &diffuser_pz, "diffuser_pz/D");
outputTree->Branch("diffuser_pt", &diffuser_pt, "diffuser_pt/D");
outputTree->Branch("diffuser_p", &diffuser_p, "diffuser_p/D");
// TKU
outputTree->Branch("TKU_s1_x", &TKU_plane1_x, "TKU_s1_x/D"); // station 1
outputTree->Branch("TKU_s1_y", &TKU_plane1_y, "TKU_s1_y/D");
outputTree->Branch("TKU_s1_r", &TKU_plane1_r, "TKU_s1_r/D");
outputTree->Branch("TKU_s1_z", &TKU_plane1_z, "TKU_s1_z/D");
outputTree->Branch("TKU_s1_px", &TKU_plane1_px, "TKU_s1_px/D");
outputTree->Branch("TKU_s1_py", &TKU_plane1_py, "TKU_s1_py/D");
outputTree->Branch("TKU_s1_pz", &TKU_plane1_pz, "TKU_s1_pz/D");
outputTree->Branch("TKU_s1_pt", &TKU_plane1_pt, "TKU_s1_pt/D");
outputTree->Branch("TKU_s1_p", &TKU_plane1_p, "TKU_s1_p/D");
outputTree->Branch("TKU_s1_pull", &TKU_plane1_pull, "TKU_s1_pull/D");
outputTree->Branch("TKU_s1_x_error", &TKU_plane1_x_error, "TKU_s1_x_error/D");
outputTree->Branch("TKU_s1_y_error", &TKU_plane1_y_error, "TKU_s1_y_error/D");
outputTree->Branch("TKU_s1_px_error", &TKU_plane1_px_error, "TKU_s1_px_error/D");
outputTree->Branch("TKU_s1_py_error", &TKU_plane1_py_error, "TKU_s1_py_error/D");
outputTree->Branch("TKU_s1_kappa_error", &TKU_plane1_kappa_error, "TKU_s1_kappa_error/D");
outputTree->Branch("TKU_s1_pz_error", &TKU_plane1_pz_error, "TKU_s1_pz_error/D");
outputTree->Branch("TKU_s2_x", &TKU_plane2_x, "TKU_s2_x/D"); // station 2
outputTree->Branch("TKU_s2_y", &TKU_plane2_y, "TKU_s2_y/D");
outputTree->Branch("TKU_s2_r", &TKU_plane2_r, "TKU_s2_r/D");
outputTree->Branch("TKU_s2_z", &TKU_plane2_z, "TKU_s2_z/D");
outputTree->Branch("TKU_s2_px", &TKU_plane2_px, "TKU_s2_px/D");
outputTree->Branch("TKU_s2_py", &TKU_plane2_py, "TKU_s2_py/D");
outputTree->Branch("TKU_s2_pz", &TKU_plane2_pz, "TKU_s2_pz/D");
outputTree->Branch("TKU_s2_pt", &TKU_plane2_pt, "TKU_s2_pt/D");
outputTree->Branch("TKU_s2_p", &TKU_plane2_p, "TKU_s2_p/D");
outputTree->Branch("TKU_s2_pull", &TKU_plane2_pull, "TKU_s2_pull/D");
outputTree->Branch("TKU_s2_x_error", &TKU_plane2_x_error, "TKU_s2_x_error/D");
outputTree->Branch("TKU_s2_y_error", &TKU_plane2_y_error, "TKU_s2_y_error/D");
outputTree->Branch("TKU_s2_px_error", &TKU_plane2_px_error, "TKU_s2_px_error/D");
outputTree->Branch("TKU_s2_py_error", &TKU_plane2_py_error, "TKU_s2_py_error/D");
outputTree->Branch("TKU_s2_kappa_error", &TKU_plane2_kappa_error, "TKU_s2_kappa_error/D");
outputTree->Branch("TKU_s2_pz_error", &TKU_plane2_pz_error, "TKU_s2_pz_error/D");
outputTree->Branch("TKU_s3_x", &TKU_plane3_x, "TKU_s3_x/D"); // station 3
outputTree->Branch("TKU_s3_y", &TKU_plane3_y, "TKU_s3_y/D");
outputTree->Branch("TKU_s3_r", &TKU_plane3_r, "TKU_s3_r/D");
outputTree->Branch("TKU_s3_z", &TKU_plane3_z, "TKU_s3_z/D");
outputTree->Branch("TKU_s3_px", &TKU_plane3_px, "TKU_s3_px/D");
outputTree->Branch("TKU_s3_py", &TKU_plane3_py, "TKU_s3_py/D");
outputTree->Branch("TKU_s3_pz", &TKU_plane3_pz, "TKU_s3_pz/D");
outputTree->Branch("TKU_s3_pt", &TKU_plane3_pt, "TKU_s3_pt/D");
outputTree->Branch("TKU_s3_p", &TKU_plane3_p, "TKU_s3_p/D");
outputTree->Branch("TKU_s3_pull", &TKU_plane3_pull, "TKU_s3_pull/D");
outputTree->Branch("TKU_s3_x_error", &TKU_plane3_x_error, "TKU_s3_x_error/D");
outputTree->Branch("TKU_s3_y_error", &TKU_plane3_y_error, "TKU_s3_y_error/D");
outputTree->Branch("TKU_s3_px_error", &TKU_plane3_px_error, "TKU_s3_px_error/D");
outputTree->Branch("TKU_s3_py_error", &TKU_plane3_py_error, "TKU_s3_py_error/D");
outputTree->Branch("TKU_s3_kappa_error", &TKU_plane3_kappa_error, "TKU_s3_kappa_error/D");
outputTree->Branch("TKU_s3_pz_error", &TKU_plane3_pz_error, "TKU_s3_pz_error/D");
outputTree->Branch("TKU_s4_x", &TKU_plane4_x, "TKU_s4_x/D"); // station 4
outputTree->Branch("TKU_s4_y", &TKU_plane4_y, "TKU_s4_y/D");
outputTree->Branch("TKU_s4_r", &TKU_plane4_r, "TKU_s4_r/D");
outputTree->Branch("TKU_s4_z", &TKU_plane4_z, "TKU_s4_z/D");
outputTree->Branch("TKU_s4_px", &TKU_plane4_px, "TKU_s4_px/D");
outputTree->Branch("TKU_s4_py", &TKU_plane4_py, "TKU_s4_py/D");
outputTree->Branch("TKU_s4_pz", &TKU_plane4_pz, "TKU_s4_pz/D");
outputTree->Branch("TKU_s4_pt", &TKU_plane4_pt, "TKU_s4_pt/D");
outputTree->Branch("TKU_s4_p", &TKU_plane4_p, "TKU_s4_p/D");
outputTree->Branch("TKU_s4_pull", &TKU_plane4_pull, "TKU_s4_pull/D");
outputTree->Branch("TKU_s4_x_error", &TKU_plane4_x_error, "TKU_s4_x_error/D");
outputTree->Branch("TKU_s4_y_error", &TKU_plane4_y_error, "TKU_s4_y_error/D");
outputTree->Branch("TKU_s4_px_error", &TKU_plane4_px_error, "TKU_s4_px_error/D");
outputTree->Branch("TKU_s4_py_error", &TKU_plane4_py_error, "TKU_s4_py_error/D");
outputTree->Branch("TKU_s4_kappa_error", &TKU_plane4_kappa_error, "TKU_s4_kappa_error/D");
outputTree->Branch("TKU_s4_pz_error", &TKU_plane4_pz_error, "TKU_s4_pz_error/D");
outputTree->Branch("TKU_s5_x", &TKU_plane5_x, "TKU_s5_x/D"); // station 1
outputTree->Branch("TKU_s5_y", &TKU_plane5_y, "TKU_s5_y/D");
outputTree->Branch("TKU_s5_r", &TKU_plane5_r, "TKU_s5_r/D");
outputTree->Branch("TKU_s5_z", &TKU_plane5_z, "TKU_s5_z/D");
outputTree->Branch("TKU_s5_px", &TKU_plane5_px, "TKU_s5_px/D");
outputTree->Branch("TKU_s5_py", &TKU_plane5_py, "TKU_s5_py/D");
outputTree->Branch("TKU_s5_pz", &TKU_plane5_pz, "TKU_s5_pz/D");
outputTree->Branch("TKU_s5_pt", &TKU_plane5_pt, "TKU_s5_pt/D");
outputTree->Branch("TKU_s5_p", &TKU_plane5_p, "TKU_s5_p/D");
outputTree->Branch("TKU_s5_pull", &TKU_plane5_pull, "TKU_s5_pull/D");
outputTree->Branch("TKU_s5_x_error", &TKU_plane5_x_error, "TKU_s5_x_error/D");
outputTree->Branch("TKU_s5_y_error", &TKU_plane5_y_error, "TKU_s5_y_error/D");
outputTree->Branch("TKU_s5_px_error", &TKU_plane5_px_error, "TKU_s5_px_error/D");
outputTree->Branch("TKU_s5_py_error", &TKU_plane5_py_error, "TKU_s5_py_error/D");
outputTree->Branch("TKU_s5_kappa_error", &TKU_plane5_kappa_error, "TKU_s5_kappa_error/D");
outputTree->Branch("TKU_s5_pz_error", &TKU_plane5_pz_error, "TKU_s5_pz_error/D");
outputTree->Branch("TKU_assumed_field", &TKU_assumed_field, "TKU_assumed_field/D");
outputTree->Branch("TKU_chiSquare", &TKU_chiSquare, "TKU_chiSquare/D");
outputTree->Branch("TKU_ndof", &TKU_ndof, "TKU_ndof/I");
outputTree->Branch("TKU_chiSquare_per_ndof", &TKU_chiSquare_per_ndof, "TKU_chiSquare_per_ndof/D");
outputTree->Branch("TKU_pattRec_r", &TKU_patternRecognition_R, "TKU_pattRec_r/D");
outputTree->Branch("TKU_pattRec_dipAngle", &TKU_patternRecognition_dipAngle, "TKU_pattRec_dipAngle/D");
outputTree->Branch("TKU_pattRec_x0", &TKU_patternRecognition_x0, "TKU_pattRec_x0/D");
outputTree->Branch("TKU_pattRec_y0", &TKU_patternRecognition_y0, "TKU_pattRec_y0/D");
outputTree->Branch("TKU_charge", &TKU_charge, "TKU_charge/I");
// cuts: these will be 0 or 1 depending on whether the fail (0) or pass (1) the cut
outputTree->Branch("cut_tof", &cut_tof, "cut_tof/I");
outputTree->Branch("cut_normalised_tof", &cut_normalised_tof, "cut_normalised_tof/I");
outputTree->Branch("cut_diffuser", &cut_diffuser, "cut_diffuser/I");
outputTree->Branch("cut_chindof", &cut_chindof, "cut_chindof/I");
outputTree->Branch("cut_tku_r", &cut_tku_r, "cut_tku_r/I");
outputTree->Branch("cut_one_tof0", &cut_one_tof0, "cut_one_tof0/I");
outputTree->Branch("cut_one_tof1", &cut_one_tof1, "cut_one_tof1/I");
outputTree->Branch("cut_one_track", &cut_one_track, "cut_one_track/I");
outputTree->Branch("cut_tof_p", &cut_tof_p, "cut_tof_p/I");
outputTree->Branch("cut_allPassed", &cut_allPassed, "cut_allPassed/I");
outputTree->Branch("cut_allButDiffuserPassed", &cut_allButDiffuserPassed, "cut_allButDiffuserPassed/I");
}
void BetterReadMAUS::Read(QString fileToOpen, QString fileToSaveAs, QString calibrationConstantsFile){ //, QString trackingFileName){
/*
* 1. read the calibration file
* 2. create the output root file
* 3. read the maus input file
* a. Get a spacepoint at TOF0, reconstruct its (x, y) using pmt times
* b. Get a spacepoint at TOF1, do the same
* c. Get a track in the upstream tracker
* d. Get the propagated track to the diffuser from Global Track Matching
*/
multi_track_counter = 0;
set_cut_values();
readCalibrationFile(calibrationConstantsFile);
define_root_file(fileToSaveAs);
MAUS::Data data;
irstream infile(fileToOpen.toStdString().c_str(), "Spill");
int count = 0;
last_event_number = 0;
mc_spill_counter = 1;
data_spills = false;
mc_spills = false;
// iterate over events:
while(infile >> readEvent != NULL){
infile >> branchName("data") >> data;
spill = data.GetSpill();
std::cout << count << "\n";
count++;
if(spill != NULL && spill->GetDaqEventType() == "physics_event"){
// Found a spill that contains data. Iterate over all its events...
readParticleEvent();
}
}
print_tof_plots();
outputFile->cd();
outputTree->Write();
outputFile->Write();
outputFile->Close();
}
void BetterReadMAUS::readParticleEvent(){
for(size_t i = 0; i < spill->GetReconEvents()->size(); ++i){
reset_particle_variables();
spill_number = spill->GetSpillNumber();
reconstructed_event_number = i;
std::cout << "Reading spill " << spill_number << ", event " << reconstructed_event_number << "\n";
if(spill_number == 0){
// data spill start at 0
std::cout << "Detected spill 0, is this data?\n";
data_spills = true;
}
// safety check versus MC files all having spill == 1:
if(spill_number == 1 && reconstructed_event_number < last_event_number && !data_spills){
mc_spill_counter += 1;
std::cout << "spill: " << spill_number << ", event: " << reconstructed_event_number
<< ", last event: " << last_event_number << ", mc_spill: " << mc_spill_counter << "\n";
if(!mc_spills){
// first time detecting that we're actually looking at a funky MC spill/event numbering
mc_spills = true;
}
}
last_event_number = reconstructed_event_number;
if(mc_spills){
spill_number = mc_spill_counter; // set spill number to a more appropriate count
std::cout << "....Adjusting spill number to " << spill_number << ", with event " << reconstructed_event_number << "\n";
std::cout << " spill: " << spill_number << ", event: " << reconstructed_event_number
<< ", last event: " << last_event_number << ", mc_spill: " << mc_spill_counter << "\n";
}
tof_event = (*spill->GetReconEvents())[i]->GetTOFEvent();
scifi_event = (*spill->GetReconEvents())[i]->GetSciFiEvent();
global_event = (*spill->GetReconEvents())[i]->GetGlobalEvent();
read_globals();
if(tof_event != NULL){
// there are hits at TOFs, estimate pz from them
particle_at_TOF0();
particle_at_TOF1();
reconstruct_TOF_momentum();
}
if(scifi_event != NULL){
particle_at_tracker(); // get tracker info
}
check_cuts();
outputTree->Fill();
}
}
void BetterReadMAUS::write_to_file(){
outputTree->Fill();
}
void BetterReadMAUS::particle_at_TOF0(){
/*
* Want to find one spacepoint, then find the slab hits associated with
* that spacepoint. Use those slab hits to improve the particles position
* information.
*/
MAUS::TOFEventSlabHit slab_hits = tof_event->GetTOFEventSlabHit();
MAUS::TOFEventSpacePoint space_points = tof_event->GetTOFEventSpacePoint();
MAUS::TOFSlabHit tof0_slab_hits;
MAUS::TOFSpacePoint tof0_space_points;
int horizontalHit, verticalHit;
reset_TOF0_variables(); // each new space point should be a new set of slab hits
horizontalHit = -1;
verticalHit = -1;
number_of_TOF0_spacepoints = space_points.GetTOF0SpacePointArray().size();
// 1. Loop over TOF0 space points:
//for(size_t i = 0; i < space_points.GetTOF0SpacePointArray().size(); ++i){
if(space_points.GetTOF0SpacePointArray().size() >=1){
reset_TOF0_variables(); // each new space point should be a new set of slab hits
horizontalHit = -1;
verticalHit = -1;
//tof0_space_points = space_points.GetTOF0SpacePointArray()[i];
tof0_space_points = space_points.GetTOF0SpacePointArray()[0]; // get first spacepoint
TOF0_horizontal_slab = tof0_space_points.GetHorizSlab(); // returns slabs oriented horizontally
TOF0_vertical_slab = tof0_space_points.GetVertSlab(); // returns slabs oriented vertically
TOF0_xPixel = tof0_space_points.GetGlobalPosX();
TOF0_yPixel = tof0_space_points.GetGlobalPosY();
TOF0_z = beamlineTracking_TOF0_zPosition;
TOF0_hitTime = tof0_space_points.GetTime();
// 2. Loop over slab hits and look for matches:
for(size_t j = 0; j < slab_hits.GetTOF0SlabHitArray().size(); ++j){
tof0_slab_hits = slab_hits.GetTOF0SlabHitArray()[j];
if(tof0_slab_hits.IsHorizontal()){
// horizontal slab hit
horizontalHit = tof0_slab_hits.GetSlab();
TOF0_horizontal_slab_tPlus = tof0_slab_hits.GetPmt0().GetTime();
TOF0_horizontal_slab_tMinus = tof0_slab_hits.GetPmt1().GetTime();
}
else if(tof0_slab_hits.IsVertical()){
verticalHit = tof0_slab_hits.GetSlab();
if(isMCRecon == true){
TOF0_vertical_slab_tPlus = tof0_slab_hits.GetPmt0().GetTime();
TOF0_vertical_slab_tMinus = tof0_slab_hits.GetPmt1().GetTime();
}
else{
TOF0_vertical_slab_tPlus = tof0_slab_hits.GetPmt1().GetTime();
TOF0_vertical_slab_tMinus = tof0_slab_hits.GetPmt0().GetTime();
}
}
else{
std::cerr << "Warning: Unusual plane hits at TOF0. Proceed with caution.\n";
}
apply_calibration_TOF0();
}
}
}
void BetterReadMAUS::particle_at_TOF1(){
/*
* Want to find one spacepoint, then find the slab hits associated with
* that spacepoint. Use those slab hits to improve the particles position
* information.
*/
MAUS::TOFEventSlabHit slab_hits = tof_event->GetTOFEventSlabHit();
MAUS::TOFEventSpacePoint space_points = tof_event->GetTOFEventSpacePoint();
MAUS::TOFSlabHit tof1_slab_hits;
MAUS::TOFSpacePoint tof1_space_points;
int horizontalHit, verticalHit;
// bool good_particle;
number_of_TOF1_spacepoints = space_points.GetTOF1SpacePointArray().size();
// 1. Loop over TOF1 space points:
// for(size_t i = 0; i < space_points.GetTOF1SpacePointArray().size(); ++i){
reset_TOF1_variables(); // each new space point should be a new set of slab hits
horizontalHit = -1;
verticalHit = -1;
// std::cout << "space_points.GetTOF1SpacePointArray().size() = " << space_points.GetTOF1SpacePointArray().size() << "\n";
if(space_points.GetTOF1SpacePointArray().size() >= 1){
reset_TOF1_variables(); // each new space point should be a new set of slab hits
horizontalHit = -1;
verticalHit = -1;
//tof1_space_points = space_points.GetTOF1SpacePointArray()[i];
tof1_space_points = space_points.GetTOF1SpacePointArray()[0]; // get the first spacepoint
TOF1_horizontal_slab = tof1_space_points.GetHorizSlab(); // returns slabs oriented horizontally
TOF1_vertical_slab = tof1_space_points.GetVertSlab(); // returns slabs oriented vertically
TOF1_xPixel = tof1_space_points.GetGlobalPosX();
TOF1_yPixel = tof1_space_points.GetGlobalPosY();
TOF1_z = beamlineTracking_TOF1_zPosition;
TOF1_hitTime = tof1_space_points.GetTime();
// 2. Loop over slab hits and look for matches:
for(size_t j = 0; j < slab_hits.GetTOF1SlabHitArray().size(); ++j){
tof1_slab_hits = slab_hits.GetTOF1SlabHitArray()[j];
if(tof1_slab_hits.IsHorizontal()){
// horizontal slab hit
horizontalHit = tof1_slab_hits.GetSlab();
TOF1_horizontal_slab_tMinus = tof1_slab_hits.GetPmt1().GetTime();
TOF1_horizontal_slab_tPlus = tof1_slab_hits.GetPmt0().GetTime();
}
else if(tof1_slab_hits.IsVertical()){
verticalHit = tof1_slab_hits.GetSlab();
if(isMCRecon==true){
TOF1_vertical_slab_tPlus = tof1_slab_hits.GetPmt0().GetTime();
TOF1_vertical_slab_tMinus = tof1_slab_hits.GetPmt1().GetTime();
}
else{