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

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

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 1091 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, 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.

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

Member Data Documentation

plotting.AggregateHistos._mapping
private

Definition at line 1084 of file plotting.py.

Referenced by plotting.AggregateHistos.create().

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

Definition at line 1085 of file plotting.py.

Referenced by plotting.AggregateHistos.create().