5 from ROOT
import TH2F, TLine
6 from .MMMonUtils
import getMMLabelX, get_MPV_charge, get_mean_and_sigma, getXYbins, poi, get_time
12 for i
in range(len(inputs)):
13 h=inputs[i][1][0].Clone()
14 histos_unsorted.append(h.GetName())
15 names.append(h.GetName())
21 if(
'eta1' in names[0]):
26 if(
'CSide' in names[0]):
33 test_list.append(f
'pcb_{eta}_{side}_phi{phi}_multiplet{mult+1}_gas_gap{gg+1}_vs_hitcut')
34 list_of_all_histos.append(test_list)
36 for ihisto
in range(len(names)):
37 ind = histos_unsorted.index(names[ihisto])
38 histos_sorted.append(inputs[ind][1][0])
40 h_eff_per_PCB =
TH2F(f
'Efficiency_{side}_{eta}_per_PCB', f
'Efficiency {side} {eta} per PCB', bins,0,bins, 16, .5,16.5)
44 for xbin
in range(len(thisLabelx)):
45 h_eff_per_PCB.GetXaxis().SetBinLabel(xbin+1, thisLabelx[xbin])
46 h_eff_per_PCB.GetYaxis().SetTitle(
'Sector')
48 for ihisto
in range(len(histos_sorted)):
49 iphi = histos_sorted[ihisto].GetName()[18:20]
51 iphi = histos_sorted[ihisto].GetName()[18:19]
52 xbin,ybin =
getXYbins(nPCB,
int(iphi),
True, histos_sorted[ihisto].GetName(), list_of_all_histos)
54 for ipcb
in range(nPCB):
55 h_eff_per_PCB.SetBinContent(xbin, ybin, histos_sorted[ihisto].GetEfficiency(ipcb+1))
57 return [h_eff_per_PCB]
62 if(
'CSide' in inputs[0][1][0].GetName()):
65 if(
'stationEta1' in inputs[0][1][0].GetName()):
68 output1 =
TH2F(f
'h_residual_sigma_{eta}_E{side}',f
'EndCap{side}: Sigma of Gaussian Fit {eta} - residuals',8, 0, 8, 16, .5, 16.5)
69 output2 =
TH2F(f
'h_residual_mean_{eta}_E{side}',f
'EndCap{side}: Mean of Gaussian Fit {eta} - residuals',8, 0, 8, 16, .5, 16.5)
72 for xbin
in range(len(thisLabelx)):
73 output1.GetXaxis().SetBinLabel(xbin+1, thisLabelx[xbin])
74 output2.GetXaxis().SetBinLabel(xbin+1, thisLabelx[xbin])
75 output1.GetYaxis().SetTitle(
'Sector')
76 output1.GetZaxis().SetTitle(
'#sigma [mm]')
77 output2.GetYaxis().SetTitle(
'Sector')
78 output2.GetZaxis().SetTitle(
'Mean [mm]')
80 for ihisto
in range(len(inputs)):
81 h = inputs[ihisto][1][0]
82 sector = inputs[ihisto][1][0].GetName()[19:21]
83 ml = inputs[ihisto][1][0].GetName()[43:44]
84 gap = inputs[ihisto][1][0].GetName()[52:53]
86 sector = inputs[ihisto][1][0].GetName()[19:20]
87 ml = inputs[ihisto][1][0].GetName()[42:43]
88 gap = inputs[ihisto][1][0].GetName()[51:52]
90 xbin =
int(gap) + (
int(ml) -1)*4
93 output1.SetBinContent(xbin,ybin,sigma)
94 output2.SetBinContent(xbin,ybin,mean)
95 output1.GetZaxis().SetRangeUser(0, 10)
96 output2.GetZaxis().SetRangeUser(-5, 5)
98 return [output1,output2]
101 inputs =
list(inputs)
104 if(
'CSide' in inputs[0][1][0].GetName()):
107 if(
'stEta1' in inputs[0][1][0].GetName()):
110 output =
TH2F(f
'h_landau_{eta}_E{side}',f
'E{side}: MPV of Landau Fit to Cluster charge {eta}',8, 0, 8, 16, .5, 16.5)
113 for xbin
in range(len(thisLabelx)):
114 output.GetXaxis().SetBinLabel(xbin+1, thisLabelx[xbin])
115 output.GetYaxis().SetTitle(
'Sector')
116 output.GetZaxis().SetTitle(
'MPV')
118 for ihisto
in range(len(inputs)):
119 h = inputs[ihisto][1][0]
120 sector = inputs[ihisto][1][0].GetName()[18:20]
121 ml = inputs[ihisto][1][0].GetName()[37:38]
122 gap = inputs[ihisto][1][0].GetName()[42:43]
124 sector = inputs[ihisto][1][0].GetName()[18:19]
125 ml = inputs[ihisto][1][0].GetName()[36:37]
126 gap = inputs[ihisto][1][0].GetName()[41:42]
128 xbin =
int(gap) + (
int(ml) -1)*4
130 if (h.GetEntries()==0):
134 output.SetBinContent(xbin,ybin,mpv)
138 inputs =
list(inputs)
141 for i
in range(len(inputs)):
142 h=inputs[i][1][0].Clone()
143 histos_unsorted.append(h.GetName())
144 names.append(h.GetName())
150 if(
'eta1' in names[0]):
156 if(
'CSide' in names[0]):
158 list_of_all_histos=[]
159 for phi
in range(16):
161 for mult
in range(2):
163 test_list.append(f
'{histo_name}_{side}_{eta}_phi{phi+1}_ml{mult+1}_gap{gg+1}')
164 list_of_all_histos.append(test_list)
167 for ihisto
in range(len(names)):
168 ind = histos_unsorted.index(names[ihisto])
169 histos_sorted.append(inputs[ind][1][0])
170 if proctype==
'fermiDirac_tzero':
171 h_poi_per_PCB =
TH2F(f
'{histo_name}_{side}_{eta}_tzero_per_PCB',
poi(histo_name,side,eta)+
' tzero' , bins, 0, bins, 16, .5, 16.5)
172 elif proctype==
'fermiDirac_deltat':
173 h_poi_per_PCB =
TH2F(f
'{histo_name}_{side}_{eta}_tzero_per_PCB',
poi(histo_name,side,eta)+
' deltaT' , bins, 0, bins, 16, .5, 16.5)
175 h_poi_per_PCB =
TH2F(f
'{histo_name}_{side}_{eta}_per_PCB',
poi(histo_name,side,eta), bins, 0, bins, 16, .5, 16.5)
179 for xbin
in range(len(thisLabelx)):
180 h_poi_per_PCB.GetXaxis().SetBinLabel(xbin+1, thisLabelx[xbin])
181 h_poi_per_PCB.GetYaxis().SetTitle(
'Sector')
183 for ihisto
in range(len(histos_sorted)):
184 histo_name=histos_sorted[ihisto].GetName()
185 iphi = histos_sorted[ihisto].GetName()[start_index:start_index+2]
187 iphi = histos_sorted[ihisto].GetName()[start_index:start_index+1]
189 xbin,ybin =
getXYbins(nPCB,
int(iphi),
False, histos_sorted[ihisto].GetName(), list_of_all_histos)
190 for ipcb
in range(nPCB):
191 histo_tmp = histos_sorted[ihisto].ProjectionY(histos_sorted[ihisto].GetName()+
"_py_"+
str(ipcb+1),ipcb+1,ipcb+1)
193 if (histo_tmp.GetEntries()==0):
194 h_poi_per_PCB.SetBinContent(xbin, ybin, -999)
196 h_poi_per_PCB.SetBinContent(xbin, ybin, histo_tmp.GetMean())
197 h_poi_per_PCB.GetZaxis().SetRangeUser(0, 20)
199 if (histo_tmp.GetEntries()<100):
200 h_poi_per_PCB.SetBinContent(xbin, ybin, -999)
203 h_poi_per_PCB.SetBinContent(xbin, ybin, gmean)
204 h_poi_per_PCB.GetZaxis().SetRangeUser(-100, 700)
205 if proctype==
'landau':
206 if (histo_tmp.GetEntries()<100):
207 h_poi_per_PCB.SetBinContent(xbin, ybin, -999)
210 h_poi_per_PCB.SetBinContent(xbin, ybin, mpv)
211 h_poi_per_PCB.GetZaxis().SetRangeUser(0, 100)
212 if proctype==
'fermiDirac_tzero':
213 if (histo_tmp.GetEntries()<100):
214 h_poi_per_PCB.SetBinContent(xbin, ybin, -999)
217 h_poi_per_PCB.SetBinContent(xbin, ybin, t0)
218 h_poi_per_PCB.GetZaxis().SetRangeUser(-100, 700)
219 if proctype==
'fermiDirac_deltat':
220 if (histo_tmp.GetEntries()<100):
221 h_poi_per_PCB.SetBinContent(xbin, ybin, -999)
224 h_poi_per_PCB.SetBinContent(xbin, ybin, tmax-t0)
225 h_poi_per_PCB.GetZaxis().SetRangeUser(0, 300)
227 return[h_poi_per_PCB]
231 h1 = inputs[0][1][0].Clone()
232 putLine(h1, 16, 0.5, 16, 16.5, offset=0, c=2)
233 putLine(h1, 32, 0.5, 32, 16.5, offset=0, c=2)
234 putLine(h1, 48, 0.5, 48, 16.5, offset=0, c=2)
235 putLine(h1, 64, 0.5, 64, 16.5, offset=0, c=2)
236 putLine(h1, 80, 0.5, 80, 16.5, offset=0, c=2)
237 putLine(h1, 96, 0.5, 96, 16.5, offset=0, c=2)
238 putLine(h1, 112, 0.5, 112, 16.5, offset=0, c=2)
240 h2 = inputs[0][1][1].Clone()
241 putLine(h2, 16, 0.5, 16, 16.5, offset=0, c=2)
242 putLine(h2, 32, 0.5, 32, 16.5, offset=0, c=2)
243 putLine(h2, 48, 0.5, 48, 16.5, offset=0, c=2)
244 putLine(h2, 64, 0.5, 64, 16.5, offset=0, c=2)
245 putLine(h2, 80, 0.5, 80, 16.5, offset=0, c=2)
246 putLine(h2, 96, 0.5, 96, 16.5, offset=0, c=2)
247 putLine(h2, 112, 0.5, 112, 16.5, offset=0, c=2)
252 def putLine(h, x1, y1, x2, y2, offset=0, c=1):
253 line = TLine(x1-offset, y1, x2-offset, y2)
257 h.GetListOfFunctions().Add(line)