CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Attributes
plotting.AggregateHistos Class Reference

Public Member Functions

def __init__
 
def __str__
 
def create
 

Private Attributes

 _mapping
 
 _name
 
 _normalizeTo
 

Detailed Description

Class to create a histogram by aggregating integrals of another histogram.

Definition at line 1075 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 1077 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

Member Function Documentation

def plotting.AggregateHistos.__str__ (   self)
String representation, returns the name

Definition at line 1091 of file plotting.py.

References 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, and SequenceTypes.TaskPlaceholder._name.

1092  def __str__(self):
1093  """String representation, returns the name"""
1094  return self._name
def plotting.AggregateHistos.create (   self,
  tdirectory 
)
Create and return the histogram from a TDirectory

Definition at line 1095 of file plotting.py.

References plotting._getObject(), TrackerHitsObject._name, FP420HitsObject._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.

1096  def create(self, tdirectory):
1097  """Create and return the histogram from a TDirectory"""
1098  result = []
1099  for key, histoName in self._mapping.items():
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
def _getObject
Definition: plotting.py:49

Member Data Documentation

plotting.AggregateHistos._mapping
private

Definition at line 1088 of file plotting.py.

plotting.AggregateHistos._name
private

Definition at line 1087 of file plotting.py.

Referenced by plotting.AggregateHistos.__str__(), plotting.ROC.__str__(), trackingPlots.TimePerEventPlot.__str__(), trackingPlots.TimePerTrackPlot.__str__(), trackingPlots.TimePerEventPlot._create(), plotting.PlotGroup._drawSeparate(), plotting.PlotGroup._save(), plotting.AggregateHistos.create(), trackingPlots.TimePerTrackPlot.create(), plotting.Plot.create(), plotting.PlotGroup.draw(), plotting.Plot.getName(), plotting.PlotGroup.getName(), plotting.PlotterFolder.getName(), plotting.PlotterItem.getName(), plotting.PlotterFolder.getSelectionNameIterator(), validation.SimpleSample.name(), trackingPlots.Iteration.name(), plotting.PlotterItem.readDirs(), plotting.PlotGroup.remove(), and plotting.Plot.setName().

plotting.AggregateHistos._normalizeTo
private

Definition at line 1089 of file plotting.py.

Referenced by plotting.AggregateHistos.create().