Belle II Software  release-05-01-25
a01234_trackingEfficiency_oneshot.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 
4 
25 
26 import sys
27 import glob
28 from basf2 import *
29 from simulation import add_simulation
30 from tracking import *
31 from modularAnalysis import *
32 
33 set_random_seed(1509)
34 
35 particleGun = False
36 
37 release = sys.argv[1]
38 
39 # roi = {noROI, vxdtf1, vxdtf2}
40 # bkg = {noBkg, stdBKG, std2GBKG}
41 # vxdtf = {vxdtf1, vxdtf2}
42 
43 roi = sys.argv[2]
44 bkg = sys.argv[3]
45 vxdtf = sys.argv[4]
46 
47 release = 'merged'
48 
49 print('Performance evaluated on: ')
50 print('simulation: ' + roi + ' ' + bkg)
51 print('reconstruction: ' + vxdtf)
52 print()
53 
54 root_file_name_TRK = './' + release + '/oneshotTV_TRK_analysis_' + roi + '_' + bkg + '_' + vxdtf + '_' + release + '.root'
55 root_file_name_V0 = './' + release + '/oneshotTV_V0_analysis_' + roi + '_' + bkg + '_' + vxdtf + '_' + release + '.root'
56 
57 bkgFiles = None
58 usePXDDataReduction = True
59 mcTrackFinding = False
60 
61 if roi == 'noROI':
62  usePXDDataReduction = False
63 
64 if bkg == 'stdBKG':
65  bkgFiles = glob.glob('/sw/belle2/bkg/*.root')
66 if bkg == 'std2GsmallBKG':
67  bkgFiles = glob.glob('/sw/belle2/bkg/*.root')
68  bkgFiles = bkgFiles + glob.glob('/sw/belle2/bkg.twoPhoton/*usual.root')
69 if bkg == 'std2GBKG':
70  bkgFiles = glob.glob('/sw/belle2/bkg/*.root')
71  bkgFiles = bkgFiles + glob.glob('/sw/belle2/bkg.twoPhoton/*.root')
72 
73 print(bkgFiles)
74 
75 path = create_path()
76 
77 eventinfosetter = register_module('EventInfoSetter')
78 eventinfosetter.param('expList', [0])
79 eventinfosetter.param('runList', [1])
80 
81 progress = register_module('Progress')
82 
83 v0matcher = register_module('MCV0Matcher')
84 v0matcher.param('V0ColName', 'V0ValidationVertexs')
85 v0matcher.logging.log_level = LogLevel.INFO
86 
87 create_plots_TRK = register_module('TrackingPerformanceEvaluation')
88 create_plots_TRK.param('outputFileName', root_file_name_TRK)
89 create_plots_TRK.logging.log_level = LogLevel.INFO
90 
91 
92 create_plots_V0 = register_module('V0findingPerformanceEvaluation')
93 create_plots_V0.param('outputFileName', root_file_name_V0)
94 create_plots_V0.logging.log_level = LogLevel.INFO
95 
96 if particleGun:
97  particleGunModule = register_module('ParticleGun')
98  particleGunModule.param({
99  'pdgCodes': [211, -211],
100  'nTracks': 1,
101  'varyNTracks': False,
102  'momentumGeneration': 'uniformpt',
103  'momentumParams': [0.5, 1.],
104  'thetaGeneration': 'uniform',
105  'thetaParams': [60., 60.],
106  })
107  path.add_module('EventInfoSetter')
108  path.add_module(particleGunModule)
109 else:
110  setupEventInfo(100, path)
111  add_evtgen_generator(path, 'signal', None)
112 
113 path.add_module(progress)
114 
115 add_simulation(path, None, bkgFiles, None, 1.0, usePXDDataReduction)
116 
117 add_tracking_reconstruction(
118  path,
119  components=None,
120  pruneTracks=False,
121  mcTrackFinding=mcTrackFinding,
122  skipGeometryAdding=False
123 )
124 
125 
126 modList = path.modules()
127 for modItem in modList:
128  if modItem.name() == 'V0Finder':
129  modItem.param('Validation', True)
130 path.add_module(v0matcher)
131 
132 path.add_module(create_plots_TRK)
133 path.add_module(create_plots_V0)
134 
135 process(path)
136 
137 print(statistics)