Belle II Software  release-08-01-10
testbeam2017_SVDChargeSharingAnalysis.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 
11 import basf2 as b2
12 import sys
13 
14 fileIN = sys.argv[1]
15 dirOUT = sys.argv[2]
16 
17 # slightly changed method from testbeam.utils: the geometry for 2017 TB is loaded from .xml file, whereas in the current
18 # version of the software it's created from DB by default, thus I had to add "useDB = False" parameter to the geometry
19 # module.
20 
21 
22 def add_geometry(
23  path,
24  magnet=True,
25  field_override=None,
26  target=None,
27  geometry_xml='testbeam/vxd/2017_geometry.xml',
28  excluded_components=[],
29  geometry_version=1):
30  additonal_components = []
31 
32  if geometry_version == 0:
33  print('WARNING: overriding the setting of parameter geometry_xml! Old value: ' + geometry_xml)
34  geometry_xml = 'testbeam/vxd/2017_geometry.xml'
35  print('New value: ' + geometry_xml)
36 
37  if geometry_version == 1:
38  print('WARNING: overriding the setting of parameter geometry_xml! Old value: ' + geometry_xml)
39  geometry_xml = 'testbeam/vxd/2017_geometry_1.xml'
40  print('New value: ' + geometry_xml)
41 
42  if target is not None:
43  additonal_components += [target]
44 
45  if not magnet:
46  excluded_components += ['MagneticField']
47 
48  if field_override is not None:
49  excluded_components += ['MagneticField']
50  additonal_components += ['MagneticFieldConstant']
51 
52  # Add gearbox, additonally override field value if set
53  if field_override is not None:
54  path.add_module('Gearbox',
55  fileName=geometry_xml,
56  override=[("/DetectorComponent[@name='MagneticFieldConstant']//Z",
57  str(field_override),
58  "")])
59  else:
60  path.add_module('Gearbox', fileName=geometry_xml)
61 
62  # Add geometry with additional/removed components
63  path.add_module('Geometry', excludedComponents=excluded_components, additionalComponents=additonal_components,
64  useDB=False)
65 
66 
67 main = b2.create_path()
68 main.add_module('RootInput', inputFileName=str(fileIN))
69 
70 # define geometry version
71 magnet_off = True
72 # run 400, p = 4 GeV, 1T B-Field
73 geom = 1
74 # run 111, p = 5 GeV, no B-Field
75 if (magnet_off):
76  geom = 0
77 
78 add_geometry(main, magnet=not magnet_off, field_override=None, target=None, geometry_version=geom)
79 
80 main.add_module('SVDChargeSharingAnalysis', outputDirName=str(dirOUT), outputRootFileName='test.root',
81  useTrackInfo=True, is2017TBanalysis=True)
82 
83 main.add_module('Progress')
84 b2.print_path(main)
85 b2.process(main)
86 print(b2.statistics)