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.

Definition at line 37 of file PixelMapPlotter.py.

Constructor & Destructor Documentation

◆ __init__()

def PixelMapPlotter.HistogramManager.__init__ (   self)

Definition at line 38 of file PixelMapPlotter.py.

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

Member Function Documentation

◆ drawLine()

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

Definition at line 110 of file PixelMapPlotter.py.

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

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

◆ drawRectangle()

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

Definition at line 117 of file PixelMapPlotter.py.

117  def drawRectangle(self, lineObj, x1, x2, y1, y2, width=2, style=1, color=1):
118  self.drawLine(lineObj, x1, x2, y2, y2, width, style, color)
119  self.drawLine(lineObj, x2, x2, y2, y1, width, style, color)
120  self.drawLine(lineObj, x2, x1, y1, y1, width, style, color)
121  self.drawLine(lineObj, x1, x1, y1, y2, width, style, color)
122 

References PixelMapPlotter.HistogramManager.drawLine().

Referenced by PixelMapPlotter.HistogramManager.prettifyCanvas().

◆ fillHistograms()

def PixelMapPlotter.HistogramManager.fillHistograms (   self,
  barrelObjs,
  forwardObjs 
)

Definition at line 80 of file PixelMapPlotter.py.

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

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

◆ prettifyCanvas()

def PixelMapPlotter.HistogramManager.prettifyCanvas (   self,
  hist 
)

Definition at line 123 of file PixelMapPlotter.py.

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

References PixelMapPlotter.HistogramManager.drawLine(), PixelMapPlotter.HistogramManager.drawRectangle(), dqmMemoryStats.float, createfilelist.int, edm.print(), and FastTimerService_cff.range.

Referenced by PixelMapPlotter.HistogramManager.saveHistograms().

◆ saveHistograms()

def PixelMapPlotter.HistogramManager.saveHistograms (   self)

Definition at line 232 of file PixelMapPlotter.py.

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

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

Member Data Documentation

◆ barrelHists

PixelMapPlotter.HistogramManager.barrelHists

◆ forwardHists

PixelMapPlotter.HistogramManager.forwardHists
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
RPCNoise_cfi.fillHistograms
fillHistograms
Definition: RPCNoise_cfi.py:8
PixelMapPlotter.TranslateReasonStringFPix
def TranslateReasonStringFPix(theReasonStr)
Definition: PixelMapPlotter.py:402
ntuplePlotting.saveHistograms
def saveHistograms(tdirectory, histos)
Definition: ntuplePlotting.py:9
PixelMapPlotter.TranslateReasonStringBPix
def TranslateReasonStringBPix(theReasonStr)
Definition: PixelMapPlotter.py:379
str
#define str(s)
Definition: TestProcessor.cc:48
mps_setup.append
append
Definition: mps_setup.py:85
createfilelist.int
int
Definition: createfilelist.py:10
edm::print
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66