CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Functions
MergeOccDeadROC Namespace Reference

Functions

def dqm_get_dataset
 
def draw_box
 
def draw_line
 
def main
 
def maskBPixROC
 
def maskFPixROC
 
def renderPluginBPIX
 
def renderPluginFPIX
 

Function Documentation

def MergeOccDeadROC.dqm_get_dataset (   server,
  match,
  run,
  type = "offline_data" 
)

Definition at line 178 of file MergeOccDeadROC.py.

References print(), and SiPixelLorentzAngle_cfi.read.

179 def dqm_get_dataset(server, match, run, type="offline_data"):
180  datareq = urllib2.Request(('%s/data/json/samples?match=%s') % (server, match))
181  datareq.add_header('User-agent', ident)
182  # Get data
183  data = eval(re.sub(r"\bnan\b", "0", urllib2.build_opener(X509CertOpen()).open(datareq).read()),
184  { "__builtins__": None }, {})
185  ret = ""
186  for l in data['samples']:
187  if l['type'] == type:
188  for x in l['items']:
189  if int(x['run']) == int(run):
190  ret=x['dataset']
191  break
192  print(ret)
193  return ret
194 
195 
196 
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
def MergeOccDeadROC.draw_box (   boxList,
  xl,
  xr,
  yl,
  yr,
  opacity = 1,
  color = 1,
  style = 1001,
  lstyle = 1,
  lw = 3 
)

Definition at line 20 of file MergeOccDeadROC.py.

Referenced by main(), maskBPixROC(), and maskFPixROC().

20 
21 def draw_box(boxList,xl,xr,yl,yr,opacity=1,color=1,style=1001,lstyle=1,lw=3):
22  from ROOT import TBox
23  b=TBox(xl,yl,xr,yr)
24  b.SetBit(ROOT.kCanDelete)
25  b.SetFillStyle(style)
26  b.SetFillColorAlpha(color, opacity)
27  b.SetLineColor(color)
28  b.SetLineWidth(lw)
29  b.SetLineStyle(lstyle)
30  b.Draw()
31  boxList.append(b)
def MergeOccDeadROC.draw_line (   lineList,
  x1,
  x2,
  y1,
  y2,
  width = 1,
  style = 1,
  color = 1 
)

Definition at line 10 of file MergeOccDeadROC.py.

Referenced by renderPluginBPIX(), and renderPluginFPIX().

10 
11 def draw_line(lineList,x1,x2,y1,y2,width=1,style=1,color=1):
12  from ROOT import TLine
13  l=TLine(x1,y1,x2,y2)
14  l.SetBit(ROOT.kCanDelete)
15  l.SetLineWidth(width)
16  l.SetLineStyle(style)
17  l.SetLineColor(color)
18  l.Draw()
19  lineList.append(l)
def MergeOccDeadROC.main ( )

Definition at line 197 of file MergeOccDeadROC.py.

References draw_box(), print(), sistrip::SpyUtilities.range(), renderPluginBPIX(), renderPluginFPIX(), str, and ComparisonHelper.zip().

