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