CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes
PixelMapPlotter.HistogramManager Class Reference

GLOBAL VARS. More...

Public Member Functions

def __init__ (self)
 
def drawLine (self, lineObj, x1, x2, y1, y2, width=2, style=1, color=1)
 
def drawRectangle (self, lineObj, x1, x2, y1, y2, width=2, style=1, color=1)
 
def fillHistograms (self, barrelObjs, forwardObjs)
 
def prettifyCanvas (self, hist)
 
def saveHistograms (self)
 

Public Attributes

 barrelHists
 
 forwardHists
 

Detailed Description

GLOBAL VARS.

GLOBAL VARS

Definition at line 36 of file PixelMapPlotter.py.

Constructor & Destructor Documentation

def PixelMapPlotter.HistogramManager.__init__ (   self)

Definition at line 37 of file PixelMapPlotter.py.

37  def __init__(self):
38  self.barrelHists = []
39  self.forwardHists = []
40 
41  # barrel histograms
42  i = 1
43  for maxLadder in onlineMaxLadder:
44  nBinsX = (maxOnlineModule * 2 + 1) * rocsInRow
45  nBinsY = (maxLadder * 2 + 1) * rocsInCol
46 
47  name = "PXBarrel_Layer" + str(i);
48  title = "PXBarrel_Layer" + str(i);
49 
50  histObj = ROOT.TH2F(name, title, nBinsX, -(maxOnlineModule + 0.5), maxOnlineModule + 0.5, nBinsY, -(maxLadder + 0.5), maxLadder + 0.5)
51  histObj.GetXaxis().SetTitle("OnlineSignedModule");
52  histObj.GetYaxis().SetTitle("OnlineSignedLadder");
53  histObj.SetOption("COLZ")
54  histObj.SetStats(0)
55  histObj.SetTitle("OnlineSignedModule")
56 
57  self.barrelHists.append(deepcopy(histObj))
58  i = i + 1
59 
60  # forward histograms
61  i = 1
62  for maxBlade in onlineMaxBlade:
63  nBinsX = (maxOnlineDisk * 2 + 1) * rocsInRow
64  nBinsY = (maxBlade * 2 + 1) * 2 * rocsInCol
65 
66  name = "PXForward_Ring" + str(i);
67  title = "PXForward_Ring" + str(i);
68 
69  histObj = ROOT.TH2F(name, title, nBinsX, -(maxOnlineDisk + 0.5), maxOnlineDisk + 0.5, nBinsY, -(maxBlade + 0.5), maxBlade + 0.5)
70  histObj.GetXaxis().SetTitle("OnlineSignedDisk");
71  histObj.GetYaxis().SetTitle("OnlineSignedBladePanel");
72  histObj.SetOption("COLZ")
73  histObj.SetStats(0)
74 
75 
76  self.forwardHists.append(deepcopy(histObj))
77  i = i + 1
78 

Member Function Documentation

def PixelMapPlotter.HistogramManager.drawLine (   self,
  lineObj,
  x1,
  x2,
  y1,
  y2,
  width = 2,
  style = 1,
  color = 1 
)

Definition at line 109 of file PixelMapPlotter.py.

Referenced by PixelMapPlotter.HistogramManager.drawRectangle(), and PixelMapPlotter.HistogramManager.prettifyCanvas().

109  def drawLine(self, lineObj, x1, x2, y1, y2, width=2, style=1, color=1):
110  lineObj.SetLineWidth(width)
111  lineObj.SetLineStyle(style)
112  lineObj.SetLineColor(color)
113 
114  lineObj.DrawLine(x1, y1, x2, y2)
115 
def drawLine(self, lineObj, x1, x2, y1, y2, width=2, style=1, color=1)
def PixelMapPlotter.HistogramManager.drawRectangle (   self,
  lineObj,
  x1,
  x2,
  y1,
  y2,
  width = 2,
  style = 1,
  color = 1 
)

Definition at line 116 of file PixelMapPlotter.py.

References PixelMapPlotter.HistogramManager.drawLine().

Referenced by PixelMapPlotter.HistogramManager.prettifyCanvas().

116  def drawRectangle(self, lineObj, x1, x2, y1, y2, width=2, style=1, color=1):
117  self.drawLine(lineObj, x1, x2, y2, y2, width, style, color)
118  self.drawLine(lineObj, x2, x2, y2, y1, width, style, color)
119  self.drawLine(lineObj, x2, x1, y1, y1, width, style, color)
120  self.drawLine(lineObj, x1, x1, y1, y2, width, style, color)
121 
def drawLine(self, lineObj, x1, x2, y1, y2, width=2, style=1, color=1)
def drawRectangle(self, lineObj, x1, x2, y1, y2, width=2, style=1, color=1)
def PixelMapPlotter.HistogramManager.fillHistograms (   self,
  barrelObjs,
  forwardObjs 
)

Definition at line 79 of file PixelMapPlotter.py.

References PixelMapPlotter.HistogramManager.barrelHists, objects.autophobj.float, PixelMapPlotter.HistogramManager.forwardHists, PixelMapPlotter.TranslateReasonStringBPix(), and PixelMapPlotter.TranslateReasonStringFPix().

