Belle II Software  release-08-01-10
trainFeasibleSegmentPairFilter.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 
11 
12 import os
13 import sys
14 import os.path
15 
16 from tracking.run.event_generation import ReadOrGenerateEventsRun
17 from trackfindingcdc.run.training import TrainingRunMixin
18 
19 
21  """Run to record segment pairs encountered at the SegmentPairCreator and retrain its mva method"""
22 
23 
24  n_events = 10000
25 
26  generator_module = "generic"
27 
28  bkg_files = os.path.join(os.environ["VO_BELLE2_SW_DIR"], "bkg")
29 
30 
31  truth = "truth_positive"
32 
33  @property
34  def identifier(self):
35  """Database identifier of the filter being trained"""
36  return "trackfindingcdc_FeasibleSegmentPairFilter.xml"
37 
38  def create_path(self):
39  """Setup the recording path after the simulation"""
40  path = super().create_path()
41 
42  # In contrast to other training use only the first *half* loop for more aggressive training
43  path.add_module("TFCDC_WireHitPreparer",
44  flightTimeEstimation="outwards")
45 
46  path.add_module('TFCDC_ClusterPreparer',
47  SuperClusterDegree=3,
48  SuperClusterExpandOverApogeeGap=True)
49 
50  # Also fix the segment orientation to outwards to make training additionally aggressive
51  path.add_module("TFCDC_SegmentFinderFacetAutomaton")
52 
53 
54  if self.tasktask == "train":
55  varSets = [
56  "feasible",
57  "filter(truth)",
58  ]
59 
60  elif self.tasktask == "eval":
61  varSets = [
62  "filter(feasible)",
63  "filter(truth)",
64  ]
65 
66  elif self.tasktask == "explore":
67  varSets = [
68  "basic",
69  # "feasible",
70  "fitless",
71  "pre_fit",
72  # "fit",
73  "truth", # for weighting
74  # "old_fit",
75  # "filter(fitless)",
76  # "filter(simple)",
77  # "filter(feasible)",
78  "filter(truth)",
79  ]
80 
81  else:
82  raise ValueError("Unknown task " + self.tasktask)
83 
84  path.add_module("TFCDC_TrackFinderSegmentPairAutomaton",
85  SegmentPairFilter="unionrecording",
86  SegmentPairFilterParameters={
87  "rootFileName": self.sample_file_name,
88  "varSets": varSets,
89  })
90 
91  return path
92 
93 
94 def main():
96  run.configure_and_execute_from_commandline()
97 
98 
99 if __name__ == "__main__":
100  import logging
101  logging.basicConfig(stream=sys.stdout, level=logging.INFO, format='%(levelname)s:%(message)s')
102  main()
task
Process each event according to the user's desired task (train, eval, explore)
Definition: main.py:1
int main(int argc, char **argv)
Run all tests.
Definition: test_main.cc:91