Belle II Software development
trainFeasibleSegmentRelationFilter.py
1#!/usr/bin/env python3
2
3
10
11import os
12import sys
13import os.path
14
15from tracking.run.event_generation import ReadOrGenerateEventsRun
16from trackfindingcdc.run.training import TrainingRunMixin
17
18
20 """Run to record segment relations encountered at the SegmentLinker and retrain its mva method"""
21
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_FeasibleSegmentRelationFilter.xml"
36
37 def create_path(self):
38 """Setup the recording path after the simulation"""
39 path = super().create_path()
40 path.add_module("TFCDC_WireHitPreparer",
41 flightTimeEstimation="outwards")
42
43 path.add_module("TFCDC_ClusterPreparer",
44 SuperClusterDegree=3,
45 SuperClusterExpandOverApogeeGap=True)
46
47
48 if self.task == "train":
49 varSets = [
50 "feasible",
51 "filter(truth)",
52 ]
53
54 elif self.task == "eval":
55 varSets = [
56 "filter(feasible)",
57 "filter(truth)",
58 ]
59
60 elif self.task == "explore":
61 varSets = [
62 "feasible",
63 "hit_gap",
64 "fit",
65 "filter(truth)",
66 ]
67
68 else:
69 raise ValueError("Unknown task " + self.task)
70
71 path.add_module("TFCDC_SegmentFinderFacetAutomaton",
72 SegmentRelationFilter="unionrecording",
73 SegmentRelationFilterParameters={
74 "rootFileName": self.sample_file_name,
75 "varSets": varSets,
76 })
77
78 return path
79
80
81def main():
83 run.configure_and_execute_from_commandline()
84
85
86if __name__ == "__main__":
87 import logging
88 logging.basicConfig(stream=sys.stdout, level=logging.INFO, format='%(levelname)s:%(message)s')
89 main()
task
Process each event according to the user's desired task (train, eval, explore)
Definition: main.py:1