198 def main():
199  import sys
200  import os
201  import ROOT
202 
203  if len(sys.argv) != 2:
204  print("input file needed!")
205  return
206  else:
207  filename=sys.argv[1]
208  print(filename+" -- "+filename[19:25])
209  runNum=filename[19:25]
210 
211  dir="DQMData/Run " + runNum + "/PixelPhase1/Run summary/Pahse1_MechanicalView/"
212  dirFED="DQMData/Run " + runNum + "/PixelPhase1/Run summary/FED/"
213 
214 
215  dirBPix=dir + "PXBarrel/"
216  dirFPix=dir + "PXForward/"
217 
218  hoccB="digi_occupancy_per_SignedModuleCoord_per_SignedLadderCoord_PXLayer_"
219  hoccF="digi_occupancy_per_SignedDiskCoord_per_SignedBladePanelCoord_PXRing_"
220  hdeadB="Dead Channels per ROC_per_SignedModuleCoord_per_SignedLadderCoord_PXLayer_"
221  hdeadF="Dead Channels per ROC_per_SignedDiskCoord_per_SignedBladePanelCoord_PXRing_"
222 
223  ROOT.gROOT.SetBatch(1)
224  ROOT.gStyle.SetOptStat(0)
225  ROOT.gStyle.SetPalette(1) #104 kTemperatureMap // 55 kRainBow
226  ROOT.gStyle.SetNumberContours(128)
227  rootf=ROOT.TFile(filename)
228 
229 
230 
231  c=ROOT.TCanvas("c","c",1250,1000)
232  #BPIX
233  print("----> Build maps for BPix")
234  histOccList=[]
235  histDeadList=[]
236  for lyr in range(1,5):
237  histOccList.append(rootf.FindObjectAny(hoccB+str(lyr)))
238  histDeadList.append(rootf.FindObjectAny(hdeadB+str(lyr)))
239  for hist1, hist2 in zip(histOccList, histDeadList):
240  if hist1 != None or hist2 !=None:
241  hist1.Draw("colz")
242  match=re.search('(?<=PXLayer_)[0-9]',hist1.GetName())
243  if match != None and "per_SignedModuleCoord_per_SignedLadderCoord" in hist1.GetName():
244  lyr=int(match.group(0))
245  hist1.SetTitle("Digi Occupancy Layer {0}".format(lyr))
246  boxList=[]
247  lineList=[]
248  renderPluginBPIX(lineList,lyr)
249  lineWd=3
250  if lyr==4 :
251  lineWd=2
252  if lyr==1:
253  tbmRoc=4
254  else:
255  tbmRoc=8
256  binTBM=[]
257  for biny in range(1,hist2.GetNbinsY()+1):
258  if len(binTBM)!=0:
259  x1=hist2.GetXaxis().GetBinLowEdge(binTBM[0])
260  x2=hist2.GetXaxis().GetBinUpEdge(binTBM[len(binTBM)-1])
261  y1=hist2.GetYaxis().GetBinLowEdge(biny-1)
262  y2=hist2.GetYaxis().GetBinUpEdge(biny-1)
263  if hist2.GetBinContent(binTBM[0],biny-1) >= 0.97*hist2.GetMaximum():
264  draw_box(boxList,x1,x2,y1,y2,0.2,1,0,1,lineWd)
265  else:
266  draw_box(boxList,x1,x2,y1,y2,0.2,633,0,1,lineWd)
267  binTBM=[]
268  for binx in range(1,hist2.GetNbinsX()+1):
269  if hist2.GetBinContent(binx,biny)!=0:
270  if len(binTBM)==0:
271  binTBM.append(binx)
272  else:
273  if len(binTBM)==tbmRoc:
274  x1=hist2.GetXaxis().GetBinLowEdge(binTBM[0])
275  x2=hist2.GetXaxis().GetBinUpEdge(binTBM[len(binTBM)-1])
276  y1=hist2.GetYaxis().GetBinLowEdge(biny)
277  y2=hist2.GetYaxis().GetBinUpEdge(biny)
278  if hist2.GetBinContent(binTBM[0],biny) >= 0.97*hist2.GetMaximum():
279  draw_box(boxList,x1,x2,y1,y2,0.2,1,0,1,lineWd)
280  else:
281  draw_box(boxList,x1,x2,y1,y2,0.2,633,0,1,lineWd)
282  binTBM=[]
283  binTBM.append(binx)
284  else:
285  binTBM.append(binx)
286  else:
287  if len(binTBM)!=0:
288  x1=hist2.GetXaxis().GetBinLowEdge(binTBM[0])
289  x2=hist2.GetXaxis().GetBinUpEdge(binTBM[len(binTBM)-1])
290  y1=hist2.GetYaxis().GetBinLowEdge(biny)
291  y2=hist2.GetYaxis().GetBinUpEdge(biny)
292  if hist2.GetBinContent(binTBM[0],biny) >= 0.97*hist2.GetMaximum():
293  draw_box(boxList,x1,x2,y1,y2,0.2,1,0,1,lineWd)
294  else:
295  draw_box(boxList,x1,x2,y1,y2,0.2,633,0,1,lineWd)
296  c.SaveAs('MergedOccupancyDeadROC_BPix_Layer{0}_TBM.pdf'.format(lyr))
297  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))
298  os.system('rm -f MergedOccupancyDeadROC_BPix_Layer{0}_TBM.pdf'.format(lyr))
299  else :
300  print("Some Error in get the histograms for FPIX")
301  #FPIX
302  print("----> Build maps for FPix")
303  for rng in range(1,3):
304  histOccList.append(rootf.FindObjectAny(hoccF+str(rng)))
305  histDeadList.append(rootf.FindObjectAny(hdeadF+str(rng)))
306  for hist1, hist2 in zip(histOccList, histDeadList):
307  if hist1 != None or hist2 !=None:
308  hist1.Draw("colz")
309  match=re.search('(?<=PXRing_)[0-9]',hist1.GetName())
310  if match != None and "per_SignedDiskCoord_per_SignedBladePanelCoord" in hist1.GetName():
311  ring=int(match.group(0))
312  hist1.SetTitle("Digi Occupancy Ring {0}".format(ring))
313  boxList=[]
314  lineList=[]
315  renderPluginFPIX(lineList,ring)
316  lineWd=3
317  if ring==2 :
318  lineWd=2
319  tbmRoc=8
320  binTBM=[]
321  for biny in range(1,hist2.GetNbinsY()+1):
322  if len(binTBM)!=0:
323  x1=hist2.GetXaxis().GetBinLowEdge(binTBM[0])
324  x2=hist2.GetXaxis().GetBinUpEdge(binTBM[len(binTBM)-1])
325  y1=hist2.GetYaxis().GetBinLowEdge(biny-1)
326  y2=hist2.GetYaxis().GetBinUpEdge(biny-1)
327  if hist2.GetBinContent(binTBM[0],biny-1) >= 0.97*hist2.GetMaximum():
328  draw_box(boxList,x1,x2,y1,y2,0.2,1,0,1,lineWd)
329  else:
330  draw_box(boxList,x1,x2,y1,y2,0.2,633,0,1,lineWd)
331  binTBM=[]
332  for binx in range(1,hist2.GetNbinsX()+1):
333  if hist2.GetBinContent(binx,biny)!=0:
334  if len(binTBM)==0:
335  binTBM.append(binx)
336  else:
337  if len(binTBM)==tbmRoc:
338  x1=hist2.GetXaxis().GetBinLowEdge(binTBM[0])
339  x2=hist2.GetXaxis().GetBinUpEdge(binTBM[len(binTBM)-1])
340  y1=hist2.GetYaxis().GetBinLowEdge(biny)
341  y2=hist2.GetYaxis().GetBinUpEdge(biny)
342  if hist2.GetBinContent(binTBM[0],biny) >= 0.97*hist2.GetMaximum():
343  draw_box(boxList,x1,x2,y1,y2,0.2,1,0,1,lineWd)
344  else:
345  draw_box(boxList,x1,x2,y1,y2,0.2,633,0,1,lineWd)
346  binTBM=[]
347  binTBM.append(binx)
348  else:
349  binTBM.append(binx)
350  else:
351  if len(binTBM)!=0:
352  x1=hist2.GetXaxis().GetBinLowEdge(binTBM[0])
353  x2=hist2.GetXaxis().GetBinUpEdge(binTBM[len(binTBM)-1])
354  y1=hist2.GetYaxis().GetBinLowEdge(biny)
355  y2=hist2.GetYaxis().GetBinUpEdge(biny)
356  if hist2.GetBinContent(binTBM[0],biny) >= 0.97*hist2.GetMaximum():
357  draw_box(boxList,x1,x2,y1,y2,0.2,1,0,1,lineWd)
358  else:
359  draw_box(boxList,x1,x2,y1,y2,0.2,633,0,1,lineWd)
360  c.SaveAs('MergedOccupancyDeadROC_FPix_Ring{0}_TBM.pdf'.format(ring))
361  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))
362  os.system('rm -f MergedOccupancyDeadROC_FPix_Ring{0}_TBM.pdf'.format(ring))
363 
364  else :
365  print("Some Error in get the histograms for FPIX")
366 
367 
368 
const uint16_t range(const Frame &aFrame)
OutputIterator zip(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
#define str(s)
def MergeOccDeadROC.maskBPixROC (   boxList,
  xsign,
  ysign,
  layer,
  lad,
  mod,
  roc 
)

Definition at line 90 of file MergeOccDeadROC.py.

References draw_box(), SiStripPI.max, and min().

90 
91 def maskBPixROC(boxList,xsign,ysign,layer,lad,mod,roc):
92  if roc<8 :
93  rocShiftX=roc*1./8
94  rocShiftY=0
95  else :
96  rocShiftX=(15-roc)*1./8
97  rocShiftY=1./2
98  if ysign==1:
99  flipped = not(lad%2==0)
100  else :
101  flipped = not(lad%2==1)
102  if flipped : roc0_orientation = -1
103  else : roc0_orientation = 1
104  if xsign==-1 : roc0_orientation *= -1
105  if ysign==-1 : roc0_orientation *= -1
106  x1 = xsign * (mod+0.5-rocShiftX)
107  x2 = xsign * (mod+0.5 - 1./8-rocShiftX);
108  y1 = ysign * (lad-roc0_orientation*rocShiftY)
109  y2 = ysign * (lad + roc0_orientation*1./2-roc0_orientation*rocShiftY)
110  if layer == 1 and xsign == -1 :
111  x1 = xsign * (mod-0.5)-rocShiftX
112  x2 = xsign * (mod-0.5 + 1./8)-rocShiftX
113  y1 = ysign * (lad +rocShiftY)
114  y2 = ysign * (lad - roc0_orientation*1./2+rocShiftY)
115  draw_box(boxList,min(x1,x2),max(x1,x2),min(y1, y2),max(y1,y2),0.75)
116 
117 
T min(T a, T b)
Definition: MathUtil.h:58
def MergeOccDeadROC.maskFPixROC (   boxList,
  xsign,
  ysign,
  dsk,
  bld,
  pnl,
  roc 
)

Definition at line 158 of file MergeOccDeadROC.py.

References draw_box(), SiStripPI.max, and min().

159 def maskFPixROC(boxList,xsign,ysign,dsk,bld,pnl,roc) :
160  from ROOT import TCanvas,TLine
161  if roc<8 :
162  rocShiftX=roc*1./8
163  rocShiftY=0
164  else :
165  rocShiftX=(15-roc)*1./8
166  rocShiftY=1./4
167  sign=ysign
168  x1 = xsign * (0.5 + dsk - 1/8.-rocShiftX)
169  x2 = xsign * (0.5 + dsk-rocShiftX)
170  if pnl==1:
171  y1 = ysign * (bld + sign*0.25)-xsign*rocShiftY
172  y2 = ysign * (bld + sign*0.25 + xsign*ysign*0.25)-xsign*rocShiftY
173  else:
174  y1 = ysign * (bld - sign*0.25)+xsign*rocShiftY
175  y2 = ysign * (bld - sign*0.25 - xsign*ysign*0.25)+xsign*rocShiftY
176  draw_box(boxList,min(x1,x2),max(x1,x2),min(y1,y2),max(y1,y2),0.75)
177 
T min(T a, T b)
Definition: MathUtil.h:58
def MergeOccDeadROC.renderPluginBPIX (   lineList,
  layer 
)

Definition at line 32 of file MergeOccDeadROC.py.

References draw_line(), and sistrip::SpyUtilities.range().

Referenced by main().

32 
33 def renderPluginBPIX(lineList,layer) :
34  from ROOT import TCanvas,TLine
35  nlad=[6,14,22,32]
36  coordSign=[(-1,-1),(-1,1),(1,-1),(1,1)]
37  for xsign,ysign in coordSign:
38  xlow = xsign*0.5
39  xhigh= xsign*(0.5+4)
40  ylow = ysign*0.5
41  yhigh= ysign*(0.5 + nlad[layer-1])
42  # Outside Box
43  draw_line(lineList,xlow, xhigh, ylow, ylow) # bottom
44  draw_line(lineList,xlow, xhigh, yhigh, yhigh) # top
45  draw_line(lineList,xlow, xlow, ylow, yhigh) # left
46  draw_line(lineList,xhigh, xhigh, ylow, yhigh) # right
47  # Inner Horizontal lines
48  for lad in range(nlad[layer-1]):
49  lad+=1
50  if lad != nlad[layer-1]:
51  y = ysign * (lad+0.5)
52  draw_line(lineList,xlow, xhigh, y, y)
53  y = ysign * (lad);
54  draw_line(lineList,xlow, xhigh, y, y, 1, 3);
55  # Inner Vertical lines
56  for mod in range(3) :
57  mod+=1
58  x = xsign * (mod + 0.5);
59  draw_line(lineList,x, x, ylow, yhigh);
60 
61  # Draw ROC0
62  for mod in range(4):
63  mod+=1
64  for lad in range(nlad[layer-1]):
65  lad+=1
66  if ysign==1:
67  flipped = not(lad%2==0)
68  else :
69  flipped = not(lad%2==1)
70  if flipped : roc0_orientation = -1
71  else : roc0_orientation = 1
72  if xsign==-1 : roc0_orientation *= -1
73  if ysign==-1 : roc0_orientation *= -1
74  x1 = xsign * (mod+0.5)
75  x2 = xsign * (mod+0.5 - 1./8);
76  y1 = ysign * (lad)
77  y2 = ysign * (lad + roc0_orientation*1./2)
78  if layer == 1 and xsign == -1 :
79  x1 = xsign * (mod-0.5)
80  x2 = xsign * (mod-0.5 + 1./8)
81  y1 = ysign * (lad)
82  y2 = ysign * (lad - roc0_orientation*1./2)
83 
84  draw_line(lineList,x1, x2, y1, y1, 1)
85  draw_line(lineList,x2, x2, y1, y2, 1)
86 
87  else:
88  draw_line(lineList,x1, x2, y1, y1, 1)
89  draw_line(lineList,x2, x2, y1, y2, 1)
const uint16_t range(const Frame &aFrame)
def MergeOccDeadROC.renderPluginFPIX (   lineList,
  ring 
)

Definition at line 118 of file MergeOccDeadROC.py.

References draw_line(), and sistrip::SpyUtilities.range().

Referenced by main().

119 def renderPluginFPIX(lineList,ring) :
120  from ROOT import TCanvas,TLine
121  coordSign=[(-1,-1),(-1,1),(1,-1),(1,1)]
122  for dsk in range(3) :
123  dsk+=1
124  for xsign,ysign in coordSign:
125  for bld in range(5+ring*6):
126  bld+=1
127  # Panel 2 has dashed mid-plane
128  x1 = xsign * (0.5 + dsk - 1)
129  x2 = xsign * (0.5 + dsk)
130  sign = ysign
131  y1 = ysign * (bld + sign*0.5)
132  y2 = ysign * (bld)
133  yp2_mid = ysign * (bld - sign*0.25)
134  y3 = ysign * (bld - sign*0.5)
135  draw_line(lineList,x1, x2, y1, y1)
136  draw_line(lineList,x1, x2, y2, y2)
137  draw_line(lineList,x1, x2, yp2_mid, yp2_mid,1,2)
138  draw_line(lineList,x1, x2, y3, y3)
139  # Vertical lines
140  x = xsign * (0.5 + dsk - 1)
141  draw_line(lineList,x, x, y1, y2)
142  draw_line(lineList,x, x, y2, y3)
143  if ring==2 :
144  x = xsign * (0.5 + dsk)
145  draw_line(lineList,x, x, y1, y2)
146  draw_line(lineList,x, x, y2, y3)
147  #Make a BOX around ROC 0
148  x1 = xsign * (0.5 + dsk - 1/8.)
149  x2 = xsign * (0.5 + dsk)
150  y1_p1 = ysign * (bld + sign*0.25)
151  y2_p1 = ysign * (bld + sign*0.25 + xsign*ysign*0.25)
152  draw_line(lineList,x1, x2, y1_p1, y1_p1, 1)
153  draw_line(lineList,x1, x1, y1_p1, y2_p1, 1)
154  y1_p2 = ysign * (bld - sign*0.25)
155  y2_p2 = ysign * (bld - sign*0.25 - xsign*ysign*0.25)
156  draw_line(lineList,x1, x2, y1_p2, y1_p2)
157  draw_line(lineList,x1, x1, y1_p2, y2_p2)
const uint16_t range(const Frame &aFrame)