Belle II Software  release-05-02-19
trainTrackFilter.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 import os
5 import sys
6 import os.path
7 import shutil
8 
9 import basf2
10 
11 from tracking import add_cdc_track_finding
12 from tracking.run.event_generation import ReadOrGenerateEventsRun
13 from trackfindingcdc.run.training import TrainingRunMixin
14 from tracking.adjustments import adjust_module
15 
16 
18  """Run to record tracks encountered at the TrackRejecter and retrain its mva method"""
19 
20 
21  n_events = 3000
22 
23  generator_module = "generic"
24 
25  bkg_files = os.path.join(os.environ["VO_BELLE2_SW_DIR"], "bkg")
26 
27 
28  truth = "truth"
29 
30  @property
31  def identifier(self):
32  """Database identifier of the filter being trained"""
33  return "trackfindingcdc_TrackFilter.xml"
34 
35  def create_path(self):
36  """Setup the recording path after the simulation"""
37  path = super().create_path()
38 
39  add_cdc_track_finding(path)
40 
41 
42  if self.task == "train":
43  filterName = "recording"
44 
45  elif self.task == "eval":
46  filterName = "eval"
47 
48  self.truth = "truth_accepted"
49 
50  elif self.task == "explore":
51  # Change me.
52  filterName = "recording"
53 
54  adjust_module(path, "TFCDC_SegmentTrackCombiner",
55  trackFilter=filterName,
56  trackFilterParameters={
57  "rootFileName": self.sample_file_name,
58  })
59 
60  return path
61 
62  def postprocess(self):
63  """Post-process the results for MC-truth acceptance"""
64  if self.task == "eval":
65  self.truth = "truth_accept"
66  super().postprocess()
67 
68 
69 def main():
71  run.configure_and_execute_from_commandline()
72 
73 
74 if __name__ == "__main__":
75  import logging
76  logging.basicConfig(stream=sys.stdout, level=logging.INFO, format='%(levelname)s:%(message)s')
77  main()
tracking.adjustments
Definition: adjustments.py:1
tracking.run.event_generation.ReadOrGenerateEventsRun
Definition: event_generation.py:26
main
int main(int argc, char **argv)
Run all tests.
Definition: test_main.cc:77
trainTrackFilter.TrackFilterTrainingRun
Definition: trainTrackFilter.py:17
trainTrackFilter.TrackFilterTrainingRun.postprocess
def postprocess(self)
Definition: trainTrackFilter.py:62
trainTrackFilter.TrackFilterTrainingRun.task
task
Process each event according to the user's desired task (train, eval, explore)
Definition: trainTrackFilter.py:42
tracking.run.event_generation
Definition: event_generation.py:1
trainTrackFilter.TrackFilterTrainingRun.identifier
def identifier(self)
Definition: trainTrackFilter.py:31
trainTrackFilter.TrackFilterTrainingRun.truth
string truth
degree of MC truth-matching
Definition: trainTrackFilter.py:28
trainTrackFilter.TrackFilterTrainingRun.create_path
def create_path(self)
Definition: trainTrackFilter.py:35