CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Attributes
plotting.ROC Class Reference

Public Member Functions

def __init__
 
def __str__
 
def create
 

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

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.

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

Member Function Documentation

def plotting.ROC.__str__ (   self)
String representation, returns the name

Definition at line 1139 of file plotting.py.

References FP420HitsObject._name, TrackerHitsObject._name, PGeometricDet::Item._name, TrackingRecHitAlgorithm._name, Logger._name, hcaldqm::DQModule._name, citk::IsolationConeDefinitionBase._name, DrellYanValidation._name, WValidation._name, hcaldqm::flag::Flag._name, hcaldqm::quantity::Quantity._name, HistoParams< T >._name, CutApplicatorBase._name, HistoParams< TH2F >._name, HistoParams< TProfile2D >._name, SequenceTypes.SequencePlaceholder._name, plotting.Subtract._name, plotting.Transform._name, plotting.FakeDuplicate._name, plotting.CutEfficiency._name, plotting.AggregateBins._name, plotting.AggregateHistos._name, plotting.ROC._name, and SequenceTypes.TaskPlaceholder._name.

1140  def __str__(self):
1141  """String representation, returns the name"""
1142  return self._name
def plotting.ROC.create (   self,
  tdirectory 
)
Create and return the histogram from a TDirectory

Definition at line 1143 of file plotting.py.

References plotting._getOrCreateObject(), plotting.ROC._xhistoName, plotting.ROC._yhistoName, plotting.ROC._zaxis, and sistrip::SpyUtilities.range().

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 
# Plot styles
const uint16_t range(const Frame &aFrame)
def _getOrCreateObject
Definition: plotting.py:57

Member Data Documentation

plotting.ROC._name
private

Definition at line 1134 of file plotting.py.

Referenced by plotting.ROC.__str__(), trackingPlots.TimePerEventPlot.__str__(), trackingPlots.TimePerTrackPlot.__str__(), trackingPlots.TimePerEventPlot._create(), plotting.PlotGroup._drawSeparate(), plotting.PlotGroup._save(), trackingPlots.TimePerTrackPlot.create(), plotting.Plot.create(), plotting.PlotGroup.draw(), plotting.Plot.getName(), plotting.PlotGroup.getName(), plotting.PlotterFolder.getName(), plotting.PlotterItem.getName(), plotting.PlotterFolder.getSelectionNameIterator(), validation.SimpleSample.name(), trackingPlots.Iteration.name(), plotting.PlotterItem.readDirs(), plotting.PlotGroup.remove(), and plotting.Plot.setName().

plotting.ROC._xhistoName
private

Definition at line 1135 of file plotting.py.

Referenced by plotting.ROC.create().

plotting.ROC._yhistoName
private

Definition at line 1136 of file plotting.py.

Referenced by plotting.ROC.create().

plotting.ROC._zaxis
private

Definition at line 1137 of file plotting.py.

Referenced by plotting.ROC.create().