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