test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 aggregaging integrals of another histoggrams.

Definition at line 888 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 890 of file plotting.py.

891  def __init__(self, name, mapping, normalizeTo=None):
892  """Constructor.
893 
894  Arguments:
895  name -- String for the name of the resulting histogram
896  mapping -- Dictionary for mapping the bin label to a histogram name
897 
898  Keyword arguments:
899  normalizeTo -- Optional string for a histogram. If given, all bins of the resulting histograqm are divided by the integral of this histogram.
900  """
901  self._name = name
902  self._mapping = mapping
903  self._normalizeTo = normalizeTo

Member Function Documentation

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

Definition at line 904 of file plotting.py.

References FP420HitsObject._name, TrackerHitsObject._name, PGeometricDet::Item._name, TrackingRecHitAlgorithm._name, LikelihoodSpecies._name, L1TMuon::PtAssignmentUnit._name, L1TMuon::PtRefinementUnit._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, ElectronMVAEstimatorRun2Phys14NonTrig._name, PhotonMVAEstimatorRun2Spring15NonTrig._name, PhotonMVAEstimatorRun2Phys14NonTrig._name, GeometricDetExtra._name, ElectronMVAEstimatorRun2Spring15Trig._name, ElectronMVAEstimatorRun2Spring15NonTrig._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, and plotting.AggregateHistos._name.

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

Definition at line 908 of file plotting.py.

References plotting._getObject(), FP420HitsObject._name, TrackerHitsObject._name, PGeometricDet::Item._name, TrackingRecHitAlgorithm._name, LikelihoodSpecies._name, L1TMuon::PtAssignmentUnit._name, L1TMuon::PtRefinementUnit._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, ElectronMVAEstimatorRun2Phys14NonTrig._name, PhotonMVAEstimatorRun2Spring15NonTrig._name, PhotonMVAEstimatorRun2Phys14NonTrig._name, ElectronMVAEstimatorRun2Spring15Trig._name, GeometricDetExtra._name, ElectronMVAEstimatorRun2Spring15NonTrig._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, plotting.AggregateBins._normalizeTo, and plotting.AggregateHistos._normalizeTo.

909  def create(self, tdirectory):
910  """Create and return the histogram from a TDirectory"""
911  result = []
912  for key, histoName in self._mapping.iteritems():
913  th1 = _getObject(tdirectory, histoName)
914  if th1 is None:
915  continue
916  result.append( (key, th1.Integral(0, th1.GetNbinsX()+1)) ) # include under- and overflow bins
917  if len(result) == 0:
918  return None
919 
920  res = ROOT.TH1F(self._name, self._name, len(result), 0, len(result))
921 
922  for i, (name, count) in enumerate(result):
923  res.SetBinContent(i+1, count)
924  res.GetXaxis().SetBinLabel(i+1, name)
925 
926  if self._normalizeTo is not None:
927  th1 = _getObject(tdirectory, self._normalizeTo)
928  if th1 is None:
929  return None
930  scale = th1.Integral(0, th1.GetNbinsX()+1)
931  res.Scale(1/scale)
932 
933  return res
def _getObject
Definition: plotting.py:45

Member Data Documentation

plotting.AggregateHistos._mapping
private

Definition at line 901 of file plotting.py.

plotting.AggregateHistos._name
private

Definition at line 900 of file plotting.py.

Referenced by plotting.AggregateHistos.__str__(), plotting.ROC.__str__(), trackingPlots.TimePerTrackPlot.__str__(), 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(), and plotting.PlotGroup.remove().

plotting.AggregateHistos._normalizeTo
private

Definition at line 902 of file plotting.py.

Referenced by plotting.AggregateHistos.create().