Gaudi Framework, version v22r2

Home   Generated: Tue May 10 2011
Classes | Functions | Variables

GaudiPython::HistoUtils Namespace Reference

Classes

class  HistoFile

Functions

def _getAppMgr
 Helper private auxiliary function to get Application Manager.
def _getHistoSvc
 Helper private auxiliary function to get iHistogramSvs.
def _getEvtSvc
 Helper private auxiliary function to get iDataSvs.
def book
 The trivial function to book the various 1D,2D&3D-histograms.
def bookProf
 The trivial function to book 1D&2D profile histograms:
def getAsAIDA
 The most trivial function to retrieve the histogram from Histogram Transient Store.
def getAsROOT
 The most trivial function to retrieve the histogram from Histogram Transient Store.
def fill
 The function which allows 'the smart fill' of 1D-histogram.
def _to_root_
 Convert AIDA to ROOT.
def _moment_
 Evaluate 'bin-by-bin' momentum of certain order around the value.
def _momentErr_
 Evaluate error in 'bin-by-bin' momentum of certain order around the value.
def _centralMoment_
 Evaluate 'bin-by-bin' central momentum (around mean value)
def _centralMomentErr_
 Evaluate error in 'bin-by-bin' momentum of certain order around the value.
def _skewness_
 Evaluate 'bin-by-bin' skewness for 1D histogram.
def _skewnessErr_
 Evaluate error for 'bin-by-bin' skewness for 1D histogram.
def _kurtosis_
 Evaluate 'bin-by-bin' kurtosis for 1D histogram.
def _kurtosisErr_
 Evaluate error for 'bin-by-bin' kurtosis for 1D histogram.
def _nEff_
def _mean_
def _meanErr_
def _rms_
def _rmsErr_
def _sumBinHeightErr_
def _sumAllBinHeightErr_
def _overflowEntriesFrac_
def _overflowEntriesFracErr_
def _underflowEntriesFrac_
def _underflowEntriesFracErr_
def _overflowIntegralFrac_
def _overflowIntegralFracErr_
def _underflowIntegralFrac_
def _underflowIntegralFracErr_
def _nEntries_
 get number of entries in histogram up to the certain bin (not-included) get number of entries in histogram form the certain minimal bin up to the certain maximal bin (not-included)
def _nEntriesFrac_
def _nEntriesFracErr_
def _path_
 ============================================================================
def __dumpHisto__
 =============================================================================

Variables

string __author__ = "Vanya BELYAEV ibelyaev@physics.syr.edu"
 This module contains set of simple and useful utilities for booking and manipulations with Gaudi-AIDA histograms, inspired by Thomas' request.
tuple __all__
 HID = cpp.GaudiAlg.ID
 useROOT = False
 global flag
 aida2root = cpp.Gaudi.Utils.Aida2ROOT.aida2root
 AIDA -> ROOT converter.
 HistoStats = cpp.Gaudi.Utils.HistoStats
 i1DH = cpp.AIDA.IHistogram1D
 iBH = cpp.AIDA.IBaseHistogram
 histoDump = __dumpHisto__
 the actual function for text dump of the histogram
 dumpHisto = __dumpHisto__

Function Documentation

def GaudiPython::HistoUtils::__dumpHisto__ (   histo,
  args 
)

=============================================================================


