Belle II Software
release-08-01-10
trainTrackFilter.py
1
#!/usr/bin/env python3
2
# -*- coding: utf-8 -*-
3
4
11
12
import
os
13
import
sys
14
import
os.path
15
16
17
from
tracking.path_utils
import
add_cdc_track_finding
18
from
tracking.run.event_generation
import
ReadOrGenerateEventsRun
19
from
trackfindingcdc.run.training
import
TrainingRunMixin
20
from
tracking.adjustments
import
adjust_module
21
22
23
class
TrackFilterTrainingRun
(TrainingRunMixin,
ReadOrGenerateEventsRun
):
24
"""Run to record tracks encountered at the TrackRejecter and retrain its mva method"""
25
26
27
n_events = 3000
28
29
generator_module =
"generic"
30
31
bkg_files = os.path.join(os.environ[
"VO_BELLE2_SW_DIR"
],
"bkg"
)
32
33
34
truth =
"truth"
35
36
@property
37
def
identifier
(self):
38
"""Database identifier of the filter being trained"""
39
return
"trackfindingcdc_TrackFilter.xml"
40
41
def
create_path
(self):
42
"""Setup the recording path after the simulation"""
43
path = super().
create_path
()
44
45
add_cdc_track_finding(path)
46
47
48
if
self.
task
task ==
"train"
:
49
filterName =
"recording"
50
51
elif
self.
task
task ==
"eval"
:
52
filterName =
"eval"
53
54
self.
truth
truth
truth =
"truth_accepted"
55
56
elif
self.
task
task ==
"explore"
:
57
# Change me.
58
filterName =
"recording"
59
60
adjust_module(path,
"TFCDC_SegmentTrackCombiner"
,
61
trackFilter=filterName,
62
trackFilterParameters={
63
"rootFileName"
: self.sample_file_name,
64
})
65
66
return
path
67
68
def
postprocess
(self):
69
"""Post-process the results for MC-truth acceptance"""
70
if
self.
task
task ==
"eval"
:
71
self.
truth
truth
truth =
"truth_accept"
72
super().
postprocess
()
73
74
75
def
main
():
76
run =
TrackFilterTrainingRun
()
77
run.configure_and_execute_from_commandline()
78
79
80
if
__name__ ==
"__main__"
:
81
import
logging
82
logging.basicConfig(stream=sys.stdout, level=logging.INFO, format=
'%(levelname)s:%(message)s'
)
83
main
()
tracking.run.event_generation.ReadOrGenerateEventsRun
Definition:
event_generation.py:35
trainTrackFilter.TrackFilterTrainingRun
Definition:
trainTrackFilter.py:23
trainTrackFilter.TrackFilterTrainingRun.truth
string truth
degree of MC truth-matching
Definition:
trainTrackFilter.py:34
trainTrackFilter.TrackFilterTrainingRun.create_path
def create_path(self)
Definition:
trainTrackFilter.py:41
trainTrackFilter.TrackFilterTrainingRun.truth
truth
Modify degree of MC truth-matching.
Definition:
trainTrackFilter.py:54
trainTrackFilter.TrackFilterTrainingRun.task
task
Process each event according to the user's desired task (train, eval, explore)
Definition:
trainTrackFilter.py:48
trainTrackFilter.TrackFilterTrainingRun.postprocess
def postprocess(self)
Definition:
trainTrackFilter.py:68
trainTrackFilter.TrackFilterTrainingRun.identifier
def identifier(self)
Definition:
trainTrackFilter.py:37
main
Definition:
main.py:1
tracking.adjustments
Definition:
adjustments.py:1
tracking.path_utils
Definition:
path_utils.py:1
tracking.run.event_generation
Definition:
event_generation.py:1
main
int main(int argc, char **argv)
Run all tests.
Definition:
test_main.cc:91
tracking
trackFindingCDC
train
trainTrackFilter.py
Generated on Mon Sep 23 2024 14:06:22 for Belle II Software by
1.9.1