79  def fillHistograms(self, barrelObjs, forwardObjs):
80  for b in barrelObjs:
81  coord = b.GetXYCoords()
82  histRef = self.barrelHists[b.layer - 1]
83 
84  binNum = histRef.FindBin(coord[0], coord[1])
85  if colorCoded:
86  binContent = TranslateReasonStringBPix(b.reason)
87  elif pixelAlive:
88  binContent = float(b.reason)
89  else:
90  binContent = b.roc + 1
91 
92  histRef.SetBinContent(binNum, binContent)
93  # self.barrelHists[b.layer - 1].Fill(coord[0], coord[1], b.roc + 1)
94 
95  for f in forwardObjs:
96  coord = f.GetXYCoords()
97  histRef = self.forwardHists[f.ring - 1]
98 
99  binNum = histRef.FindBin(coord[0], coord[1])
100 
101  if colorCoded:
102  binContent = TranslateReasonStringFPix(f.reason)
103  else:
104  binContent = f.roc + 1
105  histRef.SetBinContent(binNum, binContent)
106 
107  # self.forwardHists[f.ring - 1].Fill(coord[0], coord[1], f.roc + 1)
108 
def TranslateReasonStringFPix(theReasonStr)
def TranslateReasonStringBPix(theReasonStr)
def fillHistograms(self, barrelObjs, forwardObjs)
def PixelMapPlotter.HistogramManager.prettifyCanvas (   self,
  hist 
)

Definition at line 122 of file PixelMapPlotter.py.

References PixelMapPlotter.HistogramManager.drawLine(), PixelMapPlotter.HistogramManager.drawRectangle(), objects.autophobj.float, createfilelist.int, and edm.print().

Referenced by PixelMapPlotter.HistogramManager.saveHistograms().

122  def prettifyCanvas(self, hist):
123  nBinsX = hist.GetXaxis().GetNbins()
124  xMin = hist.GetXaxis().GetXmin()
125  xMax = hist.GetXaxis().GetXmax()
126  nBinsY = hist.GetYaxis().GetNbins()
127  yMin = hist.GetYaxis().GetXmin()
128  yMax = hist.GetYaxis().GetXmax()
129 
130  xLen = int(xMax)
131  yLen = int(yMax)
132 
133  name = hist.GetName()[0:3]
134  isBarrel = True if name != "PXF" else False
135  print(name, isBarrel)
136 
137  xBaseStep = 1
138  xRange = (nBinsX - 1) // (rocsInRow * 2) + 1
139  yBaseStep = (yMax - yMin) / nBinsY
140  yRange = (nBinsY - 1) // (2) + 1
141  if not isBarrel:
142  yBaseStep = yBaseStep * 2
143  yRange = yRange // 2
144 
145  # horizontal
146  x1 = xMin
147  x2 = xMin + xLen
148  y1 = yMin
149  y2 = yMin
150 
151  lineObj = ROOT.TLine()
152  lineObj.SetBit(ROOT.kCanDelete)
153 
154  for i in range(yRange):
155  w = 1 if i % 2 else 2
156  self.drawLine(lineObj, x1, x2, y1, y2, w)
157  self.drawLine(lineObj, x1, x2, -y1, -y2, w)
158  self.drawLine(lineObj, -x1, -x2, -y1, -y2,w )
159  self.drawLine(lineObj, -x1, -x2, y1, y2, w)
160 
161  y1 = y1 + yBaseStep
162  y2 = y2 + yBaseStep
163 
164  # vertical
165  x1 = xMin
166  x2 = xMin
167  y1 = yMin
168  y2 = yMin + yLen
169 
170  for i in range(xRange):
171  self.drawLine(lineObj, x1, x2, y1, y2, style = 9)
172  self.drawLine(lineObj, x1, x2, -y1, -y2, style = 9)
173  self.drawLine(lineObj, -x1, -x2, -y1, -y2, style = 9)
174  self.drawLine(lineObj, -x1, -x2, y1, y2, style = 9)
175 
176  x1 = x1 + xBaseStep
177  x2 = x2 + xBaseStep
178 
179  # mark zero ROC
180  zeroModuleHeight = yBaseStep if isBarrel else yBaseStep * 0.5 # because there are two panels height of roc is smaller
181 
182  yRange = int(yMax) if isBarrel else int(yMax) * 2
183 
184  x1_base = 0 + xMin
185  x2_base = xBaseStep / float(rocsInRow) + xMin
186  y1_base = zeroModuleHeight + yMin
187  y2_base = 2 * zeroModuleHeight + yMin
188 
189  for i in range(yRange):
190  y1 = y1_base + i * (zeroModuleHeight * 2) - (zeroModuleHeight if i % 2 else 0)
191  y2 = y2_base + i * (zeroModuleHeight * 2) - (zeroModuleHeight if i % 2 else 0)
192 
193  #negative ladders/blades
194  for j in range(int(xMax)):
195  x1 = x1_base + j * xBaseStep
196  x2 = x2_base + j * xBaseStep
197  if yMax == 6.5 and x1 <0:
198  y1 = y1_base + i * (zeroModuleHeight * 2) + (zeroModuleHeight if i % 2 else 0)
199  y2 = y2_base + i * (zeroModuleHeight * 2) + (zeroModuleHeight if i % 2 else 0)
200  self.drawRectangle(lineObj,(xBaseStep+x1-(x2-x1)),(xBaseStep+x2-(x2-x1)), y1+(y1-y2), y2+(y1-y2), color=8)
201  x1, x2 = -x1, -x2
202  yPosChange = -zeroModuleHeight if i % 2 else zeroModuleHeight
203  self.drawRectangle(lineObj, x1, x2, y1 - yPosChange-2*(zeroModuleHeight if i % 2 else 0), y2 - yPosChange-2*(zeroModuleHeight if i % 2 else 0), color=8)
204  else:
205  self.drawRectangle(lineObj, x1, x2, y1, y2, color=8)
206 
207  x1, x2 = -x1, -x2
208  yPosChange = -zeroModuleHeight if i % 2 else zeroModuleHeight
209  self.drawRectangle(lineObj, x1, x2, y1 - yPosChange, y2 - yPosChange, color=8)
210 
211 
212  # positive ladders/blades
213  y1 = y1 - yMin + yBaseStep
214  y2 = y2 - yMin + yBaseStep
215 
216  for j in range(int(xMax)):
217  x1 = x1_base + j * xBaseStep
218  x2 = x2_base + j * xBaseStep
219 
220  if yMax== 6.5 and x1 <0:
221  self.drawRectangle(lineObj, xBaseStep+x1-(x2-x1), xBaseStep+x2-(x2-x1), y1+(y1-y2), y2+(y1-y2), color=8)
222  x1, x2 = -x1, -x2
223  self.drawRectangle(lineObj, x1, x2, y1 - yPosChange- 2*(zeroModuleHeight if i % 2 else 0), y2 - yPosChange-2*(zeroModuleHeight if i % 2 else 0), color=8)
224  else:
225  self.drawRectangle(lineObj, x1, x2, y1, y2, color=8)
226  x1, x2 = -x1, -x2
227  self.drawRectangle(lineObj, x1, x2, y1 - yPosChange, y2 - yPosChange, color=8)
228 
229 # hist.GetZaxis().SetRangeUser(-0.5,15.5)
230 
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:65
def drawLine(self, lineObj, x1, x2, y1, y2, width=2, style=1, color=1)
def drawRectangle(self, lineObj, x1, x2, y1, y2, width=2, style=1, color=1)
def PixelMapPlotter.HistogramManager.saveHistograms (   self)

