CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
trackingPlots.TrackingSeedingLayerTable Class Reference

Public Member Functions

def __init__ (self, fileName, plots, titles, isRate, kwargs)
 
def create (self, tdirectoryNEvents, requireAllHistograms=False)
 
def draw (self, legendLabels, prefix=None, directory="", args, kwargs)
 
def onlyForPileup (self)
 

Private Attributes

 _fileName
 
 _format
 
 _plots
 
 _titles
 

Detailed Description

Definition at line 1040 of file trackingPlots.py.

Constructor & Destructor Documentation

◆ __init__()

def trackingPlots.TrackingSeedingLayerTable.__init__ (   self,
  fileName,
  plots,
  titles,
  isRate,
  kwargs 
)

Definition at line 1041 of file trackingPlots.py.

1041  def __init__(self, fileName, plots, titles, isRate, **kwargs):
1042  self._plots = plots
1043  self._titles = titles
1044  self._fileName = fileName
1045  self._format = "%.4g" if isRate else "%d"
1046 
1047  if len(plots) != len(titles):
1048  raise Exception("Number of plots (%d) has to be the same as number of titles (%d)" % (len(plots), len(titles)))
1049 
1050  def _set(attr, default):
1051  setattr(self, "_"+attr, kwargs.get(attr, default))
1052 
1053  _set("onlyForPileup", False)
1054 
def __init__(self, dataset, job_number, job_id, job_name, isDA, isMC, applyBOWS, applyEXTRACOND, extraconditions, runboundary, lumilist, intlumi, maxevents, gt, allFromGT, alignmentDB, alignmentTAG, apeDB, apeTAG, bowDB, bowTAG, vertextype, tracktype, refittertype, ttrhtype, applyruncontrol, ptcut, CMSSW_dir, the_dir)

Member Function Documentation

◆ create()

def trackingPlots.TrackingSeedingLayerTable.create (   self,
  tdirectoryNEvents,
  requireAllHistograms = False 
)

Definition at line 1059 of file trackingPlots.py.

References trackingPlots.TrackingSeedingLayerTable._plots, plotting.PlotGroup._plots, plotting.PlotOnSideGroup._plots, and plotting.Plotter._plots.

1059  def create(self, tdirectoryNEvents, requireAllHistograms=False):
1060  # [plot][histo]
1061  for plot in self._plots:
1062  plot.create(tdirectoryNEvents, requireAllHistograms)
1063 
def create(alignables, pedeDump, additionalData, outputFile, config)

◆ draw()

def trackingPlots.TrackingSeedingLayerTable.draw (   self,
  legendLabels,
  prefix = None,
  directory = "",
  args,
  kwargs 
)

Definition at line 1064 of file trackingPlots.py.

References L1Validator._fileName, trackingPlots.TrackingSeedingLayerTable._fileName, trackingPlots.TrackingSeedingLayerTable._format, plotting._mergeBinLabelsX(), trackingPlots.TrackingSeedingLayerTable._plots, plotting.PlotGroup._plots, plotting.PlotOnSideGroup._plots, plotting.Plotter._plots, plotting._th1IncludeOnlyBins(), plotting._th1RemoveEmptyBins(), trackingPlots.TrackingSeedingLayerTable._titles, genParticles_cff.map, SiStripPI.max, FastTimerService_cff.range, str, and reco.zip().

