Belle II Software development
trainRealisticSegmentRelationFilter.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 after the feasible filter 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_RealisticSegmentRelationFilter.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 "realistic",
51 "filter(truth)",
52 ]
53 skim = "feasible"
54
55 elif self.task == "eval":
56 varSets = [
57 "filter(feasible)",
58 "filter(realistic)",
59 "filter(truth)",
60 ]
61 skim = ""
62
63 elif self.task == "explore":
64 varSets = [
65 "realistic",
66 "hit_gap",
67 "fit",
68 "filter(truth)",
69 ]
70 skim = "feasible"
71
72 else:
73 raise ValueError("Unknown task " + self.task)
74
75 path.add_module("TFCDC_SegmentFinderFacetAutomaton",
76 SegmentRelationFilter="unionrecording",
77 SegmentRelationFilterParameters={
78 "rootFileName": self.sample_file_name,
79 "varSets": varSets,
80 "skim": skim,
81 })
82
83 return path
84
85
86def main():
88 run.configure_and_execute_from_commandline()
89
90
91if __name__ == "__main__":
92 import logging
93 logging.basicConfig(stream=sys.stdout, level=logging.INFO, format='%(levelname)s:%(message)s')
94 main()
task
Process each event according to the user's desired task (train, eval, explore)
Definition: main.py:1