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

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

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

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

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, plotting.AggregateHistos._normalizeTo, and mps_monitormerge.items.

Member Data Documentation

◆ _mapping

plotting.AggregateHistos._mapping
private

Definition at line 1088 of file plotting.py.

Referenced by plotting.AggregateHistos.create().

◆ _name

plotting.AggregateHistos._name
private

◆ _normalizeTo

plotting.AggregateHistos._normalizeTo
private

Definition at line 1089 of file plotting.py.

Referenced by plotting.AggregateHistos.create().

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