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

947  def __init__(self, name, xhistoName, yhistoName, zaxis=False):
948  """Constructor.
949 
950  Arguments:
951  name -- String for the name of the resulting histogram
952  xhistoName -- String for the name of the x-axis histogram (or another "creator" object)
953  yhistoName -- String for the name of the y-axis histogram (or another "creator" object)
954 
955  Keyword arguments:
956  zaxis -- If set to True (default False), create a TGraph2D with z axis showing the cut value (recommended drawStyle 'pcolz')
957  """
958  self._name = name
959  self._xhistoName = xhistoName
960  self._yhistoName = yhistoName
961  self._zaxis = zaxis
def __init__
Definition: plotting.py:946

Member Function Documentation

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

Definition at line 962 of file plotting.py.

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

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

Definition at line 966 of file plotting.py.

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

967  def create(self, tdirectory):
968  """Create and return the histogram from a TDirectory"""
969  xhisto = _getOrCreateObject(tdirectory, self._xhistoName)
970  yhisto = _getOrCreateObject(tdirectory, self._yhistoName);
971  if xhisto is None or yhisto is None:
972  return None
973 
974  x = []
975  xerrup = []
976  xerrdown = []
977  y = []
978  yerrup = []
979  yerrdown = []
980  z = []
981 
982  for i in xrange(1, xhisto.GetNbinsX()+1):
983  x.append(xhisto.GetBinContent(i))
984  xerrup.append(xhisto.GetBinError(i))
985  xerrdown.append(xhisto.GetBinError(i))
986 
987  y.append(yhisto.GetBinContent(i))
988  yerrup.append(yhisto.GetBinError(i))
989  yerrdown.append(yhisto.GetBinError(i))
990 
991  z.append(xhisto.GetXaxis().GetBinUpEdge(i))
992 
993  # If either axis has only zeroes, no graph makes no point
994  if x.count(0.0) == len(x) or y.count(0.0) == len(y):
995  return None
996 
997  arr = lambda v: array.array("d", v)
998  gr = None
999  if self._zaxis:
1000  gr = ROOT.TGraph2D(len(x), arr(x), arr(y), arr(z))
1001  else:
1002  gr = ROOT.TGraphAsymmErrors(len(x), arr(x), arr(y), arr(xerrdown), arr(xerrup), arr(yerrdown), arr(yerrup))
1003  gr.SetTitle("")
1004  return gr
1005 
1006 
# Plot styles
def _getOrCreateObject
Definition: plotting.py:53

Member Data Documentation

plotting.ROC._name
private

Definition at line 957 of file plotting.py.

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

plotting.ROC._xhistoName
private

Definition at line 958 of file plotting.py.

Referenced by plotting.ROC.create().

plotting.ROC._yhistoName
private

Definition at line 959 of file plotting.py.

Referenced by plotting.ROC.create().

plotting.ROC._zaxis
private

Definition at line 960 of file plotting.py.

Referenced by plotting.ROC.create().