Dump the histogram/profile in text format (a'la HBOOK)

>>> histo
>>> print dumpHisto ( histo )

>>> print histo.dump()
>>> print histo.dump( 20 , 20 )
>>> print histo.dump( 20 , 20 , True )

Uses:

Definition at line 778 of file HistoUtils.py.

00779                                     :
00780     """
00781 
00782     Dump the histogram/profile in text format (a'la HBOOK)
00783 
00784     >>> histo
00785     >>> print dumpHisto ( histo )
00786 
00787     >>> print histo.dump()
00788     >>> print histo.dump( 20 , 20 )
00789     >>> print histo.dump( 20 , 20 , True )
00790 
00791     Uses:
00792 
00793     """
00794     return cpp.Gaudi.Utils.Histos.histoDump ( histo , *args )

def GaudiPython::HistoUtils::_centralMoment_ (   self,
  order 
) [private]

Evaluate 'bin-by-bin' central momentum (around mean value)

Evaluate 'bin-by-bin' central momentum (around mean value)
for 1D histogram

>>> h1 = ...
>>> print h1.centralMoment ( 5 )

Definition at line 502 of file HistoUtils.py.

00503                                      :
00504     """
00505     Evaluate 'bin-by-bin' central momentum (around mean value)
00506     for 1D histogram
00507 
00508     >>> h1 = ...
00509     >>> print h1.centralMoment ( 5 )
00510 
00511     """
00512     return HistoStats.centralMoment ( self , order )
00513 
# =============================================================================
def GaudiPython::HistoUtils::_centralMomentErr_ (   self,
  order 
) [private]

Evaluate error in 'bin-by-bin' momentum of certain order around the value.

Evaluate error for 'bin-by-bin' central momentum (around mean value)
for 1D histogram

>>> h1 = ...
>>> print h1.centralMomentErr ( 5 )

Definition at line 515 of file HistoUtils.py.

00516                                         :
00517     """
00518     Evaluate error for 'bin-by-bin' central momentum (around mean value)
00519     for 1D histogram
00520 
00521     >>> h1 = ...
00522     >>> print h1.centralMomentErr ( 5 )
00523 
00524     """
00525     return HistoStats.centralMomentErr ( self , order )
00526 
# =============================================================================
def GaudiPython::HistoUtils::_getAppMgr (   kwargs ) [private]

Helper private auxiliary function to get Application Manager.

Helper private auxiliary function to get Application Manager

Definition at line 54 of file HistoUtils.py.

00055                                :
00056     """
00057     Helper private auxiliary function to get Application Manager
00058     """
00059     gaudi = kwargs.get ( 'gaudi' , None )
00060     if not gaudi : gaudi = AppMgr()
00061     if not gaudi : raise RuntimeError, 'Unable to get valid ApplicationMgr'
00062 
00063     state = gaudi._isvc.FSMState()
00064     if state < cpp.Gaudi.StateMachine.CONFIGURED  : gaudi.config     ()
00065     state = gaudi._isvc.FSMState()
00066     if state < cpp.Gaudi.StateMachine.INITIALIZED : gaudi.initialize ()
00067 
00068     return gaudi                                               ## RETURN
00069 
# =============================================================================
def GaudiPython::HistoUtils::_getEvtSvc (   kwargs ) [private]

Helper private auxiliary function to get iDataSvs.

Helper private auxiliary function to get iDataSvs

Definition at line 83 of file HistoUtils.py.

00084                             :
00085     """
00086     Helper private auxiliary function to get iDataSvs
00087     """
00088     svc = kwargs.get ( 'service' , None )
00089     if not svc : svc = kwargs.get ( 'svc' , None )
00090     else       : return svc                                    ## RETURN
00091     gaudi = _getAppMgr ( **kwargs )
00092     return gaudi.evtsvc()                                      ## RETURN
00093 
# =============================================================================
def GaudiPython::HistoUtils::_getHistoSvc (   kwargs ) [private]

Helper private auxiliary function to get iHistogramSvs.

Helper private auxiliary function to get iHistogramSvs

Definition at line 71 of file HistoUtils.py.

00072                               :
00073     """
00074     Helper private auxiliary function to get iHistogramSvs
00075     """
00076     svc = kwargs.get ( 'service' , None )
00077     if not svc : svc = kwargs.get ( 'svc' , None )
00078     else       : return svc                                    ## RETURN
00079     gaudi = _getAppMgr ( **kwargs )
00080     return gaudi.histsvc ()                                    ## RETURN
00081 
# =============================================================================
def GaudiPython::HistoUtils::_kurtosis_ (   self ) [private]

Evaluate 'bin-by-bin' kurtosis for 1D histogram.

Evaluate 'bin-by-bin' kurtosis

>>> h1 = ...
>>> print h1.kurtosis ()

Definition at line 552 of file HistoUtils.py.

00553                         :
00554     """
00555     Evaluate 'bin-by-bin' kurtosis
00556 
00557     >>> h1 = ...
00558     >>> print h1.kurtosis ()
00559 
00560     """
00561     return HistoStats.kurtosis ( self )
00562 
# =============================================================================
def GaudiPython::HistoUtils::_kurtosisErr_ (   self ) [private]

Evaluate error for 'bin-by-bin' kurtosis for 1D histogram.

Evaluate error for 'bin-by-bin' kurtotis for 1D AIDA histogram

>>> h1 = ...
>>> print h1.kurtotisErr()

Definition at line 564 of file HistoUtils.py.

00565                            :
00566     """
00567     Evaluate error for 'bin-by-bin' kurtotis for 1D AIDA histogram
00568 
00569     >>> h1 = ...
00570     >>> print h1.kurtotisErr()
00571 
00572     """
00573     return HistoStats.kurtosisErr ( self )
00574 
# =============================================================================
def GaudiPython::HistoUtils::_mean_ (   self ) [private]
Evaluate the MEAN value

Definition at line 581 of file HistoUtils.py.

00582                        :
00583     """
00584     Evaluate the MEAN value
00585     """
00586     return HistoStats.mean ( self )
# =============================================================================
def GaudiPython::HistoUtils::_meanErr_ (   self ) [private]
Evaluate the error for MEAN estimate

Definition at line 587 of file HistoUtils.py.

00588                        :
00589     """
00590     Evaluate the error for MEAN estimate
00591     """
00592     return HistoStats.meanErr ( self )
00593 
# =============================================================================
def GaudiPython::HistoUtils::_moment_ (   self,
  order,
  value = 0 
) [private]

Evaluate 'bin-by-bin' momentum of certain order around the value.

Evaluate 'bin-by-bin' momentum of order 'order' around the value 'value'
for 1D histogram

>>> h1 = ...
>>> print h1.moment ( 5 )

Definition at line 477 of file HistoUtils.py.

00478                                           :
00479     """
00480     Evaluate 'bin-by-bin' momentum of order 'order' around the value 'value'
00481     for 1D histogram
00482 
00483     >>> h1 = ...
00484     >>> print h1.moment ( 5 )
00485 
00486     """
00487     return HistoStats.moment ( self , order , value )
00488 
# =============================================================================
def GaudiPython::HistoUtils::_momentErr_ (   self,
  order 
) [private]

Evaluate error in 'bin-by-bin' momentum of certain order around the value.

Evaluate error for 'bin-by-bin' momentum of order 'order' around the value 'value'
for 1D histogram

>>> h1 = ...
>>> print h1.momentErr ( 5 )

Definition at line 490 of file HistoUtils.py.

00491                                  :
00492     """
00493     Evaluate error for 'bin-by-bin' momentum of order 'order' around the value 'value'
00494     for 1D histogram
00495 
00496     >>> h1 = ...
00497     >>> print h1.momentErr ( 5 )
00498 
00499     """
00500     return HistoStats.momentErr ( self , order )
# =============================================================================
def GaudiPython::HistoUtils::_nEff_ (   self ) [private]
Number of equivalent entries

Definition at line 575 of file HistoUtils.py.

00576                        :
00577     """
00578     Number of equivalent entries
00579     """
00580     return HistoStats.nEff ( self )
# =============================================================================
def GaudiPython::HistoUtils::_nEntries_ (   self,
  i1,
  i2 = -10000000 
) [private]

get number of entries in histogram up to the certain bin (not-included) get number of entries in histogram form the certain minimal bin up to the certain maximal bin (not-included)

Get number of entries in histogram up to  the certain bin (not-included)

attention: underflow bin is included!

>>> h1
>>> print h1.nEntries ( 10 )

Get number of entries in histogram form the certain
minimal bin up to the certain maximal bin (not-included)

>>> h1
>>> print h1.nEntries ( 10 , 15 )

Definition at line 672 of file HistoUtils.py.

00673                                               :
00674     """
00675     Get number of entries in histogram up to  the certain bin (not-included)
00676 
00677     attention: underflow bin is included!
00678 
00679     >>> h1
00680     >>> print h1.nEntries ( 10 )
00681 
00682     Get number of entries in histogram form the certain
00683     minimal bin up to the certain maximal bin (not-included)
00684 
00685     >>> h1
00686     >>> print h1.nEntries ( 10 , 15 )
00687 
00688     """
00689     if  i2 < i1 or i2 < 0 : return HistoStats.nEntries ( self , i1 )
00690     return HistoStats.nEntries ( self , i1 , i2 )
# =============================================================================
def GaudiPython::HistoUtils::_nEntriesFrac_ (   self,
  i1,
  i2 = -10000000 
) [private]
Get the fraction of entries in histogram up to  the certain bin (not-included)

attention: underflow bin is included!

>>> h1
>>> print h1.nEntriesFrac ( 10 )

Get the fraction of entries in histogram form the certain
minimal bin up to the certain maximal bin (not-included)

>>> h1
>>> print h1.nEntriesFrac ( 10 , 15 )

Definition at line 691 of file HistoUtils.py.

00692                                                   :
00693     """
00694     Get the fraction of entries in histogram up to  the certain bin (not-included)
00695 
00696     attention: underflow bin is included!
00697 
00698     >>> h1
00699     >>> print h1.nEntriesFrac ( 10 )
00700 
00701     Get the fraction of entries in histogram form the certain
00702     minimal bin up to the certain maximal bin (not-included)
00703 
00704     >>> h1
00705     >>> print h1.nEntriesFrac ( 10 , 15 )
00706 
00707     """
00708     if  i2 < i1 or i2 < 0 : return HistoStats.nEntriesFrac ( self , i1 )
00709     return HistoStats.nEntriesFrac ( self , i1 , i2 )
# =============================================================================
def GaudiPython::HistoUtils::_nEntriesFracErr_ (   self,
  i1,
  i2 = -10000000 
) [private]
Get error for  fraction of entries in histogram up to  the certain bin (not-included)

attention: underflow bin is included!

>>> h1
>>> print h1.nEntriesFracErr( 10 )

Get error  fraction of entries in histogram form the certain
minimal bin up to the certain maximal bin (not-included)

>>> h1
>>> print h1.nEntriesFracErr ( 10 , 15 )

Definition at line 710 of file HistoUtils.py.

00711                                                      :
00712     """
00713     Get error for  fraction of entries in histogram up to  the certain bin (not-included)
00714 
00715     attention: underflow bin is included!
00716 
00717     >>> h1
00718     >>> print h1.nEntriesFracErr( 10 )
00719 
00720     Get error  fraction of entries in histogram form the certain
00721     minimal bin up to the certain maximal bin (not-included)
00722 
00723     >>> h1
00724     >>> print h1.nEntriesFracErr ( 10 , 15 )
00725 
00726     """
00727     if  i2 < i1 or i2 < 0 : return HistoStats.nEntriesFracErr ( self , i1 )
00728     return HistoStats.nEntriesFracErr ( self , i1 , i2 )
00729 
# =============================================================================
def GaudiPython::HistoUtils::_overflowEntriesFrac_ (   self ) [private]
The fraction of overflow entries  (useful for shape comparison)

Definition at line 619 of file HistoUtils.py.

00620                                        :
00621     """
00622     The fraction of overflow entries  (useful for shape comparison)
00623     """
00624     return HistoStats.overflowEntriesFrac     ( self )
# =============================================================================
def GaudiPython::HistoUtils::_overflowEntriesFracErr_ (   self ) [private]
The error for fraction of overflow entries  (useful for shape comparison)

Definition at line 625 of file HistoUtils.py.

00626                                        :
00627     """
00628     The error for fraction of overflow entries  (useful for shape comparison)
00629     """
00630     return HistoStats.overflowEntriesFracErr  ( self )
# =============================================================================
def GaudiPython::HistoUtils::_overflowIntegralFrac_ (   self ) [private]
The fraction of overflow integral  (useful for shape comparison)

Definition at line 644 of file HistoUtils.py.

00645                                         :
00646     """
00647     The fraction of overflow integral  (useful for shape comparison)
00648     """
00649     return HistoStats.overflowIntegralFrac     ( self )
# =============================================================================
def GaudiPython::HistoUtils::_overflowIntegralFracErr_ (   self ) [private]
The error for fraction of overflow integral  (useful for shape comparison)

Definition at line 650 of file HistoUtils.py.

00651                                         :
00652     """
00653     The error for fraction of overflow integral  (useful for shape comparison)
00654     """
00655     return HistoStats.overflowIntegralFracErr  ( self )
# =============================================================================
def GaudiPython::HistoUtils::_path_ (   self ) [private]

============================================================================

Get the path in THS for the given AIDA object:

>>> aida =
>>> print aida.path()

Definition at line 761 of file HistoUtils.py.

00762                     :
00763     """
00764     Get the path in THS for the given AIDA object:
00765 
00766     >>> aida =
00767     >>> print aida.path()
00768 
00769     """
00770     return cpp.Gaudi.Utils.Histos.path ( self )

def GaudiPython::HistoUtils::_rms_ (   self ) [private]
Evaluate the RMS for AIDA histogram

Definition at line 594 of file HistoUtils.py.

00595                       :
00596     """
00597     Evaluate the RMS for AIDA histogram
00598     """
00599     return HistoStats.rms ( self )
# =============================================================================
def GaudiPython::HistoUtils::_rmsErr_ (   self ) [private]
Evaluate the error for RMS estimate

Definition at line 600 of file HistoUtils.py.

00601                       :
00602     """
00603     Evaluate the error for RMS estimate
00604     """
00605     return HistoStats.rmsErr ( self )
00606 
# =============================================================================
def GaudiPython::HistoUtils::_skewness_ (   self ) [private]

Evaluate 'bin-by-bin' skewness for 1D histogram.

Evaluate 'bin-by-bin' skewness for 1D AIDA histogram

>>> h1 = ...
>>> print h1.skewness()

Definition at line 528 of file HistoUtils.py.

00529                         :
00530     """
00531     Evaluate 'bin-by-bin' skewness for 1D AIDA histogram
00532 
00533     >>> h1 = ...
00534     >>> print h1.skewness()
00535 
00536     """
00537     return HistoStats.skewness ( self )
00538 
# =============================================================================
def GaudiPython::HistoUtils::_skewnessErr_ (   self ) [private]

Evaluate error for 'bin-by-bin' skewness for 1D histogram.

Evaluate error for 'bin-by-bin' skewness

>>> h1 = ...
>>> print h1.skewnessErr()

Definition at line 540 of file HistoUtils.py.

00541                            :
00542     """
00543     Evaluate error for 'bin-by-bin' skewness
00544 
00545     >>> h1 = ...
00546     >>> print h1.skewnessErr()
00547 
00548     """
00549     return HistoStats.skewnessErr ( self )
00550 
# =============================================================================
def GaudiPython::HistoUtils::_sumAllBinHeightErr_ (   self ) [private]
Get an error in the sum bin height ('in-range integral') 

Definition at line 614 of file HistoUtils.py.

00615                                   :
00616     """ Get an error in the sum bin height ('in-range integral') """
00617     return HistoStats.sumAllBinHeightErr ( self )
00618 
# =============================================================================
def GaudiPython::HistoUtils::_sumBinHeightErr_ (   self ) [private]
Get an error in the sum bin height ('in-range integral')

Definition at line 607 of file HistoUtils.py.

00608                                   :
00609     """
00610     Get an error in the sum bin height ('in-range integral')
00611     """
00612     return HistoStats.sumBinHeightErr ( self )
00613 
# =============================================================================
def GaudiPython::HistoUtils::_to_root_ (   self ) [private]

Convert AIDA to ROOT.

Convert AIDA to ROOT

>>> aida = ...            ## get AIDA histogram
>>> root = aida.toROOT()  ## convert it to ROOT

Definition at line 445 of file HistoUtils.py.

00446                        :
00447     """
00448     Convert AIDA to ROOT
00449 
00450     >>> aida = ...            ## get AIDA histogram
00451     >>> root = aida.toROOT()  ## convert it to ROOT
00452 
00453     """
00454     return aida2root ( self )

def GaudiPython::HistoUtils::_underflowEntriesFrac_ (   self ) [private]
The fraction of underflow entries  (useful for shape comparison)

Definition at line 631 of file HistoUtils.py.

00632                                        :
00633     """
00634     The fraction of underflow entries  (useful for shape comparison)
00635     """
00636     return HistoStats.underflowEntriesFrac    ( self )
# =============================================================================
def GaudiPython::HistoUtils::_underflowEntriesFracErr_ (   self ) [private]
The error for fraction of underflow entries  (useful for shape comparison)

Definition at line 637 of file HistoUtils.py.

00638                                        :
00639     """
00640     The error for fraction of underflow entries  (useful for shape comparison)
00641     """
00642     return HistoStats.underflowEntriesFracErr ( self )
00643 
# =============================================================================
def GaudiPython::HistoUtils::_underflowIntegralFrac_ (   self ) [private]
The fraction of underflow integral  (useful for shape comparison)

Definition at line 656 of file HistoUtils.py.

00657                                         :
00658     """
00659     The fraction of underflow integral  (useful for shape comparison)
00660     """
00661     return HistoStats.underflowIntegralFrac    ( self )
# =============================================================================
def GaudiPython::HistoUtils::_underflowIntegralFracErr_ (   self ) [private]
The error for fraction of underflow integral (useful for shape comparison)

Definition at line 662 of file HistoUtils.py.

00663                                         :
00664     """
00665     The error for fraction of underflow integral (useful for shape comparison)
00666     """
00667     return HistoStats.underflowIntegralFracErr ( self )
00668 
# =============================================================================
def GaudiPython::HistoUtils::book (   args,
  kwargs 
)

The trivial function to book the various 1D,2D&3D-histograms.

The trivial function to book the various 1D,2D&3D-histograms

(1) book the trivial 1D histogram with full path

>>> h1D = book ( 'path/to/my/histo'       , ## path in Histogram Transient Store
                 'cosine of decay angle ' , ## histogram title
                  100                     , ## number of bins
                  -1                      , ## low edge
                  100                     ) ## high edge

(2) book the trivial 1D histogram with directory path and string ID :

>>> h1D = book ( 'path/to/directory'      , ## the path to directory in HTS
                 'H1'                     , ## string histogram identifier
                 'cosine of decay angle ' , ## histogram title
                  100                     , ## number of bins
                  -1                      , ## low edge
                  100                     ) ## high edge

(3) book the trivial 1D histogram with directory path and integer ID :

>>> h1D = book ( 'path/to/directory'      , ## the path to directory in HTS
                 124                      , ## integer histogram identifier
                 'cosine of decay angle ' , ## histogram title
                  100                     , ## number of bins
                  -1                      , ## low edge
                  100                     ) ## high edge

(4) book the trivial 2D histogram with full path

>>> h1D = book ( 'path/to/my/histo'       , ## path in Histogram Transient Store
                 'm12**2 versus m13**2'   , ## histogram title
                  50                      , ## number of X-bins
                  1.0                     , ## low X-edge
                  4.0                     , ## high X-edge
                  50                      , ## number of Y-bins
                  1                       , ## low Y-edge
                  2                       ) ## high Y-edge

(5) book the trivial 2D histogram with directory path and literal ID

>>> h1D = book ( 'path/to/directory'      , ## path in Histogram Transient Store
                 'Dalitz1'                , ## literal histogram identifier
                 'm12**2 versus m13**2'   , ## histogram title
                  50                      , ## number of X-bins
                  1.0                     , ## low X-edge
                  4.0                     , ## high X-edge
                  50                      , ## number of Y-bins
                  1                       , ## low Y-edge
                  2                       ) ## high Y-edge

(6) book the trivial 2D histogram with directory path and integer ID

>>> h1D = book ( 'path/to/directory'      , ## path in Histogram Transient Store
                 854                      , ## integer histogram identifier
                 'm12**2 versus m13**2'   , ## histogram title
                  50                      , ## number of X-bins
                  1.0                     , ## low X-edge
                  4.0                     , ## high X-edge
                  50                      , ## number of Y-bins
                  1.0                     , ## low Y-edge
                  4.0                     ) ## high Y-edge

(7) book the trivial 3D histogram with full path

>>> h1D = book ( 'path/to/my/histo'       , ## path in Histogram Transient Store
                 'x vs y vs z '           , ## histogram title
                  10                      , ## number of X-bins
                  -1.0                    , ## low X-edge
                  1.0                     , ## high X-edge
                  10                      , ## number of Y-bins
                  -1.0                    , ## low Y-edge
                  1.0                     , ## high Y-edge
                  10                      , ## number of Z-bins
                  -1.0                    , ## low Z-edge
                  1.0                     ) ## high Z-edge

(8) book the trivial 3D histogram with directory path and literal ID

>>> h1D = book ( 'path/to/directory'      , ## path in Histogram Transient Store
                 'xyz'                    , ## literal histogram identifier
                 'x vs y vs z'            , ## histogram title
                  10                      , ## number of X-bins
                  -1.0                    , ## low X-edge
                  1.0                     , ## high X-edge
                  10                      , ## number of Y-bins
                  -1.0                    , ## low Y-edge
                  1.0                     , ## high Y-edge
                  10                      , ## number of Z-bins
                  -1.0                    , ## low Z-edge
                  1.0                     ) ## high Z-edge

(9) book the trivial 3D histogram with directory path and integer ID

>>> h1D = book ( 'path/to/directory'      , ## path in Histogram Transient Store
                 888                      , ## integer histogram identifier
                 'x vs y vs z'            , ## histogram title
                  10                      , ## number of X-bins
                  -1.0                    , ## low X-edge
                  1.0                     , ## high X-edge
                  10                      , ## number of Y-bins
                  -1.0                    , ## low Y-edge
                  1.0                     , ## high Y-edge
                  10                      , ## number of Z-bins
                  -1.0                    , ## low Z-edge
                  1.0                     ) ## high Z-edge

Many other booking methods are available,
e.g. for the histograms with non-equidistant bins, see IHistogamSvc::book

Definition at line 95 of file HistoUtils.py.

00096                               :
00097     """
00098     The trivial function to book the various 1D,2D&3D-histograms
00099 
00100     (1) book the trivial 1D histogram with full path
00101 
00102     >>> h1D = book ( 'path/to/my/histo'       , ## path in Histogram Transient Store
00103                      'cosine of decay angle ' , ## histogram title
00104                       100                     , ## number of bins
00105                       -1                      , ## low edge
00106                       100                     ) ## high edge
00107 
00108     (2) book the trivial 1D histogram with directory path and string ID :
00109 
00110     >>> h1D = book ( 'path/to/directory'      , ## the path to directory in HTS
00111                      'H1'                     , ## string histogram identifier
00112                      'cosine of decay angle ' , ## histogram title
00113                       100                     , ## number of bins
00114                       -1                      , ## low edge
00115                       100                     ) ## high edge
00116 
00117     (3) book the trivial 1D histogram with directory path and integer ID :
00118 
00119     >>> h1D = book ( 'path/to/directory'      , ## the path to directory in HTS
00120                      124                      , ## integer histogram identifier
00121                      'cosine of decay angle ' , ## histogram title
00122                       100                     , ## number of bins
00123                       -1                      , ## low edge
00124                       100                     ) ## high edge
00125 
00126     (4) book the trivial 2D histogram with full path
00127 
00128     >>> h1D = book ( 'path/to/my/histo'       , ## path in Histogram Transient Store
00129                      'm12**2 versus m13**2'   , ## histogram title
00130                       50                      , ## number of X-bins
00131                       1.0                     , ## low X-edge
00132                       4.0                     , ## high X-edge
00133                       50                      , ## number of Y-bins
00134                       1                       , ## low Y-edge
00135                       2                       ) ## high Y-edge
00136 
00137     (5) book the trivial 2D histogram with directory path and literal ID
00138 
00139     >>> h1D = book ( 'path/to/directory'      , ## path in Histogram Transient Store
00140                      'Dalitz1'                , ## literal histogram identifier
00141                      'm12**2 versus m13**2'   , ## histogram title
00142                       50                      , ## number of X-bins
00143                       1.0                     , ## low X-edge
00144                       4.0                     , ## high X-edge
00145                       50                      , ## number of Y-bins
00146                       1                       , ## low Y-edge
00147                       2                       ) ## high Y-edge
00148 
00149     (6) book the trivial 2D histogram with directory path and integer ID
00150 
00151     >>> h1D = book ( 'path/to/directory'      , ## path in Histogram Transient Store
00152                      854                      , ## integer histogram identifier
00153                      'm12**2 versus m13**2'   , ## histogram title
00154                       50                      , ## number of X-bins
00155                       1.0                     , ## low X-edge
00156                       4.0                     , ## high X-edge
00157                       50                      , ## number of Y-bins
00158                       1.0                     , ## low Y-edge
00159                       4.0                     ) ## high Y-edge
00160 
00161     (7) book the trivial 3D histogram with full path
00162 
00163     >>> h1D = book ( 'path/to/my/histo'       , ## path in Histogram Transient Store
00164                      'x vs y vs z '           , ## histogram title
00165                       10                      , ## number of X-bins
00166                       -1.0                    , ## low X-edge
00167                       1.0                     , ## high X-edge
00168                       10                      , ## number of Y-bins
00169                       -1.0                    , ## low Y-edge
00170                       1.0                     , ## high Y-edge
00171                       10                      , ## number of Z-bins
00172                       -1.0                    , ## low Z-edge
00173                       1.0                     ) ## high Z-edge
00174 
00175     (8) book the trivial 3D histogram with directory path and literal ID
00176 
00177     >>> h1D = book ( 'path/to/directory'      , ## path in Histogram Transient Store
00178                      'xyz'                    , ## literal histogram identifier
00179                      'x vs y vs z'            , ## histogram title
00180                       10                      , ## number of X-bins
00181                       -1.0                    , ## low X-edge
00182                       1.0                     , ## high X-edge
00183                       10                      , ## number of Y-bins
00184                       -1.0                    , ## low Y-edge
00185                       1.0                     , ## high Y-edge
00186                       10                      , ## number of Z-bins
00187                       -1.0                    , ## low Z-edge
00188                       1.0                     ) ## high Z-edge
00189 
00190     (9) book the trivial 3D histogram with directory path and integer ID
00191 
00192     >>> h1D = book ( 'path/to/directory'      , ## path in Histogram Transient Store
00193                      888                      , ## integer histogram identifier
00194                      'x vs y vs z'            , ## histogram title
00195                       10                      , ## number of X-bins
00196                       -1.0                    , ## low X-edge
00197                       1.0                     , ## high X-edge
00198                       10                      , ## number of Y-bins
00199                       -1.0                    , ## low Y-edge
00200                       1.0                     , ## high Y-edge
00201                       10                      , ## number of Z-bins
00202                       -1.0                    , ## low Z-edge
00203                       1.0                     ) ## high Z-edge
00204 
00205     Many other booking methods are available,
00206     e.g. for the histograms with non-equidistant bins, see IHistogamSvc::book
00207 
00208     """
00209     if useROOT or kwargs.get( 'useROOT' , False ) or not kwargs.get('useAIDA' , True ) :
00210         from ROOT import TH1D
00211         a0 = args[0]
00212         a1 = args[1]
00213         a2 = args[2]
00214         if not str is type(a1) :
00215             a1 = 'h'+str(a1)
00216         if     str is type(a2) :
00217             return TH1D ( a0+a1 , a2 , *args[3:] )
00218         else :
00219             return TH1D ( a0    , a1 , *args[2:] )
00220 
00221     svc = _getHistoSvc ( **kwargs )
00222     if not svc : raise RuntimeError, 'Unable to get valid HistogramService '
00223     ## book the histogram using the service
00224     return svc.book(*args)                                          ## RETURN
00225 
00226 book.__doc__ += '\n\n' + '\thelp(iHistogramSvc.book) : \n\n' \
00227                 + iHistogramSvc.book       . __doc__
00228 book.__doc__ += '\n\n' + '\thelp(IHistogramSvc::book) : \n\n'            \
00229                 + cpp.IHistogramSvc.book . __doc__
00230 
# =============================================================================
def GaudiPython::HistoUtils::bookProf (   args,
  kwargs 
)

The trivial function to book 1D&2D profile histograms:


The trivial function to book 1D&2D profile histograms:

(1) book 1D-profile histogram with full path in Histogram Transient Store:
>>> histo = bookProf ( 'path/to/my/profile'  , ## path in Histogram Transient Store
                       'Energy Correction'   , ## the histogram title
                       100                   , ## number of X-bins
                       0.0                   , ## low X-edge
                       100                   ) ## high X-edge

(2) book 1D-profile histogram with directory path and literal ID
>>> histo = bookProf ( 'path/to/my/profile'  , ## path in Histogram Transient Store
                       'Calibration'         , ## the histogram literal identifier
                       'Energy Correction'   , ## the histogram title
                       100                   , ## number of X-bins
                       0.0                   , ## low X-edge
                       100                   ) ## high X-edge

(3) book 1D-profile histogram with directory path and integer  ID
>>> histo = bookProf ( 'path/to/my/profile'  , ## path in Histogram Transient Store
                       418                   , ## the histogram integer identifier
                       'Energy Correction'   , ## the histogram title
                       100                   , ## number of X-bins
                       0.0                   , ## low X-edge
                       100                   ) ## high X-edge

(4) book 2D-profile histogram with full path in Histogram Transient Store:
>>> histo = bookProf ( 'path/to/my/profile'  , ## path in Histogram Transient Store
                       'Energy Correction'   , ## the histogram title
                       50                    , ## number of X-bins
                       0.0                   , ## low X-edge
                       100                   , ## high X-edge
                       50                    , ## number of Y-bins
                       0.0                   , ## low Y-edge
                       100                   ) ## high Y-edge

(5) book 2D-profile histogram with directory path and literal ID
>>> histo = bookProf ( 'path/to/my/profile'  , ## path in Histogram Transient Store
                       'Calibration'         , ## the histogram literal identifier
                       'Energy Correction'   , ## the histogram title
                       50                    , ## number of X-bins
                       0.0                   , ## low X-edge
                       100                   , ## high X-edge
                       50                    , ## number of Y-bins
                       0.0                   , ## low Y-edge
                       100                   ) ## high Y-edge

(6) book 2D-profile histogram with directory path and integer  ID
>>> histo = bookProf ( 'path/to/my/profile'  , ## path in Histogram Transient Store
                       418                   , ## the histogram integer identifier
                       'Energy Correction'   , ## the histogram title
                       50                    , ## number of X-bins
                       0.0                   , ## low X-edge
                       100                   , ## high X-edge
                       50                    , ## number of Y-bins
                       0.0                   , ## low Y-edge
                       100                   ) ## high Y-edge

Many other booking methods are available,
e.g. for the histograms with non-equidistant bins, see IHistogamSvc::book

Definition at line 232 of file HistoUtils.py.

00233                                   :
00234     """
00235 
00236     The trivial function to book 1D&2D profile histograms:
00237 
00238     (1) book 1D-profile histogram with full path in Histogram Transient Store:
00239     >>> histo = bookProf ( 'path/to/my/profile'  , ## path in Histogram Transient Store
00240                            'Energy Correction'   , ## the histogram title
00241                            100                   , ## number of X-bins
00242                            0.0                   , ## low X-edge
00243                            100                   ) ## high X-edge
00244 
00245     (2) book 1D-profile histogram with directory path and literal ID
00246     >>> histo = bookProf ( 'path/to/my/profile'  , ## path in Histogram Transient Store
00247                            'Calibration'         , ## the histogram literal identifier
00248                            'Energy Correction'   , ## the histogram title
00249                            100                   , ## number of X-bins
00250                            0.0                   , ## low X-edge
00251                            100                   ) ## high X-edge
00252 
00253     (3) book 1D-profile histogram with directory path and integer  ID
00254     >>> histo = bookProf ( 'path/to/my/profile'  , ## path in Histogram Transient Store
00255                            418                   , ## the histogram integer identifier
00256                            'Energy Correction'   , ## the histogram title
00257                            100                   , ## number of X-bins
00258                            0.0                   , ## low X-edge
00259                            100                   ) ## high X-edge
00260 
00261     (4) book 2D-profile histogram with full path in Histogram Transient Store:
00262     >>> histo = bookProf ( 'path/to/my/profile'  , ## path in Histogram Transient Store
00263                            'Energy Correction'   , ## the histogram title
00264                            50                    , ## number of X-bins
00265                            0.0                   , ## low X-edge
00266                            100                   , ## high X-edge
00267                            50                    , ## number of Y-bins
00268                            0.0                   , ## low Y-edge
00269                            100                   ) ## high Y-edge
00270 
00271     (5) book 2D-profile histogram with directory path and literal ID
00272     >>> histo = bookProf ( 'path/to/my/profile'  , ## path in Histogram Transient Store
00273                            'Calibration'         , ## the histogram literal identifier
00274                            'Energy Correction'   , ## the histogram title
00275                            50                    , ## number of X-bins
00276                            0.0                   , ## low X-edge
00277                            100                   , ## high X-edge
00278                            50                    , ## number of Y-bins
00279                            0.0                   , ## low Y-edge
00280                            100                   ) ## high Y-edge
00281 
00282     (6) book 2D-profile histogram with directory path and integer  ID
00283     >>> histo = bookProf ( 'path/to/my/profile'  , ## path in Histogram Transient Store
00284                            418                   , ## the histogram integer identifier
00285                            'Energy Correction'   , ## the histogram title
00286                            50                    , ## number of X-bins
00287                            0.0                   , ## low X-edge
00288                            100                   , ## high X-edge
00289                            50                    , ## number of Y-bins
00290                            0.0                   , ## low Y-edge
00291                            100                   ) ## high Y-edge
00292 
00293     Many other booking methods are available,
00294     e.g. for the histograms with non-equidistant bins, see IHistogamSvc::book
00295 
00296     """
00297     svc = _getHistoSvc ( **kwargs )
00298     if not svc : raise RuntimeError, 'Unable to get valid HistogramService '
00299     ## book the histogram using the service
00300     return svc.bookProf(*args)                                      ## RETURN
00301 
00302 
00303 bookProf.__doc__ += '\n\n' + '\thelp(iHistogramSvc.bookProf) : \n\n' \
00304                     + iHistogramSvc.bookProf . __doc__
00305 bookProf.__doc__ += '\n\n' + '\thelp(IHistogramSvc::bookProf) : \n\n'             \
00306                     + cpp.IHistogramSvc.bookProf . __doc__
00307 
# =============================================================================
def GaudiPython::HistoUtils::fill (   histo,
  data,
  fun = lambda x : x,
  cut = lambda x : True,
  kwargs 
)

The function which allows 'the smart fill' of 1D-histogram.


The function which allows 'the smart fill' of 1D-histogram

>>> histo = ...

The most trivial case, fill with the value
>>> fill ( histo , 1.0 )

Fill from any iterable object (sequence)
>>> fill ( histo , [1,,2,3,4,5,10] )

Fill from iterable object and apply the function:
>>> fill ( histo , [1,2,3,4,5] , math.sin )

Use lambda form:
>>> fill ( histo , [1,2,3,4,5] , lambda x : x*x )

The same
>>> fill ( histo , [1,2,3,4,5] , fun = lambda x : x*x )

Use internal attributes:
>>> tracks = evtSvc['Rec/Track/Best']    ## iterable container of tracks
>>> fill ( histo , tracks , lambda t : t.pt() )

Apply the predicate: fill only even numbers:
>>> fill ( histo , [1,2,3,4,5,6,7] , lambda x : x , lambda y : y%2 )

The same (omit the trivial function) :
>>> fill ( histo , [1,2,3,4,5,6,7] , cut = lambda y : y%2 )

Apply the predicate: fill only pt for positively charged tracks:
>>> tracks = evtSvc['Rec/Track/Best']
>>> fill ( histo , tracks , lambda t : t.pt() , lambda t : 0<t.charge() )

The same:
>>> fill ( histo , tracks ,
           fun = lambda t : t.pt()       ,
           cut = lambda t : 0<t.charge() )

Ordinary functions are also fine:
>>> def myfun ( track ) : return sin( track.pt() + track.p() )
>>> def mycut ( track ) : return track.p() > 100 * GeV
>>> fill ( histo , tracks , myfun , mycut )

The 'data' could be the address in TES, in this case the object
is retrieved from TES and the method is applied to the objects,
retrieved from TES:
>>> fill (  histo             , ## the reference to the histogram
           'Rec/Track/Best'   , ## the location of objects in TES
            lambda t : t.pt() ) ## function to be used for histogram fill
>>> fill (  histo             , ## the reference to the histogram
           'Rec/Track/Best'   , ## the address of objects in TES
            lambda t : t.pt() , ## the function to be used for histogram fill
            lambda t : t.charge()>0 ) ## the criteria to select tracks

The arguments 'fun' and 'cut' could be strings, in this case
they are evaluated by python before usage.
This option could be often very useful.

Definition at line 350 of file HistoUtils.py.

00352                             : x    ,   ## function to be used
00353            cut   = lambda x : True ,   ## cut to be applied
00354            **kwargs                ) : ## optional extra arguments
00355     """
00356 
00357     The function which allows 'the smart fill' of 1D-histogram
00358 
00359     >>> histo = ...
00360 
00361     The most trivial case, fill with the value
00362     >>> fill ( histo , 1.0 )
00363 
00364     Fill from any iterable object (sequence)
00365     >>> fill ( histo , [1,,2,3,4,5,10] )
00366 
00367     Fill from iterable object and apply the function:
00368     >>> fill ( histo , [1,2,3,4,5] , math.sin )
00369 
00370     Use lambda form:
00371     >>> fill ( histo , [1,2,3,4,5] , lambda x : x*x )
00372 
00373     The same
00374     >>> fill ( histo , [1,2,3,4,5] , fun = lambda x : x*x )
00375 
00376     Use internal attributes:
00377     >>> tracks = evtSvc['Rec/Track/Best']    ## iterable container of tracks
00378     >>> fill ( histo , tracks , lambda t : t.pt() )
00379 
00380     Apply the predicate: fill only even numbers:
00381     >>> fill ( histo , [1,2,3,4,5,6,7] , lambda x : x , lambda y : y%2 )
00382 
00383     The same (omit the trivial function) :
00384     >>> fill ( histo , [1,2,3,4,5,6,7] , cut = lambda y : y%2 )
00385 
00386     Apply the predicate: fill only pt for positively charged tracks:
00387     >>> tracks = evtSvc['Rec/Track/Best']
00388     >>> fill ( histo , tracks , lambda t : t.pt() , lambda t : 0<t.charge() )
00389 
00390     The same:
00391     >>> fill ( histo , tracks ,
00392                fun = lambda t : t.pt()       ,
00393                cut = lambda t : 0<t.charge() )
00394 
00395     Ordinary functions are also fine:
00396     >>> def myfun ( track ) : return sin( track.pt() + track.p() )
00397     >>> def mycut ( track ) : return track.p() > 100 * GeV
00398     >>> fill ( histo , tracks , myfun , mycut )
00399 
00400     The 'data' could be the address in TES, in this case the object
00401     is retrieved from TES and the method is applied to the objects,
00402     retrieved from TES:
00403     >>> fill (  histo             , ## the reference to the histogram
00404                'Rec/Track/Best'   , ## the location of objects in TES
00405                 lambda t : t.pt() ) ## function to be used for histogram fill
00406     >>> fill (  histo             , ## the reference to the histogram
00407                'Rec/Track/Best'   , ## the address of objects in TES
00408                 lambda t : t.pt() , ## the function to be used for histogram fill
00409                 lambda t : t.charge()>0 ) ## the criteria to select tracks
00410 
00411     The arguments 'fun' and 'cut' could be strings, in this case
00412     they are evaluated by python before usage.
00413     This option could be often very useful.
00414 
00415     """
00416 
00417     # if value is a string, try to get the objects from TES
00418     if type ( data ) == str :
00419         svc  = _getEvtSvc ( **kwargs )
00420         data = svc[data]
00421         return fill ( histo , data , fun , cut , **kwargs )
00422 
00423     # if the function  is a string: evaluate it!
00424     if type ( fun  ) == str : fun  = eval ( fun  , globals() )
00425 
00426     # if the criterion is a string: evaluate it!
00427     if type ( cut  ) == str : cut  = eval ( cut  , globals() )
00428 
00429     if not hasattr ( data , '__iter__' ) : data = [ data ]
00430 
00431     if not hasattr ( histo , 'fill' ) and hasattr ( histo , 'Fill' ) :
00432         setattr ( histo , 'fill' , getattr ( histo , 'Fill' ) )
00433 
00434     for item in data :
00435         if not cut ( item )         : continue             ## CONTINUE
00436         histo.fill ( fun ( item ) )
00437 
00438     return histo                                           ## RETURN
00439 
00440 # =============================================================================
def GaudiPython::HistoUtils::getAsAIDA (   path,
  kwargs 
)

