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.AggregateHistos Class Reference

Public Member Functions

def __init__
 
def __str__
 
def create
 

Private Attributes

 _mapping
 
 _name
 
 _normalizeTo
 

Detailed Description

Class to create a histogram by aggregaging integrals of another histoggrams.

Definition at line 329 of file plotting.py.

Constructor & Destructor Documentation

def plotting.AggregateHistos.__init__ (   self,
  name,
  mapping,
  normalizeTo = None 
)
Constructor.

Arguments:
name    -- String for the name of the resulting histogram
mapping -- Dictionary for mapping the bin label to a histogram name

Keyword arguments:
normalizeTo -- Optional string for a histogram. If given, all bins of the resulting histograqm are divided by the integral of this histogram.

Definition at line 331 of file plotting.py.

332  def __init__(self, name, mapping, normalizeTo=None):
333  """Constructor.
334 
335  Arguments:
336  name -- String for the name of the resulting histogram
337  mapping -- Dictionary for mapping the bin label to a histogram name
338 
339  Keyword arguments:
340  normalizeTo -- Optional string for a histogram. If given, all bins of the resulting histograqm are divided by the integral of this histogram.
341  """
342  self._name = name
343  self._mapping = mapping
344  self._normalizeTo = normalizeTo

Member Function Documentation

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

Definition at line 345 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, Vispa.Views.PropertyView.Property._name, and SequenceTypes.SequencePlaceholder._name.

346  def __str__(self):
347  """String representation, returns the name"""
348  return self._name
def plotting.AggregateHistos.create (   self,
  tdirectory 
)
Create and return the histogram from a TDirectory

Definition at line 349 of file plotting.py.

References plotting._getObject(), 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, ElectronMVAEstimatorRun2Spring15Trig._name, GeometricDetExtra._name, ElectronMVAEstimatorRun2Spring15NonTrig._name, HistoParams< TH2F >._name, plotting.Subtract._name, HistoParams< TProfile2D >._name, plotting.FakeDuplicate._name, plotting.AggregateBins._name, plotting.AggregateHistos._name, Vispa.Views.PropertyView.Property._name, SequenceTypes.SequencePlaceholder._name, plotting.AggregateBins._normalizeTo, and plotting.AggregateHistos._normalizeTo.

350  def create(self, tdirectory):
351  """Create and return the histogram from a TDirectory"""
352  result = []
353  for key, histoName in self._mapping.iteritems():
354  th1 = _getObject(tdirectory, histoName)
355  if th1 is None:
356  continue
357  result.append( (key, th1.Integral(0, th1.GetNbinsX()+1)) ) # include under- and overflow bins
358  if len(result) == 0:
359  return None
360 
361  res = ROOT.TH1F(self._name, self._name, len(result), 0, len(result))
362 
363  for i, (name, count) in enumerate(result):
364  res.SetBinContent(i+1, count)
365  res.GetXaxis().SetBinLabel(i+1, name)
366 
367  if self._normalizeTo is not None:
368  th1 = _getObject(tdirectory, self._normalizeTo)
369  if th1 is None:
370  return None
371  scale = th1.Integral(0, th1.GetNbinsX()+1)
372  res.Scale(1/scale)
373 
374  return res
def _getObject
Definition: plotting.py:9

Member Data Documentation

plotting.AggregateHistos._mapping
private

Definition at line 342 of file plotting.py.

plotting.AggregateHistos._name
private

Definition at line 341 of file plotting.py.

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

plotting.AggregateHistos._normalizeTo
private

Definition at line 343 of file plotting.py.

Referenced by plotting.AggregateHistos.create().