|
Gaudi Framework, version v21r4 |
| Home | Generated: 7 Sep 2009 |
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_ |
| ============================================================================ | |
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 | |
| aida2root = cpp.Gaudi.Utils.Aida2ROOT.aida2root | |
| AIDA -> ROOT converter. | |
| HistoStats = cpp.Gaudi.Utils.HistoStats | |
| i1DH = cpp.AIDA.IHistogram1D | |
| iBH = cpp.AIDA.IBaseHistogram | |
| 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 473 of file HistoUtils.py.
00473 : 00474 """ 00475 Evaluate 'bin-by-bin' central momentum (around mean value) 00476 for 1D histogram 00477 00478 >>> h1 = ... 00479 >>> print h1.centralMoment ( 5 ) 00480 00481 """ 00482 return HistoStats.centralMoment ( self , order ) 00483 00484 # ============================================================================= ## Evaluate error in 'bin-by-bin' momentum of certain order around the value
| 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 486 of file HistoUtils.py.
00486 : 00487 """ 00488 Evaluate error for 'bin-by-bin' central momentum (around mean value) 00489 for 1D histogram 00490 00491 >>> h1 = ... 00492 >>> print h1.centralMomentErr ( 5 ) 00493 00494 """ 00495 return HistoStats.centralMomentErr ( self , order ) 00496 00497 # ============================================================================= ## Evaluate 'bin-by-bin' skewness for 1D histogram
| 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 46 of file HistoUtils.py.
00046 : 00047 """ 00048 Helper private auxiliary function to get Application Manager 00049 """ 00050 gaudi = kwargs.get ( 'gaudi' , None ) 00051 if not gaudi : gaudi = AppMgr() 00052 if not gaudi : raise RuntimeError, 'Unable to get valid ApplicationMgr' 00053 return gaudi ## RETURN 00054 00055 # ============================================================================= ## Helper private auxiliary function to get iHistogramSvs
| def GaudiPython::HistoUtils::_getEvtSvc | ( | kwargs | ) | [private] |
Helper private auxiliary function to get iDataSvs.
Helper private auxiliary function to get iDataSvs
Definition at line 69 of file HistoUtils.py.
00069 : 00070 """ 00071 Helper private auxiliary function to get iDataSvs 00072 """ 00073 svc = kwargs.get ( 'service' , None ) 00074 if not svc : svc = kwargs.get ( 'svc' , None ) 00075 else : return svc ## RETURN 00076 gaudi = _getAppMgr ( **kwargs ) 00077 return gaudi.evtsvc() ## RETURN 00078 00079 # ============================================================================= ## The trivial function to book the various 1D,2D&3D-histograms
| def GaudiPython::HistoUtils::_getHistoSvc | ( | kwargs | ) | [private] |
Helper private auxiliary function to get iHistogramSvs.
Helper private auxiliary function to get iHistogramSvs
Definition at line 57 of file HistoUtils.py.
00057 : 00058 """ 00059 Helper private auxiliary function to get iHistogramSvs 00060 """ 00061 svc = kwargs.get ( 'service' , None ) 00062 if not svc : svc = kwargs.get ( 'svc' , None ) 00063 else : return svc ## RETURN 00064 gaudi = _getAppMgr ( **kwargs ) 00065 return gaudi.histsvc () ## RETURN 00066 00067 # ============================================================================= ## Helper private auxiliary function to get iDataSvs
| def GaudiPython::HistoUtils::_kurtosis_ | ( | self | ) | [private] |
Evaluate 'bin-by-bin' kurtosis for 1D histogram.
Evaluate 'bin-by-bin' kurtosis for 1D histogram >>> h1 = ... >>> print h1.kurtosis ()
Definition at line 523 of file HistoUtils.py.
00523 : 00524 """ 00525 Evaluate 'bin-by-bin' kurtosis for 1D histogram 00526 00527 >>> h1 = ... 00528 >>> print h1.kurtosis () 00529 00530 """ 00531 return HistoStats.kurtosis ( self ) 00532 00533 # ============================================================================= ## Evaluate error for 'bin-by-bin' kurtosis for 1D histogram
| 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 histogram >>> h1 = ... >>> print h1.kurtotisErr()
Definition at line 535 of file HistoUtils.py.
00535 : 00536 """ 00537 Evaluate error for 'bin-by-bin' kurtotis for 1D histogram 00538 00539 >>> h1 = ... 00540 >>> print h1.kurtotisErr() 00541 00542 """ 00543 return HistoStats.kurtosisErr ( self ) 00544 00545 # ============================================================================= def _nEff_ ( self ) :
| def GaudiPython::HistoUtils::_mean_ | ( | self | ) | [private] |
Evaluate the MEAN value
Definition at line 552 of file HistoUtils.py.
00552 : 00553 """ 00554 Evaluate the MEAN value 00555 """ 00556 return HistoStats.mean ( self ) 00557 # ============================================================================= def _meanErr_ ( self ) :
| def GaudiPython::HistoUtils::_meanErr_ | ( | self | ) | [private] |
Evaluate the error for MEAN estimate
Definition at line 558 of file HistoUtils.py.
00558 : 00559 """ 00560 Evaluate the error for MEAN estimate 00561 """ 00562 return HistoStats.meanErr ( self ) 00563 00564 # ============================================================================= def _rms_ ( self ) :
| 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 448 of file HistoUtils.py.
00448 : 00449 """ 00450 Evaluate 'bin-by-bin' momentum of order 'order' around the value 'value' 00451 for 1D histogram 00452 00453 >>> h1 = ... 00454 >>> print h1.moment ( 5 ) 00455 00456 """ 00457 return HistoStats.moment ( self , order , value ) 00458 00459 # ============================================================================= ## Evaluate error in 'bin-by-bin' momentum of certain order around the value
| 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 461 of file HistoUtils.py.
00461 : 00462 """ 00463 Evaluate error for 'bin-by-bin' momentum of order 'order' around the value 'value' 00464 for 1D histogram 00465 00466 >>> h1 = ... 00467 >>> print h1.momentErr ( 5 ) 00468 00469 """ 00470 return HistoStats.momentErr ( self , order ) 00471 # ============================================================================= ## Evaluate 'bin-by-bin' central momentum (around mean value)
| def GaudiPython::HistoUtils::_nEff_ | ( | self | ) | [private] |
Number of equivalent entries
Definition at line 546 of file HistoUtils.py.
00546 : 00547 """ 00548 Number of equivalent entries 00549 """ 00550 return HistoStats.nEff ( self ) 00551 # ============================================================================= def _mean_ ( 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 643 of file HistoUtils.py.
00643 : 00644 """ 00645 Get number of entries in histogram up to the certain bin (not-included) 00646 00647 attention: underflow bin is included! 00648 00649 >>> h1 00650 >>> print h1.nEntries ( 10 ) 00651 00652 Get number of entries in histogram form the certain 00653 minimal bin up to the certain maximal bin (not-included) 00654 00655 >>> h1 00656 >>> print h1.nEntries ( 10 , 15 ) 00657 00658 """ 00659 if i2 < i1 or i2 < 0 : return HistoStats.nEntries ( self , i1 ) 00660 return HistoStats.nEntries ( self , i1 , i2 ) 00661 # ============================================================================= def _nEntriesFrac_ ( self , i1 , i2 = -10000000 ) :
| 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 662 of file HistoUtils.py.
00662 : 00663 """ 00664 Get the fraction of entries in histogram up to the certain bin (not-included) 00665 00666 attention: underflow bin is included! 00667 00668 >>> h1 00669 >>> print h1.nEntriesFrac ( 10 ) 00670 00671 Get the fraction of entries in histogram form the certain 00672 minimal bin up to the certain maximal bin (not-included) 00673 00674 >>> h1 00675 >>> print h1.nEntriesFrac ( 10 , 15 ) 00676 00677 """ 00678 if i2 < i1 or i2 < 0 : return HistoStats.nEntriesFrac ( self , i1 ) 00679 return HistoStats.nEntriesFrac ( self , i1 , i2 ) 00680 # ============================================================================= def _nEntriesFracErr_ ( self , i1 , i2 = -10000000 ) :
| 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 681 of file HistoUtils.py.
00681 : 00682 """ 00683 Get error for fraction of entries in histogram up to the certain bin (not-included) 00684 00685 attention: underflow bin is included! 00686 00687 >>> h1 00688 >>> print h1.nEntriesFracErr( 10 ) 00689 00690 Get error fraction of entries in histogram form the certain 00691 minimal bin up to the certain maximal bin (not-included) 00692 00693 >>> h1 00694 >>> print h1.nEntriesFracErr ( 10 , 15 ) 00695 00696 """ 00697 if i2 < i1 or i2 < 0 : return HistoStats.nEntriesFracErr ( self , i1 ) 00698 return HistoStats.nEntriesFracErr ( self , i1 , i2 ) 00699 00700 # ============================================================================= i1DH = cpp.AIDA.IHistogram1D
| def GaudiPython::HistoUtils::_overflowEntriesFrac_ | ( | self | ) | [private] |
The fraction of overflow entries (useful for shape comparison)
Definition at line 590 of file HistoUtils.py.
00590 : 00591 """ 00592 The fraction of overflow entries (useful for shape comparison) 00593 """ 00594 return HistoStats.overflowEntriesFrac ( self ) 00595 # ============================================================================= def _overflowEntriesFracErr_ ( self ) :
| def GaudiPython::HistoUtils::_overflowEntriesFracErr_ | ( | self | ) | [private] |
The error for fraction of overflow entries (useful for shape comparison)
Definition at line 596 of file HistoUtils.py.
00596 : 00597 """ 00598 The error for fraction of overflow entries (useful for shape comparison) 00599 """ 00600 return HistoStats.overflowEntriesFracErr ( self ) 00601 # ============================================================================= def _underflowEntriesFrac_ ( self ) :
| def GaudiPython::HistoUtils::_overflowIntegralFrac_ | ( | self | ) | [private] |
The fraction of overflow integral (useful for shape comparison)
Definition at line 615 of file HistoUtils.py.
00615 : 00616 """ 00617 The fraction of overflow integral (useful for shape comparison) 00618 """ 00619 return HistoStats.overflowIntegralFrac ( self ) 00620 # ============================================================================= def _overflowIntegralFracErr_ ( self ) :
| def GaudiPython::HistoUtils::_overflowIntegralFracErr_ | ( | self | ) | [private] |
The error for fraction of overflow integral (useful for shape comparison)
Definition at line 621 of file HistoUtils.py.
00621 : 00622 """ 00623 The error for fraction of overflow integral (useful for shape comparison) 00624 """ 00625 return HistoStats.overflowIntegralFracErr ( self ) 00626 # ============================================================================= def _underflowIntegralFrac_ ( self ) :
| def GaudiPython::HistoUtils::_path_ | ( | self | ) | [private] |
============================================================================
Get the path in THS for the given AIDA object: >>> aida = >>> print aida.path()
Definition at line 732 of file HistoUtils.py.
00732 : 00733 """ 00734 Get the path in THS for the given AIDA object: 00735 00736 >>> aida = 00737 >>> print aida.path() 00738 00739 """ 00740 return cpp.Gaudi.Utils.Histos.path ( self ) 00741 iBH = cpp.AIDA.IBaseHistogram
| def GaudiPython::HistoUtils::_rms_ | ( | self | ) | [private] |
Evaluate the RMS
Definition at line 565 of file HistoUtils.py.
00565 : 00566 """ 00567 Evaluate the RMS 00568 """ 00569 return HistoStats.rms ( self ) 00570 # ============================================================================= def _rmsErr_ ( self ) :
| def GaudiPython::HistoUtils::_rmsErr_ | ( | self | ) | [private] |
Evaluate the error for RMS estimate
Definition at line 571 of file HistoUtils.py.
00571 : 00572 """ 00573 Evaluate the error for RMS estimate 00574 """ 00575 return HistoStats.rmsErr ( self ) 00576 00577 # ============================================================================= def _sumBinHeightErr_ ( self ) :
| def GaudiPython::HistoUtils::_skewness_ | ( | self | ) | [private] |
Evaluate 'bin-by-bin' skewness for 1D histogram.
Evaluate 'bin-by-bin' skewness for 1D histogram >>> h1 = ... >>> print h1.skewness()
Definition at line 499 of file HistoUtils.py.
00499 : 00500 """ 00501 Evaluate 'bin-by-bin' skewness for 1D histogram 00502 00503 >>> h1 = ... 00504 >>> print h1.skewness() 00505 00506 """ 00507 return HistoStats.skewness ( self ) 00508 00509 # ============================================================================= ## Evaluate error for 'bin-by-bin' skewness for 1D histogram
| def GaudiPython::HistoUtils::_skewnessErr_ | ( | self | ) | [private] |
Evaluate error for 'bin-by-bin' skewness for 1D histogram.
Evaluate error for 'bin-by-bin' skewness for 1D histogram >>> h1 = ... >>> print h1.skewnessErr()
Definition at line 511 of file HistoUtils.py.
00511 : 00512 """ 00513 Evaluate error for 'bin-by-bin' skewness for 1D histogram 00514 00515 >>> h1 = ... 00516 >>> print h1.skewnessErr() 00517 00518 """ 00519 return HistoStats.skewnessErr ( self ) 00520 00521 # ============================================================================= ## Evaluate 'bin-by-bin' kurtosis for 1D histogram
| def GaudiPython::HistoUtils::_sumAllBinHeightErr_ | ( | self | ) | [private] |
Get an error in the sum bin height ('in-range integral') Definition at line 585 of file HistoUtils.py.
00585 : 00586 """ Get an error in the sum bin height ('in-range integral') """ 00587 return HistoStats.sumAllBinHeightErr ( self ) 00588 00589 # ============================================================================= def _overflowEntriesFrac_ ( self ) :
| def GaudiPython::HistoUtils::_sumBinHeightErr_ | ( | self | ) | [private] |
Get an error in the sum bin height ('in-range integral')
Definition at line 578 of file HistoUtils.py.
00578 : 00579 """ 00580 Get an error in the sum bin height ('in-range integral') 00581 """ 00582 return HistoStats.sumBinHeightErr ( self ) 00583 00584 # ============================================================================= def _sumAllBinHeightErr_ ( self ) :
| def GaudiPython::HistoUtils::_to_root_ | ( | self | ) | [private] |
Convert AIDA to ROOT >>> aida = ... ## get AIDA histogram >>> root = aida.toROOT() ## convert it to ROOT
Definition at line 419 of file HistoUtils.py.
00419 : 00420 """ 00421 Convert AIDA to ROOT 00422 00423 >>> aida = ... ## get AIDA histogram 00424 >>> root = aida.toROOT() ## convert it to ROOT 00425 00426 """ 00427 return aida2root ( self ) 00428 _to_root_ . __doc__ += aida2root . __doc__
| def GaudiPython::HistoUtils::_underflowEntriesFrac_ | ( | self | ) | [private] |
The fraction of underflow entries (useful for shape comparison)
Definition at line 602 of file HistoUtils.py.
00602 : 00603 """ 00604 The fraction of underflow entries (useful for shape comparison) 00605 """ 00606 return HistoStats.underflowEntriesFrac ( self ) 00607 # ============================================================================= def _underflowEntriesFracErr_ ( self ) :
| def GaudiPython::HistoUtils::_underflowEntriesFracErr_ | ( | self | ) | [private] |
The error for fraction of underflow entries (useful for shape comparison)
Definition at line 608 of file HistoUtils.py.
00608 : 00609 """ 00610 The error for fraction of underflow entries (useful for shape comparison) 00611 """ 00612 return HistoStats.underflowEntriesFracErr ( self ) 00613 00614 # ============================================================================= def _overflowIntegralFrac_ ( self ) :
| def GaudiPython::HistoUtils::_underflowIntegralFrac_ | ( | self | ) | [private] |
The fraction of underflow integral (useful for shape comparison)
Definition at line 627 of file HistoUtils.py.
00627 : 00628 """ 00629 The fraction of underflow integral (useful for shape comparison) 00630 """ 00631 return HistoStats.underflowIntegralFrac ( self ) 00632 # ============================================================================= def _underflowIntegralFracErr_ ( self ) :
| def GaudiPython::HistoUtils::_underflowIntegralFracErr_ | ( | self | ) | [private] |
The error for fraction of underflow integral (useful for shape comparison)
Definition at line 633 of file HistoUtils.py.
00633 : 00634 """ 00635 The error for fraction of underflow integral (useful for shape comparison) 00636 """ 00637 return HistoStats.underflowIntegralFracErr ( self ) 00638 00639 # ============================================================================= ## get number of entries in histogram up to the certain bin (not-included)
| 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 81 of file HistoUtils.py.
00081 : 00082 """ 00083 The trivial function to book the various 1D,2D&3D-histograms 00084 00085 (1) book the trivial 1D histogram with full path 00086 00087 >>> h1D = book ( 'path/to/my/histo' , ## path in Histogram Transient Store 00088 'cosine of decay angle ' , ## histogram title 00089 100 , ## number of bins 00090 -1 , ## low edge 00091 100 ) ## high edge 00092 00093 (2) book the trivial 1D histogram with directory path and string ID : 00094 00095 >>> h1D = book ( 'path/to/directory' , ## the path to directory in HTS 00096 'H1' , ## string histogram identifier 00097 'cosine of decay angle ' , ## histogram title 00098 100 , ## number of bins 00099 -1 , ## low edge 00100 100 ) ## high edge 00101 00102 (3) book the trivial 1D histogram with directory path and integer ID : 00103 00104 >>> h1D = book ( 'path/to/directory' , ## the path to directory in HTS 00105 124 , ## integer histogram identifier 00106 'cosine of decay angle ' , ## histogram title 00107 100 , ## number of bins 00108 -1 , ## low edge 00109 100 ) ## high edge 00110 00111 (4) book the trivial 2D histogram with full path 00112 00113 >>> h1D = book ( 'path/to/my/histo' , ## path in Histogram Transient Store 00114 'm12**2 versus m13**2' , ## histogram title 00115 50 , ## number of X-bins 00116 1.0 , ## low X-edge 00117 4.0 , ## high X-edge 00118 50 , ## number of Y-bins 00119 1 , ## low Y-edge 00120 2 ) ## high Y-edge 00121 00122 (5) book the trivial 2D histogram with directory path and literal ID 00123 00124 >>> h1D = book ( 'path/to/directory' , ## path in Histogram Transient Store 00125 'Dalitz1' , ## literal histogram identifier 00126 'm12**2 versus m13**2' , ## histogram title 00127 50 , ## number of X-bins 00128 1.0 , ## low X-edge 00129 4.0 , ## high X-edge 00130 50 , ## number of Y-bins 00131 1 , ## low Y-edge 00132 2 ) ## high Y-edge 00133 00134 (6) book the trivial 2D histogram with directory path and integer ID 00135 00136 >>> h1D = book ( 'path/to/directory' , ## path in Histogram Transient Store 00137 854 , ## integer histogram identifier 00138 'm12**2 versus m13**2' , ## histogram title 00139 50 , ## number of X-bins 00140 1.0 , ## low X-edge 00141 4.0 , ## high X-edge 00142 50 , ## number of Y-bins 00143 1.0 , ## low Y-edge 00144 4.0 ) ## high Y-edge 00145 00146 (7) book the trivial 3D histogram with full path 00147 00148 >>> h1D = book ( 'path/to/my/histo' , ## path in Histogram Transient Store 00149 'x vs y vs z ' , ## histogram title 00150 10 , ## number of X-bins 00151 -1.0 , ## low X-edge 00152 1.0 , ## high X-edge 00153 10 , ## number of Y-bins 00154 -1.0 , ## low Y-edge 00155 1.0 , ## high Y-edge 00156 10 , ## number of Z-bins 00157 -1.0 , ## low Z-edge 00158 1.0 ) ## high Z-edge 00159 00160 (8) book the trivial 3D histogram with directory path and literal ID 00161 00162 >>> h1D = book ( 'path/to/directory' , ## path in Histogram Transient Store 00163 'xyz' , ## literal histogram identifier 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 (9) book the trivial 3D histogram with directory path and integer ID 00176 00177 >>> h1D = book ( 'path/to/directory' , ## path in Histogram Transient Store 00178 888 , ## integer 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 Many other booking methods are available, 00191 e.g. for the histograms with non-equidistant bins, see IHistogamSvc::book 00192 00193 """ 00194 svc = _getHistoSvc ( **kwargs ) 00195 if not svc : raise RuntimeError, 'Unable to get valid HistogramService ' 00196 ## book the histogram using the service 00197 return svc.book(*args) ## RETURN 00198 00199 book.__doc__ += '\n\n' + '\thelp(iHistogramSvc.book) : \n\n' \ 00200 + iHistogramSvc.book . __doc__ 00201 book.__doc__ += '\n\n' + '\thelp(IHistogramSvc::book) : \n\n' \ 00202 + cpp.IHistogramSvc.book . __doc__ 00203 00204 # ============================================================================= ## The trivial function to book 1D&2D profile histograms:
| 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 206 of file HistoUtils.py.
00206 : 00207 """ 00208 00209 The trivial function to book 1D&2D profile histograms: 00210 00211 (1) book 1D-profile histogram with full path in Histogram Transient Store: 00212 >>> histo = bookProf ( 'path/to/my/profile' , ## path in Histogram Transient Store 00213 'Energy Correction' , ## the histogram title 00214 100 , ## number of X-bins 00215 0.0 , ## low X-edge 00216 100 ) ## high X-edge 00217 00218 (2) book 1D-profile histogram with directory path and literal ID 00219 >>> histo = bookProf ( 'path/to/my/profile' , ## path in Histogram Transient Store 00220 'Calibration' , ## the histogram literal identifier 00221 'Energy Correction' , ## the histogram title 00222 100 , ## number of X-bins 00223 0.0 , ## low X-edge 00224 100 ) ## high X-edge 00225 00226 (3) book 1D-profile histogram with directory path and integer ID 00227 >>> histo = bookProf ( 'path/to/my/profile' , ## path in Histogram Transient Store 00228 418 , ## the histogram integer identifier 00229 'Energy Correction' , ## the histogram title 00230 100 , ## number of X-bins 00231 0.0 , ## low X-edge 00232 100 ) ## high X-edge 00233 00234 (4) book 2D-profile histogram with full path in Histogram Transient Store: 00235 >>> histo = bookProf ( 'path/to/my/profile' , ## path in Histogram Transient Store 00236 'Energy Correction' , ## the histogram title 00237 50 , ## number of X-bins 00238 0.0 , ## low X-edge 00239 100 , ## high X-edge 00240 50 , ## number of Y-bins 00241 0.0 , ## low Y-edge 00242 100 ) ## high Y-edge 00243 00244 (5) book 2D-profile histogram with directory path and literal ID 00245 >>> histo = bookProf ( 'path/to/my/profile' , ## path in Histogram Transient Store 00246 'Calibration' , ## the histogram literal identifier 00247 'Energy Correction' , ## the histogram title 00248 50 , ## number of X-bins 00249 0.0 , ## low X-edge 00250 100 , ## high X-edge 00251 50 , ## number of Y-bins 00252 0.0 , ## low Y-edge 00253 100 ) ## high Y-edge 00254 00255 (6) book 2D-profile histogram with directory path and integer ID 00256 >>> histo = bookProf ( 'path/to/my/profile' , ## path in Histogram Transient Store 00257 418 , ## the histogram integer identifier 00258 'Energy Correction' , ## the histogram title 00259 50 , ## number of X-bins 00260 0.0 , ## low X-edge 00261 100 , ## high X-edge 00262 50 , ## number of Y-bins 00263 0.0 , ## low Y-edge 00264 100 ) ## high Y-edge 00265 00266 Many other booking methods are available, 00267 e.g. for the histograms with non-equidistant bins, see IHistogamSvc::book 00268 00269 """ 00270 svc = _getHistoSvc ( **kwargs ) 00271 if not svc : raise RuntimeError, 'Unable to get valid HistogramService ' 00272 ## book the histogram using the service 00273 return svc.bookProf(*args) ## RETURN 00274 00275 00276 bookProf.__doc__ += '\n\n' + '\thelp(iHistogramSvc.bookProf) : \n\n' \ 00277 + iHistogramSvc.bookProf . __doc__ 00278 bookProf.__doc__ += '\n\n' + '\thelp(IHistogramSvc::bookProf) : \n\n' \ 00279 + cpp.IHistogramSvc.bookProf . __doc__ 00280 00281 # ============================================================================= ## The most trivial function to retrieve the histogram from Histogram Transient Store
| 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 324 of file HistoUtils.py.
00326 : x , ## function to be used 00327 cut = lambda x : True , ## cut to be applied 00328 **kwargs ) : ## optional extra arguments 00329 """ 00330 00331 The function which allows 'the smart fill' of 1D-histogram 00332 00333 >>> histo = ... 00334 00335 The most trivial case, fill with the value 00336 >>> fill ( histo , 1.0 ) 00337 00338 Fill from any iterable object (sequence) 00339 >>> fill ( histo , [1,,2,3,4,5,10] ) 00340 00341 Fill from iterable object and apply the function: 00342 >>> fill ( histo , [1,2,3,4,5] , math.sin ) 00343 00344 Use lambda form: 00345 >>> fill ( histo , [1,2,3,4,5] , lambda x : x*x ) 00346 00347 The same 00348 >>> fill ( histo , [1,2,3,4,5] , fun = lambda x : x*x ) 00349 00350 Use internal attributes: 00351 >>> tracks = evtSvc['Rec/Track/Best'] ## iterable container of tracks 00352 >>> fill ( histo , tracks , lambda t : t.pt() ) 00353 00354 Apply the predicate: fill only even numbers: 00355 >>> fill ( histo , [1,2,3,4,5,6,7] , lambda x : x , lambda y : y%2 ) 00356 00357 The same (omit the trivial function) : 00358 >>> fill ( histo , [1,2,3,4,5,6,7] , cut = lambda y : y%2 ) 00359 00360 Apply the predicate: fill only pt for positively charged tracks: 00361 >>> tracks = evtSvc['Rec/Track/Best'] 00362 >>> fill ( histo , tracks , lambda t : t.pt() , lambda t : 0<t.charge() ) 00363 00364 The same: 00365 >>> fill ( histo , tracks , 00366 fun = lambda t : t.pt() , 00367 cut = lambda t : 0<t.charge() ) 00368 00369 Ordinary functions are also fine: 00370 >>> def myfun ( track ) : return sin( track.pt() + track.p() ) 00371 >>> def mycut ( track ) : return track.p() > 100 * GeV 00372 >>> fill ( histo , tracks , myfun , mycut ) 00373 00374 The 'data' could be the address in TES, in this case the object 00375 is retrieved from TES and the method is applied to the objects, 00376 retrieved from TES: 00377 >>> fill ( histo , ## the reference to the histogram 00378 'Rec/Track/Best' , ## the location of objects in TES 00379 lambda t : t.pt() ) ## function to be used for histogram fill 00380 >>> fill ( histo , ## the reference to the histogram 00381 'Rec/Track/Best' , ## the address of objects in TES 00382 lambda t : t.pt() , ## the function to be used for histogram fill 00383 lambda t : t.charge()>0 ) ## the criteria to select tracks 00384 00385 The arguments 'fun' and 'cut' could be strings, in this case 00386 they are evaluated by python before usage. 00387 This option could be often very useful. 00388 00389 """ 00390 00391 # if value is a string, try to get the objects from TES 00392 if type ( data ) == str : 00393 svc = _getEvtSvc ( **kwargs ) 00394 data = svc[data] 00395 return fill ( histo , data , fun , cut , **kwargs ) 00396 00397 # if the function is a string: evaluate it! 00398 if type ( fun ) == str : fun = eval ( fun , globals() ) 00399 00400 # if the criterion is a string: evaluate it! 00401 if type ( cut ) == str : cut = eval ( cut , globals() ) 00402 00403 if not hasattr ( data , '__iter__' ) : data = [ data ] 00404 00405 if not hasattr ( histo , 'fill' ) and hasattr ( histo , 'Fill' ) : 00406 setattr ( histo , 'fill' , getattr ( histo , 'Fill' ) ) 00407 00408 for item in data : 00409 if not cut ( item ) : continue ## CONTINUE 00410 histo.fill ( fun ( item ) ) 00411 00412 return histo ## RETURN 00413 00414 # =============================================================================
| 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 283 of file HistoUtils.py.
00283 : 00284 """ 00285 00286 The most trivial function to retrieve the histogram from Histogram Transient Store 00287 The histogram is returned by reference to its AIDA-representation (if possible) 00288 00289 >>> h = getAsAIDA ( 'some/path/to/my/histogram' ) 00290 00291 """ 00292 svc = _getHistoSvc ( **kwargs ) 00293 if not svc : raise RuntimeError, 'Unable to get valid HistogramService ' 00294 ## return the histogram 00295 return svc.getAsAIDA( path ) ## RETURN 00296 00297 getAsAIDA.__doc__ += '\n\n' + '\thelp(iHistogramSvc.getAsAIDA) : \n\n' \ 00298 + iHistogramSvc.getAsAIDA . __doc__ 00299 getAsAIDA.__doc__ += '\n\n' + '\thelp(iHistogramSvc.retrieve) : \n\n' \ 00300 + iHistogramSvc.retrieve . __doc__ 00301 00302 # ============================================================================= ## The most trivial function to retrieve the histogram from Histogram Transient Store
| 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 304 of file HistoUtils.py.
00304 : 00305 """ 00306 00307 The most trivial function to retrieve the histogram from Histogram Transient Store 00308 The histogram is returned by reference to its underlying native ROOT-representation (if possible) 00309 00310 >>> h = getAsROOT ( 'some/path/to/my/histogram' ) 00311 00312 """ 00313 svc = _getHistoSvc ( **kwargs ) 00314 if not svc : raise RuntimeError, 'Unable to get valid HistogramService ' 00315 ## return the histogram 00316 return svc.getAsROOT( path ) ## RETURN 00317 00318 getAsROOT.__doc__ += '\n\n' + '\thelp(iHistogramSvc.getAsROOT) : \n\n' \ 00319 + iHistogramSvc.getAsROOT . __doc__ 00320 00321 00322 # ============================================================================= ## The function which allows 'the smart fill' of 1D-histogram
Initial value:
(
'book' , ## book AIDA histogram using Histogram Service
'bookProf' , ## book AIDA profile histogram using Histogram Service
'getAsAIDA' , ## get the histogram form Histogram Service as AIDA histogram
'getAsROOT' , ## get the histogram form Histogram Service as AIDA histogram
'fill' , ## "power-fill" method for filling of histograms
'aida2root' , ## AIDA -> ROOT converter
'HistoStats' ## statistical information for 1D-histograms
'HistoFile' ## class for storing histograms to a file
)
Definition at line 27 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.
Definition at line 25 of file HistoUtils.py.
| GaudiPython::HistoUtils::aida2root = cpp.Gaudi.Utils.Aida2ROOT.aida2root |
| GaudiPython::HistoUtils::HID = cpp.GaudiAlg.ID |
Definition at line 42 of file HistoUtils.py.
| GaudiPython::HistoUtils::HistoStats = cpp.Gaudi.Utils.HistoStats |
Definition at line 444 of file HistoUtils.py.
| GaudiPython::HistoUtils::i1DH = cpp.AIDA.IHistogram1D |
Definition at line 701 of file HistoUtils.py.
| GaudiPython::HistoUtils::iBH = cpp.AIDA.IBaseHistogram |
Definition at line 742 of file HistoUtils.py.