The most trivial function to retrieve the histogram from Histogram Transient Store.


The most trivial function to retrieve the histogram from Histogram Transient Store
The histogram is returned by reference to its AIDA-representation (if possible)

>>> h = getAsAIDA ( 'some/path/to/my/histogram' )

Definition at line 309 of file HistoUtils.py.

00310                                   :
00311     """
00312 
00313     The most trivial function to retrieve the histogram from Histogram Transient Store
00314     The histogram is returned by reference to its AIDA-representation (if possible)
00315 
00316     >>> h = getAsAIDA ( 'some/path/to/my/histogram' )
00317 
00318     """
00319     svc = _getHistoSvc ( **kwargs )
00320     if not svc : raise RuntimeError, 'Unable to get valid HistogramService '
00321     ## return the histogram
00322     return svc.getAsAIDA( path )                                   ## RETURN
00323 
00324 getAsAIDA.__doc__ += '\n\n' + '\thelp(iHistogramSvc.getAsAIDA) : \n\n' \
00325                      + iHistogramSvc.getAsAIDA . __doc__
00326 getAsAIDA.__doc__ += '\n\n' + '\thelp(iHistogramSvc.retrieve)  : \n\n' \
00327                      + iHistogramSvc.retrieve  . __doc__
00328 
# =============================================================================
def GaudiPython::HistoUtils::getAsROOT (   path,
  kwargs 
)