Definition at line 231 of file PixelMapPlotter.py.

References PixelMapPlotter.HistogramManager.barrelHists, PixelMapPlotter.HistogramManager.forwardHists, and PixelMapPlotter.HistogramManager.prettifyCanvas().

231  def saveHistograms(self):
232  for hists in [self.barrelHists, self.forwardHists]:
233  for hist in hists:
234  # if hist.GetEntries():
235  c1 = ROOT.TCanvas(hist.GetName(), hist.GetName(), hRes, vRes)
236  if colorCoded:
237  hist.GetZaxis().SetRangeUser(0,5)
238  ROOT.gStyle.SetPalette(55)
239  elif pixelAlive:
240  hist.GetZaxis().SetRangeUser(0,4160)
241  ROOT.gStyle.SetPalette(70)
242  hist.Draw()
243 
244  txt = TLatex()
245  txt.SetNDC()
246  txt.SetTextFont(1)
247  txt.SetTextColor(1)
248  txt.SetTextAlign(22)
249  txt.SetTextAngle(0)
250  txt.SetTextSize(0.05)
251  txt.DrawLatex(0.5, 0.95, hist.GetName())
252 
253  xMin = hist.GetXaxis().GetXmin()
254 
255  yMin = hist.GetYaxis().GetXmin()
256 
257  box1 = TBox(xMin*1.1,yMin*1.25,xMin*1,yMin*1.15);
258  box1.SetFillColor(kRed+3)
259  box1.Draw()
260  txt.SetTextSize(0.035)
261  txt.DrawLatex(0.25, 0.077, "Dead At Beginning")
262 
263 
264  box2 = TBox(xMin*0.45,yMin*1.25,xMin*0.35,yMin*1.15);
265  box2.SetFillColor(kAzure+2)
266  box2.Draw()
267  txt.SetTextSize(0.035)
268  txt.DrawLatex(0.47, 0.077, "Dead At End")
269 
270 
271  self.prettifyCanvas(hist)
272  colorString = ""
273  if colorCoded:
274  colorString = "_coded"
275  elif pixelAlive:
276  colorString = "_pixelalive"
277  if useFileSuffix:
278  c1.Print(hist.GetName() + colorString + "_" + inputFileName[:-4] + ".png")
279  else:
280  c1.Print(hist.GetName() + colorString + ".png")
281 

Member Data Documentation

PixelMapPlotter.HistogramManager.barrelHists
PixelMapPlotter.HistogramManager.forwardHists