Belle II Software  release-08-01-10
evaluateVXDTF2.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 
11 
12 
21 
22 
23 import basf2 as b2
24 import sys
25 import argparse
26 # Import custom module chain for VXDTF2
27 from setup_modules import setup_VXDTF2
28 from tracking.harvesting_validation.combined_module import CombinedTrackingValidationModule
29 
30 # ---------------------------------------------------------------------------------------
31 # Argument parser for input of trained Sector Map.
32 arg_parser = argparse.ArgumentParser(description='VXDTF2 evaluation:\
33  Applies VXDTF2 to selected dataset \n\
34  Usage: basf2 testVXDTF2.py -i <inputFileName> -- --secmap <secmapFile>')
35 
36 arg_parser.add_argument('--secmap', '-s', type=str,
37  help='Inclusion of the root file containing the trained SecMap for the application of the VXDTF2.')
38 
39 arguments = arg_parser.parse_args(sys.argv[1:])
40 sec_map_file = arguments.secmap
41 
42 
43 # ---------------------------------------------------------------------------------------
44 # Settings
45 usePXD = False
46 
47 # these are the "default" settings
48 setup_name = 'SVDOnlyDefault'
49 if usePXD:
50  setup_name = 'SVDPXDDefault'
51 
52 performFit = False
53 
54 # Logging and Debug Levels
55 b2.set_log_level(b2.LogLevel.ERROR)
56 b2.log_to_file('logVXDTF2Evaluation.log', append=False)
57 
58 
59 # ---------------------------------------------------------------------------------------
60 path = b2.create_path()
61 
62 # Input
63 rootInput = b2.register_module('RootInput')
64 path.add_module(rootInput)
65 
66 # Event Info Module
67 eventinfoprinter = b2.register_module('EventInfoPrinter')
68 path.add_module(eventinfoprinter)
69 
70 # Gearbox
71 gearbox = b2.register_module('Gearbox')
72 path.add_module(gearbox)
73 
74 # puts gearbox and geometry into the path
75 # Geometry
76 geometry = b2.register_module('Geometry')
77 geometry.param('components', ['BeamPipe',
78  'MagneticFieldConstant4LimitedRSVD',
79  'PXD',
80  'SVD'])
81 path.add_module(geometry)
82 
83 # VXDTF2: Including actual VXDTF2 Modul Chain
84 setup_VXDTF2(path=path,
85  use_pxd=usePXD,
86  sec_map_file=sec_map_file,
87  setup_name=setup_name,
88  overlap_filter='hopfield',
89  quality_estimator='circleFit')
90 
91 if performFit:
92  genFitExtrapolation = b2.register_module('SetupGenfitExtrapolation')
93  path.add_module(genFitExtrapolation)
94 
95  fitter = b2.register_module('DAFRecoFitter')
96  path.add_module(fitter)
97  path.add_module('TrackCreator', pdgCodes=[211, 13, 321, 2212])
98 
99 # Matching
100 mcTrackMatcherModule = b2.register_module('MCRecoTracksMatcher')
101 mcTrackMatcherModule.param({
102  'UseCDCHits': False,
103  'UseSVDHits': True,
104  'UsePXDHits': usePXD,
105  'mcRecoTracksStoreArrayName': 'MCRecoTracks',
106  'MinimalPurity': .66,
107 })
108 path.add_module(mcTrackMatcherModule)
109 
110 # Evaluation of matching
111 trackingValidationModule = CombinedTrackingValidationModule(
112  "",
113  contact="",
114  output_file_name="VXDTF2Validation.root",
115  expert_level=2)
116 path.add_module(trackingValidationModule)
117 
118 path.add_module('Progress')
119 b2.process(path)
120 print(b2.statistics)