Belle II Software development
trainFacetRelationFilter.py
1#!/usr/bin/env python3
2
3
10
11# This is for training a mva classifier for relations between hit triplets
12# It performs a tip better than the current default chi2 filter
13# However run time is quite a bit slower which is why it won't be used in the standard chain.
14# Nevertheless this script can be used to generate variables to consider
15# for improvements or cross checks with --task explore
16
17import sys
18
19from tracking.run.event_generation import StandardEventGenerationRun
20from trackfindingcdc.run.training import TrainingRunMixin
21
22
24 """Run for recording facets encountered at the filter"""
25
26 n_events = 1000
27
28
29 generator_module = "generic"
30 # detector_setup = "TrackingDetector"
31
32
33 task = "explore"
34
35
36 truth = "truth_positive"
37
38 @property
39 def identifier(self):
40 """Database identifier of the filter being trained"""
41 return "trackfindingcdc_FacetRelationFilter.xml"
42
43 def create_path(self):
44 """Setup the recording path after the simulation"""
45 path = super().create_path()
46
47
48 if self.tasktask == "train":
49 var_sets = [
50 "mva",
51 "filter(truth)",
52 ]
53
54 elif self.tasktask == "eval":
55 var_sets = [
56 "basic",
57 "filter(chi2)",
58 "filter(chi2_old)",
59 "filter(simple)",
60 "filter(truth)",
61 ]
62
63 self.variables = [
64 "chi2_weight",
65 "chi2_accept",
66 "chi2_old_weight",
67 "chi2_old_accept",
68 "simple_accept",
69 ]
70
71 self.groupby = ["", "superlayer_id"]
72 self.auxiliaries = [
73 "superlayer_id",
74 ]
75
76 elif self.tasktask == "explore":
77 var_sets = [
78 "basic",
79 "bend",
80 "fit",
81 "filter(chi2)",
82 "filter(simple)",
83 "filter(truth)",
84 ]
85
86
87 self.variables = [
88 # "delta_phi",
89 # "delta_phi_pull",
90 # "delta_phi_pull_per_r",
91 # "delta_curv",
92 # "delta_curv_pull",
93 # "delta_curv_pull_per_r",
94
95 # "cos_delta",
96 # "from_middle_cos_delta",
97 # "to_middle_cos_delta",
98
99 "chi2_0",
100 # "chi2_0_per_s",
101 # "erf_0",
102 # "fit_0_phi0",
103 # "fit_0_cos_delta",
104
105 # "chi2_1",
106 # "chi2_1_per_s",
107 # "fit_1_phi0",
108 # "fit_1_cos_delta",
109
110 # "chi2",
111 # "chi2_per_s",
112 # "fit_phi0",
113 # "fit_cos_delta",
114
115 # "phi0_from_sigma",
116 # "phi0_to_sigma",
117
118 # "phi0_ref_pull",
119 # "phi0_ref_diff",
120 # "phi0_ref_sigma",
121
122 # "chi2_comb",
123 # "phi0_comb_pull",
124 # "phi0_comb_diff",
125 # "phi0_comb_sigma",
126
127 # "chi2_kari_unit",
128 # "abs_curv_unit",
129
130 # "chi2_kari_l",
131 # "abs_curv_l",
132
133 # "chi2_kari_pseudo",
134 # "abs_curv_pseudo",
135
136 # "chi2_kari_proper",
137 # "abs_curv_proper",
138 ]
139
140
141 self.groupby = ["", "superlayer_id"]
142
143 self.auxiliaries = [
144 "superlayer_id",
145 ]
146
147 path.add_module("TFCDC_WireHitPreparer",
148 flightTimeEstimation="outwards",
149 UseNLoops=1.0)
150
151 path.add_module("TFCDC_ClusterPreparer")
152
153 path.add_module("TFCDC_SegmentFinderFacetAutomaton",
154 FacetRelationFilter="unionrecording",
155 FacetRelationFilterParameters={
156 "rootFileName": self.sample_file_name,
157 "varSets": var_sets,
158 })
159
160 return path
161
162
163def main():
164 """Execute the facet relation recording"""
166 run.configure_and_execute_from_commandline()
167
168
169if __name__ == "__main__":
170 import logging
171 logging.basicConfig(stream=sys.stdout, level=logging.INFO, format='%(levelname)s:%(message)s')
172 main()
variables
Signal some variables to select in the classification analysis.
task
Post-process events according to the user's desired task (train, eval, explore)
Definition: main.py:1