CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
plotting.CutEfficiency Class Reference

Public Member Functions

def __init__ (self, name, histo, title="")
 
def __str__ (self)
 
def create (self, tdirectory)
 

Private Attributes

 _histo
 
 _name
 
 _title
 

Detailed Description

Class for making a cut efficiency histograms.

      N after cut
eff = -----------
        N total

Definition at line 897 of file plotting.py.

Constructor & Destructor Documentation

def plotting.CutEfficiency.__init__ (   self,
  name,
  histo,
  title = "" 
)
Constructor

Arguments:
name  -- String for name of the resulting histogram
histo -- String for a source histogram (needs to be cumulative)

Definition at line 904 of file plotting.py.

904  def __init__(self, name, histo, title=""):
905  """Constructor
906 
907  Arguments:
908  name -- String for name of the resulting histogram
909  histo -- String for a source histogram (needs to be cumulative)
910  """
911  self._name = name
912  self._histo = histo
913  self._title = title
914 
def __init__(self, name, histo, title="")
Definition: plotting.py:904

Member Function Documentation

def plotting.CutEfficiency.__str__ (   self)
def plotting.CutEfficiency.create (   self,
  tdirectory 
)
Create and return the cut efficiency histogram from a TDirectory

Definition at line 919 of file plotting.py.

References plotting._getOrCreateObject(), plotting.Transform._histo, plotting.CutEfficiency._histo, 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, GeometricDetExtra._name, GeometricTimingDetExtra._name, HistoParams< T >._name, CutApplicatorBase._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, SequenceTypes.TaskPlaceholder._name, HistoParams< T >._title, HistoParams< TH2F >._title, SiStripHitEffFromCalibTree._title, HistoParams< TProfile2D >._title, html.PageSet._title, html.HtmlReport._title, plotting.Subtract._title, plotting.Transform._title, plotting.FakeDuplicate._title, plotting.CutEfficiency._title, and FastTimerService_cff.range.

919  def create(self, tdirectory):
920  """Create and return the cut efficiency histogram from a TDirectory"""
921  histo = _getOrCreateObject(tdirectory, self._histo)
922  if not histo:
923  return None
924 
925  # infer cumulative direction from the under/overflow bins
926  ascending = histo.GetBinContent(0) < histo.GetBinContent(histo.GetNbinsX())
927  if ascending:
928  n_tot = histo.GetBinContent(histo.GetNbinsX())
929  else:
930  n_tot = histo.GetBinContent(0)
931 
932  if n_tot == 0:
933  return histo
934 
935  ret = histo.Clone(self._name)
936  ret.SetTitle(self._title)
937 
938  # calculate efficiency
939  for i in range(1, histo.GetNbinsX()+1):
940  n = histo.GetBinContent(i)
941  val = n/n_tot
942  errVal = math.sqrt(val*(1-val)/n_tot)
943  ret.SetBinContent(i, val)
944  ret.SetBinError(i, errVal)
945  return ret
946 
def _getOrCreateObject(tdirectory, nameOrCreator)
Definition: plotting.py:58
def create(self, tdirectory)
Definition: plotting.py:919

Member Data Documentation

plotting.CutEfficiency._histo
private

Definition at line 912 of file plotting.py.

Referenced by plotting.CutEfficiency.create().

plotting.CutEfficiency._name
private
plotting.CutEfficiency._title
private

Definition at line 913 of file plotting.py.

Referenced by plotting.CutEfficiency.create(), and plotting.Plot.create().