Belle II Software development
trainFeasibleAxialSegmentPairFilter.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
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_FeasibleAxialSegmentPairFilter.xml"
36
37 def create_path(self):
38 """Setup the recording path after the simulation"""
39 path = super().create_path()
40
41 # In contrast to other training use only the first *half* loop for more aggressive training
42 path.add_module("TFCDC_WireHitPreparer",
43 flightTimeEstimation="outwards")
44
45 path.add_module('TFCDC_ClusterPreparer',
46 SuperClusterDegree=3,
47 SuperClusterExpandOverApogeeGap=True)
48
49 # Also fix the segment orientation to outwards to make training additionally aggressive
50 path.add_module("TFCDC_SegmentFinderFacetAutomaton")
51
52
53 if self.task == "train":
54 varSets = [
55 "feasible",
56 "filter(truth)",
57 ]
58
59 elif self.task == "eval":
60 varSets = [
61 "filter(feasible)",
62 "filter(truth)",
63 ]
64
65 elif self.task == "explore":
66 varSets = [
67 "basic",
68 "fitless",
69 "hit_gap",
70 "fit",
71 # "filter(simple)",
72 # "filter(feasible)",
73 # "filter(realistic)",
74 "filter(truth)",
75 ]
76
77 else:
78 raise ValueError("Unknown task " + self.task)
79
80 path.add_module("TFCDC_TrackFinderSegmentPairAutomaton",
81 SegmentPairAxialBridging=True,
82 AxialSegmentPairFilter="unionrecording",
83 AxialSegmentPairFilterParameters={
84 "rootFileName": self.sample_file_name,
85 "varSets": varSets,
86 },
87 SegmentPairFilter='none',
88 SegmentPairRelationFilter='none')
89
90 return path
91
92
93def main():
95 run.configure_and_execute_from_commandline()
96
97
98if __name__ == "__main__":
99 import logging
100 logging.basicConfig(stream=sys.stdout, level=logging.INFO, format='%(levelname)s:%(message)s')
101 main()
task
Process each event according to the user's desired task (train, eval, explore)
Definition: main.py:1