Belle II Software
development
Toggle main menu visibility
Main Page
Topics
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
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
v
w
x
z
Typedefs
a
b
c
d
e
g
i
k
l
m
n
p
r
s
t
u
v
w
Enumerations
a
b
c
e
f
g
n
p
s
v
z
Enumerator
c
d
f
p
t
v
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 Symbols
b
c
d
g
i
o
r
s
t
Files
File List
File Members
All
Functions
Typedefs
Macros
run.py
1
8
9
import
argparse
10
import
pickle
11
12
from
tracking.run.event_generation
import
StandardEventGenerationRun
13
from
tracking.run.mixins
import
BrowseTFileOnTerminateRunMixin, PostProcessingRunMixin
14
15
16
class
HarvestingRunMixin
(
BrowseTFileOnTerminateRunMixin
,
PostProcessingRunMixin
):
17
"""Harvester to select crops, postprocess, and inspect"""
18
19
20
output_file_name =
None
21
22
def
harvesting_module
(self, path=None):
23
"""This virtual method must be overridden by the inheriting class"""
24
raise
RuntimeError(
"Override the harvesting_module method"
)
25
22
def
harvesting_module
(self, path=None):
…
26
def
create_argument_parser
(self, **kwds):
27
"""Parse the arguments and append them to the harvester's list"""
28
argument_parser = super().
create_argument_parser
(**kwds)
29
harvesting_argument_group = argument_parser.add_argument_group(
"Harvest arguments"
)
30
31
harvesting_argument_group.add_argument(
32
"-o"
,
33
"--output"
,
34
dest=
"output_file_name"
,
35
default=argparse.SUPPRESS,
36
help=
"File name for the harvest products"
37
)
38
39
return
argument_parser
40
26
def
create_argument_parser
(self, **kwds):
…
41
def
pickle_crops(self, harvesting_module, crops, **kwds):
42
"""Save the raw crops as a pickle file"""
43
with
open(self.
output_file_name
+
".pickle"
,
"wb"
)
as
pickle_file:
44
pickle.dump(crops, pickle_file)
45
41
def
pickle_crops(self, harvesting_module, crops, **kwds):
…
46
def
unpickle_crops
(self):
47
"""Load the raw crops from a pickle file"""
48
with
open(self.
output_file_name
+
".pickle"
,
"rb"
)
as
pickle_file:
49
return
pickle.load(pickle_file)
50
46
def
unpickle_crops
(self):
…
51
def
postprocess
(self):
52
"""Post-process the crops"""
53
if
self.
postprocess_only
:
54
harvesting_module = self.
harvesting_module
()
55
if
self.
output_file_name
:
56
harvesting_module.output_file_name = self.
output_file_name
57
try
:
58
crops = self.
unpickle_crops
()
59
except
FileNotFoundError:
60
print(
"Crops pickle file not found. Create it now."
)
61
else
:
62
harvesting_module.refine(crops)
63
64
super().
postprocess
()
65
51
def
postprocess
(self):
…
66
def
adjust_path
(self, path):
67
"""Add the harvester to the basf2 path"""
68
super().
adjust_path
(path)
69
harvesting_module = self.
harvesting_module
()
70
if
self.
output_file_name
:
71
harvesting_module.output_file_name = self.
output_file_name
72
harvesting_module.refiners.append(self.
pickle_crops
)
73
path.add_module(harvesting_module)
74
return
path
75
76
66
def
adjust_path
(self, path):
…
16
class
HarvestingRunMixin
(
BrowseTFileOnTerminateRunMixin
,
PostProcessingRunMixin
):
…
77
class
HarvestingRun
(
HarvestingRunMixin
,
StandardEventGenerationRun
):
78
"""Harvester to generate MC events followed by crop selection, postprocessing, inspection"""
77
class
HarvestingRun
(
HarvestingRunMixin
,
StandardEventGenerationRun
):
…
tracking.harvest.run.HarvestingRunMixin
Definition
run.py:16
tracking.harvest.run.HarvestingRunMixin.adjust_path
adjust_path(self, path)
Definition
run.py:66
tracking.harvest.run.HarvestingRunMixin.pickle_crops
pickle_crops
Definition
run.py:72
tracking.harvest.run.HarvestingRunMixin.unpickle_crops
unpickle_crops(self)
Definition
run.py:46
tracking.harvest.run.HarvestingRunMixin.harvesting_module
harvesting_module(self, path=None)
Definition
run.py:22
tracking.harvest.run.HarvestingRunMixin.create_argument_parser
create_argument_parser(self, **kwds)
Definition
run.py:26
tracking.harvest.run.HarvestingRunMixin.postprocess
postprocess(self)
Definition
run.py:51
tracking.harvest.run.HarvestingRun
Definition
run.py:77
tracking.run.event_generation.StandardEventGenerationRun
Definition
event_generation.py:196
tracking.run.mixins.BrowseTFileOnTerminateRunMixin
Definition
mixins.py:56
tracking.run.mixins.PostProcessingRunMixin
Definition
mixins.py:25
tracking.run.event_generation
Definition
event_generation.py:1
tracking.run.mixins
Definition
mixins.py:1
tracking
scripts
tracking
harvest
run.py
Generated on Sun May 18 2025 03:04:56 for Belle II Software by
1.13.2