CMS 3D CMS Logo

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

Public Member Functions

def __init__ (self, name, mapping, normalizeTo=None)
 
def __str__ (self)
 
def create (self, tdirectory)
 

Private Attributes

 _mapping
 
 _name
 
 _normalizeTo
 

Detailed Description

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

Definition at line 906 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 908 of file plotting.py.

908  def __init__(self, name, mapping, normalizeTo=None):
909  """Constructor.
910 
911  Arguments:
912  name -- String for the name of the resulting histogram
913  mapping -- Dictionary for mapping the bin label to a histogram name
914 
915  Keyword arguments:
916  normalizeTo -- Optional string for a histogram. If given, all bins of the resulting histograqm are divided by the integral of this histogram.
917  """
918  self._name = name
919  self._mapping = mapping
920  self._normalizeTo = normalizeTo
921 
def __init__(self, name, mapping, normalizeTo=None)
Definition: plotting.py:908

Member Function Documentation

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

Definition at line 926 of file plotting.py.

References plotting._getObject(), 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, plotting.AggregateBins._normalizeTo, and plotting.AggregateHistos._normalizeTo.

926  def create(self, tdirectory):
927  """Create and return the histogram from a TDirectory"""
928  result = []
929  for key, histoName in self._mapping.iteritems():
930  th1 = _getObject(tdirectory, histoName)
931  if th1 is None:
932  continue
933  result.append( (key, th1.Integral(0, th1.GetNbinsX()+1)) ) # include under- and overflow bins
934  if len(result) == 0:
935  return None
936 
937  res = ROOT.TH1F(self._name, self._name, len(result), 0, len(result))
938 
939  for i, (name, count) in enumerate(result):
940  res.SetBinContent(i+1, count)
941  res.GetXaxis().SetBinLabel(i+1, name)
942 
943  if self._normalizeTo is not None:
944  th1 = _getObject(tdirectory, self._normalizeTo)
945  if th1 is None:
946  return None
947  scale = th1.Integral(0, th1.GetNbinsX()+1)
948  res.Scale(1/scale)
949 
950  return res
951 
def create(self, tdirectory)
Definition: plotting.py:926
def _getObject(tdirectory, name)
Definition: plotting.py:45

Member Data Documentation

plotting.AggregateHistos._mapping
private

Definition at line 919 of file plotting.py.

plotting.AggregateHistos._name
private
plotting.AggregateHistos._normalizeTo
private

Definition at line 920 of file plotting.py.

Referenced by plotting.AggregateHistos.create().