The Gaudi Framework
v36r1 (3e2fb5a8)
HistoEx.py
Go to the documentation of this file.
1
#!/usr/bin/env python
2
13
"""
14
*******************************************************************************
15
* *
16
* Simple example which illustrate the usage of useful algorithm base class *
17
* HistoAlgo (python version of C++ GaudiHistoAlg) for "easy" histogramming. *
18
* *
19
*******************************************************************************
20
"""
21
from
__future__
import
print_function
22
# =============================================================================
23
__author__ =
'Vanya BELYAEV Ivan.Belyaev@lapp.in2p3.fr'
24
# =============================================================================
25
26
from
GaudiPython.GaudiAlgs
import
HistoAlgo, SUCCESS
27
28
# =============================================================================
29
# Simple algorithm which book&fill 3 histograms
30
# =============================================================================
31
32
33
class
HistoEx
(
HistoAlgo
):
34
""" Simple algorithm which implicitely book&fill three histograms """
35
36
def
__init__
(self, name):
37
""" Constructor """
38
HistoAlgo.__init__(self, name)
39
40
def
execute
(self):
41
""" The major method 'execute', it is invoked for each event """
42
for
i
in
range
(0, 10):
43
self.plot1D(i,
' 1D histo '
, 0, 20, 20)
44
for
j
in
range
(0, 10):
45
self.plot2D(i, j,
' 2D histo '
, 0, 20, 0, 20, 20, 20)
46
for
k
in
range
(0, 10):
47
self.plot3D(i, j, k,
' 3D histo '
, 0, 20, 0, 20, 0, 20, 20,
48
20, 20)
49
50
return
SUCCESS
51
52
53
# =============================================================================
54
# job configuration
55
# =============================================================================
56
def
configure
(gaudi=None):
57
""" Configuration of the job """
58
59
if
not
gaudi:
60
from
GaudiPython.Bindings
import
AppMgr
61
gaudi =
AppMgr
()
62
63
gaudi.JobOptionsType =
'NONE'
64
gaudi.EvtSel =
'NONE'
65
gaudi.HistogramPersistency =
'ROOT'
66
67
gaudi.config()
68
69
gaudi.DLLs = [
70
'GaudiAlg'
,
71
'RootHistCnv'
,
72
]
73
74
alg =
HistoEx
(
'HistoEx'
)
75
gaudi.setAlgorithms([alg])
76
alg.HistoPrint =
True
77
78
hsvc = gaudi.service(
'HistogramPersistencySvc'
)
79
hsvc.OutputFile =
"histo1.root"
80
81
# This does not harm and tests bug #50389
82
getMyalgBack = gaudi.algorithm(
'HistoEx'
)
83
84
return
SUCCESS
85
86
87
# =============================================================================
88
# The actual job excution
89
# =============================================================================
90
if
'__main__'
== __name__:
91
print(__doc__ + __author__)
92
93
from
GaudiPython.Bindings
import
AppMgr
94
gaudi =
AppMgr
()
95
configure
(gaudi)
96
gaudi.run(20)
97
98
import
GaudiPython.HistoUtils
99
100
alg = gaudi.algorithm(
'HistoEx'
)
101
histos = alg.Histos()
102
for
key
in
sorted(histos):
103
histo = histos[key]
104
if
hasattr(histo,
'dump'
):
105
print(histo.dump(80, 20,
True
))
106
107
# =============================================================================
108
# The END
109
# =============================================================================
GaudiPython.HistoUtils
Definition:
HistoUtils.py:1
GaudiPython.GaudiAlgs.HistoAlgo
Definition:
GaudiAlgs.py:768
GaudiPython.Bindings.AppMgr
Definition:
Bindings.py:842
GaudiPython.Bindings
Definition:
Bindings.py:1
HistoEx.configure
def configure(gaudi=None)
Definition:
HistoEx.py:56
HistoEx.HistoEx.__init__
def __init__(self, name)
Definition:
HistoEx.py:36
HistoEx.HistoEx.execute
def execute(self)
Definition:
HistoEx.py:40
GaudiPython.GaudiAlgs
Definition:
GaudiAlgs.py:1
HistoEx.HistoEx
Definition:
HistoEx.py:33
Gaudi::Functional::details::zip::range
decltype(auto) range(Args &&... args)
Zips multiple containers together to form a single range.
Definition:
FunctionalDetails.h:97
GaudiExamples
scripts
HistoEx.py
Generated on Tue Sep 21 2021 12:27:41 for The Gaudi Framework by
1.8.18