Belle II Software development
trainRealisticSegmentPairFilter.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 SegmentPairCreator 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_RealisticSegmentPairFilter.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
51 if self.task == "train":
52 varSets = [
53 "realistic",
54 "filter(truth)",
55 "truth", # for weighting
56 ]
57 skim = "feasible"
58
59 elif self.task == "eval":
60 varSets = [
61 "filter(truth)",
62 "filter(realistic)",
63 "filter(feasible)",
64 "filter(fitless)",
65 "filter(simple)",
66 ]
67 skim = ""
68
69 elif self.task == "explore":
70 varSets = [
71 "basic",
72 # "realistic",
73 "fitless",
74 "pre_fit",
75 "fit",
76 "truth", # for weighting
77 # "old_fit",
78 # "filter(fitless)",
79 # "filter(simple)",
80 "filter(realistic)",
81 "filter(truth)",
82 ]
83 skim = "feasible"
84
85 else:
86 raise ValueError("Unknown task " + self.task)
87
88 path.add_module("TFCDC_TrackFinderSegmentPairAutomaton",
89 SegmentPairFilter="unionrecording",
90 SegmentPairFilterParameters={
91 "rootFileName": self.sample_file_name,
92 "varSets": varSets,
93 "skim": skim,
94 })
95
96 return path
97
98
99def main():
101 run.configure_and_execute_from_commandline()
102
103
104if __name__ == "__main__":
105 import logging
106 logging.basicConfig(stream=sys.stdout, level=logging.INFO, format='%(levelname)s:%(message)s')
107 main()
task
Process each event according to the user's desired task (train, eval, explore)
Definition: main.py:1