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

◆ __init__()

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 

Member Function Documentation

◆ __str__()

def plotting.AggregateHistos.__str__ (   self)

◆ create()

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

Definition at line 1094 of file plotting.py.

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 

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

Member Data Documentation

◆ _mapping

plotting.AggregateHistos._mapping
private

Definition at line 1087 of file plotting.py.

Referenced by plotting.AggregateHistos.create().

◆ _name

plotting.AggregateHistos._name
private

◆ _normalizeTo

plotting.AggregateHistos._normalizeTo
private

Definition at line 1088 of file plotting.py.

Referenced by plotting.AggregateHistos.create().

beamerCreator.create
def create(alignables, pedeDump, additionalData, outputFile, config)
Definition: beamerCreator.py:44
TriggerAnalyzer.__str__
def __str__(self)
Definition: TriggerAnalyzer.py:103
plotting._getObject
def _getObject(tdirectory, name)
Definition: plotting.py:50