Belle II Software  release-08-01-10
trainSegmentTrackFilter.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 
17 from tracking.path_utils import add_cdc_track_finding
18 from tracking.run.event_generation import ReadOrGenerateEventsRun
19 from trackfindingcdc.run.training import TrainingRunMixin
20 from tracking.adjustments import adjust_module
21 
22 
24  """Run to record segment track combinations encountered at the SegmentTrackSelector and retrain its mva method"""
25 
26 
27  n_events = 2000
28 
29  generator_module = "generic"
30 
31  bkg_files = os.path.join(os.environ["VO_BELLE2_SW_DIR"], "bkg")
32 
33 
34  truth = "truth"
35 
36  @property
37  def identifier(self):
38  """Database identifier of the filter being trained"""
39  return "trackfindingcdc_SegmentTrackFilter.xml"
40 
41  def create_path(self):
42  """Setup the recording path after the simulation"""
43  path = super().create_path()
44 
45  add_cdc_track_finding(path)
46 
47 
48  if self.tasktask == "train":
49  filterName = "recording"
50 
51  elif self.tasktask == "eval":
52  filterName = "eval"
53 
54  self.truthtruthtruth = "truth_accepted"
55 
56  elif self.tasktask == "explore":
57  # Change me.
58  filterName = "recording"
59 
60  adjust_module(path, "TFCDC_SegmentTrackCombiner",
61  segmentTrackFilter=filterName,
62  segmentTrackFilterParameters={
63  "rootFileName": self.sample_file_name,
64  },
65  trackFilter="all",
66  trackFilterParameters={})
67 
68  return path
69 
70  def postprocess(self):
71  """Post-process the results for MC-truth acceptance"""
72  if self.tasktask == "eval":
73  self.truthtruthtruth = "truth_accept"
74  super().postprocess()
75 
76 
77 def main():
79  run.configure_and_execute_from_commandline()
80 
81 
82 if __name__ == "__main__":
83  import logging
84  logging.basicConfig(stream=sys.stdout, level=logging.INFO, format='%(levelname)s:%(message)s')
85  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