Belle II Software development
trainRealisticAxialSegmentPairFilter.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 pairs encountered at the AxialSegmentPairCreator and retrain its mva method"""
21
22 n_events = 10000
23
24 generator_module = "generic"
25
26 bkg_files = os.path.join(os.environ["VO_BELLE2_SW_DIR"], "bkg")
27
28
29 truth = "truth_positive"
30
31 @property
32 def identifier(self):
33 """Database identifier of the filter being trained"""
34 return "trackfindingcdc_RealisticAxialSegmentPairFilter.xml"
35
36 def create_path(self):
37 """Setup the recording path after the simulation"""
38 path = super().create_path()
39
40 # In contrast to other training use only the first *half* loop for more aggressive training
41 path.add_module("TFCDC_WireHitPreparer",
42 flightTimeEstimation="outwards")
43
44 path.add_module('TFCDC_ClusterPreparer',
45 SuperClusterDegree=3,
46 SuperClusterExpandOverApogeeGap=True)
47
48 path.add_module("TFCDC_SegmentFinderFacetAutomaton")
49
50 # Also fix the segment orientation to outwards to make training additionally aggressive
51
52 if self.task == "train":
53 varSets = [
54 "realistic",
55 "filter(truth)",
56 ]
57 skim = "feasible"
58
59 elif self.task == "eval":
60 varSets = [
61 "filter(truth)",
62 "filter(realistic)",
63 "filter(feasible)",
64 "filter(simple)",
65 ]
66 skim = ""
67
68 elif self.task == "explore":
69 varSets = [
70 "basic",
71 "fitless",
72 "hit_gap",
73 "fit",
74 # "filter(simple)",
75 # "filter(feasible)",
76 # "filter(realistic)",
77 "filter(truth)",
78 ]
79 skim = "feasible"
80
81 else:
82 raise ValueError("Unknown task " + self.task)
83
84 path.add_module("TFCDC_TrackFinderSegmentPairAutomaton",
85 SegmentPairAxialBridging=True,
86 AxialSegmentPairFilter="unionrecording",
87 AxialSegmentPairFilterParameters={
88 "rootFileName": self.sample_file_name,
89 "varSets": varSets,
90 "skim": skim,
91 },
92 SegmentPairFilter='none',
93 SegmentPairRelationFilter='none')
94
95 return path
96
97
98def main():
100 run.configure_and_execute_from_commandline()
101
102
103if __name__ == "__main__":
104 import logging
105 logging.basicConfig(stream=sys.stdout, level=logging.INFO, format='%(levelname)s:%(message)s')
106 main()
task
Process each event according to the user's desired task (train, eval, explore)
Definition: main.py:1