1064  def draw(self, legendLabels, prefix=None, directory="", *args, **kwargs):
1065  # Do not make the table if it would be empty
1066  onlyEmptyPlots = True
1067  for plot in self._plots:
1068  if not plot.isEmpty():
1069  onlyEmptyPlots = False
1070  break
1071  if onlyEmptyPlots:
1072  return []
1073 
1074  haveShortLabels = False
1075  legendLabels = legendLabels[:]
1076  if max(map(len, legendLabels)) > 20:
1077  haveShortLabels = True
1078  labels_short = [str(chr(ord('A')+i)) for i in range(len(legendLabels))]
1079  for i, ls in enumerate(labels_short):
1080  legendLabels[i] = "%s: %s" % (ls, legendLabels[i])
1081  else:
1082  labels_short = legendLabels
1083 
1084  content = [
1085  '<html>',
1086  ' <body>',
1087  ' <table border="1">',
1088  ' <tr>',
1089  ]
1090 
1091 
1092  histos_linear = []
1093  histos_index = []
1094  labels = []
1095  for plot, title in zip(self._plots, self._titles):
1096  h_tmp = []
1097  l_tmp = []
1098  for h, l in zip(plot._histograms, labels_short):
1099  if h is not None:
1100  h_tmp.append(len(histos_linear))
1101  histos_linear.append(h)
1102  l_tmp.append(l)
1103 
1104  if len(h_tmp) > 0:
1105  histos_index.append(h_tmp)
1106  labels.append(l_tmp)
1107  content.extend([
1108  ' <td></td>',
1109  ' <td colspan="%d">%s</td>' % (len(h_tmp), title),
1110  ])
1111 
1112  if len(histos_linear) == 0:
1113  return []
1114 
1115  content.extend([
1116  ' </tr>',
1117  ' <tr>',
1118  ])
1119 
1120  xbinlabels = plotting._mergeBinLabelsX(histos_linear)
1121  histos_linear = plotting._th1IncludeOnlyBins(histos_linear, xbinlabels)
1122  if len(histos_linear) == 0:
1123  return []
1124  (histos_linear_new, xbinlabels) = plotting._th1RemoveEmptyBins(histos_linear, xbinlabels)
1125  # in practice either all histograms are returned, or none, but let's add a check anyway
1126  if len(histos_linear_new) > 0 and len(histos_linear_new) != len(histos_linear):
1127  raise Exception("This should never happen. len(histos_linear_new) %d != len(histos_linear) %d" % (len(histos_linear_new), len(histos_linear)))
1128  histos_linear = histos_linear_new
1129  if len(histos_linear) == 0:
1130  return []
1131 
1132  data = [ [h.GetBinContent(i) for i in range(1, h.GetNbinsX()+1)] for h in histos_linear]
1133  table = html.Table(["dummy"]*len(histos_linear), xbinlabels, data, None, None, None)
1134  data = table.tableAsRowColumn()
1135 
1136  for labs in labels:
1137  content.append(' <td></td>')
1138  content.extend([' <td>%s</td>' % lab for lab in labs])
1139  content.extend([
1140  ' </tr>',
1141  ])
1142 
1143  for irow, row in enumerate(data):
1144  content.extend([
1145  ' <tr>',
1146  ' <td>%s</td>' % table.rowHeaders()[irow]
1147  ])
1148 
1149  for hindices in histos_index:
1150  for hindex in hindices:
1151  item = row[hindex]
1152  formatted = self._format%item if item is not None else ""
1153  content.append(' <td align="right">%s</td>' % formatted)
1154  content.append(' <td></td>')
1155  del content[-1]
1156  content.append(' </tr>')
1157 
1158  content.append(' </table>')
1159  if haveShortLabels:
1160  for lab in legendLabels:
1161  content.append(' %s<br/>' % lab)
1162 
1163  content.extend([
1164  ' </body>',
1165  '<html>'
1166  ])
1167 
1168  name = self._fileName
1169  if prefix is not None:
1170  name = prefix+name
1171  name += ".html"
1172  name = os.path.join(directory, name)
1173 
1174  with open(name, "w") as f:
1175  for line in content:
1176  f.write(line)
1177  f.write("\n")
1178  return [name]
1179 
ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE constexpr float zip(ConstView const &tracks, int32_t i)
Definition: TracksSoA.h:90
def draw(name, histos, styles=_defaultStyles, legendLabels=[], kwargs)
def _th1RemoveEmptyBins(histos, xbinlabels)
Definition: plotting.py:607
#define str(s)
def _mergeBinLabelsX(histos)
Definition: plotting.py:707
def _th1IncludeOnlyBins(histos, xbinlabels)
Definition: plotting.py:744

◆ onlyForPileup()

def trackingPlots.TrackingSeedingLayerTable.onlyForPileup (   self)
Return True if the PlotGroup is intended only for pileup samples

Definition at line 1055 of file trackingPlots.py.

References plotting.PlotFolder._onlyForPileup.

1055  def onlyForPileup(self):
1056  """Return True if the PlotGroup is intended only for pileup samples"""
1057  return self._onlyForPileup
1058 

Member Data Documentation

◆ _fileName

trackingPlots.TrackingSeedingLayerTable._fileName
private

Definition at line 1044 of file trackingPlots.py.

Referenced by trackingPlots.TrackingSeedingLayerTable.draw().

◆ _format

trackingPlots.TrackingSeedingLayerTable._format
private

Definition at line 1045 of file trackingPlots.py.

Referenced by trackingPlots.TrackingSeedingLayerTable.draw().

◆ _plots

trackingPlots.TrackingSeedingLayerTable._plots
private

◆ _titles

trackingPlots.TrackingSeedingLayerTable._titles
private

Definition at line 1043 of file trackingPlots.py.

Referenced by trackingPlots.TrackingSeedingLayerTable.draw().