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