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

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

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

References plotting._getObject(), plotting.AggregateBins._mapping, plotting.AggregateHistos._mapping, TrackerHitsObject._name, FP420HitsObject._name, PGeometricDet::Item._name, LikelihoodSpecies._name, TrackingRecHitAlgorithm._name, LikelihoodPdfProduct._name, Logger._name, hcaldqm::DQModule._name, LikelihoodPdf._name, citk::IsolationConeDefinitionBase._name, DrellYanValidation._name, WValidation._name, hcaldqm::flag::Flag._name, hcaldqm::quantity::Quantity._name, HistoParams< T >._name, GeometricTimingDetExtra._name, CutApplicatorBase._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.

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

Member Data Documentation

plotting.AggregateHistos._mapping
private

Definition at line 1087 of file plotting.py.

Referenced by plotting.AggregateHistos.create().

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

Definition at line 1088 of file plotting.py.

Referenced by plotting.AggregateHistos.create().