Belle II Software
release-08-01-10
trainRealisticSegmentPairFilter.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
from
tracking.run.event_generation
import
ReadOrGenerateEventsRun
17
from
trackfindingcdc.run.training
import
TrainingRunMixin
18
19
20
class
RealisticSegmentPairFilterTrainingRun
(TrainingRunMixin,
ReadOrGenerateEventsRun
):
21
"""Run to record segment pairs encountered at the SegmentPairCreator and retrain its mva method"""
22
23
n_events = 10000
24
25
generator_module =
"generic"
26
27
bkg_files = os.path.join(os.environ[
"VO_BELLE2_SW_DIR"
],
"bkg"
)
28
29
30
truth =
"truth_positive"
31
32
@property
33
def
identifier
(self):
34
"""Database identifier of the filter being trained"""
35
return
"trackfindingcdc_RealisticSegmentPairFilter.xml"
36
37
def
create_path
(self):
38
"""Setup the recording path after the simulation"""
39
path = super().
create_path
()
40
41
# In contrast to other training use only the first *half* loop for more aggressive training
42
path.add_module(
"TFCDC_WireHitPreparer"
,
43
flightTimeEstimation=
"outwards"
)
44
45
path.add_module(
'TFCDC_ClusterPreparer'
,
46
SuperClusterDegree=3,
47
SuperClusterExpandOverApogeeGap=
True
)
48
49
path.add_module(
"TFCDC_SegmentFinderFacetAutomaton"
)
50
51
52
if
self.
task
task ==
"train"
:
53
varSets = [
54
"realistic"
,
55
"filter(truth)"
,
56
"truth"
,
# for weighting
57
]
58
skim =
"feasible"
59
60
elif
self.
task
task ==
"eval"
:
61
varSets = [
62
"filter(truth)"
,
63
"filter(realistic)"
,
64
"filter(feasible)"
,
65
"filter(fitless)"
,
66
"filter(simple)"
,
67
]
68
skim =
""
69
70
elif
self.
task
task ==
"explore"
:
71
varSets = [
72
"basic"
,
73
# "realistic",
74
"fitless"
,
75
"pre_fit"
,
76
"fit"
,
77
"truth"
,
# for weighting
78
# "old_fit",
79
# "filter(fitless)",
80
# "filter(simple)",
81
"filter(realistic)"
,
82
"filter(truth)"
,
83
]
84
skim =
"feasible"
85
86
else
:
87
raise
ValueError(
"Unknown task "
+ self.
task
task)
88
89
path.add_module(
"TFCDC_TrackFinderSegmentPairAutomaton"
,
90
SegmentPairFilter=
"unionrecording"
,
91
SegmentPairFilterParameters={
92
"rootFileName"
: self.sample_file_name,
93
"varSets"
: varSets,
94
"skim"
: skim,
95
})
96
97
return
path
98
99
100
def
main
():
101
run =
RealisticSegmentPairFilterTrainingRun
()
102
run.configure_and_execute_from_commandline()
103
104
105
if
__name__ ==
"__main__"
:
106
import
logging
107
logging.basicConfig(stream=sys.stdout, level=logging.INFO, format=
'%(levelname)s:%(message)s'
)
108
main
()
tracking.run.event_generation.ReadOrGenerateEventsRun
Definition:
event_generation.py:35
trainRealisticSegmentPairFilter.RealisticSegmentPairFilterTrainingRun
Definition:
trainRealisticSegmentPairFilter.py:20
trainRealisticSegmentPairFilter.RealisticSegmentPairFilterTrainingRun.create_path
def create_path(self)
Definition:
trainRealisticSegmentPairFilter.py:37
trainRealisticSegmentPairFilter.RealisticSegmentPairFilterTrainingRun.task
task
Process each event according to the user's desired task (train, eval, explore)
Definition:
trainRealisticSegmentPairFilter.py:52
trainRealisticSegmentPairFilter.RealisticSegmentPairFilterTrainingRun.identifier
def identifier(self)
Definition:
trainRealisticSegmentPairFilter.py:33
main
Definition:
main.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
trainRealisticSegmentPairFilter.py
Generated on Mon Sep 23 2024 14:06:21 for Belle II Software by
1.9.1