forked from ActarSimGroup/Actarsim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAnalysis_Angle.C
2291 lines (1872 loc) · 77.8 KB
/
Analysis_Angle.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
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
///////////////////////////////////////////////////////////////////
//*-- AUTHOR : Piotr Konczykowski
//*-- Date: 05/2016
//
// --------------------------------------------------------------
// This macro compares Horizontal and Vertical angles calculate
// by the steps information (GEANT4) or the pad's ones (digitization)
//
//
// --------------------------------------------------------------
// How to run this program:
// 1 - Run the simulation
// 2 - Run the digitization
// 3 - Run this macro inside root
// .L Analysis_Angle.C;
// Run()
// --------------------------------------------------------------
/////////////////////////////////////////////////////////////////
#include "TH1F.h"
#include "TH2F.h"
#include "TH3F.h"
#include "TF1.h"
#include "TFile.h"
#include "TTree.h"
#include "TProfile.h"
#include "TClonesArray.h"
#include "TCanvas.h"
#include "TSystem.h"
#include "TGraph.h"
#include "TSpline.h"
#include "TVector3.h"
#include "MTrack.h"
//#include "digit_piotr.h"
//#include "digit.h"
//#include "include/ActarSimPrimaryInfo.hh"
#include <iostream>
Int_t npeaks=20;
//void Run(Char_t *name="root_files/simFile.root",Char_t *name2="dig_files/digFile.root",Int_t event=0){
void Run(){
Int_t event=0;
//gROOT->ProcessLine(".L digit.h+");
//gROOT->ProcessLine(".L digit_piotr.h+");
//gSystem->Load("digit_david8_h.so");
gSystem->Load("libactar.sl");
gStyle->SetOptStat(1);
gStyle->SetOptFit(1);
//Flags
Bool_t TrackVisuFlag=1;
Bool_t TrackBragFlag=0;
Bool_t RangeFlag=0;
Bool_t DEdepFlag=0;
Bool_t AngleFlag=1;
Int_t NRun=200;
const Int_t NHAngle=6;
const Int_t NVAngle=3;
Double_t StopPoint=2.;//Stopping point will be MaxValue/StopPoint
gROOT->ProcessLine(".L digit.h+");
padsGeometry thePadsGeometry;
thePadsGeometry.SetGeometryValues(0.,0.,0.,155.,150.,105.,0.,0.,0.,2.,5.,5.);//For Phi and Theta study
//thePadsGeometry.SetGeometryValues(0.,0.,0.,37.,150.,105.,0.,0.,0.,2.,5.,5.);//For Phi study
//thePadsGeometry.SetGeometryValues(0.,0.,0.,105.,85.,105.,0.,0.,0.,2.,5.,5.);//For Theta study
//thePadsGeometry.SetGeometryValues(0.,0.,0.,37.,85.,133.,0.,0.,0.,2.,5.,5.);
//thePadsGeometry.SetGeometryValues(0,0,0,151.,151.,150,151.,2); //Rectangular Pads 30x30x30 cm^3 2mm pads
driftManager theDriftManager;
Double_t v_drift,sigma_trans,sigma_long;
Int_t nentries;
//theDriftManager.SetDriftVelocity(v_drift); // in mm/ns
//theDriftManager.SetDiffusionParameters(sigma_long,sigma_trans); // in mm^2/ns
//He:iC4H10 (9:1) 122.94 V/cm
//theDriftManager.SetDriftVelocity(6.865e-3);
//theDriftManager.SetDiffusionParameters(2.369e-5,2.892e-5);
//105 mbar iC4H10, E=2150/17
//theDriftManager.SetDriftVelocity(36.8e-3);
//theDriftManager.SetDiffusionParameters(18.89e-5,25.83e-5);
//1 atm iC4H10, E=2150/17
//theDriftManager.SetDriftVelocity(3.432e-3);
//theDriftManager.SetDiffusionParameters(0.8179e-5,0.7397e-5);
//#######iC4H10 (105.9mbar) Gas MagBoltz Values E=2150/17#########
theDriftManager.SetDriftVelocity(36.43e-3);
theDriftManager.SetDiffusionParameters(20.62e-5,24.94e-5);
cout<<"Drift Parameters are:"<<endl;
cout<<"v_drift---------> "<<theDriftManager.GetDriftVelocity()<<"mm/ns"<<endl;
cout<<"D_long----------> "<<theDriftManager.GetLongitudinalDiffusion()<<"mm^2/ns"<<endl;
cout<<"D_trans---------> "<<theDriftManager.GetTransversalDiffusion()<<"mm^2/ns"<<endl;
Double_t driftVelocity=theDriftManager.GetDriftVelocity();
Double_t xBox=thePadsGeometry.GetXLength();
Double_t yBox=thePadsGeometry.GetYLength();
Double_t zBox=thePadsGeometry.GetZLength();
cout<<"xBox "<<xBox<<" yBox "<<yBox<<" zBox "<<zBox<<endl;
Double_t PI=3.1415926535897932384626433;
Double_t deg=180./PI;
Double_t rad=PI/180.;
//==================================================================================//
for(const Int_t t=0;t<2;t++)MTrack* T[t]=new MTrack();
Double_t Start[3],Out[3],End[3],Stop[3];
Double_t TStart[3],TStop[3];
Double_t StrideStart[3],StrideStop[3],StrideStartInit[3],StrideStopInit[3],StrideStartFin[3],StrideStopFin[3];
Double_t StopX[3],StopY[3];
Double_t StartTrack[3]={150,10,150};
Double_t Qtot;
Double_t a,b;
Double_t astride,bstride;
Double_t IniPoint[2][2],FinPoint[2][2],IniFitPoint[2][2],FinFitPoint[2][2];
Double_t IniPoint1[2],FinPoint1[2],IniFitPoint1[2],FinFitPoint1[2];
Double_t IniPoint2[2],FinPoint2[2],IniFitPoint2[2],FinFitPoint2[2];
Double_t PointA[3],PointB[3];
Double_t range;
Double_t RangeA,RangeB,RangeAB;
Double_t RangeX,RangeY,RangeXY,RangeW1,RangeW2,RangeW3,RangeP1,RangeP2,RangeP3,RangeG4;
Double_t DeltaRXY_M[NHAngle][NVAngle],DeltaRXY_S[NHAngle][NVAngle];
Double_t DeltaRP1_M[NHAngle][NVAngle],DeltaRP2_M[NHAngle][NVAngle],DeltaRP3_M[NHAngle][NVAngle];
Double_t DeltaRP1_S[NHAngle][NVAngle],DeltaRP2_S[NHAngle][NVAngle],DeltaRP3_S[NHAngle][NVAngle];
Double_t DeltaRW1_M[NHAngle][NVAngle],DeltaRW2_M[NHAngle][NVAngle],DeltaRW3_M[NHAngle][NVAngle];
Double_t DeltaRW1_S[NHAngle][NVAngle],DeltaRW2_S[NHAngle][NVAngle],DeltaRW3_S[NHAngle][NVAngle];
Double_t phi;
Double_t theta;
Double_t VAngle;
Double_t HAngle;
Double_t StrideHAngle,TotStrideHAngle;
Double_t Angle3D;
Double_t LazyG4HAngle;
TSpline3 *bragRP2;
TSpline3 *bragRP3;
TSpline3 *bragRW;
TSpline3 *bragX;
TSpline3 *bragY;
TSpline3 *bragR1;
TSpline3 *bragR2;
Double_t padSize = thePadsGeometry.GetPadSize();
//Int_t padType = thePadsGeometry.GetPadType();
//Int_t padLayout= thePadsGeometry.GetPadLayout();
//Double_t sideBlankSpace = thePadsGeometry.GetSideBlankSpace();
// Double_t rHexagon = thePadsGeometry.GetRHexagon();
Double_t tracked_position;
Double_t tracked_positionV;
const Int_t numberOfRows = thePadsGeometry.GetNumberOfRows();
const Int_t numberOfColumns= thePadsGeometry.GetNumberOfColumns();
cout<<"Number of Rows "<<numberOfRows<<" Number of Columns "<<numberOfColumns<<endl;
//Int_t Rmin=0, Rmax=31;
//Int_t Cmin=0, Cmax=127; //Cmax=63;
Int_t Rmin=0, Rmax=numberOfRows-1;
Int_t Cmin=0, Cmax=numberOfColumns-1; //Cmax=63;
//Char_t *name="root_files/sim_files/simFile.root";
//Char_t *name="root_files/sim_files/simFile_3alpha_iC4H10_105mbar_VA0_z100.root";
//Char_t *name="root_files/sim_files/simFile_3alpha_iC4H10_105mbar_HA-80_-70_-60_-50_-45_-40_-30_-20_-10.root";
//Char_t *name="root_files/sim_files/simFile_3alpha_iC4H10_105mbar_HA80_70_60_50_45_40_30_20_10.root";
//Char_t *name="root_files/sim_files/simFile_gasBox37x150x105_3alpha_iC4H10_105mbar_VA0.root";
//Char_t *name="root_files/sim_files/simFile_gasBox37x150x105_3alpha_iC4H10_105mbar_VA-80_-70_-60_-50_-45_-40_-30_-20_-10.root";
//Char_t *name="root_files/sim_files/simFile_gasBox37x150x105_3alpha_iC4H10_105mbar_VA80_70_60_50_45_40_30_20_10.root";
//Char_t *name="root_files/sim_files/simFile_gasBox105x85x105_alpha_5.8MeV_VA0.root";
//Char_t *name="root_files/sim_files/simFile_gasBox105x85x105_alpha_5.8MeV_VA0_pos_x1_y15_z-90.root";
//Char_t *name="root_files/sim_files/simFile_gasBox155x150x105_alpha_5.8MeV_VA0.root";
//Char_t *name="root_files/sim_files/simFile_gasBox155x150x105_alpha_5.8MeV_HA-80to80.root";
Char_t *name="root_files/sim_files/simFile_gasBox155x150x105_alpha_5.8MeV_HA-80to80_2000.root";
//Char_t *name="root_files/sim_files/simFile_gasBox155x150x105_alpha_5.8MeV_HA-75to75.root";
//Char_t *name="root_files/sim_files/simFile_gasBox155x150x105_alpha_5.8MeV_HA-75to75_2000.root";
//Char_t *name="root_files/sim_files/simFile_gasBox155x150x105_alpha_5.8MeV_HA0x5.root";
//Char_t *name2="root_files/dig_files/digFile.root";
//Char_t *name2="root_files/dig_files/digFile_3alpha_iC4H10_105mbar_VA0_z100.root";
//Char_t *name2="root_files/dig_files/digFile_3alpha_iC4H10_105mbar_HA-80_-70_-60_-50_-45_-40_-30_-20_-10.root";
//Char_t *name2="root_files/dig_files/digFile_3alpha_iC4H10_105mbar_HA80_70_60_50_45_40_30_20_10.root";
//Char_t *name2="root_files/dig_files/digFile_gasBox37x150x105_3alpha_iC4H10_105mbar_VA0.root";
//Char_t *name2="root_files/dig_files/digFile_gasBox37x150x105_3alpha_iC4H10_105mbar_VA-80_-70_-60_-50_-45_-40_-30_-20_-10.root";
//Char_t *name2="root_files/dig_files/digFile_gasBox37x150x105_3alpha_iC4H10_105mbar_VA80_70_60_50_45_40_30_20_10.root";
//Char_t *name2="root_files/dig_files/digFile_gasBox105x85x105_alpha_5.8MeV_VA0.root";
//Char_t *name2="root_files/dig_files/digFile_gasBox105x85x105_alpha_5.8MeV_VA0_piotrdigit.root";
//Char_t *name2="root_files/dig_files/digFile_gasBox105x85x105_alpha_5.8MeV_VA0_centerdigit.root";
//Char_t *name2="root_files/dig_files/digFile_gasBox105x85x105_alpha_5.8MeV_VA0_pos_x1_y15_z-90.root";
//Char_t *name2="root_files/dig_files/digFile_gasBox155x150x105_alpha_5.8MeV_VA0.root";
//Char_t *name2="root_files/dig_files/digFile_gasBox155x150x105_alpha_5.8MeV_HA-80to80.root";
Char_t *name2="root_files/dig_files/digFile_gasBox155x150x105_alpha_5.8MeV_HA-80to80_2000.root";
//Char_t *name2="root_files/dig_files/digFile_gasBox155x150x105_alpha_5.8MeV_HA-75to75.root";
//Char_t *name2="root_files/dig_files/digFile_gasBox155x150x105_alpha_5.8MeV_HA-75to75_2000.root";
//Char_t *name2="root_files/dig_files/digFile_gasBox155x150x105_alpha_5.8MeV_HA0x5.root";
//Event info;
TFile *simFile=new TFile(name);
cout<<"Opening simFile : "<<name<<endl;
//digitization data, output of digitizationMacro
TFile *digFile=new TFile(name2);
cout<<"Opening digFile : "<<name2<<endl;
if(!digFile)
return;
else{
//getting the trees
TTree *simTree=(TTree*)simFile->Get("The_ACTAR_Event_Tree");
TTree *digTree=(TTree*)digFile->Get("digiTree");
if(event==0)
nentries=digTree->GetEntries();
else
nentries=event;
cout<<"digit entries: "<<nentries<<endl;
Float_t *ta=new Float_t[nentries];
Float_t *tb=new Float_t[nentries];
//BeamInfo Branch
ActarSimBeamInfo *beamInfo = 0; // beamInfo MUST be initialized to point to a NULL or valid object
simTree->SetBranchAddress("beamInfo",&beamInfo);
//PrimaryInfoCA
TClonesArray *primaryInfoCA=new TClonesArray("ActarSimPrimaryInfo",1);
TBranch *branchPrimaryInfo=simTree->GetBranch("primaryInfo");
branchPrimaryInfo->SetAddress(&primaryInfoCA);
branchPrimaryInfo->SetAutoDelete(kTRUE);
ActarSimPrimaryInfo *thePrimaryInfo=new ActarSimPrimaryInfo;
//ClonesArray to the tracks
TClonesArray *simpleTrackCA=new TClonesArray("ActarSimSimpleTrack",400);
TBranch *branchSimpleTrack= simTree->GetBranch("simpleTrackData");
branchSimpleTrack->SetAddress(&simpleTrackCA);
branchSimpleTrack->SetAutoDelete(kTRUE);
ActarSimSimpleTrack *simpleTrack=new ActarSimSimpleTrack;
/* //ClonesArray to the silicon Hits
TClonesArray *silHitsCA=new TClonesArray("ActarSimSilHit",200);
TBranch *branchSilHits=simTree->GetBranch("silHits");
//branchSilHits->SetAddress(&silHitsCA);
//branchSilHits->SetAutoDelete(kTRUE);
ActarSimSilHit *silHit=new ActarSimSilHit;*/
//ClonesArray to the signal
TClonesArray *padSignalCA=new TClonesArray("ActarPadSignal",4000);
digTree->SetBranchAddress("padSignals",&padSignalCA);
ActarPadSignal *padSignal=new ActarPadSignal;
TGraph *SimTrack=new TGraph();
TGraph *SimTrackE=new TGraph();
TGraph *G4EdepGraph=new TGraph();
TH1F *h_G4Edep=new TH1F("G4Track","GEANT4 Track Bragg",100, 0.,200.);
TH2F *h_G4Edep_2=new TH2F("G4Track2","GEANT4 Track Bragg 2",100, 0.,200.,100,0.,0.5);
TH1F *h_braggP1=new TH1F("TrackBraggP1","Track Bragg, Projection on track, bin=1mm",200, 0.,200.);
TH1F *h_braggP2=new TH1F("TrackBraggP2","Track Bragg, Projection on track, bin=2mm",100, 0.,200.);
TH1F *h_braggP3=new TH1F("TrackBraggP3","Track Bragg, Projection on track, bin=3mm",100, 0.,300.);
TH1F *h_braggW1=new TH1F("TrackBraggW1","Track Bragg, Projection on track proportional to pads size, bin=1mm",200, 0.,200.);
TH1F *h_braggW2=new TH1F("TrackBraggW2","Track Bragg, Projection on track proportional to pads size, bin=2mm",100, 0.,200.);
TH1F *h_braggW3=new TH1F("TrackBraggW3","Track Bragg, Projection on track proportional to pads size, bin=3mm",100, 0.,300.);
TH1F *h_braggX=new TH1F("TrackBraggX","Track Bragg, X projection",100, 0.,200.);
TH1F *h_braggY=new TH1F("TrackBraggY","Track Bragg, Y projection",100, 0.,200.);
TH1F *h_braggTest=new TH1F("TrackBraggTest","Track Bragg Test",10, 0.,10.);
TH1F *h_DeltaRXY=new TH1F("h_DeltaRXY","Range_{Rec}- Range_{GEANT4}",600, -30.,30.);
TH1F *h_DeltaRW1=new TH1F("h_DeltaRW1","Range_{Rec}- Range_{GEANT4}",600, -30.,30.);
TH1F *h_DeltaRW2=new TH1F("h_DeltaRW2","Range_{Rec}- Range_{GEANT4}",600, -30.,30.);
TH1F *h_DeltaRW3=new TH1F("h_DeltaRW3","Range_{Rec}- Range_{GEANT4}",600, -30.,30.);
TH1F *h_DeltaRP1=new TH1F("h_DeltaRP1","Range_{Rec}- Range_{GEANT4}",600, -30.,30.);
TH1F *h_DeltaRP2=new TH1F("h_DeltaRP2","Range_{Rec}- Range_{GEANT4}",600, -30.,30.);
TH1F *h_DeltaRP3=new TH1F("h_DeltaRP3","Range_{Rec}- Range_{GEANT4}",600, -30.,30.);
TH1F *h_DEdepR=new TH1F("h_DEdepR","E_{dep}(sim)-E_{dep}(calc), Projection on track, bin=2mm",100, -1.,1.);
TH1F *h_DEdepR45=new TH1F("h_DEdepR45","E_{dep}(sim)-E_{dep}(calc), Projection on track, bin=2#sqrt{2}mm",100, -1.,1.);
TH1F *h_DEdepRPiotr=new TH1F("h_DEdepRPiotr","E_{dep}(sim)-E_{dep}(calc), Projection on track proportional to pads size, bin=2mm",100, -1.,1.);
TH1F *h_DEdepX=new TH1F("h_DEdepX","E_{dep}(sim)-E_{dep}(calc), X proj",100, -1.,1.);
TH1F *h_DEdepY=new TH1F("h_DEdepY","E_{dep}(sim)-E_{dep}(calc), Y proj",100, -5.,5.);
TH1F *h_DEdepXY=new TH1F("h_DEdepXY","E_{dep}(sim)-E_{dep}(calc), XY proj",100, -1.,1.);
TH1F *h_DeltaVAngle=new TH1F("h_DeltaVAngle","#phi_{GEANT4}-#phi_{REC}",1000, -0.5,0.5);
//TH1F *h_DeltaHAngle=new TH1F("h_DeltaHAngle","#theta_{GEANT4}(from each stride, weighted by length)-#theta_{REC}",100, -5.,5.);
TH1F *h_DeltaHAngle=new TH1F("h_DeltaHAngle","#theta_{GEANT4}(from each stride)-#theta_{REC}",600, -0.1,0.1);
TH1F *h_TotDeltaHAngle=new TH1F("h_TotDeltaHAngle","#theta_{GEANT4}-#theta_{REC}",300, -5.,5.);
TH1F *h_DeltaLazyHAngle=new TH1F("h_DeltaLazyHAngle","#theta_{GEANT4}(from starting and stopping points)-#theta_{REC}",300, -5.,5.);
TH1F *hHorizAngle=new TH1F("hHorizAngle","Horizontal Angle",360,-90,90);
TH1F *hVertiAngle=new TH1F("hVertiAngle","Vertical Angle",360,-90,90);
TH1F *h_HAngle=new TH1F("h_HAngle","#theta_{REC}",300, -5.,5.);
TH1F *h_TotHAngle=new TH1F("h_TotHAngle","#theta_{GEANT4}",300, -5.,5.);
TString MultiDeltaHAngleName[17];
TString MultiDeltaHAngle[17];
TH1F *h_MultiDeltaHAngle[17];
for(Int_t i=0; i<17; i++)
{
MultiDeltaHAngleName[i]=TString::Format("h_MultiDeltaHAngle%d",i*10-80);
MultiDeltaHAngle[i]=TString::Format("#theta_{GEANT4}-#theta_{REC}, #theta beam = %d deg",i*10-80);
h_MultiDeltaHAngle[i]=new TH1F(MultiDeltaHAngleName[i],MultiDeltaHAngle[i],600, -0.1,0.1);
}
TH1F *h_DeltaVAngle80=new TH1F("h_DeltaVAngle80","#theta_{GEANT4}-#theta_{REC}, #theta beam = 80 deg",200, -0.5,1);
TH1F *h_DeltaVAngle70=new TH1F("h_DeltaVAngle70","#theta_{GEANT4}-#theta_{REC}, #theta beam = 70 deg",200, -0.5,1);
TH1F *h_DeltaVAngle60=new TH1F("h_DeltaVAngle60","#theta_{GEANT4}-#theta_{REC}, #theta beam = 60 deg",200, -0.5,1);
TH1F *h_DeltaVAngle50=new TH1F("h_DeltaVAngle50","#theta_{GEANT4}-#theta_{REC}, #theta beam = 50 deg",200, -0.5,1);
TH1F *h_DeltaVAngle45=new TH1F("h_DeltaVAngle45","#theta_{GEANT4}-#theta_{REC}, #theta beam = 45 deg",200, -0.5,1);
TH1F *h_DeltaVAngle40=new TH1F("h_DeltaVAngle40","#theta_{GEANT4}-#theta_{REC}, #theta beam = 40 deg",200, -0.5,1);
TH1F *h_DeltaVAngle30=new TH1F("h_DeltaVAngle30","#theta_{GEANT4}-#theta_{REC}, #theta beam = 30 deg",200, -0.5,1);
TH1F *h_DeltaVAngle20=new TH1F("h_DeltaVAngle20","#theta_{GEANT4}-#theta_{REC}, #theta beam = 20 deg",200, -0.5,1);
TH1F *h_DeltaVAngle10=new TH1F("h_DeltaVAngle10","#theta_{GEANT4}-#theta_{REC}, #theta beam = 10 deg",200, -0.5,1);
TH1F *h_DeltaVAnglem80=new TH1F("h_DeltaVAnglem80","#theta_{GEANT4}-#theta_{REC}, #theta beam = -80 deg",500, -0.4,0.);
TH1F *h_DeltaVAnglem70=new TH1F("h_DeltaVAnglem70","#theta_{GEANT4}-#theta_{REC}, #theta beam = -70 deg",500, -0.4,0.);
TH1F *h_DeltaVAnglem60=new TH1F("h_DeltaVAnglem60","#theta_{GEANT4}-#theta_{REC}, #theta beam = -60 deg",500, -0.4,0.);
TH1F *h_DeltaVAnglem50=new TH1F("h_DeltaVAnglem50","#theta_{GEANT4}-#theta_{REC}, #theta beam = -50 deg",500, -0.4,0.);
TH1F *h_DeltaVAnglem45=new TH1F("h_DeltaVAnglem45","#theta_{GEANT4}-#theta_{REC}, #theta beam = -45 deg",500, -0.4,0.);
TH1F *h_DeltaVAnglem40=new TH1F("h_DeltaVAnglem40","#theta_{GEANT4}-#theta_{REC}, #theta beam = -40 deg",500, -0.4,0.);
TH1F *h_DeltaVAnglem30=new TH1F("h_DeltaVAnglem30","#theta_{GEANT4}-#theta_{REC}, #theta beam = -30 deg",500, -0.4,0.);
TH1F *h_DeltaVAnglem20=new TH1F("h_DeltaVAnglem20","#theta_{GEANT4}-#theta_{REC}, #theta beam = -20 deg",500, -0.4,0.);
TH1F *h_DeltaVAnglem10=new TH1F("h_DeltaVAnglem10","#theta_{GEANT4}-#theta_{REC}, #theta beam = -10 deg",500, -0.4,0.);
//TH2F *visu_charge=new TH2F("visu_charge","visu_charge",64,0,64,32,0,32);
//TH2F *visu_time=new TH2F("visu_time","visu_time",64,0,64,32,0,32);
//TH2F *visu_charge=new TH2F("visu_charge","visu_charge",128,0,128,32,0,32);
//TH2F *visu_time=new TH2F("visu_time","visu_time",128,0,128,32,0,32);
TH2F *visu_charge=new TH2F("visu_charge","visu_charge",numberOfColumns,0,numberOfColumns,numberOfRows,0,numberOfRows);
TH2F *visu_time=new TH2F("visu_time","visu_time",numberOfColumns,0,numberOfColumns,numberOfRows,0,numberOfRows);
//Double_t threshold = 0.0034;
Double_t threshold = 0.;
Double_t thresholdADC = threshold*1e9/30;
Double_t sigma_time=3;//ns
Double_t dE_sim=0;
//Matrix for the charge map
Double_t **padCharge=new Double_t*[numberOfRows];
Double_t **padTime=new Double_t*[numberOfRows];
Double_t **padHeight=new Double_t*[numberOfRows];
for(Int_t i=0;i<numberOfRows;i++){
padCharge[i]=new Double_t[numberOfColumns];
padTime[i]=new Double_t[numberOfColumns];
padHeight[i]=new Double_t[numberOfColumns];
}
if(TrackBragFlag){
Can_brag=new TCanvas("Can_brag","Can_brag",900,600);
Can_brag->Divide(3,3);
}
if(TrackVisuFlag){
//Can_sil=new TCanvas("Can_sil","Can_sil",900,900);
Can_track=new TCanvas("Can_track","Can_track",900,900);
//Can_track->Divide(1,2);
//Can_track->cd(2)->Divide(2,1);
//Can_fig=new TCanvas("Can_fig","Can_fig",900,900);
//Can_fig->Divide(2,2);
}
Int_t nb=0;
//*********************************************************************************************************//
//*********************************************************************************************************//
//** **//
//** Event Loop **//
//** **//
//*********************************************************************************************************//
//*********************************************************************************************************//
for (Long64_t jentry=0;jentry<nentries;jentry++)
//for (Long64_t jentry=16000;jentry<nentries;jentry++)
//for (Long64_t jentry=0;jentry<nentries;jentry+=25)
{
if(jentry%100==0 && jentry!=0)cout<<"."<<flush;
if(jentry%500==0)cout<<jentry<<endl;
if(jentry%NRun==0 && jentry!=0){
h_DeltaRW1->Reset();
h_DeltaRW2->Reset();
h_DeltaRW3->Reset();
h_DeltaRP1->Reset();
h_DeltaRP2->Reset();
h_DeltaRP3->Reset();
h_DeltaRXY->Reset();
}
//cout<<endl<<"NEW EVENT "<<jentry<<endl<<endl;
for(Int_t u=0;u<numberOfRows;u++){
for(Int_t k=0;k<numberOfColumns;k++){
padCharge[u][k]=0.;
padTime[u][k]=0.;
padHeight[u][k]=0.;
}
}
for(Int_t i=0;i<3;i++){
Start[i]=Out[i]=End[i]=Stop[i]=0.;
StopX[i]=StopY[i]=0.;
}
a=b=0.;
astride=bstride=0.;
T[0]->ResetLines();
T[1]->ResetLines();
visu_charge->Reset();
visu_time->Reset();
padSignalCA->Clear();
simpleTrackCA->Clear();
nb+=digTree->GetEvent(jentry);
nb+=simTree->GetEvent(jentry);
Int_t nbprimaries=primaryInfoCA->GetEntries();
//cout<<" PRIMARIES "<<nbprimaries<<endl;
Int_t numberofpads=padSignalCA->GetEntries();
//cout<<"# Pads fired "<< numberofpads<<endl;
//Loop on TClonesArray
Int_t counter=0;
if( numberofpads>0){
Double_t maxenergydeposit=0;
Double_t maxenergytime=0;
Int_t maxRow=0;
for(Int_t k=0;k<numberofpads;k++){
padSignal=(ActarPadSignal*)padSignalCA->At(k);
Double_t thisCharge = padSignal->GetChargeDeposited();
Double_t thisTime = (padSignal->GetInitTime()+padSignal->GetFinalTime())/2.;
Double_t thisSigmaTime=padSignal->GetSigmaTime();
//thisTime=gRandom->Gaus(thisTime,thisSigmaTime);
//cout<<"Time "<<thisTime<<" Sigma Time "<<thisSigmaTime<<endl;
Int_t PadRow=padSignal->GetPadRow();
Int_t PadColumn=padSignal->GetPadColumn();
//cout<<k<<" "<<PadColumn<<" "<<PadRow<<" "<<thisCharge<<" "<<thisTime<<endl;
if(thisCharge>=maxenergydeposit){
maxenergydeposit=thisCharge;
maxenergytime=thisTime;
maxRow=PadRow;
}
if (thisCharge!=0){
padCharge[padSignal->GetPadRow()-1][padSignal->GetPadColumn()-1]
+= thisCharge;
padTime[padSignal->GetPadRow()-1][padSignal->GetPadColumn()-1]
+= thisCharge*thisTime;
//cout<<"Event "<<jentry<<" k "<<k<<" Row "<<padSignal->GetPadRow()-1<<" Col "<<padSignal->GetPadColumn()-1<<" PadCharge "<<padCharge[padSignal->GetPadRow()-1][padSignal->GetPadColumn()-1]<<endl;
}
Int_t r=padSignal->GetPadRow()-1;
Int_t c=padSignal->GetPadColumn()-1;
}//Loop on ActarPadSignals
}
////////////////////////////////////////////////////
////////////// Loop on columns & rows //////////////
////////////////////////////////////////////////////
for(Int_t c=0;c<numberOfColumns;c++){ //LOOP on Columns
for(Int_t r=0;r<numberOfRows;r++){ //LOOP on Rows
if(padCharge[r][c] >thresholdADC){
//cout<<"Sigma Time "<<thisSigmaTime<<endl;
padTime[r][c]/=padCharge[r][c];
padTime[r][c]=gRandom->Gaus(padTime[r][c],sigma_time);
//padTime[r][c]=gRandom->Gaus(padTime[r][c],thisSigmaTime);
padCharge[r][c]*=30/1e9;
//padCharge[r][c]*=15/1e9;
padHeight[r][c]=padTime[r][c]*driftVelocity;
//cout<<c<<" "<<r<<" "<<padHeight[r][c]<<endl;
if(r>150 && padCharge[r][c]>0)cout<<"Row "<<r<<" Col "<<c<<" padCharge "<<padCharge[r][c]<<" padTime "<<padTime[r][c]<<endl;
if(TrackVisuFlag){
visu_charge->SetBinContent(c+1.,r+1,padCharge[r][c]);
visu_time->SetBinContent(c+1.,r+1.,padTime[r][c]);
}
}
else{
padCharge[r][c]=-1;
padTime[r][c]=-1;
padHeight[r][c]=-1;
}
}//End of Loop on Rows
}//End of Loop on Columns
//FitMat(padCharge,0,31,0,63,threshold,a,b);
FitMat(padCharge,Rmin,Rmax,Cmin,Cmax,threshold,a,b);
IniPoint[0][0]=0; IniPoint[1][0]=a*IniPoint[0][0]+b/2;
//FinPoint[1][0]=32; FinPoint[0][0]=(FinPoint[1][0]-b/2)/a; //if horizontal angle>0
//FinPoint[0][0]=64; FinPoint[1][0]=a*FinPoint[0][0]+b/2; //if horizontal angle=0
FinPoint[0][0]=numberOfColumns; FinPoint[1][0]=FinPoint[0][0]*a+b/2;
//Double_t chi2=FitMat3D(padCharge,padHeight,0,31,0,63,threshold,T[0]);
Double_t chi2=FitMat3D(padCharge,padHeight,Rmin,Rmax,Cmin,Cmax,threshold,T[0]);
Int_t t=0;
if(T[0]->Xm-T[0]->Xh!=0){
Double_t tstart=(0-T[0]->Xh)/(T[0]->Xm-T[0]->Xh);
Start[0]=0.;
Start[1]=tstart*(T[0]->Ym-T[0]->Yh)+T[0]->Yh;
Start[2]=tstart*(T[0]->Zm-T[0]->Zh)+T[0]->Zh;
Double_t tstop=((Double_t)numberOfColumns*2-T[0]->Xh)/(T[0]->Xm-T[0]->Xh);
Stop[0]=(Double_t)numberOfColumns*2;
Stop[1]=tstop*(T[0]->Ym-T[0]->Yh)+T[0]->Yh;
Stop[2]=tstop*(T[0]->Zm-T[0]->Zh)+T[0]->Zh;
Double_t trstart=(10-T[0]->Xh)/(T[0]->Xm-T[0]->Xh);
TStart[0]=10.;
TStart[1]=trstart*(T[0]->Ym-T[0]->Yh)+T[0]->Yh;
TStart[2]=trstart*(T[0]->Zm-T[0]->Zh)+T[0]->Zh;
}
/*
if(T[t]->Xm-T[t]->Xh!=0){
Double_t tstart=(-T[0]->Xh)/(T[0]->Xm-T[0]->Xh);
Double_t tend=(32*2-T[0]->Xh)/(T[0]->Xm-T[0]->Xh); //if horizontal angle=0
}
Start[0]=tstart*(T[t]->Xm-T[t]->Xh)+T[t]->Xh;
Start[1]=tstart*(T[t]->Ym-T[t]->Yh)+T[t]->Yh;
Start[2]=tstart*(T[t]->Zm-T[t]->Zh)+T[t]->Zh;
End[0]=tend*(T[t]->Xm-T[t]->Xh)+T[t]->Xh;
End[1]=tend*(T[t]->Ym-T[t]->Yh)+T[t]->Yh;
End[2]=tend*(T[t]->Zm-T[t]->Zh)+T[t]->Zh;
VAngle=TMath::ATan((End[2]-Start[2])/TMath::Sqrt((End[0]-Start[0])*(End[0]-Start[0])+(End[1]-Start[1])*(End[1]-Start[1])))*deg;
if(End[0]-Start[0]>0){
HAngle=TMath::ATan((End[1]-Start[1])/(End[0]-Start[0]))*deg;
Angle3D=TMath::ATan(TMath::Sqrt((End[1]-Start[1])*(End[1]-Start[1])+(End[2]-Start[2])*(End[2]-Start[2]))/(End[0]-Start[0]))*deg;
}
else{
HAngle=180.+TMath::ATan((End[1]-Start[1])/(End[0]-Start[0]))*deg;
Angle3D=180.+TMath::ATan(TMath::Sqrt((End[1]-Start[1])*(End[1]-Start[1])+(End[2]-Start[2])*(End[2]-Start[2]))/(End[0]-Start[0]))*deg;
}
*/
VAngle=TMath::ATan((Stop[2]-Start[2])/TMath::Sqrt((Stop[0]-Start[0])*(Stop[0]-Start[0])+(Stop[1]-Start[1])*(Stop[1]-Start[1])))*deg;
/*
if(Stop[0]-Start[0]>0){
HAngle=TMath::ATan((Stop[1]-Start[1])/(Stop[0]-Start[0]))*deg;
Angle3D=TMath::ATan(TMath::Sqrt((Stop[1]-Start[1])*(Stop[1]-Start[1])+(Stop[2]-Start[2])*(Stop[2]-Start[2]))/(Stop[0]-Start[0]))*deg;
}
else{
HAngle=180.+TMath::ATan((Stop[1]-Start[1])/(Stop[0]-Start[0]))*deg;
Angle3D=180.+TMath::ATan(TMath::Sqrt((Stop[1]-Start[1])*(Stop[1]-Start[1])+(Stop[2]-Start[2])*(Stop[2]-Start[2]))/(Stop[0]-Start[0]))*deg;
}
*/
HAngle=TMath::ATan(a)*deg;
hVertiAngle->Fill(VAngle);
hHorizAngle->Fill(HAngle);
//cout<<"VAngle "<<VAngle<<" HAngle "<<HAngle<<" Angle3D "<<Angle3D<<" HAngle from a "<<TMath::ATan(a)*deg<<" Diff Theta from Start/Stop and a "<<HAngle-TMath::ATan(a)*deg<<endl;
Double_t OS;//Distance from Track intersection with x=0 plane and (10,10,100) point
OS=TMath::Sqrt((Start[0]-StartTrack[0])*(Start[0]-StartTrack[0])+(Start[1]-StartTrack[1])*(Start[1]-StartTrack[1])+(Start[2]-StartTrack[2])*(Start[2]-StartTrack[2]));
//cout<<"OS "<<OS<<endl;
if(DEdepFlag){
Double_t dE_digW=0.;
Double_t value=0.;
Double_t step=2*TMath::Abs(RangeB-RangeA)/100.;
for(Double_t val=RangeA;val<=RangeB;val=val+step){
if(val>RangeA){
dE_digW+=step*(value+bragRW2->Eval(val))/2/2;//this is because the bragR binning is *2
value=bragRW2->Eval(val);
}
//cout<<"val "<<val<<" value "<<value<<" dE_dig "<<dE_dig<<endl;
}
//cout<<"dE_digPiotr "<<dE_digPiotr<<" MeV"<<endl;
Double_t dE_digP2=0.;
value=0.;
//Double_t step=2*TMath::Abs(RangeAB)/100.;
step=2*TMath::Abs(RangeB-RangeA)/100.;
//cout<<"step "<<step<<endl;
//for(Double_t val=0;val<=RangeAB;val=val+step){
for(Double_t val=RangeA;val<=RangeB;val=val+step){
//Double_t value=bragR->Eval(val);
//if(val>0){
if(val>RangeA){
dE_digP2+=step*(value+bragRP2->Eval(val))/2/2;//this is because the bragR binning is *2
value=bragRP2->Eval(val);
//dE_dig+=step*value;
}
//cout<<"val "<<val<<" value "<<value<<" dE_dig "<<dE_dig<<endl;
}
//cout<<"dE_dig "<<dE_dig<<" MeV"<<endl;
}
//Getting the simulated track
Int_t nbOfStrides=simpleTrackCA->GetEntries();
//const Int_t NStride=nbOfStrides;
//cout<<"nbOfStrides "<<nbOfStrides<<" NStride "<<NStride<<endl;
const Int_t NStride=500;
Double_t StrideX[NStride],StrideY[NStride],StrideZ[NStride];
Double_t StrideQ[NStride];
Double_t StrideLength;
Double_t TotalStrideLength=0;
Double_t StrideCenter[3];
Double_t G4Range,G4Edep;
Double_t posmaxG4=0;
Double_t Elast=0;
Double_t dE_sim2=0;
dE_sim=0;
Int_t m1=0;
Int_t m2=0;
Double_t G4VAngle=0;
Double_t G4HAngle=0;
Double_t G4StrideHAngle=0;
Double_t TotG4HAngle=0;
Double_t G4QTot=0.;
SimTrack->Set(0);
G4EdepGraph->Set(0);
if(nbOfStrides>0){
for(Int_t m=0;m<nbOfStrides;m++){
simpleTrack=(ActarSimSimpleTrack *)simpleTrackCA->At(m);
//cout<<simpleTrack->GetZPre()<<" "<<simpleTrack->GetXPre()<<" "<<simpleTrack->GetZPost()<<" "<<simpleTrack->GetXPost()<<endl;
//cout<<simpleTrack->GetEnergyStride()<<" "<<simpleTrack->GetParticleEnergy()<<endl;
//cout<<m<<" "<<simpleTrack->GetXPre()<<" "<<simpleTrack->GetYPre()<<" "<<simpleTrack->GetZPre()<<endl;
//if(m==0)cout<<"XPre "<<simpleTrack->GetXPre()<<" ZPre "<<simpleTrack->GetZPre()<<" YPre "<<simpleTrack->GetYPre()<<endl;
//In ActarSim Y <-> Z and origin at the center of gas box for X and Z
//StrideCenter[0]=(simpleTrack->GetXPost()+simpleTrack->GetXPre()+2*32)/2;
//StrideCenter[2]=(simpleTrack->GetYPost()+simpleTrack->GetYPre()+2*85)/2;
//StrideCenter[1]=(simpleTrack->GetZPost()+simpleTrack->GetZPre()+2*128)/2;
StrideCenter[0]=(simpleTrack->GetXPost()+simpleTrack->GetXPre()+2*numberOfRows)/2;
//StrideCenter[2]=(simpleTrack->GetYPost()+simpleTrack->GetYPre()+2*85)/2;
StrideCenter[2]=(simpleTrack->GetYPost()+simpleTrack->GetYPre()+2*yBox)/2;
StrideCenter[1]=(simpleTrack->GetZPost()+simpleTrack->GetZPre()+2*numberOfColumns)/2;
//if(m==0)cout<<"StrideCenter[x] "<<StrideCenter[0]<<" StrideCenter[y] "<<StrideCenter[1]<<" StrideCenter[z] "<<StrideCenter[2]<<endl;
StrideX[m]=StrideCenter[1];
StrideY[m]=StrideCenter[0];
StrideZ[m]=StrideCenter[2];
StrideLength=TMath::Power(simpleTrack->GetXPost()-simpleTrack->GetXPre(),2);
//StrideLength+=TMath::Power(simpleTrack->GetYPost()-simpleTrack->GetYPre(),2);
StrideLength+=TMath::Power(simpleTrack->GetZPost()-simpleTrack->GetZPre(),2);
StrideLength=TMath::Sqrt(StrideLength);
TotalStrideLength+=StrideLength;
G4Range=OS+TMath::Sqrt(TMath::Power(StrideCenter[0]-StartTrack[0],2) + TMath::Power(StrideCenter[1]-StartTrack[1],2) + TMath::Power(StrideCenter[2]-StartTrack[2],2));
//G4Range=TMath::Sqrt(TMath::Power(StrideCenter[1]-StartTrack[1],2) + TMath::Power(StrideCenter[2]-StartTrack[2],2));
G4Edep=simpleTrack->GetEnergyStride()/StrideLength;
G4QTot+=simpleTrack->GetEnergyStride();
StrideQ[m]=simpleTrack->GetEnergyStride();//or /StrideLength ???
//cout<<"S "<<S<<" STRIDEX "<<STRIDEX[S]<<" STRIDEY "<<STRIDEY[S]<<" STRIDENET "<<STRIDENET[S]<<endl;
//if(TrackVisuFlag)SimTrack->SetPoint(m,simpleTrack->GetZPre()/2+64,simpleTrack->GetXPre()/2+16);
if(TrackVisuFlag)SimTrack->SetPoint(m,simpleTrack->GetZPre()/2+numberOfColumns/2,simpleTrack->GetXPre()/2+numberOfRows/2);
/*
if(m==0){StrideStartInit[0]=simpleTrack->GetZPre()+128; StrideStartInit[1]=simpleTrack->GetXPre()+32;}
if(m==nbOfStrides-1){StrideStopFin[0]=simpleTrack->GetZPost()+128; StrideStopFin[1]=simpleTrack->GetXPost()+32;}
StrideStart[1]=simpleTrack->GetXPre()+32;
StrideStart[0]=simpleTrack->GetZPre()+128;
StrideStop[1]=simpleTrack->GetXPost()+32;
StrideStop[0]=simpleTrack->GetZPost()+128;
*/
if(m==0){StrideStartInit[0]=simpleTrack->GetZPre()+numberOfColumns; StrideStartInit[1]=simpleTrack->GetXPre()+numberOfRows;}
if(m==nbOfStrides-1){StrideStopFin[0]=simpleTrack->GetZPost()+numberOfColumns; StrideStopFin[1]=simpleTrack->GetXPost()+numberOfRows;}
StrideStart[1]=simpleTrack->GetXPre()+numberOfRows;
StrideStart[0]=simpleTrack->GetZPre()+numberOfColumns;
StrideStop[1]=simpleTrack->GetXPost()+numberOfRows;
StrideStop[0]=simpleTrack->GetZPost()+numberOfColumns;
if(StrideStop[0]-StrideStart[0]>0){
StrideHAngle=TMath::ATan((StrideStop[1]-StrideStart[1])/(StrideStop[0]-StrideStart[0]))*deg;
}
else{
StrideHAngle=180.+TMath::ATan((StrideStop[1]-StrideStart[1])/(StrideStop[0]-StrideStart[0]))*deg;
}
if(StrideStop[0]-StrideStartInit[0]>0){
TotStrideHAngle=TMath::ATan((StrideStop[1]-StrideStartInit[1])/(StrideStop[0]-StrideStartInit[0]))*deg;
}
else{
TotStrideHAngle=180.+TMath::ATan((StrideStop[1]-StrideStartInit[1])/(StrideStop[0]-StrideStartInit[0]))*deg;
}
//cout<<"Stride "<<m<<" StrideHAngle "<<StrideHAngle<<" StrideLength "<<StrideLength<<" Stride Energy "<<simpleTrack->GetEnergyStride()<<endl;
TotG4HAngle+=TotStrideHAngle;
//G4HAngle+=StrideHAngle;
G4StrideHAngle+=StrideHAngle*StrideLength;
//G4HAngle+=StrideHAngle*simpleTrack->GetEnergyStride();
}
if(RangeFlag){
//posmaxG4=G4Range;
//cout<<"XPre "<<simpleTrack->GetXPre()<<" ZPre "<<simpleTrack->GetZPre()<<" YPre "<<simpleTrack->GetYPre()<<endl;
//cout<<"XPost "<<simpleTrack->GetXPost()<<" ZPost "<<simpleTrack->GetZPost()<<" YPost "<<simpleTrack->GetYPost()<<endl;
//posmaxG4=OS+TMath::Sqrt(TMath::Power(simpleTrack->GetXPost()+32-StartTrack[0],2) + TMath::Power(simpleTrack->GetZPost()-5-StartTrack[1],2) + TMath::Power(simpleTrack->GetYPost()+85-StartTrack[2],2));
posmaxG4=OS+TMath::Sqrt(TMath::Power(simpleTrack->GetXPost()+32-StartTrack[0],2) + TMath::Power(simpleTrack->GetZPost()-5-StartTrack[1],2) + TMath::Power(simpleTrack->GetYPost()+150-StartTrack[2],2));
//cout<<"G4Range "<<G4Range<<" posmaxG4 "<<posmaxG4<<endl;
RangeX=TMath::Sqrt((StopX[0]-StartTrack[0])*(StopX[0]-StartTrack[0])+(StopX[1]-StartTrack[1])*(StopX[1]-StartTrack[1])+(StopX[2]-StartTrack[2])*(StopX[2]-StartTrack[2]));
RangeY=TMath::Sqrt((StopY[0]-StartTrack[0])*(StopY[0]-StartTrack[0])+(StopY[1]-StartTrack[1])*(StopY[1]-StartTrack[1])+(StopY[2]-StartTrack[2])*(StopY[2]-StartTrack[2]));
RangeXY=TMath::Cos(HAngle*rad)*TMath::Cos(HAngle*rad)*RangeX+TMath::Sin(HAngle*rad)*TMath::Sin(HAngle*rad)*RangeY;
}
}
FitStride(StrideQ, StrideX, StrideY, StrideZ, nbOfStrides, threshold, astride, bstride);
Double_t stridechi2=FitStride3D(StrideQ, StrideX, StrideY, StrideZ, nbOfStrides, threshold, T[1]);
if(T[1]->Xm-T[1]->Xh!=0){
Double_t tstart=(0-T[1]->Xh)/(T[1]->Xm-T[1]->Xh);
Start[0]=0.;
Start[1]=tstart*(T[1]->Ym-T[1]->Yh)+T[1]->Yh;
Start[2]=tstart*(T[1]->Zm-T[1]->Zh)+T[1]->Zh;
Double_t tstop=((Double_t)numberOfColumns*2-T[1]->Xh)/(T[1]->Xm-T[1]->Xh);
Stop[0]=(Double_t)numberOfColumns*2;
Stop[1]=tstop*(T[1]->Ym-T[1]->Yh)+T[1]->Yh;
Stop[2]=tstop*(T[1]->Zm-T[1]->Zh)+T[1]->Zh;
Double_t trstart=(10-T[1]->Xh)/(T[1]->Xm-T[1]->Xh);
TStart[0]=10.;
TStart[1]=trstart*(T[1]->Ym-T[1]->Yh)+T[1]->Yh;
TStart[2]=trstart*(T[1]->Zm-T[1]->Zh)+T[1]->Zh;
}
G4VAngle=TMath::ATan((Stop[2]-Start[2])/TMath::Sqrt((Stop[0]-Start[0])*(Stop[0]-Start[0])+(Stop[1]-Start[1])*(Stop[1]-Start[1])))*deg;
/*
if(Stop[0]-Start[0]>0){
G4HAngle=TMath::ATan((Stop[1]-Start[1])/(Stop[0]-Start[0]))*deg;
}
else if(Stop[0]-Start[0]<0){
G4HAngle=180.+TMath::ATan((Stop[1]-Start[1])/(Stop[0]-Start[0]))*deg;
}
else cout<<"Stop[0] = Start[0]"<<endl;
//cout<<"G4QTot "<<G4QTot<<endl;
*/
G4HAngle=TMath::ATan(astride)*deg;
TotG4HAngle/=nbOfStrides;
//G4HAngle/=nbOfStrides;
G4StrideHAngle/=TotalStrideLength;
//G4HAngle/=G4QTot;
LazyG4HAngle=TMath::ATan((StrideStopFin[1]-StrideStartInit[1])/(StrideStopFin[0]-StrideStartInit[0]))*deg;
//cout<<"ATan a "<<atan(a)*deg<<" Stride aTan a "<<atan(astride)*deg<<" G4HAngle "<<G4HAngle<<" Diff ATan a "<<atan(a)*deg-atan(astride)*deg<<" Diff TMath::ATan a "<<TMath::ATan(a)*deg-TMath::ATan(astride)*deg<<endl;
//cout<<"LazyG4HAngle "<<LazyG4HAngle<<" G4HAngle "<<G4HAngle<<" TotG4HAngle "<<TotG4HAngle<<" G4HAngle2 "<<G4HAngle2<<" HAngle "<<HAngle<<endl;
//cout<<"TotG4HAngle "<<TotG4HAngle<<" G4HAngle2 "<<G4HAngle2<<" HAngle "<<HAngle<<endl;
//cout<<"G4VAngle "<<G4VAngle<<" VAngle "<<VAngle<<" diff "<<G4VAngle-VAngle<<endl;
h_DeltaVAngle->Fill(G4VAngle-VAngle);
h_DeltaHAngle->Fill(G4HAngle-HAngle);
h_TotDeltaHAngle->Fill(TotG4HAngle-HAngle);
h_DeltaLazyHAngle->Fill(LazyG4HAngle-HAngle);
h_HAngle->Fill(HAngle);
h_TotHAngle->Fill(TotG4HAngle);
//Int_t NEvent=500;
Int_t NEvent=2000;
h_MultiDeltaHAngle[(int)jentry/NEvent]->Fill(G4HAngle-HAngle);
/*
if(jentry<500)h_DeltaVAngle80->Fill(G4VAngle-VAngle);
else if(jentry<1000)h_DeltaVAngle70->Fill(G4VAngle-VAngle);
else if(jentry<1500)h_DeltaVAngle60->Fill(G4VAngle-VAngle);
else if(jentry<2000)h_DeltaVAngle50->Fill(G4VAngle-VAngle);
else if(jentry<2500)h_DeltaVAngle45->Fill(G4VAngle-VAngle);
else if(jentry<3000)h_DeltaVAngle40->Fill(G4VAngle-VAngle);
else if(jentry<3500)h_DeltaVAngle30->Fill(G4VAngle-VAngle);
else if(jentry<4000)h_DeltaVAngle20->Fill(G4VAngle-VAngle);
else if(jentry<4500)h_DeltaVAngle10->Fill(G4VAngle-VAngle);
*/
/*
if(jentry<500)h_DeltaVAnglem80->Fill(G4VAngle-VAngle);
else if(jentry<1000)h_DeltaVAnglem70->Fill(G4VAngle-VAngle);
else if(jentry<1500)h_DeltaVAnglem60->Fill(G4VAngle-VAngle);
else if(jentry<2000)h_DeltaVAnglem50->Fill(G4VAngle-VAngle);
else if(jentry<2500)h_DeltaVAnglem45->Fill(G4VAngle-VAngle);
else if(jentry<3000)h_DeltaVAnglem40->Fill(G4VAngle-VAngle);
else if(jentry<3500)h_DeltaVAnglem30->Fill(G4VAngle-VAngle);
else if(jentry<4000)h_DeltaVAnglem20->Fill(G4VAngle-VAngle);
else if(jentry<4500)h_DeltaVAnglem10->Fill(G4VAngle-VAngle);
*/
if(TrackBragFlag){
//cout<<"RangeA[0] "<<RangeA[0]<<" RangeB[0] "<<RangeB[0]<<endl;
//cout<<"RangeA[1] "<<RangeA[1]<<" RangeB[1] "<<RangeB[1]<<endl;
Can_brag->cd(1);
h_braggP1->Draw();
bragRP1->Draw("same");
if(RangeFlag){
TLine lineP1(posmaxP1, 0, posmaxP1, 10e7);
lineP1.SetLineWidth(3);
lineP1.Draw("same");
TLine lineG4(posmaxG4, 0, posmaxG4, 10e7);
lineG4.SetLineWidth(3);
lineG4.SetLineColor(kRed);
lineG4.Draw("same");
}
Can_brag->cd(2);
h_braggP2->Draw();
bragRP2->Draw("same");
if(RangeFlag){
TLine lineP2(posmaxP2, 0, posmaxP2, 10e7);
lineP2.SetLineWidth(3);
lineP2.Draw("same");
lineG4.Draw("same");
}
if(DEdepFlag){
TLine lineya1(RangeA[0], 0, RangeA[0], 10e7);
//TLine lineya1(0, 0, 0, 10e7);
lineya1.SetLineWidth(3);
lineya1.Draw("same");
TLine lineyb1(RangeB[0], 0, RangeB[0], 10e7);
//TLine lineyb1(RangeO[0], 0, RangeO[0], 10e7);
lineyb1.Draw("same");
lineyb1.SetLineWidth(3);
}
Can_brag->cd(3);
h_braggP3->Draw();
bragRP3->Draw("same");
if(RangeFlag){
TLine lineP3(posmaxP3, 0, posmaxP3, 10e7);
lineP3.SetLineWidth(3);
lineP3.Draw("same");
lineG4.Draw("same");
}
if(DEdepFlag){
TLine linemin45(RangeA[0], 0, RangeA[0], 10e7);
linemin45.SetLineWidth(3);
linemin45.Draw("same");
TLine linemax45(RangeB[0], 0, RangeB[0], 10e7);
linemax45.Draw("same");
linemax45.SetLineWidth(3);
}
Can_brag->cd(4);
h_braggW1->Draw();
bragRW1->Draw("same");
if(RangeFlag){
TLine lineW1(posmaxW1, 0, posmaxW1, 10e7);
lineW1.SetLineWidth(3);
lineW1.Draw("same");
lineG4.Draw("same");
}
Can_brag->cd(5);
h_braggW2->Draw();
bragRW2->Draw("same");
if(RangeFlag){
TLine lineW2(posmaxW2, 0, posmaxW2, 10e7);
lineW2.SetLineWidth(3);
lineW2.Draw("same");
lineG4.Draw("same");
}
if(DEdepFlag){
TLine lineminW(RangeA[0], 0, RangeA[0], 10e7);
lineminW.SetLineWidth(3);
lineminW.Draw("same");
TLine linemaxW(RangeB[0], 0, RangeB[0], 10e7);
linemaxW.Draw("same");
linemaxW.SetLineWidth(3);
}
Can_brag->cd(6);
h_braggW3->Draw();
bragRW3->Draw("same");
if(RangeFlag){
TLine lineW3(posmaxW3, 0, posmaxW3, 10e7);
lineW3.SetLineWidth(3);
lineW3.Draw("same");
lineG4.Draw("same");
}
Can_brag->cd(7);
h_braggX->Draw();
bragX->Draw("same");
if(RangeFlag){
TLine lineX(posmaxX, 0, posmaxX, 10e7);
lineX.SetLineWidth(3);
lineX.Draw("same");
}
if(DEdepFlag){
TLine linemin2(MinCol*2, 0, MinCol*2, 10e7);
linemin2.SetLineWidth(3);
linemin2.Draw("same");
TLine linemax2(MaxCol*2, 0, MaxCol*2, 10e7);
linemax2.Draw("same");
linemax2.SetLineWidth(3);
}
Can_brag->cd(8);
h_braggY->Draw();
bragY->Draw("same");
if(RangeFlag){
TLine lineY(posmaxY, 0, posmaxY, 10e7);
lineY.SetLineWidth(3);
lineY.Draw("same");
}
if(DEdepFlag){
TLine linemin3(MinRow*2, 0, MinRow*2, 10e7);
linemin3.SetLineWidth(3);