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 1072 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 1074 of file plotting.py.

1074  def __init__(self, name, mapping, normalizeTo=None):
1075  """Constructor.
1076 
1077  Arguments:
1078  name -- String for the name of the resulting histogram
1079  mapping -- Dictionary for mapping the bin label to a histogram name
1080 
1081  Keyword arguments:
1082  normalizeTo -- Optional string for a histogram. If given, all bins of the resulting histograqm are divided by the integral of this histogram.
1083  """
1084  self._name = name
1085  self._mapping = mapping
1086  self._normalizeTo = normalizeTo
1087 
def __init__(self, name, mapping, normalizeTo=None)
Definition: plotting.py:1074

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

References plotting._getObject(), plotting.AggregateBins._mapping, plotting.AggregateHistos._mapping, FP420HitsObject._name, TrackerHitsObject._name, PGeometricDet::Item._name, LikelihoodSpecies._name, TrackingRecHitAlgorithm._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, GeometricTimingDetExtra._name, CutApplicatorBase._name, DetGeomDesc._name, GeometricDetExtra._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, SequenceTypes.TaskPlaceholder._name, plotting.AggregateBins._normalizeTo, and plotting.AggregateHistos._normalizeTo.

1092  def create(self, tdirectory):
1093  """Create and return the histogram from a TDirectory"""
1094  result = []
1095  for key, histoName in six.iteritems(self._mapping):
1096  th1 = _getObject(tdirectory, histoName)
1097  if th1 is None:
1098  continue
1099  result.append( (key, th1.Integral(0, th1.GetNbinsX()+1)) ) # include under- and overflow bins
1100  if len(result) == 0:
1101  return None
1102 
1103  res = ROOT.TH1F(self._name, self._name, len(result), 0, len(result))
1104 
1105  for i, (name, count) in enumerate(result):
1106  res.SetBinContent(i+1, count)
1107  res.GetXaxis().SetBinLabel(i+1, name)
1108 
1109  if self._normalizeTo is not None:
1110  th1 = _getObject(tdirectory, self._normalizeTo)
1111  if th1 is None:
1112  return None
1113  scale = th1.Integral(0, th1.GetNbinsX()+1)
1114  res.Scale(1/scale)
1115 
1116  return res
1117 
def create(self, tdirectory)
Definition: plotting.py:1092
def _getObject(tdirectory, name)
Definition: plotting.py:48

Member Data Documentation

plotting.AggregateHistos._mapping
private

Definition at line 1085 of file plotting.py.

Referenced by plotting.AggregateHistos.create().

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

Definition at line 1086 of file plotting.py.

Referenced by plotting.AggregateHistos.create().