Belle II Software
release-05-01-25
trainFacetFilter.py
1
#!/usr/bin/env python3
2
# -*- coding: utf-8 -*-
3
4
# This is for training a mva classifier for hit triplets
5
# It performs a tip better than the current default chi2 filter
6
# However run time is quite a bit slower which is why it wont be used in the standard chain.
7
# Nevertheless this script can be used to generate variables to consider
8
# for improvements or cross checks with --task explore
9
10
import
os
11
import
sys
12
import
os.path
13
14
from
tracking.run.event_generation
import
StandardEventGenerationRun
15
from
trackfindingcdc.run.training
import
TrainingRunMixin
16
17
18
class
FacetFilterTrainingRun
(TrainingRunMixin,
StandardEventGenerationRun
):
19
"""Run for recording facets encountered at the filter"""
20
21
n_events = 100
22
23
24
generator_module =
"generic"
25
# detector_setup = "TrackingDetector"
26
27
28
task =
"explore"
29
30
31
truth =
"truth_positive"
32
33
34
flight_time_reestimation =
False
35
36
37
facet_least_square_fit =
False
38
39
@property
40
def
identifier
(self):
41
"""Database identifier of the filter being trained"""
42
return
"trackfindingcdc_FacetFilter.xml"
43
44
def
create_argument_parser
(self, **kwds):
45
"""Convert command-line arguments to basf2 argument list"""
46
47
argument_parser = super().
create_argument_parser
(**kwds)
48
49
argument_parser.add_argument(
50
"-fr"
,
51
"--flight-time-reestimation"
,
52
action=
"store_true"
,
53
dest=
"flight_time_reestimation"
,
54
help=
"Switch to reestimate drift length before fitting."
55
)
56
57
argument_parser.add_argument(
58
"-fl"
,
59
"--facet-least-square-fit"
,
60
action=
"store_true"
,
61
dest=
"facet_least_square_fit"
,
62
help=
"Switch to fit the facet with least square method for the drift length update"
63
)
64
65
return
argument_parser
66
67
def
create_path
(self):
68
"""
69
Sets up a path that plays back pregenerated events or generates events
70
based on the properties in the base class.
71
"""
72
73
path = super().
create_path
()
74
75
76
if
self.
task
==
"train"
:
77
var_sets = [
78
"mva"
,
79
"filter(truth)"
,
80
]
81
82
elif
self.
task
==
"eval"
:
83
var_sets = [
84
"filter(chi2)"
,
85
"filter(realistic)"
,
86
"filter(mva)"
,
87
"filter(truth)"
,
88
]
89
90
elif
self.
task
==
"explore"
:
91
var_sets = [
92
"basic"
,
93
"truth"
,
94
"bend"
,
95
"fit"
,
96
"filter(truth)"
,
97
"filter(realistic)"
,
98
"filter(chi2)"
,
99
]
100
101
102
self.
variables
= [
103
"curv"
,
104
"curv_pull"
,
105
"middle_phi_pull"
,
106
"middle_chi2"
,
107
"fit_0_phi0_sigma"
,
108
"chi2_0"
,
109
"chi2_0_per_s"
,
110
"fit_1_phi0_sigma"
,
111
"chi2_1"
,
112
"chi2_1_per_s"
,
113
"fit_phi0_sigma"
,
114
"chi2 chi2_per_s"
,
115
"realistic_accept"
,
116
"chi2_accept"
,
117
]
118
119
wire_hit_preparer = path.add_module(
"TFCDC_WireHitPreparer"
,
120
flightTimeEstimation=
"outwards"
,
121
UseNLoops=1.0)
122
123
path.add_module(
"TFCDC_ClusterPreparer"
)
124
125
path.add_module(
"TFCDC_SegmentFinderFacetAutomaton"
,
126
FacetUpdateDriftLength=self.
flight_time_reestimation
,
127
FacetLeastSquareFit=self.
facet_least_square_fit
,
128
FacetFilter=
"unionrecording"
,
129
FacetFilterParameters={
130
"rootFileName"
: self.sample_file_name,
131
"varSets"
: var_sets,
132
},
133
FacetRelationFilter=
"none"
)
134
135
return
path
136
137
138
def
main
():
139
"""Execute the facet recording"""
140
run =
FacetFilterTrainingRun
()
141
run.configure_and_execute_from_commandline()
142
143
144
if
__name__ ==
"__main__"
:
145
import
logging
146
logging.basicConfig(stream=sys.stdout, level=logging.INFO, format=
"%(levelname)s:%(message)s"
)
147
main
()
trainFacetFilter.FacetFilterTrainingRun.flight_time_reestimation
bool flight_time_reestimation
Option whether to reestimate the drift length.
Definition:
trainFacetFilter.py:34
trainFacetFilter.FacetFilterTrainingRun.variables
variables
Signal some variables to select in the classification analysis.
Definition:
trainFacetFilter.py:102
trainFacetFilter.FacetFilterTrainingRun
Definition:
trainFacetFilter.py:18
trainFacetFilter.FacetFilterTrainingRun.task
string task
Default task set to explore.
Definition:
trainFacetFilter.py:28
tracking.run.event_generation.StandardEventGenerationRun
Definition:
event_generation.py:188
main
int main(int argc, char **argv)
Run all tests.
Definition:
test_main.cc:77
trainFacetFilter.FacetFilterTrainingRun.facet_least_square_fit
bool facet_least_square_fit
Option whether to use the least square fit to the hit triplet.
Definition:
trainFacetFilter.py:37
tracking.run.event_generation
Definition:
event_generation.py:1
trainFacetFilter.FacetFilterTrainingRun.create_argument_parser
def create_argument_parser(self, **kwds)
Definition:
trainFacetFilter.py:44
trainFacetFilter.FacetFilterTrainingRun.create_path
def create_path(self)
Definition:
trainFacetFilter.py:67
trainFacetFilter.FacetFilterTrainingRun.identifier
def identifier(self)
Definition:
trainFacetFilter.py:40
tracking
trackFindingCDC
train
trainFacetFilter.py
Generated on Fri Nov 5 2021 04:04:05 for Belle II Software by
1.8.17