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

493  def __init__(self, name, xhistoName, yhistoName, zaxis=False):
494  """Constructor.
495 
496  Arguments:
497  name -- String for the name of the resulting histogram
498  xhistoName -- String for the name of the x-axis histogram (or another "creator" object)
499  yhistoName -- String for the name of the y-axis histogram (or another "creator" object)
500 
501  Keyword arguments:
502  zaxis -- If set to True (default False), create a TGraph2D with z axis showing the cut value (recommended drawStyle 'pcolz')
503  """
504  self._name = name
505  self._xhistoName = xhistoName
506  self._yhistoName = yhistoName
507  self._zaxis = zaxis
def __init__
Definition: plotting.py:492

Member Function Documentation

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

Definition at line 508 of file plotting.py.

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

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

Definition at line 512 of file plotting.py.

References plotting._getOrCreateObject(), plotting.ROC._xhistoName, plotting.ROC._yhistoName, hcaldqm::Container2D._zaxis, hcaldqm::ContainerSingle2D._zaxis, and plotting.ROC._zaxis.

513  def create(self, tdirectory):
514  """Create and return the histogram from a TDirectory"""
515  xhisto = _getOrCreateObject(tdirectory, self._xhistoName)
516  yhisto = _getOrCreateObject(tdirectory, self._yhistoName);
517  if xhisto is None or yhisto is None:
518  return None
519 
520  x = []
521  xerrup = []
522  xerrdown = []
523  y = []
524  yerrup = []
525  yerrdown = []
526  z = []
527 
528  for i in xrange(1, xhisto.GetNbinsX()+1):
529  x.append(xhisto.GetBinContent(i))
530  xerrup.append(xhisto.GetBinError(i))
531  xerrdown.append(xhisto.GetBinError(i))
532 
533  y.append(yhisto.GetBinContent(i))
534  yerrup.append(yhisto.GetBinError(i))
535  yerrdown.append(yhisto.GetBinError(i))
536 
537  z.append(xhisto.GetXaxis().GetBinUpEdge(i))
538 
539  # If either axis has only zeroes, no graph makes no point
540  if x.count(0.0) == len(x) or y.count(0.0) == len(y):
541  return None
542 
543  arr = lambda v: array.array("d", v)
544  gr = None
545  if self._zaxis:
546  gr = ROOT.TGraph2D(len(x), arr(x), arr(y), arr(z))
547  else:
548  gr = ROOT.TGraphAsymmErrors(len(x), arr(x), arr(y), arr(xerrdown), arr(xerrup), arr(yerrdown), arr(yerrup))
549  gr.SetTitle("")
550  return gr
551 
552 
# Plot styles
def _getOrCreateObject
Definition: plotting.py:22

Member Data Documentation

plotting.ROC._name
private

Definition at line 503 of file plotting.py.

Referenced by plotting.ROC.__str__(), plotting.PlotGroup._drawSeparate(), plotting.PlotGroup._save(), 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(), and plotting.PlotGroup.remove().

plotting.ROC._xhistoName
private

Definition at line 504 of file plotting.py.

Referenced by plotting.ROC.create().

plotting.ROC._yhistoName
private

Definition at line 505 of file plotting.py.

Referenced by plotting.ROC.create().

plotting.ROC._zaxis
private

Definition at line 506 of file plotting.py.

Referenced by plotting.ROC.create().