The most trivial function to retrieve the histogram from Histogram Transient Store.


The most trivial function to retrieve the histogram from Histogram Transient Store
The histogram is returned by reference to its underlying native ROOT-representation (if possible)

>>> h = getAsROOT ( 'some/path/to/my/histogram' )

Definition at line 330 of file HistoUtils.py.

00331                                   :
00332     """
00333 
00334     The most trivial function to retrieve the histogram from Histogram Transient Store
00335     The histogram is returned by reference to its underlying native ROOT-representation (if possible)
00336 
00337     >>> h = getAsROOT ( 'some/path/to/my/histogram' )
00338 
00339     """
00340     svc = _getHistoSvc ( **kwargs )
00341     if not svc : raise RuntimeError, 'Unable to get valid HistogramService '
00342     ## return the histogram
00343     return svc.getAsROOT( path )                                   ## RETURN
00344 
00345 getAsROOT.__doc__ += '\n\n' + '\thelp(iHistogramSvc.getAsROOT) : \n\n' \
00346                      + iHistogramSvc.getAsROOT . __doc__
00347 
00348 
# =============================================================================

Variable Documentation

Initial value:
00001 (
00002     'book'      , ##                book AIDA histogram using Histogram Service
00003     'bookProf'  , ##        book AIDA profile histogram using Histogram Service
00004     'getAsAIDA' , ## get the histogram form Histogram Service as AIDA histogram
00005     'getAsROOT' , ## get the histogram form Histogram Service as AIDA histogram
00006     'fill'      , ##              "power-fill" method for filling of histograms
00007     'aida2root' , ##                                     AIDA -> ROOT converter
00008     'HistoStats', ##                  statistical information for 1D-histograms
00009     'HistoFile' , ##                     class for storing histograms to a file
00010     'histoDump' , ##                     dump histogramintext format a'la HBOOK
00011     'dumpHisto'   ##                     dump histogramintext format a'la HBOOK
00012     )

