![]() |
The Gaudi Framework
v38r3 (c3fc9673)
|
Classes | |
class | HistoFile |
Functions | |
def | _getAppMgr (**kwargs) |
def | _getHistoSvc (**kwargs) |
def | _getEvtSvc (**kwargs) |
def | book (*args, **kwargs) |
def | bookProf (*args, **kwargs) |
def | getAsAIDA (path, **kwargs) |
def | getAsROOT (path, **kwargs) |
def | fill (histo, data, fun=lambda x:x, cut=lambda x:True, **kwargs) |
def | _to_root_ (self) |
def | _moment_ (self, order, value=0) |
def | _momentErr_ (self, order) |
def | _centralMoment_ (self, order) |
def | _centralMomentErr_ (self, order) |
def | _skewness_ (self) |
def | _skewnessErr_ (self) |
def | _kurtosis_ (self) |
def | _kurtosisErr_ (self) |
def | _nEff_ (self) |
def | _mean_ (self) |
def | _meanErr_ (self) |
def | _rms_ (self) |
def | _rmsErr_ (self) |
def | _sumBinHeightErr_ (self) |
def | _sumAllBinHeightErr_ (self) |
def | _overflowEntriesFrac_ (self) |
def | _overflowEntriesFracErr_ (self) |
def | _underflowEntriesFrac_ (self) |
def | _underflowEntriesFracErr_ (self) |
def | _overflowIntegralFrac_ (self) |
def | _overflowIntegralFracErr_ (self) |
def | _underflowIntegralFrac_ (self) |
def | _underflowIntegralFracErr_ (self) |
def | _nEntries_ (self, i1, i2=-10000000) |
def | _nEntriesFrac_ (self, i1, i2=-10000000) |
def | _nEntriesFracErr_ (self, i1, i2=-10000000) |
def | _path_ (self) |
def | __dumpHisto__ (histo, *args) |
Variables | |
__author__ | |
(c) Copyright 1998-2023 CERN for the benefit of the LHCb and ATLAS collaborations # # This software is distributed under the terms of the Apache version 2 licence, # copied verbatim in the file "LICENSE". More... | |
__all__ | |
HID | |
useROOT | |
global flag More... | |
aida2root | |
__repr__ | |
__str__ | |
HistoStats | |
i1DH | |
moment | |
momentErr | |
centralMoment | |
centralMomentErr | |
nEff | |
mean | |
meanErr | |
rms | |
rmsErr | |
skewness | |
skewnessErr | |
kurtosis | |
kurtosisErr | |
overflowEntriesFrac | |
overflowEntriesFracErr | |
underflowEntriesFrac | |
underflowEntriesFracErr | |
overflowIntegralFrac | |
overflowIntegralFracErr | |
underflowIntegralFrac | |
underflowIntegralFracErr | |
nEntries | |
nEntriesFrac | |
nEntriesFracErr | |
iBH | |
path | |
TESpath | |
location | |
histoDump | |
dumpHisto | |
def GaudiAlg.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 968 of file HistoUtils.py.
|
private |
Evaluate 'bin-by-bin' central momentum (around mean value) for 1D histogram >>> h1 = ... >>> print(h1.centralMoment ( 5 ))
Definition at line 578 of file HistoUtils.py.
|
private |
Evaluate error for 'bin-by-bin' central momentum (around mean value) for 1D histogram >>> h1 = ... >>> print(h1.centralMomentErr ( 5 ))
Definition at line 594 of file HistoUtils.py.
|
private |
Helper private auxiliary function to get Application Manager
Definition at line 68 of file HistoUtils.py.
|
private |
|
private |
|
private |
Evaluate 'bin-by-bin' kurtosis >>> h1 = ... >>> print(h1.kurtosis ())
Definition at line 640 of file HistoUtils.py.
|
private |
Evaluate error for 'bin-by-bin' kurtotis for 1D AIDA histogram >>> h1 = ... >>> print(h1.kurtotisErr())
Definition at line 655 of file HistoUtils.py.
|
private |
|
private |
|
private |
Evaluate 'bin-by-bin' momentum of order 'order' around the value 'value' for 1D histogram >>> h1 = ... >>> print(h1.moment ( 5 ))
Definition at line 546 of file HistoUtils.py.
|
private |
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 562 of file HistoUtils.py.
|
private |
|
private |
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 820 of file HistoUtils.py.
|
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 844 of file HistoUtils.py.
|
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 868 of file HistoUtils.py.
|
private |
The fraction of overflow entries (useful for shape comparison)
Definition at line 737 of file HistoUtils.py.
|
private |
The error for fraction of overflow entries (useful for shape comparison)
Definition at line 747 of file HistoUtils.py.
|
private |
The fraction of overflow integral (useful for shape comparison)
Definition at line 777 of file HistoUtils.py.
|
private |
The error for fraction of overflow integral (useful for shape comparison)
Definition at line 787 of file HistoUtils.py.
|
private |
Get the path in THS for the given AIDA object: >>> aida = >>> print(aida.path())
Definition at line 947 of file HistoUtils.py.
|
private |
|
private |
|
private |
Evaluate 'bin-by-bin' skewness for 1D AIDA histogram >>> h1 = ... >>> print(h1.skewness())
Definition at line 610 of file HistoUtils.py.
|
private |
Evaluate error for 'bin-by-bin' skewness >>> h1 = ... >>> print(h1.skewnessErr())
Definition at line 625 of file HistoUtils.py.
|
private |
Get an error in the sum bin height ('in-range integral')
Definition at line 729 of file HistoUtils.py.
|
private |
Get an error in the sum bin height ('in-range integral')
Definition at line 719 of file HistoUtils.py.
|
private |
Convert AIDA to ROOT >>> aida = ... ## get AIDA histogram >>> root = aida.toROOT() ## convert it to ROOT
Definition at line 509 of file HistoUtils.py.
|
private |
The fraction of underflow entries (useful for shape comparison)
Definition at line 757 of file HistoUtils.py.
|
private |
The error for fraction of underflow entries (useful for shape comparison)
Definition at line 767 of file HistoUtils.py.
|
private |
The fraction of underflow integral (useful for shape comparison)
Definition at line 797 of file HistoUtils.py.
|
private |
The error for fraction of underflow integral (useful for shape comparison)
Definition at line 807 of file HistoUtils.py.
def GaudiAlg.HistoUtils.book | ( | * | args, |
** | kwargs | ||
) |
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 126 of file HistoUtils.py.
def GaudiAlg.HistoUtils.bookProf | ( | * | args, |
** | kwargs | ||
) |
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 270 of file HistoUtils.py.
def GaudiAlg.HistoUtils.fill | ( | histo, | |
data, | |||
fun = lambda x: x , |
|||
cut = lambda x: True , |
|||
** | kwargs | ||
) |
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 404 of file HistoUtils.py.
def GaudiAlg.HistoUtils.getAsAIDA | ( | path, | |
** | kwargs | ||
) |
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 354 of file HistoUtils.py.
def GaudiAlg.HistoUtils.getAsROOT | ( | path, | |
** | kwargs | ||
) |
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 381 of file HistoUtils.py.
|
private |
Definition at line 40 of file HistoUtils.py.
|
private |
(c) Copyright 1998-2023 CERN for the benefit of the LHCb and ATLAS collaborations # # This software is distributed under the terms of the Apache version 2 licence, # copied verbatim in the file "LICENSE".
# # In applying this licence, CERN does not waive the privileges and immunities # granted to it by virtue of its status as an Intergovernmental Organization # or submit itself to any jurisdiction. #
This module contains set of simple and useful utilities for booking and manipulations with Gaudi-AIDA histograms, inspired by Thomas' request
Definition at line 38 of file HistoUtils.py.
|
private |
Definition at line 535 of file HistoUtils.py.
|
private |
Definition at line 538 of file HistoUtils.py.
GaudiAlg.HistoUtils.aida2root |
Definition at line 503 of file HistoUtils.py.
GaudiAlg.HistoUtils.centralMoment |
Definition at line 897 of file HistoUtils.py.
GaudiAlg.HistoUtils.centralMomentErr |
Definition at line 899 of file HistoUtils.py.
GaudiAlg.HistoUtils.dumpHisto |
Definition at line 991 of file HistoUtils.py.
GaudiAlg.HistoUtils.HID |
Definition at line 59 of file HistoUtils.py.
GaudiAlg.HistoUtils.histoDump |
Definition at line 990 of file HistoUtils.py.
GaudiAlg.HistoUtils.HistoStats |
Definition at line 540 of file HistoUtils.py.
GaudiAlg.HistoUtils.i1DH |
Definition at line 890 of file HistoUtils.py.
GaudiAlg.HistoUtils.iBH |
Definition at line 958 of file HistoUtils.py.
GaudiAlg.HistoUtils.kurtosis |
Definition at line 915 of file HistoUtils.py.
GaudiAlg.HistoUtils.kurtosisErr |
Definition at line 917 of file HistoUtils.py.
GaudiAlg.HistoUtils.location |
Definition at line 964 of file HistoUtils.py.
GaudiAlg.HistoUtils.mean |
Definition at line 903 of file HistoUtils.py.
GaudiAlg.HistoUtils.meanErr |
Definition at line 905 of file HistoUtils.py.
GaudiAlg.HistoUtils.moment |
Definition at line 893 of file HistoUtils.py.
GaudiAlg.HistoUtils.momentErr |
Definition at line 895 of file HistoUtils.py.
GaudiAlg.HistoUtils.nEff |
Definition at line 901 of file HistoUtils.py.
GaudiAlg.HistoUtils.nEntries |
Definition at line 938 of file HistoUtils.py.
GaudiAlg.HistoUtils.nEntriesFrac |
Definition at line 940 of file HistoUtils.py.
GaudiAlg.HistoUtils.nEntriesFracErr |
Definition at line 942 of file HistoUtils.py.
GaudiAlg.HistoUtils.overflowEntriesFrac |
Definition at line 920 of file HistoUtils.py.
GaudiAlg.HistoUtils.overflowEntriesFracErr |
Definition at line 922 of file HistoUtils.py.
GaudiAlg.HistoUtils.overflowIntegralFrac |
Definition at line 929 of file HistoUtils.py.
GaudiAlg.HistoUtils.overflowIntegralFracErr |
Definition at line 931 of file HistoUtils.py.
GaudiAlg.HistoUtils.path |
Definition at line 960 of file HistoUtils.py.
GaudiAlg.HistoUtils.rms |
Definition at line 907 of file HistoUtils.py.
GaudiAlg.HistoUtils.rmsErr |
Definition at line 909 of file HistoUtils.py.
GaudiAlg.HistoUtils.skewness |
Definition at line 911 of file HistoUtils.py.
GaudiAlg.HistoUtils.skewnessErr |
Definition at line 913 of file HistoUtils.py.
GaudiAlg.HistoUtils.TESpath |
Definition at line 962 of file HistoUtils.py.
GaudiAlg.HistoUtils.underflowEntriesFrac |
Definition at line 924 of file HistoUtils.py.
GaudiAlg.HistoUtils.underflowEntriesFracErr |
Definition at line 926 of file HistoUtils.py.
GaudiAlg.HistoUtils.underflowIntegralFrac |
Definition at line 933 of file HistoUtils.py.
GaudiAlg.HistoUtils.underflowIntegralFracErr |
Definition at line 935 of file HistoUtils.py.
GaudiAlg.HistoUtils.useROOT |
global flag
Definition at line 62 of file HistoUtils.py.