CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 375 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 377 of file plotting.py.

378  def __init__(self, name, xhistoName, yhistoName, zaxis=False):
379  """Constructor.
380 
381  Arguments:
382  name -- String for the name of the resulting histogram
383  xhistoName -- String for the name of the x-axis histogram (or another "creator" object)
384  yhistoName -- String for the name of the y-axis histogram (or another "creator" object)
385 
386  Keyword arguments:
387  zaxis -- If set to True (default False), create a TGraph2D with z axis showing the cut value (recommended drawStyle 'pcolz')
388  """
389  self._name = name
390  self._xhistoName = xhistoName
391  self._yhistoName = yhistoName
392  self._zaxis = zaxis
def __init__
Definition: plotting.py:377

Member Function Documentation

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

Definition at line 393 of file plotting.py.

References FP420HitsObject._name, TrackerHitsObject._name, PGeometricDet::Item._name, LikelihoodSpecies._name, LikelihoodPdfProduct._name, LikelihoodPdf._name, citk::IsolationConeDefinitionBase._name, DrellYanValidation._name, WValidation._name, HistoParams< T >._name, CutApplicatorBase._name, ElectronMVAEstimatorRun2Phys14NonTrig._name, PhotonMVAEstimatorRun2Spring15NonTrig._name, PhotonMVAEstimatorRun2Phys14NonTrig._name, GeometricDetExtra._name, ElectronMVAEstimatorRun2Spring15Trig._name, ElectronMVAEstimatorRun2Spring15NonTrig._name, HistoParams< TH2F >._name, plotting.Subtract._name, HistoParams< TProfile2D >._name, plotting.FakeDuplicate._name, plotting.AggregateBins._name, plotting.AggregateHistos._name, plotting.ROC._name, Vispa.Views.PropertyView.Property._name, and SequenceTypes.SequencePlaceholder._name.

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

Definition at line 397 of file plotting.py.

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

398  def create(self, tdirectory):
399  """Create and return the histogram from a TDirectory"""
400  xhisto = _getOrCreateObject(tdirectory, self._xhistoName)
401  yhisto = _getOrCreateObject(tdirectory, self._yhistoName);
402  if xhisto is None or yhisto is None:
403  return None
404 
405  x = []
406  xerrup = []
407  xerrdown = []
408  y = []
409  yerrup = []
410  yerrdown = []
411  z = []
412 
413  for i in xrange(1, xhisto.GetNbinsX()+1):
414  x.append(xhisto.GetBinContent(i))
415  xerrup.append(xhisto.GetBinError(i))
416  xerrdown.append(xhisto.GetBinError(i))
417 
418  y.append(yhisto.GetBinContent(i))
419  yerrup.append(yhisto.GetBinError(i))
420  yerrdown.append(yhisto.GetBinError(i))
421 
422  z.append(xhisto.GetXaxis().GetBinUpEdge(i))
423 
424  arr = lambda v: array.array("d", v)
425  gr = None
426  if self._zaxis:
427  gr = ROOT.TGraph2D(len(x), arr(x), arr(y), arr(z))
428  else:
429  gr = ROOT.TGraphAsymmErrors(len(x), arr(x), arr(y), arr(xerrdown), arr(xerrup), arr(yerrdown), arr(yerrup))
430  gr.SetTitle("")
431  return gr
432 
433 
# Plot styles
def _getOrCreateObject
Definition: plotting.py:16

Member Data Documentation

plotting.ROC._name
private

Definition at line 388 of file plotting.py.

Referenced by plotting.ROC.__str__(), plotting.Plot._createOne(), plotting.PlotGroup._drawSeparate(), plotting.PlotGroup._save(), plotting.PlotGroup.draw(), plotting.Plot.getName(), plotting.PlotterFolder.getName(), plotting.PlotterFolder.getSelectionNameIterator(), validation.SimpleSample.name(), and plotting.PlotterItem.readDirs().

plotting.ROC._xhistoName
private

Definition at line 389 of file plotting.py.

Referenced by plotting.ROC.create().

plotting.ROC._yhistoName
private

Definition at line 390 of file plotting.py.

Referenced by plotting.ROC.create().

plotting.ROC._zaxis
private

Definition at line 391 of file plotting.py.

Referenced by plotting.ROC.create().