10 clname = cylLayer.GetName()
15 radius = evt.cylRadius
16 position = evt.cylPosZ
18 binsz = evt.cylMatBinsZ
19 binsphi = evt.cylMatBinsPhi
23 if binsz > numbinsz : numbinsz = binsz
24 if binsphi > numbinsphi : numbinsphi = binsphi
27 print (
'----------------------------------------------------------------')
28 print (
' Layer: ', clname,
' ( LayerIndex : ',evt.cylLayerIndex,
')')
29 print (
' r, halflength : ', radius, halfz)
30 print (
' bins (z/phi) : ', evt.cylMatBinsZ, evt.cylMatBinsPhi)
34 clmap_x0 =
TH2F(
'clmap_x0_'+clname,clname,binsz,-halfz,halfz,binsphi,-math.pi,math.pi)
37 for ibin
in range(evt.cylMatBinsTotal) :
39 ibinz = ibin/numbinsphi
40 ibinphi = ibin - ibinz*numbinsphi
41 x0 = evt.cylMatX0[ibin]
42 if x0 > x0max : x0max = x0
43 clmap_x0.SetBinContent(ibinz+1,ibinphi+1,x0)
47 canvasX0map = TCanvas(clname+
'_x0',clname,100,100,800,1000)
48 canvasX0map.Divide(2,3)
53 x0profZG4 =
TProfile(clname+
'x0profZG4',clname+
'x0profZG4',numbinsz,-halfz+position,halfz+position)
54 x0profZTG =
TProfile(clname+
'x0profZTG',clname+
'x0profZTG',numbinsz,-halfz+position,halfz+position)
55 g4CylTree.Draw(
'PathInX0:DensedHitZ>>'+clname+
'x0profZG4',
'',
'prof')
56 tgCylTree.Draw(
'PathInX0:DensedHitZ>>'+clname+
'x0profZTG',
'',
'prof')
57 x0profG4z = gDirectory.Get(clname+
'x0profZG4')
58 x0profTGz = gDirectory.Get(clname+
'x0profZTG')
60 x0profTGz.SetMarkerStyle(8)
61 x0profTGz.SetMarkerSize(0.5)
62 x0profTGz.SetMarkerColor(kRed)
63 x0profTGz.SetLineColor(kRed)
64 x0profG4z.GetYaxis().SetTitle(
't [X_{0}]')
65 x0profG4z.GetXaxis().SetTitle(
'z [mm]')
66 x0maxProf = 1.5*x0profG4z.GetMaximum()
67 x0profG4z.GetYaxis().SetRangeUser(0.,x0maxProf)
68 x0profG4z.Draw(
'hist')
69 x0profTGz.SetMarkerColor(kRed)
70 x0profTGz.SetMarkerSize(0.8)
71 x0profTGz.Draw(
'pe,same')
73 x0profPhiG4 =
TProfile(clname+
'x0profPhiG4',clname+
'x0profPhiG4',numbinsphi,-math.pi,math.pi)
74 x0profPhiTG =
TProfile(clname+
'x0profPhiTG',clname+
'x0profPhiTG',numbinsphi,-math.pi,math.pi)
75 g4CylTree.Draw(
'PathInX0:DensedHitPhi>>'+clname+
'x0profPhiG4',
'',
'prof')
76 tgCylTree.Draw(
'PathInX0:DensedHitPhi>>'+clname+
'x0profPhiTG',
'',
'prof')
77 x0profG4phi = gDirectory.Get(clname+
'x0profPhiG4')
78 x0profTGphi = gDirectory.Get(clname+
'x0profPhiTG')
80 x0profTGphi.SetMarkerStyle(8)
81 x0profTGphi.SetMarkerSize(0.5)
82 x0profTGphi.SetMarkerColor(kRed)
83 x0profTGphi.SetLineColor(kRed)
84 x0profG4phi.GetXaxis().SetTitle(
'#phi')
85 x0profG4phi.GetYaxis().SetTitle(
't [X_{0}]')
86 if 1.5*x0profG4phi.GetMaximum() > x0maxProf : x0maxProf = 1.5*x0profG4phi.GetMaximum()
87 x0profG4phi.GetYaxis().SetRangeUser(0.,1.5*x0profG4phi.GetMaximum())
88 x0profG4phi.Draw(
'hist')
89 x0profTGphi.SetMarkerColor(kRed)
90 x0profTGphi.SetMarkerSize(0.8)
91 x0profTGphi.Draw(
'pe,same')
95 g4CylTree.Draw(
'PathInX0>>'+clname+
'range')
96 x0range = gDirectory.Get(clname+
'range')
97 x0maxProf = 1.2*x0range.GetXaxis().GetXmax()
99 print (
' -> TTree does not exist in TrackingGeometry ')
100 x0mapG4 = TH3F(clname+
'x0mapG4',clname+
'x0mapG4', numbinsphi,-math.pi,math.pi,numbinsz,-halfz+position,halfz+position,50,0.,x0maxProf)
102 g4CylTree.Draw(
'PathInX0:DensedHitZ:DensedHitPhi>>'+clname+
'x0mapG4',
'',
'')
103 x0mapG4 = gDirectory.Get(clname+
'x0mapG4')
104 x0mapG4Prof = x0mapG4.Project3DProfile(
'xy')
105 x0mapG4Prof.GetXaxis().SetTitle(
'z [mm]')
106 x0mapG4Prof.GetYaxis().SetTitle(
'#phi')
107 x0mapG4Prof.GetZaxis().SetTitle(
't [X_{0}]')
108 x0mapG4Prof.GetZaxis().SetTitleOffset(1.5*x0mapG4Prof.GetZaxis().GetTitleOffset())
109 x0mapG4Prof.GetZaxis().SetRangeUser(0.,x0maxProf)
110 x0mapG4Prof.SetBit(kCanDelete)
111 x0mapG4Prof.SetBit(kMustCleanup)
112 x0mapG4Prof.Draw(
'colz')
114 print (
' -> TTree does not exist in TrackingGeometry ')
116 x0mapTG = TH3F(clname+
'x0mapTG',clname+
'x0mapTG',numbinsphi,-math.pi,math.pi,numbinsz,-halfz+position,halfz+position,50,0.,x0maxProf)
118 tgCylTree.Draw(
'PathInX0:DensedHitZ:DensedHitPhi>>'+clname+
'x0mapTG',
'',
'')
119 x0mapTG = gDirectory.Get(clname+
'x0mapTG')
120 x0mapTGProf = x0mapTG.Project3DProfile(
'xy')
121 x0mapTGProf.GetXaxis().SetTitle(
'z [mm]')
122 x0mapTGProf.GetYaxis().SetTitle(
'#phi')
123 x0mapTGProf.GetZaxis().SetTitle(
't [X_{0}]')
124 x0mapTGProf.GetZaxis().SetTitleOffset(1.5*x0mapTGProf.GetZaxis().GetTitleOffset())
125 x0mapTGProf.GetZaxis().SetRangeUser(0.,x0maxProf)
126 x0mapTGProf.SetBit(kCanDelete)
127 x0mapTGProf.SetBit(kMustCleanup)
128 x0mapTGProf.Draw(
'colz')
130 print (
' -> TTree does not exist in Geant4 ')
132 clmap_x0.GetZaxis().SetRangeUser(0.,x0max)
133 clmap_x0.GetXaxis().SetTitle(
'z [mm]')
134 clmap_x0.GetYaxis().SetTitle(
'#phi')
135 clmap_x0.GetZaxis().SetTitle(
't [X_{0}]')
136 clmap_x0.GetZaxis().SetTitleOffset(1.2*clmap_x0.GetZaxis().GetTitleOffset())
137 clmap_x0.Draw(
'colz')
141 x0mapDiff = x0mapTGProf.Clone()
142 x0mapDiff.Add(x0mapG4Prof,-1)
143 x0mapDiff.GetXaxis().SetTitle(
'z [mm]')
144 x0mapDiff.GetYaxis().SetTitle(
'#phi')
145 x0mapDiff.GetZaxis().SetTitle(
'#Delta(t) [X_{0}]')
146 x0mapDiff.GetZaxis().SetRangeUser(-1.,1.)
147 x0mapDiff.GetZaxis().SetTitleOffset(1.5*x0mapDiff.GetZaxis().GetTitleOffset())
148 x0mapDiff.Divide(x0mapG4Prof)
149 x0mapDiff.Draw(
'colz')
150 except UnboundLocalError :
151 print (
' -> No TrackingGeometry/G4 histograms to divide')
154 canvasX0map.SaveAs(saveLocation+
'/LayerMaterial_CylinderLayer_'+
str(evt.cylLayerIndex)+
'.png')
156 canvasAnalysis = TCanvas(clname+
'_analyse',clname,100,100,600,1200)
157 canvasAnalysis.Divide(1,3)
159 cylLayer.Draw(
'LayerMaterialL0:LayerMaterialX0',
'',
'box')
161 cylLayer.Draw(
'LayerMaterialZARho:LayerMaterialX0',
'',
'box')
163 cylLayer.Draw(
'LayerMaterialZARho:LayerMaterialL0',
'',
'box')
164 canvasAnalysis.SaveAs(saveLocation+
'/'+clname+
'_analysis.png')
167 gDirectory.Delete(clname+
'x0mapTG')
168 gDirectory.Delete(clname+
'x0mapG4')
169 gDirectory.Delete(
'clmap_x0_'+clname)
170 gDirectory.Delete(
'clmap_x0_pz_'+clname)
171 gDirectory.Delete(
'clmap_x0_pphi_'+clname)