Belle II Software  release-08-01-10
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 
88  self.variablesvariables = [
89  # "delta_phi",
90  # "delta_phi_pull",
91  # "delta_phi_pull_per_r",
92  # "delta_curv",
93  # "delta_curv_pull",
94  # "delta_curv_pull_per_r",
95 
96  # "cos_delta",
97  # "from_middle_cos_delta",
98  # "to_middle_cos_delta",
99 
100  "chi2_0",
101  # "chi2_0_per_s",
102  # "erf_0",
103  # "fit_0_phi0",
104  # "fit_0_cos_delta",
105 
106  # "chi2_1",
107  # "chi2_1_per_s",
108  # "fit_1_phi0",
109  # "fit_1_cos_delta",
110 
111  # "chi2",
112  # "chi2_per_s",
113  # "fit_phi0",
114  # "fit_cos_delta",
115 
116  # "phi0_from_sigma",
117  # "phi0_to_sigma",
118 
119  # "phi0_ref_pull",
120  # "phi0_ref_diff",
121  # "phi0_ref_sigma",
122 
123  # "chi2_comb",
124  # "phi0_comb_pull",
125  # "phi0_comb_diff",
126  # "phi0_comb_sigma",
127 
128  # "chi2_kari_unit",
129  # "abs_curv_unit",
130 
131  # "chi2_kari_l",
132  # "abs_curv_l",
133 
134  # "chi2_kari_pseudo",
135  # "abs_curv_pseudo",
136 
137  # "chi2_kari_proper",
138  # "abs_curv_proper",
139  ]
140 
141 
142  self.groupbygroupby = ["", "superlayer_id"]
143 
144  self.auxiliariesauxiliaries = [
145  "superlayer_id",
146  ]
147 
148  path.add_module("TFCDC_WireHitPreparer",
149  flightTimeEstimation="outwards",
150  UseNLoops=1.0)
151 
152  path.add_module("TFCDC_ClusterPreparer")
153 
154  path.add_module("TFCDC_SegmentFinderFacetAutomaton",
155  FacetRelationFilter="unionrecording",
156  FacetRelationFilterParameters={
157  "rootFileName": self.sample_file_name,
158  "varSets": var_sets,
159  })
160 
161  return path
162 
163 
164 def main():
165  """Execute the facet relation recording"""
167  run.configure_and_execute_from_commandline()
168 
169 
170 if __name__ == "__main__":
171  import logging
172  logging.basicConfig(stream=sys.stdout, level=logging.INFO, format='%(levelname)s:%(message)s')
173  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
int main(int argc, char **argv)
Run all tests.
Definition: test_main.cc:91