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.AggregateBins Class Reference

Public Member Functions

def __init__
 
def __str__
 
def create
 

Private Attributes

 _histoName
 
 _mapping
 
 _name
 
 _normalizeTo
 
 _scale
 

Detailed Description

Definition at line 145 of file plotting.py.

Constructor & Destructor Documentation

def plotting.AggregateBins.__init__ (   self,
  name,
  histoName,
  mapping,
  normalizeTo = None,
  scale = None 
)

Definition at line 146 of file plotting.py.

147  def __init__(self, name, histoName, mapping, normalizeTo=None, scale=None):
148  self._name = name
149  self._histoName = histoName
150  self._mapping = mapping
151  self._normalizeTo = normalizeTo
152  self._scale = scale

Member Function Documentation

def plotting.AggregateBins.__str__ (   self)

Definition at line 153 of file plotting.py.

References FP420HitsObject._name, TrackerHitsObject._name, PGeometricDet::Item._name, LikelihoodSpecies._name, LikelihoodPdfProduct._name, LikelihoodPdf._name, citk::IsolationConeDefinitionBase._name, DrellYanValidation._name, WValidation._name, HistoParams< T >._name, CutApplicatorBase._name, ElectronMVAEstimatorRun2Phys14NonTrig._name, PhotonMVAEstimatorRun2Spring15NonTrig._name, PhotonMVAEstimatorRun2Phys14NonTrig._name, plotting.FakeDuplicate._name, GeometricDetExtra._name, ElectronMVAEstimatorRun2Spring15NonTrig._name, HistoParams< TH2F >._name, plotting.AggregateBins._name, HistoParams< TProfile2D >._name, Vispa.Views.PropertyView.Property._name, and SequenceTypes.SequencePlaceholder._name.

154  def __str__(self):
155  return self._name
def plotting.AggregateBins.create (   self,
  tdirectory 
)

Definition at line 156 of file plotting.py.

References plotting._getObject(), plotting.AggregateBins._histoName, plotting.AggregateBins._mapping, FP420HitsObject._name, TrackerHitsObject._name, PGeometricDet::Item._name, LikelihoodSpecies._name, LikelihoodPdfProduct._name, LikelihoodPdf._name, citk::IsolationConeDefinitionBase._name, DrellYanValidation._name, WValidation._name, HistoParams< T >._name, CutApplicatorBase._name, ElectronMVAEstimatorRun2Phys14NonTrig._name, PhotonMVAEstimatorRun2Spring15NonTrig._name, PhotonMVAEstimatorRun2Phys14NonTrig._name, plotting.FakeDuplicate._name, GeometricDetExtra._name, ElectronMVAEstimatorRun2Spring15NonTrig._name, HistoParams< TH2F >._name, plotting.AggregateBins._name, HistoParams< TProfile2D >._name, Vispa.Views.PropertyView.Property._name, SequenceTypes.SequencePlaceholder._name, plotting.AggregateBins._normalizeTo, plotting.AggregateBins._scale, and Vispa.Gui.VispaWidget.VispaWidget._scale.

157  def create(self, tdirectory):
158  th1 = _getObject(tdirectory, self._histoName)
159  if th1 is None:
160  return None
161 
162  result = ROOT.TH1F(self._name, self._name, len(self._mapping), 0, len(self._mapping))
163 
164  if isinstance(self._mapping, list):
165  for i, label in enumerate(self._mapping):
166  bin = th1.GetXaxis().FindBin(label)
167  if bin > 0:
168  result.SetBinContent(i+1, th1.GetBinContent(bin))
169  result.GetXaxis().SetBinLabel(i+1, label)
170  else:
171  for i, (key, labels) in enumerate(self._mapping.iteritems()):
172  sumTime = 0
173  for l in labels:
174  bin = th1.GetXaxis().FindBin(l)
175  if bin > 0:
176  sumTime += th1.GetBinContent(bin)
177  result.SetBinContent(i+1, sumTime)
178  result.GetXaxis().SetBinLabel(i+1, key)
179 
180  if self._normalizeTo is not None:
181  bin = th1.GetXaxis().FindBin(self._normalizeTo)
182  if bin <= 0:
183  print "Trying to normalize {name} to {binlabel}, which does not exist".format(name=self._name, binlabel=self._normalizeTo)
184  sys.exit(1)
185  value = th1.GetBinContent(bin)
186  if value != 0:
187  result.Scale(1/value)
188 
189  if self._scale is not None:
190  result.Scale(self._scale)
191 
192  return result
def _getObject
Definition: plotting.py:32

Member Data Documentation

plotting.AggregateBins._histoName
private

Definition at line 148 of file plotting.py.

Referenced by plotting.AggregateBins.create().

plotting.AggregateBins._mapping
private

Definition at line 149 of file plotting.py.

Referenced by plotting.AggregateBins.create().

plotting.AggregateBins._name
private

Definition at line 147 of file plotting.py.

Referenced by plotting.AggregateBins.__str__(), plotting.AggregateHistos.__str__(), plotting.Plot._createOne(), plotting.PlotGroup._save(), plotting.AggregateBins.create(), plotting.AggregateHistos.create(), plotting.Plot.draw(), and plotting.Plot.getName().

plotting.AggregateBins._normalizeTo
private

Definition at line 150 of file plotting.py.

Referenced by plotting.AggregateBins.create(), and plotting.AggregateHistos.create().

plotting.AggregateBins._scale
private

Definition at line 151 of file plotting.py.

Referenced by plotting.AggregateBins.create(), and plotting.Plot.create().