4 from ROOT
import TBufferFile, TH1F, TProfile, TProfile2D, TH2F, TFile, TH1D, TH2D
9 def draw_line(lineList,x1,x2,y1,y2,width=1,style=1,color=1):
10 from ROOT
import TLine
12 l.SetBit(ROOT.kCanDelete)
19 def draw_box(boxList,xl,xr,yl,yr,opacity=1,color=1,style=1001,lstyle=1,lw=3):
22 b.SetBit(ROOT.kCanDelete)
24 b.SetFillColorAlpha(color, opacity)
27 b.SetLineStyle(lstyle)
32 from ROOT
import TCanvas,TLine
34 coordSign=[(-1,-1),(-1,1),(1,-1),(1,1)]
35 for xsign,ysign
in coordSign:
39 yhigh= ysign*(0.5 + nlad[layer-1])
41 draw_line(lineList,xlow, xhigh, ylow, ylow)
42 draw_line(lineList,xlow, xhigh, yhigh, yhigh)
43 draw_line(lineList,xlow, xlow, ylow, yhigh)
44 draw_line(lineList,xhigh, xhigh, ylow, yhigh)
46 for lad
in range(nlad[layer-1]):
48 if lad != nlad[layer-1]:
52 draw_line(lineList,xlow, xhigh, y, y, 1, 3);
56 x = xsign * (mod + 0.5);
62 for lad
in range(nlad[layer-1]):
65 flipped = not(lad%2==0)
67 flipped = not(lad%2==1)
68 if flipped : roc0_orientation = -1
69 else : roc0_orientation = 1
70 if xsign==-1 : roc0_orientation *= -1
71 if ysign==-1 : roc0_orientation *= -1
72 x1 = xsign * (mod+0.5)
73 x2 = xsign * (mod+0.5 - 1./8);
75 y2 = ysign * (lad + roc0_orientation*1./2)
76 if layer == 1
and xsign == -1 :
77 x1 = xsign * (mod-0.5)
78 x2 = xsign * (mod-0.5 + 1./8)
80 y2 = ysign * (lad - roc0_orientation*1./2)
94 rocShiftX=(15-roc)*1./8
97 flipped = not(lad%2==0)
99 flipped = not(lad%2==1)
100 if flipped : roc0_orientation = -1
101 else : roc0_orientation = 1
102 if xsign==-1 : roc0_orientation *= -1
103 if ysign==-1 : roc0_orientation *= -1
104 x1 = xsign * (mod+0.5-rocShiftX)
105 x2 = xsign * (mod+0.5 - 1./8-rocShiftX);
106 y1 = ysign * (lad-roc0_orientation*rocShiftY)
107 y2 = ysign * (lad + roc0_orientation*1./2-roc0_orientation*rocShiftY)
108 if layer == 1
and xsign == -1 :
109 x1 = xsign * (mod-0.5)-rocShiftX
110 x2 = xsign * (mod-0.5 + 1./8)-rocShiftX
111 y1 = ysign * (lad +rocShiftY)
112 y2 = ysign * (lad - roc0_orientation*1./2+rocShiftY)
118 from ROOT
import TCanvas,TLine
119 coordSign=[(-1,-1),(-1,1),(1,-1),(1,1)]
120 for dsk
in range(3) :
122 for xsign,ysign
in coordSign:
123 for bld
in range(5+ring*6):
126 x1 = xsign * (0.5 + dsk - 1)
127 x2 = xsign * (0.5 + dsk)
129 y1 = ysign * (bld + sign*0.5)
131 yp2_mid = ysign * (bld - sign*0.25)
132 y3 = ysign * (bld - sign*0.5)
135 draw_line(lineList,x1, x2, yp2_mid, yp2_mid,1,2)
138 x = xsign * (0.5 + dsk - 1)
142 x = xsign * (0.5 + dsk)
146 x1 = xsign * (0.5 + dsk - 1/8.)
147 x2 = xsign * (0.5 + dsk)
148 y1_p1 = ysign * (bld + sign*0.25)
149 y2_p1 = ysign * (bld + sign*0.25 + xsign*ysign*0.25)
150 draw_line(lineList,x1, x2, y1_p1, y1_p1, 1)
151 draw_line(lineList,x1, x1, y1_p1, y2_p1, 1)
152 y1_p2 = ysign * (bld - sign*0.25)
153 y2_p2 = ysign * (bld - sign*0.25 - xsign*ysign*0.25)
158 from ROOT
import TCanvas,TLine
163 rocShiftX=(15-roc)*1./8
166 x1 = xsign * (0.5 + dsk - 1/8.-rocShiftX)
167 x2 = xsign * (0.5 + dsk-rocShiftX)
169 y1 = ysign * (bld + sign*0.25)-xsign*rocShiftY
170 y2 = ysign * (bld + sign*0.25 + xsign*ysign*0.25)-xsign*rocShiftY
172 y1 = ysign * (bld - sign*0.25)+xsign*rocShiftY
173 y2 = ysign * (bld - sign*0.25 - xsign*ysign*0.25)+xsign*rocShiftY
178 datareq = urllib2.Request((
'%s/data/json/samples?match=%s') % (server, match))
179 datareq.add_header(
'User-agent', ident)
181 data = eval(re.sub(
r"\bnan\b",
"0", urllib2.build_opener(X509CertOpen()).open(datareq).read()),
182 {
"__builtins__":
None }, {})
184 for l
in data[
'samples']:
185 if l[
'type'] == type:
187 if int(x[
'run']) ==
int(run):
201 if len(sys.argv) != 2:
202 print "input file needed!" 206 print filename+
" -- "+filename[19:25]
207 runNum=filename[19:25]
209 dir=
"DQMData/Run " + runNum +
"/PixelPhase1/Run summary/Pahse1_MechanicalView/" 210 dirFED=
"DQMData/Run " + runNum +
"/PixelPhase1/Run summary/FED/" 213 dirBPix=dir +
"PXBarrel/" 214 dirFPix=dir +
"PXForward/" 216 hoccB=
"digi_occupancy_per_SignedModuleCoord_per_SignedLadderCoord_PXLayer_" 217 hoccF=
"digi_occupancy_per_SignedDiskCoord_per_SignedBladePanelCoord_PXRing_" 218 hdeadB=
"Dead Channels per ROC_per_SignedModuleCoord_per_SignedLadderCoord_PXLayer_" 219 hdeadF=
"Dead Channels per ROC_per_SignedDiskCoord_per_SignedBladePanelCoord_PXRing_" 221 ROOT.gROOT.SetBatch(1)
222 ROOT.gStyle.SetOptStat(0)
223 ROOT.gStyle.SetPalette(1)
224 ROOT.gStyle.SetNumberContours(128)
225 rootf=ROOT.TFile(filename)
229 c=ROOT.TCanvas(
"c",
"c",1250,1000)
231 print "----> Build maps for BPix" 234 for lyr
in range(1,5):
235 histOccList.append(rootf.FindObjectAny(hoccB+
str(lyr)))
236 histDeadList.append(rootf.FindObjectAny(hdeadB+
str(lyr)))
237 for hist1, hist2
in zip(histOccList, histDeadList):
238 if hist1 !=
None or hist2 !=
None:
240 match=re.search(
'(?<=PXLayer_)[0-9]',hist1.GetName())
241 if match !=
None and "per_SignedModuleCoord_per_SignedLadderCoord" in hist1.GetName():
242 lyr=
int(match.group(0))
243 hist1.SetTitle(
"Digi Occupancy Layer {0}".
format(lyr))
255 for biny
in range(1,hist2.GetNbinsY()+1):
257 x1=hist2.GetXaxis().GetBinLowEdge(binTBM[0])
258 x2=hist2.GetXaxis().GetBinUpEdge(binTBM[len(binTBM)-1])
259 y1=hist2.GetYaxis().GetBinLowEdge(biny-1)
260 y2=hist2.GetYaxis().GetBinUpEdge(biny-1)
261 if hist2.GetBinContent(binTBM[0],biny-1) >= 0.97*hist2.GetMaximum():
262 draw_box(boxList,x1,x2,y1,y2,0.2,1,0,1,lineWd)
264 draw_box(boxList,x1,x2,y1,y2,0.2,633,0,1,lineWd)
266 for binx
in range(1,hist2.GetNbinsX()+1):
267 if hist2.GetBinContent(binx,biny)!=0:
271 if len(binTBM)==tbmRoc:
272 x1=hist2.GetXaxis().GetBinLowEdge(binTBM[0])
273 x2=hist2.GetXaxis().GetBinUpEdge(binTBM[len(binTBM)-1])
274 y1=hist2.GetYaxis().GetBinLowEdge(biny)
275 y2=hist2.GetYaxis().GetBinUpEdge(biny)
276 if hist2.GetBinContent(binTBM[0],biny) >= 0.97*hist2.GetMaximum():
277 draw_box(boxList,x1,x2,y1,y2,0.2,1,0,1,lineWd)
279 draw_box(boxList,x1,x2,y1,y2,0.2,633,0,1,lineWd)
286 x1=hist2.GetXaxis().GetBinLowEdge(binTBM[0])
287 x2=hist2.GetXaxis().GetBinUpEdge(binTBM[len(binTBM)-1])
288 y1=hist2.GetYaxis().GetBinLowEdge(biny)
289 y2=hist2.GetYaxis().GetBinUpEdge(biny)
290 if hist2.GetBinContent(binTBM[0],biny) >= 0.97*hist2.GetMaximum():
291 draw_box(boxList,x1,x2,y1,y2,0.2,1,0,1,lineWd)
293 draw_box(boxList,x1,x2,y1,y2,0.2,633,0,1,lineWd)
294 c.SaveAs(
'MergedOccupancyDeadROC_BPix_Layer{0}_TBM.pdf'.
format(lyr))
295 os.system(
'gs -dBATCH -dNOPAUSE -sDEVICE=png16m -dUseCropBox -sOutputFile=MergedOccupancyDeadROC_BPix_Layer{0}_TBM.png -r144 -q MergedOccupancyDeadROC_BPix_Layer{0}_TBM.pdf'.
format(lyr))
296 os.system(
'rm -f MergedOccupancyDeadROC_BPix_Layer{0}_TBM.pdf'.
format(lyr))
298 print "Some Error in get the histograms for FPIX" 300 print "----> Build maps for FPix" 301 for rng
in range(1,3):
302 histOccList.append(rootf.FindObjectAny(hoccF+
str(rng)))
303 histDeadList.append(rootf.FindObjectAny(hdeadF+
str(rng)))
304 for hist1, hist2
in zip(histOccList, histDeadList):
305 if hist1 !=
None or hist2 !=
None:
307 match=re.search(
'(?<=PXRing_)[0-9]',hist1.GetName())
308 if match !=
None and "per_SignedDiskCoord_per_SignedBladePanelCoord" in hist1.GetName():
309 ring=
int(match.group(0))
310 hist1.SetTitle(
"Digi Occupancy Ring {0}".
format(ring))
319 for biny
in range(1,hist2.GetNbinsY()+1):
321 x1=hist2.GetXaxis().GetBinLowEdge(binTBM[0])
322 x2=hist2.GetXaxis().GetBinUpEdge(binTBM[len(binTBM)-1])
323 y1=hist2.GetYaxis().GetBinLowEdge(biny-1)
324 y2=hist2.GetYaxis().GetBinUpEdge(biny-1)
325 if hist2.GetBinContent(binTBM[0],biny-1) >= 0.97*hist2.GetMaximum():
326 draw_box(boxList,x1,x2,y1,y2,0.2,1,0,1,lineWd)
328 draw_box(boxList,x1,x2,y1,y2,0.2,633,0,1,lineWd)
330 for binx
in range(1,hist2.GetNbinsX()+1):
331 if hist2.GetBinContent(binx,biny)!=0:
335 if len(binTBM)==tbmRoc:
336 x1=hist2.GetXaxis().GetBinLowEdge(binTBM[0])
337 x2=hist2.GetXaxis().GetBinUpEdge(binTBM[len(binTBM)-1])
338 y1=hist2.GetYaxis().GetBinLowEdge(biny)
339 y2=hist2.GetYaxis().GetBinUpEdge(biny)
340 if hist2.GetBinContent(binTBM[0],biny) >= 0.97*hist2.GetMaximum():
341 draw_box(boxList,x1,x2,y1,y2,0.2,1,0,1,lineWd)
343 draw_box(boxList,x1,x2,y1,y2,0.2,633,0,1,lineWd)
350 x1=hist2.GetXaxis().GetBinLowEdge(binTBM[0])
351 x2=hist2.GetXaxis().GetBinUpEdge(binTBM[len(binTBM)-1])
352 y1=hist2.GetYaxis().GetBinLowEdge(biny)
353 y2=hist2.GetYaxis().GetBinUpEdge(biny)
354 if hist2.GetBinContent(binTBM[0],biny) >= 0.97*hist2.GetMaximum():
355 draw_box(boxList,x1,x2,y1,y2,0.2,1,0,1,lineWd)
357 draw_box(boxList,x1,x2,y1,y2,0.2,633,0,1,lineWd)
358 c.SaveAs(
'MergedOccupancyDeadROC_FPix_Ring{0}_TBM.pdf'.
format(ring))
359 os.system(
'gs -dBATCH -dNOPAUSE -sDEVICE=png16m -dUseCropBox -sOutputFile=MergedOccupancyDeadROC_FPix_Ring{0}_TBM.png -r144 -q MergedOccupancyDeadROC_FPix_Ring{0}_TBM.pdf'.
format(ring))
360 os.system(
'rm -f MergedOccupancyDeadROC_FPix_Ring{0}_TBM.pdf'.
format(ring))
363 print "Some Error in get the histograms for FPIX" 368 if __name__ ==
'__main__':
def draw_box(boxList, xl, xr, yl, yr, opacity=1, color=1, style=1001, lstyle=1, lw=3)
def draw_line(lineList, x1, x2, y1, y2, width=1, style=1, color=1)
def maskFPixROC(boxList, xsign, ysign, dsk, bld, pnl, roc)
OutputIterator zip(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp)
def maskBPixROC(boxList, xsign, ysign, layer, lad, mod, roc)
def dqm_get_dataset(server, match, run, type="offline_data")
def renderPluginFPIX(lineList, ring)
def renderPluginBPIX(lineList, layer)