test
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 444 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 446 of file plotting.py.

447  def __init__(self, name, mapping, normalizeTo=None):
448  """Constructor.
449 
450  Arguments:
451  name -- String for the name of the resulting histogram
452  mapping -- Dictionary for mapping the bin label to a histogram name
453 
454  Keyword arguments:
455  normalizeTo -- Optional string for a histogram. If given, all bins of the resulting histograqm are divided by the integral of this histogram.
456  """
457  self._name = name
458  self._mapping = mapping
459  self._normalizeTo = normalizeTo

Member Function Documentation

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

Definition at line 460 of file plotting.py.

References FP420HitsObject._name, TrackerHitsObject._name, PGeometricDet::Item._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, plotting.Subtract._name, plotting.FakeDuplicate._name, plotting.AggregateBins._name, Vispa.Views.PropertyView.Property._name, plotting.AggregateHistos._name, and SequenceTypes.SequencePlaceholder._name.

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

Definition at line 464 of file plotting.py.

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

465  def create(self, tdirectory):
466  """Create and return the histogram from a TDirectory"""
467  result = []
468  for key, histoName in self._mapping.iteritems():
469  th1 = _getObject(tdirectory, histoName)
470  if th1 is None:
471  continue
472  result.append( (key, th1.Integral(0, th1.GetNbinsX()+1)) ) # include under- and overflow bins
473  if len(result) == 0:
474  return None
475 
476  res = ROOT.TH1F(self._name, self._name, len(result), 0, len(result))
477 
478  for i, (name, count) in enumerate(result):
479  res.SetBinContent(i+1, count)
480  res.GetXaxis().SetBinLabel(i+1, name)
481 
482  if self._normalizeTo is not None:
483  th1 = _getObject(tdirectory, self._normalizeTo)
484  if th1 is None:
485  return None
486  scale = th1.Integral(0, th1.GetNbinsX()+1)
487  res.Scale(1/scale)
488 
489  return res
def _getObject
Definition: plotting.py:14

Member Data Documentation

plotting.AggregateHistos._mapping
private

Definition at line 457 of file plotting.py.

plotting.AggregateHistos._name
private

Definition at line 456 of file plotting.py.

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

Definition at line 458 of file plotting.py.

Referenced by plotting.AggregateHistos.create().