Belle II Software
release-05-02-19
Main Page
Modules
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Functions
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
x
z
Variables
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Typedefs
a
b
c
d
e
h
i
l
m
n
p
r
s
t
v
w
Enumerations
Enumerator
c
d
f
p
t
u
v
w
Classes
Class List
Class Hierarchy
Class Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
Enumerations
a
b
c
d
e
f
g
h
i
l
m
o
p
r
s
t
u
v
Enumerator
a
b
c
d
e
f
g
h
k
l
m
n
o
p
r
s
t
u
v
w
z
Related Functions
b
c
d
g
i
o
r
s
t
Files
File List
File Members
All
Functions
caf_algorithmdb_access.py
1
# This steering file shows off algorithms accessing database constants
2
# from within the CAF. There's actually no special changes to the CAF script,
3
# we're just going to use algorithms that do this accessing.
4
#
5
# You should check the stdout of the algorithm output to see the database constants
6
# being used.
7
#
8
# We're going to pass the database constants from one Calibration to another
9
# that depends on it. AND we're going to show that when you have multiple algorithms
10
# in a SINGLE Calibration, the constants are passed forwards to the next as they get saved.
11
12
import
basf2
as
b2
13
14
import
os
15
import
sys
16
17
from
ROOT.Belle2
import
TestDBAccessAlgorithm
18
19
from
caf.framework
import
Calibration, CAF
20
from
caf
import
backends
21
22
23
def
main
(argv):
24
if
len(argv) == 1:
25
data_dir = argv[0]
26
else
:
27
print(
"Usage: python3 caf_multiple_options.py <data directory>"
)
28
sys.exit(1)
29
30
34
input_files = [os.path.join(os.path.abspath(data_dir),
'*.root'
)]
35
36
38
dep_col = b2.register_module(
'CaTest'
)
39
dep_col.set_name(
'Dependent'
)
# Sets the prefix of the collected data in the datastore.
40
# Allows us to execute algorithm over input data in a run-by-run way so we can see DB constants from each run.
41
dep_col.param(
'granularity'
,
'run'
)
42
# Specific parameter to our test collector, proportional to the probability of algorithm requesting iteration.
43
dep_col.param(
'spread'
, 15)
44
45
dep_alg = TestDBAccessAlgorithm()
46
# Since we're using several instances of the same test algorithm here, we still want the database entries to have
47
# different names. TestCalibrationAlgorithm outputs to the database using the prefix name so we change it
48
# for each calibration. Not something you'd usually have to do. And you could instead use whatever name you want,
49
# we just use the prefix as a handy string.
50
dep_alg.setPrefix(
'Dependent'
)
# Must be the same as colllector prefix
51
52
# Create our Calibration object
53
dep_cal =
Calibration
(name=
'Dependent_Calibration'
,
54
collector=dep_col,
55
algorithms=dep_alg,
56
input_files=input_files)
57
58
# Let's split up the collector jobs by files
59
dep_cal.max_files_per_collector_job = 1
60
dep_cal.max_iterations = 5
61
62
# This one runs last and picks up the final DB constants from the first one
63
last_col = b2.register_module(
'CaTest'
)
64
last_col.set_name(
'Last'
)
# Sets the prefix of the collected data in the datastore.
65
# Allows us to execute algorithm over input data in a run-by-run way so we can see DB constants from each run.
66
last_col.param(
'granularity'
,
'run'
)
67
# Specific parameter to our test collector, proportional to the probability of algorithm requesting iteration.
68
last_col.param(
'spread'
, 15)
69
70
last_alg = TestDBAccessAlgorithm()
71
last_alg.setGeneratePayloads(
False
)
72
last_alg.setPrefix(
'Last'
)
# Must be the same as colllector prefix
73
74
# Create our Calibration object
75
last_cal =
Calibration
(name=
'Last_Calibration'
,
76
collector=last_col,
77
algorithms=last_alg,
78
input_files=input_files)
79
80
# Let's split up the collector jobs by files
81
last_cal.max_files_per_collector_job = 1
82
last_cal.max_iterations = 5
83
84
# Define dependencies
85
last_cal.depends_on(dep_cal)
86
87
89
cal_fw = CAF()
90
cal_fw.add_calibration(dep_cal)
91
cal_fw.add_calibration(last_cal)
92
# Subjobs from collector jobs being split over input files can be paralellized.
93
# Also Calibrations 1 and 2, can be run at the same time.
94
# If you have 4 cores this backend will run them whenever one of the 4 processes becomes available
95
# For larger data or more calibrations, consider using the LSF or PBS batch system backends at your site
96
cal_fw.backend =
backends.Local
(max_processes=4)
97
# Start her up!
98
cal_fw.run()
99
print(
"End of CAF processing."
)
100
101
102
if
__name__ ==
"__main__"
:
103
main
(sys.argv[1:])
main
int main(int argc, char **argv)
Run all tests.
Definition:
test_main.cc:77
Calibration
Definition:
Calibration.py:1
backends.Local
Definition:
backends.py:878
calibration
examples
caf_algorithmdb_access.py
Generated on Tue Jan 4 2022 02:52:35 for Belle II Software by
1.8.17