Definition at line 29 of file HistoUtils.py.

string GaudiPython::HistoUtils::__author__ = "Vanya BELYAEV ibelyaev@physics.syr.edu"

This module contains set of simple and useful utilities for booking and manipulations with Gaudi-AIDA histograms, inspired by Thomas' request.

Author:
Vanya BELYAEV ibelyaev@physics.syr.edu
Date:
2007-08-03 =============================================================================

Definition at line 27 of file HistoUtils.py.

GaudiPython::HistoUtils::aida2root = cpp.Gaudi.Utils.Aida2ROOT.aida2root

AIDA -> ROOT converter.

Definition at line 442 of file HistoUtils.py.

Definition at line 800 of file HistoUtils.py.

GaudiPython::HistoUtils::HID = cpp.GaudiAlg.ID

Definition at line 47 of file HistoUtils.py.

the actual function for text dump of the histogram

Definition at line 799 of file HistoUtils.py.

GaudiPython::HistoUtils::HistoStats = cpp.Gaudi.Utils.HistoStats

Definition at line 473 of file HistoUtils.py.

GaudiPython::HistoUtils::i1DH = cpp.AIDA.IHistogram1D

Definition at line 730 of file HistoUtils.py.

GaudiPython::HistoUtils::iBH = cpp.AIDA.IBaseHistogram

Definition at line 771 of file HistoUtils.py.

global flag

Definition at line 50 of file HistoUtils.py.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines

Generated at Tue May 10 2011 18:55:37 for Gaudi Framework, version v22r2 by Doxygen version 1.7.2 written by Dimitri van Heesch, © 1997-2004