21barColor = [ROOT.kRed,ROOT.kRed-7,ROOT.kMagenta,ROOT.kMagenta-6,ROOT.kBlue,ROOT.kBlue-9,
41gain[
'H8'][3.65] = [49,50,51,52,53,58,59,71,74,80,86,89]
42gain[
'H8'][2.5] =[46,47,54,55,56,60,72,81,87,90]
45gain[
'H6'][3.65] =[247,248,249,250,251,252,253,254,255,284,290]
77 f = ROOT.TFile.Open(tdcCanvas)
78 tTDCcalib = f.Get(
'tTDCcalib_'+sdict[s]).Clone()
80 for pad
in tTDCcalib.GetListOfPrimitives():
81 for z
in pad.GetListOfPrimitives():
82 if z.Class_Name().find(
'TH1')==0: tag = z.GetName()
83 if tag.find(
'Mean')<0:
continue
84 for z
in pad.GetListOfPrimitives():
85 if z.Class_Name().find(
'TH1')==0:
86 h[tag] = z.Clone(
'h'+tag)
87 h[tag].SetDirectory(ROOT.gROOT)
89 if z.Class_Name() ==
'TGraphErrors':
90 h[
'g'+tag] = z.Clone()
94 h[
'L'+g] = ROOT.TGraphErrors()
95 h[
'R'+g] = ROOT.TGraphErrors()
97 h[x+g].SetLineColor(h[g].GetLineColor())
98 h[x+g].SetMarkerStyle(h[g].GetMarkerStyle())
99 for n
in range(h[g].GetN()):
100 if h[g].GetPointX(n)<80:
102 h[
'L'+g].SetPoint(nl,h[g].GetPointX(n),h[g].GetPointY(n))
103 h[
'L'+g].SetPointError(nl,h[g].GetErrorX(n),h[g].GetErrorY(n))
106 h[
'R'+g].SetPoint(nr,h[g].GetPointX(n)-80,h[g].GetPointY(n))
107 h[
'R'+g].SetPointError(nr,h[g].GetErrorX(n)-80,h[g].GetErrorY(n))
110 h[
'T'] = ROOT.TCanvas(
'T',sdict[s],1,1,1200,900)
112 h[Ltag].GetXaxis().SetRange(1,81)
115 h[
'L'+g].Draw(
'same')
116 h[
'R'+g].Draw(
'same')
154 runEvol = {1:{},2:{}}
155 badChannels = {1:{},2:{}}
159 for i
in C[r][s][l][
'mean']:
160 value = C[r][s][l][
'mean'][i]
162 rError = value[1] / value[0]
163 if rError > 0.05:
continue
164 if not key
in runEvol[s]: runEvol[s][key] = ROOT.TGraph()
165 n = runEvol[s][key].GetN()
166 runEvol[s][key].SetPoint(n,value[0],1.)
167 ut.bookHist(h,
'rms'+sdict[s],
'rms',1000,-1.,1.)
168 ut.bookCanvas(h,sdict[s],
'',900,600,1,1)
170 for key
in runEvol[s]:
171 x = runEvol[s][key].GetRMS()/runEvol[s][key].GetMean()
172 rc = h[
'rms'+sdict[s]].Fill(x)
173 if abs(x)>0.2: badChannels[key]=x
174 print(
"%s : %5.2F %5.2F %5.2F"%(key,x,runEvol[s][key].GetRMS(),runEvol[s][key].GetMean()))
175 h[
'rms'+sdict[s]+
'100']=h[
'rms'+sdict[s]].Rebin(10,
'rms'+sdict[s]+
'100')
176 h[
'rms'+sdict[s]+
'100'].Draw()
177 return runEvol,badChannels
180 for r
in X.split(
','):
182 F = ROOT.TFile.Open(options.path+
"MuFilterEff_run"+str(r)+
".root")
183 options.runNumber = r
185 if s==1
and int(r)<100:
continue
186 h[
'tdcCalib'+sdict[s]] = {}
187 for l
in range(systemAndPlanes[s]):
188 for bar
in range(systemAndBars[s]):
189 for side
in [
'L',
'R']:
190 key = sdict[s]+str(s*10+l)+
'_'+str(bar)
191 for i
in range(systemAndChannels[s][1]+systemAndChannels[s][0]):
192 if i==t0_channel:
continue
193 j = side+
'_'+key+
'-c'+str(i)
196 h[
'tdcCalib'+sdict[s]][j] =[0,0,0,0]
197 h[x] = F.GetKey(x).ReadObj()
198 if h[x].GetEntries()>10:
199 rc = h[x].Fit(
'gaus',
'SNQ')
200 rc = h[x].Fit(
'gaus',
'SNQ')
203 h[
'tdcCalib'+sdict[s]][j] =[res.Parameter(1),res.ParError(1),res.Parameter(2),res.ParError(2)]
205 for l
in range(systemAndPlanes[s]):
206 tag = sdict[s]+str(l)
207 ut.bookCanvas(h,
'sigmaTDC_'+tag,
'TDC RMS '+tag,2000,600,systemAndBars[s],2)
208 ut.bookCanvas(h,
'TDCcalib_'+tag,
'TDC TDCi-T0 '+tag,2000,600,systemAndBars[s],2)
210 for bar
in range(systemAndBars[s]):
211 for side
in [
'L',
'R']:
212 key = sdict[s]+str(10*s+l)+
'_'+str(bar)
213 for i
in range(systemAndChannels[s][1]+systemAndChannels[s][0]):
214 j = side+
'_'+key+
'-c'+str(i)
215 for x
in [
'sigmaTDC_'+tag,
'TDCcalib_'+tag]:
216 if x.find(
'calib')>0
and (i==t0_channel):
continue
219 if i==0
and x.find(
'calib')<0: opt=
""
220 if i==1
and x.find(
'calib')>0: opt=
""
221 aHist = x.split(
'_')[0]+j
222 h[aHist] = F.GetKey(aHist).ReadObj()
223 h[aHist].SetLineColor(barColor[i])
224 h[aHist].GetXaxis().SetRangeUser(-5,5)
226 h[aHist].Draw(opt+
'HIST')
228 myPrint(h[
'sigmaTDC_'+tag],
'TDC/TDCrms_'+tag)
229 myPrint(h[
'TDCcalib_'+tag],
'TDC/TDCcalib_'+tag)
231 ut.bookHist(h,
'TDCcalibMean_'+tag,
';SiPM channel ; [ns]',160,0.,160.)
232 ut.bookHist(h,
'TDCcalibSigma_'+tag,
';SiPM channel ; [ns]',160,0.,160.)
233 h[
'gTDCcalibMean_'+tag]=ROOT.TGraphErrors()
234 h[
'gTDCcalibSigma_'+tag]=ROOT.TGraphErrors()
236 for x
in h[
'tdcCalib'+sdict[s]]:
237 tmp = h[
'tdcCalib'+sdict[s]][x]
240 if z[0]==
'R': side = 1
241 l = z[1][len(z[1])-1]
243 c = z[2].split(
'c')[1]
244 xbin = int(bar)*16+side*8+int(c)
245 tag = sdict[s]+str(l)
246 rc = h[
'TDCcalibMean_'+tag].SetBinContent(xbin+1,tmp[0])
247 rc = h[
'TDCcalibMean_'+tag].SetBinError(xbin+1,tmp[1])
248 rc = h[
'TDCcalibSigma_'+tag].SetBinContent(xbin+1,tmp[2])
249 rc = h[
'TDCcalibSigma_'+tag].SetBinError(xbin+1,tmp[3])
251 ut.bookCanvas(h,
'tTDCcalib_'+sdict[s],
'TDC calib '+sdict[s],2400,1800,2,systemAndPlanes[s])
252 for l
in range(systemAndPlanes[s]):
253 tag = sdict[s]+str(l)
254 aHistS = h[
'TDCcalibSigma_'+tag]
255 aHistM = h[
'TDCcalibMean_'+tag]
257 for i
in range(1,aHistS.GetNbinsX()):
258 if aHistS.GetBinContent(i)>0:
259 h[
'gTDCcalibSigma_'+tag].SetPoint(k,i-1,aHistS.GetBinContent(i))
260 h[
'gTDCcalibSigma_'+tag].SetPointError(k,0.5,aHistS.GetBinError(i))
261 h[
'gTDCcalibMean_'+tag].SetPoint(k,i-1,aHistM.GetBinContent(i))
262 h[
'gTDCcalibMean_'+tag].SetPointError(k,0.5,aHistM.GetBinError(i))
265 planeColor = {0:ROOT.kBlue,1:ROOT.kRed,2:ROOT.kGreen,3:ROOT.kCyan,4:ROOT.kMagenta}
266 for l
in range(systemAndPlanes[s]):
267 tag = sdict[s]+str(l)
268 tc = h[
'tTDCcalib_'+sdict[s]].cd(2*l+1)
269 aHistS = h[
'TDCcalibSigma_'+tag]
271 aHistS.SetMaximum(2.0)
273 h[
'gTDCcalibSigma_'+tag].SetLineColor(planeColor[l])
274 h[
'gTDCcalibSigma_'+tag].Draw(
'same')
276 for l
in range(systemAndPlanes[s]):
277 tag = sdict[s]+str(l)
278 tc = h[
'tTDCcalib_'+sdict[s]].cd(2*l+2)
279 aHistM = h[
'TDCcalibMean_'+tag]
281 aHistM.SetMaximum(2.0)
282 aHistM.SetMinimum(-2.0)
284 h[
'gTDCcalibMean_'+tag].SetLineColor(planeColor[l])
285 h[
'gTDCcalibMean_'+tag].Draw(
'same')
286 myPrint(h[
'tTDCcalib_'+sdict[s]],
'TDC/TDCcalibration_'+sdict[s])