-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathastrogamv3_analysis1_file.pro
More file actions
2469 lines (2056 loc) · 121 KB
/
astrogamv3_analysis1_file.pro
File metadata and controls
2469 lines (2056 loc) · 121 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
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
; astrogamv3_analysis_file.pro - Description
; ---------------------------------------------------------------------------------
; Processing the THELSIM ASTROGAM simulation:
; - Tracker
; - AC
; - Calorimeter
; ---------------------------------------------------------------------------------
; Output:
; - all files are created in a self-descripted subdirectory of the current directory. If the directory is not present it is created by the IDL script.
; ---------> FITS files
; - G4.RAW.ASTROGAM<version>.<phys>List.<sim_type>.<strip>.<point>.<n_in>ph.<energy>MeV.<theta>.<phi>.<file>.fits
; - L0.5.ASTROGAM<version>.<phys>List.<sim_type>.<strip>.<point>.<n_in>ph.<energy>MeV.<theta>.<phi>.<file>.fits
; - KALMAN.ASTROGAM<version>.<phys>List.<sim_type>.<strip>.<point>.<n_in>ph.<energy>MeV.<theta>.<phi>.<file>.fits
; - G4.AC.ASTROGAM<version>.<phys>List.<sim_type>.<strip>.<point>.<n_in>ph.<energy>MeV.<theta>.<phi>.<file>.fits
; - G4.CAL.ASTROGAM<version>.<phys>List.<sim_type>.<strip>.<point>.<n_in>ph.<energy>MeV.<theta>.<phi>.<file>.fits
; ----------------------------------------------------------------------------------
; copyright : (C) 2014 Valentina Fioretti
; email : fioretti@iasfbo.inaf.it
; ----------------------------------------------
; Usage:
; astrogamv3_analysis_file
; ---------------------------------------------------------------------------------
; Notes:
; Each THELSIM FITS files individually processed
pro astrogamv3_analysis_file
; Variables initialization
N_in = 0UL ;--> Number of emitted photons
part_type = '' ; particle type
n_fits = 0 ;--> Number of FITS files produced by the simulation
astrogam_version = ''
sim_type = 0
py_list = 0
ene_range = 0
ene_type = 0.
ene_min = 0
ene_max = 0
theta_type = 0
phi_type = 0
source_g = 0
ene_min = 0
ene_max = 0
cal_flag = 0
passive_flag = 0
energy_thresh = 0
read, astrogam_version, PROMPT='% - Enter ASTROGAM release (e.g. V1.4):'
read, sim_type, PROMPT='% - Enter simulation type [0 = Mono, 1 = Range, 2 = Chen, 3: Vela, 4: Crab, 4: G400]:'
read, py_list, PROMPT='% - Enter the Physics List [0 = QGSP_BERT_EMV, 100 = ARGO, 300 = FERMI, 400 = ASTROMEV]:'
read, N_in, PROMPT='% - Enter the number of emitted particles:'
read, part_type, PROMPT='% - Enter the particle type [ph = photons, mu = muons, g = geantino, p = proton]:'
read, n_fits, PROMPT='% - Enter number of FITS files:'
read, ene_range, PROMPT='% - Enter energy distribution [0 = mono, 1 = range]:'
if (ene_range EQ 0) then begin
read, ene_type, PROMPT='% - Enter energy [MeV]:'
if (ene_type GE 1) then ene_type = strtrim(string(long(ene_type)),1)
if (ene_type LT 1) then ene_type = STRMID(STRTRIM(STRING(ene_type),1),0,5)
endif
if (ene_range EQ 1) then begin
read, ene_min, PROMPT='% - Enter miminum energy [MeV]:'
read, ene_max, PROMPT='% - Enter maximum energy [MeV]:'
ene_type = strtrim(string(ene_min),1)+'.'+strtrim(string(ene_max),1)
endif
read, theta_type, PROMPT='% - Enter theta:'
read, phi_type, PROMPT='% - Enter phi:'
read, source_g, PROMPT='% - Enter source geometry [0 = Point, 1 = Plane]:'
if (py_list EQ 0) then begin
py_dir = 'QGSP_BERT_EMV'
py_name = 'QGSP_BERT_EMV'
endif
if (py_list EQ 100) then begin
py_dir = '100List'
py_name = '100List'
endif
if (py_list EQ 300) then begin
py_dir = '300List'
py_name = '300List'
endif
if (py_list EQ 400) then begin
py_dir = 'ASTROMEV'
py_name = 'ASTROMEV'
endif
if (sim_type EQ 0) then begin
sim_name = 'MONO'
endif
if (sim_type EQ 1) then begin
sim_name = 'RANGE'
endif
if (sim_type EQ 2) then begin
sim_name = 'CHEN'
endif
if (sim_type EQ 3) then begin
sim_name = 'VELA'
endif
if (sim_type EQ 4) then begin
sim_name = 'CRAB'
endif
if (sim_type EQ 5) then begin
sim_name = 'G410'
endif
if (source_g EQ 0) then begin
sdir = '/Point'
sname = 'Point'
endif
if (source_g EQ 1) then begin
sdir = '/Plane'
sname = 'Plane'
endif
read, isStrip, PROMPT='% - Strip/Pixels activated?:'
read, repli, PROMPT='% - Strips/Pixels replicated?:'
read, cal_flag, PROMPT='% - Is Cal present? [0 = false, 1 = true]:'
read, ac_flag, PROMPT='% - Is AC present? [0 = false, 1 = true]:'
if ((cal_flag EQ 0) AND (ac_flag EQ 0)) then dir_cal = '/OnlyTracker'
if ((cal_flag EQ 1) AND (ac_flag EQ 0)) then dir_cal = '/noAC'
if ((cal_flag EQ 0) AND (ac_flag EQ 1)) then dir_cal = '/noCAL'
if ((cal_flag EQ 1) AND (ac_flag EQ 1)) then dir_cal = ''
read, passive_flag, PROMPT='% - Is Passive present? [0 = false, 1 = true]:'
if (passive_flag EQ 0) then dir_passive = ''
if (passive_flag EQ 1) then dir_passive = '/WithPassive'
read, energy_thresh, PROMPT='% - Enter energy threshold [keV]:'
if (astrogam_version EQ 'V1.0') then begin
if (isStrip EQ 0) then stripDir = 'NoStrip/'
if ((isStrip EQ 1) AND (repli EQ 0)) then stripDir = 'StripNoRepli/'
if ((isStrip EQ 1) AND (repli EQ 1)) then stripDir = 'StripRepli/'
if (isStrip EQ 0) then stripname = 'NOSTRIP'
if ((isStrip EQ 1) AND (repli EQ 0)) then stripname = 'STRIP'
if ((isStrip EQ 1) AND (repli EQ 1)) then stripname = 'STRIP.REPLI'
endif
if (astrogam_version EQ 'V2.0') then begin
if (isStrip EQ 0) then stripDir = 'NoPixel/'
if ((isStrip EQ 1) AND (repli EQ 0)) then stripDir = 'PixelNoRepli/'
if ((isStrip EQ 1) AND (repli EQ 1)) then stripDir = 'PixelRepli/'
if (isStrip EQ 0) then stripname = 'NOPIXEL'
if ((isStrip EQ 1) AND (repli EQ 0)) then stripname = 'PIXEL'
if ((isStrip EQ 1) AND (repli EQ 1)) then stripname = 'PIXEL.REPLI'
endif
if (astrogam_version EQ 'V3.0') then begin
if (isStrip EQ 0) then stripDir = 'NoPixel/'
if ((isStrip EQ 1) AND (repli EQ 0)) then stripDir = 'PixelNoRepli/'
if ((isStrip EQ 1) AND (repli EQ 1)) then stripDir = 'PixelRepli/'
if (isStrip EQ 0) then stripname = 'NOPIXEL'
if ((isStrip EQ 1) AND (repli EQ 0)) then stripname = 'PIXEL'
if ((isStrip EQ 1) AND (repli EQ 1)) then stripname = 'PIXEL.REPLI'
endif
; setting specific agile version variables
if (astrogam_version EQ 'V3.0') then begin
; --------> volume ID
tracker_top_vol_start = 1090000
tracker_bottom_vol_start = 1000000
tracker_top_bot_diff = 90000
cal_vol_start = 50000
cal_vol_end = 64399
ac_vol_start = 301
ac_vol_end = 350
panel_S = [301, 302, 303]
panel_D = [311, 312, 313]
panel_F = [321, 322, 323]
panel_B = [331, 332, 333]
panel_top = 340
; --------> design
N_tray = 70l
N_plane = N_tray*1
N_strip = 2480l
tray_side = 60.016 ;cm
strip_side = Tray_side/N_strip
bar_side = 0.5 ; cm (side of calorimeter bars)
n_bars = 120*120 ; number of calorimeter bars
; --------> processing
; accoppiamento capacitivo
;acap = [0.035, 0.045, 0.095, 0.115, 0.38, 1., 0.38, 0.115, 0.095, 0.045, 0.035]
; tracker energy threshold (0.25 MIP)
E_th = float(energy_thresh) ; keV
E_th_cal = 40. ; keV
; calorimeter bar attenuation for diods A and B
;att_a_x = [0.0281,0.0285,0.0281,0.0269,0.0238,0.0268,0.0274,0.0296,0.0272,0.0348,0.0276,0.0243, 0.0312,0.0287,0.0261]
;att_b_x = [0.0256,0.0286,0.0294,0.0259,0.0235,0.0264,0.0276,0.0295,0.0223,0.0352,0.0293,0.0256,0.0290,0.0289,0.0266]
;att_a_y = [0.0298,0.0281,0.0278,0.0301,0.0296,0.0242,0.0300,0.0294,0.0228,0.0319,0.0290,0.0304,0.0274,0.0282,0.0267]
;att_b_y = [0.0279,0.0254,0.0319,0.0260,0.0310,0.0253,0.0289,0.0268,0.0231,0.0319,0.0252,0.0242,0.0246,0.0258,0.0268]
endif
run_path = GETENV('BGRUNS')
filepath = run_path + '/ASTROGAM'+astrogam_version+sdir+'/theta'+strtrim(string(theta_type),1)+'/'+stripDir+py_dir+dir_cal+dir_passive+'/'+ene_type+'MeV.'+sim_name+'.'+strtrim(string(theta_type),1)+'theta.'+strtrim(string(N_in),1)+part_type
print, 'ASTROGAM simulation path: ', filepath
outdir = './ASTROGAM'+astrogam_version+sdir+'/theta'+strtrim(string(theta_type),1)+'/'+stripDir+py_dir+'/'+sim_name+'/'+ene_type+'MeV/'+strtrim(string(N_in),1)+part_type+dir_cal+dir_passive+'/'+strtrim(string(energy_thresh),1)+'keV'
print, 'ASTROGAM outdir path: ', outdir
CheckOutDir = DIR_EXIST( outdir)
if (CheckOutDir EQ 0) then spawn,'mkdir -p ./ASTROGAM'+astrogam_version+sdir+'/theta'+strtrim(string(theta_type),1)+'/'+stripDir+py_dir+'/'+sim_name+'/'+ene_type+'MeV/'+strtrim(string(N_in),1)+part_type+dir_cal+dir_passive+'/'+strtrim(string(energy_thresh),1)+'keV'
for ifile=0, n_fits-1 do begin
print, 'Reading the THELSIM file.....', ifile+1
; Tracker
event_id = -1l
vol_id = -1l
moth_id = -1l
energy_dep = -1.
ent_x = -1.
ent_y = -1.
ent_z = -1.
exit_x = -1.
exit_y = -1.
exit_z = -1.
theta_ent = -1.
phi_ent = -1.
theta_exit = -1.
phi_exit = -1.
; Calorimeter
event_id_cal = -1l
vol_id_cal = -1l
moth_id_cal = -1l
energy_dep_cal = -1.
ent_x_cal = -1.
ent_y_cal = -1.
ent_z_cal = -1.
exit_x_cal = -1.
exit_y_cal = -1.
exit_z_cal = -1.
theta_ent_cal = -1.
phi_ent_cal = -1.
theta_exit_cal = -1.
phi_exit_cal = -1.
; AC
event_id_ac = -1l
vol_id_ac = -1l
moth_id_ac = -1l
energy_dep_ac = -1.
ent_x_ac = -1.
ent_y_ac = -1.
ent_z_ac = -1.
exit_x_ac = -1.
exit_y_ac = -1.
exit_z_ac = -1.
theta_ent_ac = -1.
phi_ent_ac = -1.
theta_exit_ac = -1.
phi_exit_ac = -1.
filename = filepath+'/xyz.'+strtrim(string(ifile), 1)+'.fits.gz'
struct = mrdfits(filename,$
1, $
structyp = 'astrogam', $
/unsigned)
for k=0l, n_elements(struct)-1l do begin
; Reading the tracker (events with E > 0)
if ((struct(k).VOLUME_ID GE tracker_bottom_vol_start) or (struct(k).MOTHER_ID GE tracker_bottom_vol_start)) then begin
;if (struct(k).MOTHER_ID GE tracker_bottom_vol_start) then begin
if (part_type EQ 'g') then begin
struct(k).E_DEP = 100.
event_id = [event_id, struct(k).EVT_ID]
vol_id = [vol_id, struct(k).VOLUME_ID]
moth_id = [moth_id, struct(k).MOTHER_ID]
energy_dep = [energy_dep, struct(k).E_DEP]
ent_x = [ent_x, struct(k).X_ENT]
ent_y = [ent_y, struct(k).Y_ENT]
ent_z = [ent_z, struct(k).Z_ENT]
exit_x = [exit_x, struct(k).X_EXIT]
exit_y = [exit_y, struct(k).Y_EXIT]
exit_z = [exit_z, struct(k).Z_EXIT]
theta_ent = [theta_ent, (180./!PI)*acos(-(struct(k).MDZ_ENT))]
phi_ent = [phi_ent, (180./!PI)*atan((struct(k).MDY_ENT)/(struct(k).MDX_ENT))]
theta_exit = [theta_exit, (180./!PI)*acos(-(struct(k).MDZ_EXIT))]
phi_exit = [phi_exit, (180./!PI)*atan((struct(k).MDY_EXIT)/(struct(k).MDX_EXIT))]
endif else begin
if (struct(k).E_DEP GT 0.d) then begin
event_id = [event_id, struct(k).EVT_ID]
vol_id = [vol_id, struct(k).VOLUME_ID]
moth_id = [moth_id, struct(k).MOTHER_ID]
energy_dep = [energy_dep, struct(k).E_DEP]
ent_x = [ent_x, struct(k).X_ENT]
ent_y = [ent_y, struct(k).Y_ENT]
ent_z = [ent_z, struct(k).Z_ENT]
exit_x = [exit_x, struct(k).X_EXIT]
exit_y = [exit_y, struct(k).Y_EXIT]
exit_z = [exit_z, struct(k).Z_EXIT]
theta_ent = [theta_ent, (180./!PI)*acos(-(struct(k).MDZ_ENT))]
phi_ent = [phi_ent, (180./!PI)*atan((struct(k).MDY_ENT)/(struct(k).MDX_ENT))]
theta_exit = [theta_exit, (180./!PI)*acos(-(struct(k).MDZ_EXIT))]
phi_exit = [phi_exit, (180./!PI)*atan((struct(k).MDY_EXIT)/(struct(k).MDX_EXIT))]
endif
endelse
endif
; Reading the calorimeter
if (cal_flag EQ 1) then begin
if ((struct(k).VOLUME_ID GE cal_vol_start) AND (struct(k).VOLUME_ID LE cal_vol_end)) then begin
if (part_type EQ 'g') then begin
event_id_cal = [event_id_cal, struct(k).EVT_ID]
vol_id_cal = [vol_id_cal, struct(k).VOLUME_ID]
moth_id_cal = [moth_id_cal, struct(k).MOTHER_ID]
energy_dep_cal = [energy_dep_cal, struct(k).E_DEP]
ent_x_cal = [ent_x_cal, struct(k).X_ENT]
ent_y_cal = [ent_y_cal, struct(k).Y_ENT]
ent_z_cal = [ent_z_cal, struct(k).Z_ENT]
exit_x_cal = [exit_x_cal, struct(k).X_EXIT]
exit_y_cal = [exit_y_cal, struct(k).Y_EXIT]
exit_z_cal = [exit_z_cal, struct(k).Z_EXIT]
theta_ent_cal = [theta_ent_cal, (180./!PI)*acos(-(struct(k).MDZ_ENT))]
phi_ent_cal = [phi_ent_cal, (180./!PI)*atan((struct(k).MDY_ENT)/(struct(k).MDX_ENT))]
theta_exit_cal = [theta_exit_cal, (180./!PI)*acos(-(struct(k).MDZ_EXIT))]
phi_exit_cal = [phi_exit_cal, (180./!PI)*atan((struct(k).MDY_EXIT)/(struct(k).MDX_EXIT))]
endif else begin
if (struct(k).E_DEP GT 0.d) then begin
event_id_cal = [event_id_cal, struct(k).EVT_ID]
vol_id_cal = [vol_id_cal, struct(k).VOLUME_ID]
moth_id_cal = [moth_id_cal, struct(k).MOTHER_ID]
energy_dep_cal = [energy_dep_cal, struct(k).E_DEP]
ent_x_cal = [ent_x_cal, struct(k).X_ENT]
ent_y_cal = [ent_y_cal, struct(k).Y_ENT]
ent_z_cal = [ent_z_cal, struct(k).Z_ENT]
exit_x_cal = [exit_x_cal, struct(k).X_EXIT]
exit_y_cal = [exit_y_cal, struct(k).Y_EXIT]
exit_z_cal = [exit_z_cal, struct(k).Z_EXIT]
theta_ent_cal = [theta_ent_cal, (180./!PI)*acos(-(struct(k).MDZ_ENT))]
phi_ent_cal = [phi_ent_cal, (180./!PI)*atan((struct(k).MDY_ENT)/(struct(k).MDX_ENT))]
theta_exit_cal = [theta_exit_cal, (180./!PI)*acos(-(struct(k).MDZ_EXIT))]
phi_exit_cal = [phi_exit_cal, (180./!PI)*atan((struct(k).MDY_EXIT)/(struct(k).MDX_EXIT))]
endif
endelse
endif
endif
if ((struct(k).VOLUME_ID GE ac_vol_start) AND (struct(k).VOLUME_ID LE ac_vol_end)) then begin
if (part_type EQ 'g') then begin
event_id_ac = [event_id_ac, struct(k).EVT_ID]
vol_id_ac = [vol_id_ac, struct(k).VOLUME_ID]
if (isStrip EQ 1) then moth_id_ac = [moth_id_ac, struct(k).MOTHER_ID] else moth_id_ac = [moth_id_ac, 0]
energy_dep_ac = [energy_dep_ac, struct(k).E_DEP]
ent_x_ac = [ent_x_ac, struct(k).X_ENT]
ent_y_ac = [ent_y_ac, struct(k).Y_ENT]
ent_z_ac = [ent_z_ac, struct(k).Z_ENT]
exit_x_ac = [exit_x_ac, struct(k).X_EXIT]
exit_y_ac = [exit_y_ac, struct(k).Y_EXIT]
exit_z_ac = [exit_z_ac, struct(k).Z_EXIT]
theta_ent_ac = [theta_ent_ac, (180./!PI)*acos(-(struct(k).MDZ_ENT))]
phi_ent_ac = [phi_ent_ac, (180./!PI)*atan((struct(k).MDY_ENT)/(struct(k).MDX_ENT))]
theta_exit_ac = [theta_exit_ac, (180./!PI)*acos(-(struct(k).MDZ_EXIT))]
phi_exit_ac = [phi_exit_ac, (180./!PI)*atan((struct(k).MDY_EXIT)/(struct(k).MDX_EXIT))]
endif else begin
if (struct(k).E_DEP GT 0.d) then begin
event_id_ac = [event_id_ac, struct(k).EVT_ID]
vol_id_ac = [vol_id_ac, struct(k).VOLUME_ID]
if (isStrip EQ 1) then moth_id_ac = [moth_id_ac, struct(k).MOTHER_ID] else moth_id_ac = [moth_id_ac, 0]
energy_dep_ac = [energy_dep_ac, struct(k).E_DEP]
ent_x_ac = [ent_x_ac, struct(k).X_ENT]
ent_y_ac = [ent_y_ac, struct(k).Y_ENT]
ent_z_ac = [ent_z_ac, struct(k).Z_ENT]
exit_x_ac = [exit_x_ac, struct(k).X_EXIT]
exit_y_ac = [exit_y_ac, struct(k).Y_EXIT]
exit_z_ac = [exit_z_ac, struct(k).Z_EXIT]
theta_ent_ac = [theta_ent_ac, (180./!PI)*acos(-(struct(k).MDZ_ENT))]
phi_ent_ac = [phi_ent_ac, (180./!PI)*atan((struct(k).MDY_ENT)/(struct(k).MDX_ENT))]
theta_exit_ac = [theta_exit_ac, (180./!PI)*acos(-(struct(k).MDZ_EXIT))]
phi_exit_ac = [phi_exit_ac, (180./!PI)*atan((struct(k).MDY_EXIT)/(struct(k).MDX_EXIT))]
endif
endelse
endif
endfor
; Tracker (removing fake starting value)
event_id = event_id[1:*]
vol_id = vol_id[1:*]
moth_id = moth_id[1:*]
energy_dep = energy_dep[1:*]
ent_x = (ent_x[1:*])/10.
ent_y = (ent_y[1:*])/10.
ent_z = (ent_z[1:*])/10.
exit_x = (exit_x[1:*])/10.
exit_y = (exit_y[1:*])/10.
exit_z = (exit_z[1:*])/10.
x_pos = dblarr(n_elements(ent_x))
y_pos = dblarr(n_elements(ent_x))
z_pos = dblarr(n_elements(ent_x))
for j=0l, n_elements(ent_x)-1 do begin
x_pos(j) = ent_x(j) + ((exit_x(j) - ent_x(j))/2.)
y_pos(j) = ent_y(j) + ((exit_y(j) - ent_y(j))/2.)
z_pos(j) = ent_z(j) + ((exit_z(j) - ent_z(j))/2.)
endfor
theta_ent = theta_ent[1:*]
phi_ent = phi_ent[1:*]
theta_exit = theta_exit[1:*]
phi_exit = phi_exit[1:*]
; Calorimeter (removing fake starting value)
if (cal_flag EQ 1) then begin
event_id_cal = event_id_cal[1:*]
vol_id_cal = vol_id_cal[1:*]
moth_id_cal = moth_id_cal[1:*]
energy_dep_cal = energy_dep_cal[1:*]
ent_x_cal = (ent_x_cal[1:*])/10.
ent_y_cal = (ent_y_cal[1:*])/10.
ent_z_cal = (ent_z_cal[1:*])/10.
exit_x_cal = (exit_x_cal[1:*])/10.
exit_y_cal = (exit_y_cal[1:*])/10.
exit_z_cal = (exit_z_cal[1:*])/10.
theta_ent_cal = theta_ent_cal[1:*]
phi_ent_cal = phi_ent_cal[1:*]
theta_exit_cal = theta_exit_cal[1:*]
phi_exit_cal = phi_exit_cal[1:*]
endif
; AC (removing fake starting value)
if (ac_flag EQ 1) then begin
event_id_ac = event_id_ac[1:*]
vol_id_ac = vol_id_ac[1:*]
moth_id_ac = moth_id_ac[1:*]
energy_dep_ac = energy_dep_ac[1:*]
ent_x_ac = (ent_x_ac[1:*])/10.
ent_y_ac = (ent_y_ac[1:*])/10.
ent_z_ac = (ent_z_ac[1:*])/10.
exit_x_ac = (exit_x_ac[1:*])/10.
exit_y_ac = (exit_y_ac[1:*])/10.
exit_z_ac = (exit_z_ac[1:*])/10.
theta_ent_ac = theta_ent_ac[1:*]
phi_ent_ac = phi_ent_ac[1:*]
theta_exit_ac = theta_exit_ac[1:*]
phi_exit_ac = phi_exit_ac[1:*]
endif
; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
; Processing the tracker
; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if (astrogam_version EQ 'V3.0') then begin
; From Tracker volume ID to strip and tray ID
Strip_id_x = intarr(n_elements(vol_id))
Strip_id_y = intarr(n_elements(vol_id))
tray_id = intarr(n_elements(vol_id))
; Si_id = Si layer flag description:
; - 0 = X
; - 1 = Y
; Conversion from tray ID (starting from bottom) to plane ID (starting from the top)
plane_id = intarr(n_elements(tray_id))
for j=0l, n_elements(vol_id)-1 do begin
if (isStrip EQ 1) then begin ;--------> PIXEL = 1
if (repli EQ 1) then begin ;--------> REPLI = 1
;Strip_id_x(j) = vol_id(j) mod N_strip
;Strip_id_y(j) = vol_id(j)/N_strip
;tray_id(j) = moth_id(j)/tracker_bottom_vol_start
;invert_tray_id = (N_tray - tray_id(j))+1
;plane_id(j) = invert_tray_id
;vol_id(j) = Strip_id_y(j)
;moth_id(j) = moth_id(j) + Strip_id_x(j)
Strip_id_y(j) = vol_id(j)
tray_id(j) = moth_id(j)/tracker_bottom_vol_start
invert_tray_id = (N_tray - tray_id(j))+1
vol_id_temp = moth_id(j) - (tracker_bottom_vol_start*tray_id(j) + tracker_top_bot_diff) ; removing 1000000xn_tray + 90000
Strip_id_x(j) = vol_id_temp
plane_id(j) = invert_tray_id
endif
endif else begin
Strip_id_y(j) = 0
tray_id(j) = vol_id(j)/tracker_bottom_vol_start
invert_tray_id = (N_tray - tray_id(j))+1
Strip_id_x(j) = 0
plane_id(j) = invert_tray_id
endelse
endfor
endif
print, '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%'
print, ' Tracker '
print, ' Saving the Tracker raw hits (fits and .dat) '
print, '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%'
if (astrogam_version EQ 'V3.0') then begin
CREATE_STRUCT, rawData, 'rawData', ['EVT_ID', 'VOL_ID', 'MOTH_ID', 'TRAY_ID', 'PLANE_ID', 'STRIP_ID_X', 'STRIP_ID_Y', 'E_DEP', 'X_ENT', 'Y_ENT', 'Z_ENT', 'X_EXIT', 'Y_EXIT', 'Z_EXIT'], $
'I,I,J,I,I,I,I,F20.5,F20.5,F20.5,F20.5,F20.5,F20.5,F20.5', DIMEN = n_elements(event_id)
rawData.EVT_ID = event_id
rawData.VOL_ID = vol_id
rawData.MOTH_ID = moth_id
rawData.TRAY_ID = tray_id
rawData.PLANE_ID = plane_id
rawData.STRIP_ID_X = Strip_id_x
rawData.STRIP_ID_Y = Strip_id_y
rawData.E_DEP = energy_dep
rawData.X_ENT = ent_x
rawData.Y_ENT = ent_y
rawData.Z_ENT = ent_z
rawData.X_EXIT = exit_x
rawData.Y_EXIT = exit_y
rawData.Z_EXIT = exit_z
hdr_rawData = ['COMMENT ASTROGAM '+astrogam_version+' Geant4 simulation', $
'N_in = '+strtrim(string(N_in),1), $
'Energy = '+ene_type, $
'Theta = '+strtrim(string(theta_type),1), $
'Phi = '+strtrim(string(phi_type),1), $
'Position unit = cm', $
'Energy unit = keV']
MWRFITS, rawData, outdir+'/G4.RAW.ASTROGAM'+astrogam_version+'.'+py_name+'.'+sim_name+'.'+stripname+'.'+sname+'.'+strmid(strtrim(string(N_in),1),0,10)+part_type+'.'+ene_type+'MeV.'+strmid(strtrim(string(theta_type),1),0,10)+'.'+strmid(strtrim(string(phi_type),1),0,10)+'.'+strtrim(string(ifile),1)+'.fits', hdr_rawData, /create
if (isStrip EQ 0) then begin
openw,lun,outdir+'/AA_FAKE_ASTROGAM'+astrogam_version+'_'+py_name+'_'+sim_name+'_'+stripname+'_'+sname+'_'+strmid(strtrim(string(N_in),1),0,10)+part_type+'_'+ene_type+'MeV_'+strmid(strtrim(string(theta_type),1),0,10)+'_'+strmid(strtrim(string(phi_type),1),0,10)+'.'+strtrim(string(ifile),1)+'.dat',/get_lun
; ASCII Columns:
; - c1 = event ID
; - c2 = theta input
; - c3 = phi input
; - c4 = energy input
; - c5 = plane ID
; - c6 = Pos Z
; - c7 = X/Y flag (X = 0, Y = 1)
; - c8 = Cluster position (reference system center at the Silicon layer center)
; - c9 = energy deposition (keV)
; - c10 = number of strips composing the cluster
j=0l
while (1) do begin
where_event_eq = where(event_id EQ event_id(j))
plane_id_temp = plane_id(where_event_eq)
Cluster_x_temp = x_pos(where_event_eq)
Cluster_y_temp = y_pos(where_event_eq)
Cluster_z_temp = z_pos(where_event_eq)
e_dep_x_temp = (energy_dep(where_event_eq))/2.
e_dep_y_temp = (energy_dep(where_event_eq))/2.
; ------------------------------------
; X VIEW
for r=0l, n_elements(Cluster_x_temp)-1 do begin
if (e_dep_x_temp(r) GE E_th) then begin
printf, lun, event_id(j), theta_type, phi_type, ene_type, plane_id_temp(r), Cluster_z_temp(r), 0, Cluster_x_temp(r), e_dep_x_temp(r), 1, format='(I5,I5,I5,I5,I5,F10.5,I5,F10.5,F10.5,I5)'
endif
endfor
; Y VIEW
for r=0l, n_elements(Cluster_y_temp)-1 do begin
if (e_dep_y_temp(r) GE E_th) then begin
printf, lun, event_id(j), theta_type, phi_type, ene_type, plane_id_temp(r), Cluster_z_temp(r), 1, Cluster_y_temp(r), e_dep_y_temp(r), 1, format='(I5,I5,I5,I5,I5,F10.5,I5,F10.5,F10.5,I5)'
endif
endfor
; ------------------------------------
N_event_eq = n_elements(where_event_eq)
if where_event_eq(N_event_eq-1) LT (n_elements(event_id)-1) then begin
j = where_event_eq(N_event_eq-1)+1
endif else break
endwhile
Free_lun, lun
endif
; Loading the LUT
if (isStrip) then begin
filename_x_top = './conf/ARCH.XSTRIP.TOP.ASTROGAM'+astrogam_version+'.TRACKER.FITS'
filename_y_top = './conf/ARCH.YSTRIP.TOP.ASTROGAM'+astrogam_version+'.TRACKER.FITS'
struct_x_top = mrdfits(filename_x_top,$
1, $
structyp = 'astrogam_xtop', $
/unsigned)
struct_y_top = mrdfits(filename_y_top,$
1, $
structyp = 'astrogam_ytop', $
/unsigned)
Arch_vol_id_x_top = struct_x_top.VOLUME_ID
Arch_moth_id_x_top = struct_x_top.MOTHER_ID
Arch_Strip_id_x_top = struct_x_top.STRIP_ID
Arch_Si_id_x_top = struct_x_top.TRK_FLAG
Arch_tray_id_x_top = struct_x_top.TRAY_ID
Arch_plane_id_x_top = struct_x_top.PLANE_ID
Arch_xpos_x_top = struct_x_top.XPOS
Arch_zpos_x_top = struct_x_top.ZPOS
Arch_energy_dep_x_top = struct_x_top.E_DEP
Arch_vol_id_y_top = struct_y_top.VOLUME_ID
Arch_moth_id_y_top = struct_y_top.MOTHER_ID
Arch_Strip_id_y_top = struct_y_top.STRIP_ID
Arch_Si_id_y_top = struct_y_top.TRK_FLAG
Arch_tray_id_y_top = struct_y_top.TRAY_ID
Arch_plane_id_y_top = struct_y_top.PLANE_ID
Arch_ypos_y_top = struct_y_top.YPOS
Arch_zpos_y_top = struct_y_top.ZPOS
Arch_energy_dep_y_top = struct_y_top.E_DEP
N_trig = 0l
event_id_tot = -1l
vol_id_tot = -1l
moth_id_tot = -1l
Strip_id_x_tot = -1l
Strip_id_y_tot = -1l
tray_id_tot = -1l
plane_id_tot = -1l
energy_dep_tot = -1.
if (isStrip EQ 1) then begin
j=0l
while (1) do begin
where_event_eq = where(event_id EQ event_id(j))
vol_id_temp = vol_id(where_event_eq)
moth_id_temp = moth_id(where_event_eq)
Strip_id_x_temp = Strip_id_x(where_event_eq)
Strip_id_y_temp = Strip_id_y(where_event_eq)
tray_id_temp = tray_id(where_event_eq)
plane_id_temp = plane_id(where_event_eq)
energy_dep_temp = energy_dep(where_event_eq)
r = 0l
while(1) do begin
where_vol_eq = where(((vol_id_temp EQ vol_id_temp(r)) and (moth_id_temp EQ moth_id_temp(r))), complement = where_other_vol)
e_dep_temp = total(energy_dep_temp(where_vol_eq))
event_id_tot = [event_id_tot, event_id(j)]
vol_id_tot = [vol_id_tot, vol_id_temp(r)]
moth_id_tot = [moth_id_tot, moth_id_temp(r)]
Strip_id_x_tot = [Strip_id_x_tot, Strip_id_x_temp(r)]
Strip_id_y_tot = [Strip_id_y_tot, Strip_id_y_temp(r)]
tray_id_tot = [tray_id_tot, tray_id_temp(r)]
plane_id_tot = [plane_id_tot, plane_id_temp(r)]
energy_dep_tot = [energy_dep_tot, e_dep_temp]
if (where_other_vol(0) NE -1) then begin
vol_id_temp = vol_id_temp(where_other_vol)
moth_id_temp = moth_id_temp(where_other_vol)
Strip_id_x_temp = Strip_id_x_temp(where_other_vol)
Strip_id_y_temp = Strip_id_y_temp(where_other_vol)
tray_id_temp = tray_id_temp(where_other_vol)
plane_id_temp = plane_id_temp(where_other_vol)
energy_dep_temp = energy_dep_temp(where_other_vol)
endif else break
endwhile
N_event_eq = n_elements(where_event_eq)
if where_event_eq(N_event_eq-1) LT (n_elements(event_id)-1) then begin
j = where_event_eq(N_event_eq-1)+1
endif else break
endwhile
endif else begin
j=0l
while (1) do begin
where_event_eq = where(event_id EQ event_id(j))
vol_id_temp = vol_id(where_event_eq)
moth_id_temp = moth_id(where_event_eq)
Strip_id_x_temp = Strip_id_x(where_event_eq)
Strip_id_y_temp = Strip_id_y(where_event_eq)
tray_id_temp = tray_id(where_event_eq)
plane_id_temp = plane_id(where_event_eq)
energy_dep_temp = energy_dep(where_event_eq)
r = 0l
while(1) do begin
where_vol_eq = where(((vol_id_temp EQ vol_id_temp(r)) and (moth_id_temp EQ moth_id_temp(r))), complement = where_other_vol)
e_dep_temp = total(energy_dep_temp(where_vol_eq))
event_id_tot = [event_id_tot, event_id(j)]
vol_id_tot = [vol_id_tot, vol_id_temp(r)]
moth_id_tot = [moth_id_tot, moth_id_temp(r)]
Strip_id_x_tot = [Strip_id_x_tot, Strip_id_x_temp(r)]
Strip_id_y_tot = [Strip_id_y_tot, Strip_id_y_temp(r)]
tray_id_tot = [tray_id_tot, tray_id_temp(r)]
plane_id_tot = [plane_id_tot, plane_id_temp(r)]
energy_dep_tot = [energy_dep_tot, e_dep_temp]
if (where_other_vol(0) NE -1) then begin
vol_id_temp = vol_id_temp(where_other_vol)
moth_id_temp = moth_id_temp(where_other_vol)
Strip_id_x_temp = Strip_id_x_temp(where_other_vol)
Strip_id_y_temp = Strip_id_y_temp(where_other_vol)
tray_id_temp = tray_id_temp(where_other_vol)
plane_id_temp = plane_id_temp(where_other_vol)
energy_dep_temp = energy_dep_temp(where_other_vol)
endif else break
endwhile
N_event_eq = n_elements(where_event_eq)
if where_event_eq(N_event_eq-1) LT (n_elements(event_id)-1) then begin
j = where_event_eq(N_event_eq-1)+1
endif else break
endwhile
endelse
if (n_elements(event_id_tot) GT 1) then begin
event_id_tot = event_id_tot[1:*]
vol_id_tot = vol_id_tot[1:*]
moth_id_tot = moth_id_tot[1:*]
Strip_id_x_tot = Strip_id_x_tot[1:*]
Strip_id_y_tot = Strip_id_y_tot[1:*]
tray_id_tot = tray_id_tot[1:*]
plane_id_tot = plane_id_tot[1:*]
energy_dep_tot = energy_dep_tot[1:*]
endif
event_id_tot_temp = lonarr(2*n_elements(event_id_tot))
vol_id_tot_temp = lonarr(2*n_elements(event_id_tot))
moth_id_tot_temp = lonarr(2*n_elements(event_id_tot))
Strip_id_tot_temp = lonarr(2*n_elements(event_id_tot))
Si_id_tot_temp = lonarr(2*n_elements(event_id_tot))
tray_id_tot_temp = lonarr(2*n_elements(event_id_tot))
plane_id_tot_temp = lonarr(2*n_elements(event_id_tot))
energy_dep_tot_temp = dblarr(2*n_elements(event_id_tot))
for jev = 0l, n_elements(event_id_tot) - 1 do begin
ev_index = jev*2
event_id_tot_temp[ev_index] = event_id_tot[jev]
event_id_tot_temp[ev_index+1] = event_id_tot[jev]
vol_id_tot_temp[ev_index] = Strip_id_x_tot[jev]
vol_id_tot_temp[ev_index+1] = Strip_id_y_tot[jev]
moth_id_tot_temp[ev_index] = moth_id_tot[jev] - Strip_id_x_tot[jev]
moth_id_tot_temp[ev_index+1] = moth_id_tot[jev] - Strip_id_x_tot[jev]
Strip_id_tot_temp[ev_index] = Strip_id_x_tot[jev]
Strip_id_tot_temp[ev_index+1] = Strip_id_y_tot[jev]
Si_id_tot_temp[ev_index] = 0
Si_id_tot_temp[ev_index+1] = 1
tray_id_tot_temp[ev_index] = tray_id_tot[jev]
tray_id_tot_temp[ev_index+1] = tray_id_tot[jev]
plane_id_tot_temp[ev_index] = plane_id_tot[jev]
plane_id_tot_temp[ev_index+1] = plane_id_tot[jev]
energy_dep_tot_temp[ev_index] = energy_dep_tot[jev]/2.
energy_dep_tot_temp[ev_index+1] = energy_dep_tot[jev]/2.
endfor
event_id_tot = -1l
vol_id_tot = -1l
moth_id_tot = -1l
Strip_id_tot = -1l
Si_id_tot = -1l
tray_id_tot = -1l
plane_id_tot = -1l
energy_dep_tot = -1.
if (isStrip) then begin
;
; Summing the energy along the strip
;
j=0l
while (1) do begin
where_event_eq = where(event_id_tot_temp EQ event_id_tot_temp(j))
vol_id_temp = vol_id_tot_temp(where_event_eq)
moth_id_temp = moth_id_tot_temp(where_event_eq)
Strip_id_temp = Strip_id_tot_temp(where_event_eq)
Si_id_temp = Si_id_tot_temp(where_event_eq)
tray_id_temp = tray_id_tot_temp(where_event_eq)
plane_id_temp = plane_id_tot_temp(where_event_eq)
energy_dep_temp = energy_dep_tot_temp(where_event_eq)
r = 0l
while(1) do begin
where_vol_eq = where(((vol_id_temp EQ vol_id_temp(r)) and (moth_id_temp EQ moth_id_temp(r)) and (Si_id_temp EQ 0)), complement = where_other_vol)
if (where_vol_eq(0) NE -1) then begin
e_dep_temp = total(energy_dep_temp(where_vol_eq))
event_id_tot = [event_id_tot, event_id_tot_temp(j)]
vol_id_tot = [vol_id_tot, vol_id_temp(r)]
moth_id_tot = [moth_id_tot, moth_id_temp(r)]
Strip_id_tot = [Strip_id_tot, Strip_id_temp(r)]
Si_id_tot = [Si_id_tot, 0]
tray_id_tot = [tray_id_tot, tray_id_temp(r)]
plane_id_tot = [plane_id_tot, plane_id_temp(r)]
energy_dep_tot = [energy_dep_tot, e_dep_temp]
if (where_other_vol(0) NE -1) then begin
vol_id_temp = vol_id_temp(where_other_vol)
moth_id_temp = moth_id_temp(where_other_vol)
Strip_id_temp = Strip_id_temp(where_other_vol)
Si_id_temp = Si_id_temp(where_other_vol)
tray_id_temp = tray_id_temp(where_other_vol)
plane_id_temp = plane_id_temp(where_other_vol)
energy_dep_temp = energy_dep_temp(where_other_vol)
endif else break
endif
where_vol_eq = where(((vol_id_temp EQ vol_id_temp(r)) and (moth_id_temp EQ moth_id_temp(r)) and (Si_id_temp EQ 1)), complement = where_other_vol)
if (where_vol_eq(0) NE -1) then begin
e_dep_temp = total(energy_dep_temp(where_vol_eq))
event_id_tot = [event_id_tot, event_id_tot_temp(j)]
vol_id_tot = [vol_id_tot, vol_id_temp(r)]
moth_id_tot = [moth_id_tot, moth_id_temp(r)]
Strip_id_tot = [Strip_id_tot, Strip_id_temp(r)]
Si_id_tot = [Si_id_tot, 1]
tray_id_tot = [tray_id_tot, tray_id_temp(r)]
plane_id_tot = [plane_id_tot, plane_id_temp(r)]
energy_dep_tot = [energy_dep_tot, e_dep_temp]
if (where_other_vol(0) NE -1) then begin
vol_id_temp = vol_id_temp(where_other_vol)
moth_id_temp = moth_id_temp(where_other_vol)
Strip_id_temp = Strip_id_temp(where_other_vol)
Si_id_temp = Si_id_temp(where_other_vol)
tray_id_temp = tray_id_temp(where_other_vol)
plane_id_temp = plane_id_temp(where_other_vol)
energy_dep_temp = energy_dep_temp(where_other_vol)
endif else break
endif
endwhile
N_event_eq = n_elements(where_event_eq)
if where_event_eq(N_event_eq-1) LT (n_elements(event_id_tot_temp)-1) then begin
j = where_event_eq(N_event_eq-1)+1
endif else break
endwhile
if (n_elements(event_id_tot) GT 1) then begin
event_id_tot = event_id_tot[1:*]
vol_id_tot = vol_id_tot[1:*]
moth_id_tot = moth_id_tot[1:*]
Strip_id_tot = Strip_id_tot[1:*]
Si_id_tot = Si_id_tot[1:*]
tray_id_tot = tray_id_tot[1:*]
plane_id_tot = plane_id_tot[1:*]
energy_dep_tot = energy_dep_tot[1:*]
endif
endif
; apply the energy thresold
where_eth = where(energy_dep_tot GE E_th)
event_id_tot = event_id_tot[where_eth]
vol_id_tot = vol_id_tot[where_eth]
moth_id_tot = moth_id_tot[where_eth]
Strip_id_tot = Strip_id_tot[where_eth]
Si_id_tot = Si_id_tot[where_eth]
tray_id_tot = tray_id_tot[where_eth]
plane_id_tot = plane_id_tot[where_eth]
energy_dep_tot = energy_dep_tot[where_eth]
N_trig = n_elements(uniq(event_id_tot))
event_array = event_id_tot(uniq(event_id_tot))
CREATE_STRUCT, testData, 'testData', ['EVT_ID', 'TRK_FLAG', 'TRAY_ID', 'PLANE_ID', 'STRIP_ID', 'E_DEP'], $
'I,I,I,I,I,F20.5', DIMEN = n_elements(event_id_tot)
testData.EVT_ID = event_id_tot
testData.TRK_FLAG = Si_id_tot
testData.TRAY_ID = tray_id_tot
testData.PLANE_ID = plane_id_tot
testData.STRIP_ID = Strip_id_tot
testData.E_DEP = energy_dep_tot
hdr_testData = ['COMMENT ASTROGAM '+astrogam_version+' Geant4 simulation', $
'N_in = '+strtrim(string(N_in),1), $
'Energy = '+ene_type, $
'Theta = '+strtrim(string(theta_type),1), $
'Phi = '+strtrim(string(phi_type),1), $
'Position unit = cm', $
'Energy unit = keV']
MWRFITS, testData, outdir+'/G4.TEST.ASTROGAM'+astrogam_version+'.'+py_name+'.'+sim_name+'.'+stripname+'.'+sname+'.'+strmid(strtrim(string(N_in),1),0,10)+part_type+'.'+ene_type+'MeV.'+strmid(strtrim(string(theta_type),1),0,10)+'.'+strmid(strtrim(string(phi_type),1),0,10)+'.'+strtrim(string(ifile),1)+'.fits', hdr_testData, /create
endif
endif
if (astrogam_version EQ 'V3.0') then begin
if (isStrip) then begin
; Total number of strips
Total_vol_x_top = (N_tray)*N_strip
Total_vol_y_top = (N_tray)*N_strip
print, 'Number of tracker triggered events:', N_trig
Glob_event_id_x_top = lonarr(Total_vol_x_top, N_trig)
Glob_vol_id_x_top = lonarr(Total_vol_x_top, N_trig)
Glob_moth_id_x_top = lonarr(Total_vol_x_top, N_trig)
Glob_Strip_id_x_top = lonarr(Total_vol_x_top, N_trig)
Glob_Si_id_x_top = lonarr(Total_vol_x_top, N_trig)
Glob_tray_id_x_top = lonarr(Total_vol_x_top, N_trig)
Glob_plane_id_x_top = lonarr(Total_vol_x_top, N_trig)
Glob_xpos_x_top = dblarr(Total_vol_x_top, N_trig)
Glob_zpos_x_top = dblarr(Total_vol_x_top, N_trig)
Glob_energy_dep_x_top = dblarr(Total_vol_x_top, N_trig)
Glob_event_id_y_top = lonarr(Total_vol_y_top, N_trig)
Glob_vol_id_y_top = lonarr(Total_vol_y_top, N_trig)
Glob_moth_id_y_top = lonarr(Total_vol_y_top, N_trig)
Glob_Strip_id_y_top = lonarr(Total_vol_y_top, N_trig)
Glob_Si_id_y_top = lonarr(Total_vol_y_top, N_trig)
Glob_tray_id_y_top = lonarr(Total_vol_y_top, N_trig)
Glob_plane_id_y_top = lonarr(Total_vol_y_top, N_trig)
Glob_ypos_y_top = dblarr(Total_vol_y_top, N_trig)
Glob_zpos_y_top = dblarr(Total_vol_y_top, N_trig)
Glob_energy_dep_y_top = dblarr(Total_vol_y_top, N_trig)
for i=0, N_trig-1 do begin
Glob_vol_id_x_top[*,i] = Arch_vol_id_x_top
Glob_moth_id_x_top[*,i] = Arch_moth_id_x_top
Glob_Strip_id_x_top[*,i] = Arch_Strip_id_x_top
Glob_Si_id_x_top[*,i] = Arch_Si_id_x_top
Glob_tray_id_x_top[*,i] = Arch_tray_id_x_top
Glob_plane_id_x_top[*,i] = Arch_plane_id_x_top
Glob_xpos_x_top[*,i] = Arch_xpos_x_top
Glob_zpos_x_top[*,i] = Arch_zpos_x_top
Glob_energy_dep_x_top[*,i] = Arch_energy_dep_x_top
Glob_vol_id_y_top[*,i] = Arch_vol_id_y_top
Glob_moth_id_y_top[*,i] = Arch_moth_id_y_top
Glob_Strip_id_y_top[*,i] = Arch_Strip_id_y_top
Glob_Si_id_y_top[*,i] = Arch_Si_id_y_top
Glob_tray_id_y_top[*,i] = Arch_tray_id_y_top
Glob_plane_id_y_top[*,i] = Arch_plane_id_y_top
Glob_ypos_y_top[*,i] = Arch_ypos_y_top
Glob_zpos_y_top[*,i] = Arch_zpos_y_top
Glob_energy_dep_y_top[*,i] = Arch_energy_dep_y_top
endfor
j=0l
N_ev =0l