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 1122 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 1124 of file plotting.py.

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

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 1144 of file plotting.py.

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

Referenced by plotting.ROC.create().

◆ _yhistoName

plotting.ROC._yhistoName
private

Definition at line 1137 of file plotting.py.

Referenced by plotting.ROC.create().

◆ _zaxis

plotting.ROC._zaxis
private

Definition at line 1138 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:58