CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
plotting.ROC Class Reference

Public Member Functions

def __init__ (self, name, xhistoName, yhistoName, zaxis=False)
 
def __str__ (self)
 
def create (self, tdirectory)
 

Private Attributes

 _name
 
 _xhistoName
 
 _yhistoName
 
 _zaxis
 

Detailed Description

Class to construct a ROC curve (e.g. efficiency vs. fake rate) from two histograms

Definition at line 1121 of file plotting.py.

Constructor & Destructor Documentation

◆ __init__()

def plotting.ROC.__init__ (   self,
  name,
  xhistoName,
  yhistoName,
  zaxis = False 
)
Constructor.

Arguments:
name       -- String for the name of the resulting histogram
xhistoName -- String for the name of the x-axis histogram (or another "creator" object)
yhistoName -- String for the name of the y-axis histogram (or another "creator" object)

Keyword arguments:
zaxis -- If set to True (default False), create a TGraph2D with z axis showing the cut value (recommended drawStyle 'pcolz')

Definition at line 1123 of file plotting.py.

1123  def __init__(self, name, xhistoName, yhistoName, zaxis=False):
1124  """Constructor.
1125 
1126  Arguments:
1127  name -- String for the name of the resulting histogram
1128  xhistoName -- String for the name of the x-axis histogram (or another "creator" object)
1129  yhistoName -- String for the name of the y-axis histogram (or another "creator" object)
1130 
1131  Keyword arguments:
1132  zaxis -- If set to True (default False), create a TGraph2D with z axis showing the cut value (recommended drawStyle 'pcolz')
1133  """
1134  self._name = name
1135  self._xhistoName = xhistoName
1136  self._yhistoName = yhistoName
1137  self._zaxis = zaxis
1138 

Member Function Documentation

◆ __str__()

def plotting.ROC.__str__ (   self)

◆ create()

def plotting.ROC.create (   self,
  tdirectory 
)
Create and return the histogram from a TDirectory

Definition at line 1143 of file plotting.py.

1143  def create(self, tdirectory):
1144  """Create and return the histogram from a TDirectory"""
1145  xhisto = _getOrCreateObject(tdirectory, self._xhistoName)
1146  yhisto = _getOrCreateObject(tdirectory, self._yhistoName);
1147  if xhisto is None or yhisto is None:
1148  return None
1149 
1150  x = []
1151  xerrup = []
1152  xerrdown = []
1153  y = []
1154  yerrup = []
1155  yerrdown = []
1156  z = []
1157 
1158  for i in range(1, xhisto.GetNbinsX()+1):
1159  x.append(xhisto.GetBinContent(i))
1160  xerrup.append(xhisto.GetBinError(i))
1161  xerrdown.append(xhisto.GetBinError(i))
1162 
1163  y.append(yhisto.GetBinContent(i))
1164  yerrup.append(yhisto.GetBinError(i))
1165  yerrdown.append(yhisto.GetBinError(i))
1166 
1167  z.append(xhisto.GetXaxis().GetBinUpEdge(i))
1168 
1169  # If either axis has only zeroes, no graph makes no point
1170  if x.count(0.0) == len(x) or y.count(0.0) == len(y):
1171  return None
1172 
1173  arr = lambda v: array.array("d", v)
1174  gr = None
1175  if self._zaxis:
1176  gr = ROOT.TGraph2D(len(x), arr(x), arr(y), arr(z))
1177  else:
1178  gr = ROOT.TGraphAsymmErrors(len(x), arr(x), arr(y), arr(xerrdown), arr(xerrup), arr(yerrdown), arr(yerrup))
1179  gr.SetTitle("")
1180  return gr
1181 
1182 
1183 # Plot styles

References plotting._getOrCreateObject(), plotting.ROC._xhistoName, plotting.ROC._yhistoName, plotting.ROC._zaxis, and FastTimerService_cff.range.

Member Data Documentation

◆ _name

plotting.ROC._name
private

◆ _xhistoName

plotting.ROC._xhistoName
private

Definition at line 1135 of file plotting.py.

Referenced by plotting.ROC.create().

◆ _yhistoName

plotting.ROC._yhistoName
private

Definition at line 1136 of file plotting.py.

Referenced by plotting.ROC.create().

◆ _zaxis

plotting.ROC._zaxis
private

Definition at line 1137 of file plotting.py.

Referenced by plotting.ROC.create().

FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
beamerCreator.create
def create(alignables, pedeDump, additionalData, outputFile, config)
Definition: beamerCreator.py:44
TriggerAnalyzer.__str__
def __str__(self)
Definition: TriggerAnalyzer.py:103
plotting._getOrCreateObject
def _getOrCreateObject(tdirectory, nameOrCreator)
Definition: plotting.py:57