Belle II Software  release-08-01-10
trainRealisticSegmentRelationFilter.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 relations encountered at the SegmentLinker after the feasible filter 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_RealisticSegmentRelationFilter.xml"
37 
38  def create_path(self):
39  """Setup the recording path after the simulation"""
40  path = super().create_path()
41  path.add_module("TFCDC_WireHitPreparer",
42  flightTimeEstimation="outwards")
43 
44  path.add_module("TFCDC_ClusterPreparer",
45  SuperClusterDegree=3,
46  SuperClusterExpandOverApogeeGap=True)
47 
48 
49  if self.tasktask == "train":
50  varSets = [
51  "realistic",
52  "filter(truth)",
53  ]
54  skim = "feasible"
55 
56  elif self.tasktask == "eval":
57  varSets = [
58  "filter(feasible)",
59  "filter(realistic)",
60  "filter(truth)",
61  ]
62  skim = ""
63 
64  elif self.tasktask == "explore":
65  varSets = [
66  "realistic",
67  "hit_gap",
68  "fit",
69  "filter(truth)",
70  ]
71  skim = "feasible"
72 
73  else:
74  raise ValueError("Unknown task " + self.tasktask)
75 
76  path.add_module("TFCDC_SegmentFinderFacetAutomaton",
77  SegmentRelationFilter="unionrecording",
78  SegmentRelationFilterParameters={
79  "rootFileName": self.sample_file_name,
80  "varSets": varSets,
81  "skim": skim,
82  })
83 
84  return path
85 
86 
87 def main():
89  run.configure_and_execute_from_commandline()
90 
91 
92 if __name__ == "__main__":
93  import logging
94  logging.basicConfig(stream=sys.stdout, level=logging.INFO, format='%(levelname)s:%(message)s')
95  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