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

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

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

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

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

Referenced by plotting.AggregateHistos.create().

◆ _name

plotting.AggregateHistos._name
private

◆ _normalizeTo

plotting.AggregateHistos._normalizeTo
private

Definition at line 1090 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