Belle II Software development
MaterialScan.py
1#!/usr/bin/env python3
2
3
10
11from basf2 import logging, LogLevel, register_module, create_path, process
12# Don't show all the info messages
13logging.log_level = LogLevel.ERROR
14
15# We need to process one event so we need the EventInfoSetter
16eventinfosetter = register_module('EventInfoSetter')
17eventinfosetter.param({'runList': [1], 'evtNumList': [1]})
18
19# We need the geometry parameters
20gearbox = register_module('Gearbox')
21gearbox.param('fileName', '/geometry/Beast2_phase1.xml')
22# as well as the geometry
23geometry = register_module('Geometry')
24geometry.set_log_level(LogLevel.INFO)
25# Restrict Geometry to certain components, in this case only PXD and SVD
26# geometry.param('components', ['PH1BPIPE'])
27
28# MaterialScan uses the Geant4 setup which is created by the FullSim module so
29# we need this as well
30simulation = register_module('FullSim')
31
32# And finally the MaterialScan module
33materialscan = register_module('MaterialScan')
34materialscan.set_log_level(LogLevel.INFO)
35
36# Create a detailed Materialbudget for the beampipe
37# 1) 1000x1000 raster starting from IP looking at the acceptance
38# 2) 2000x2000 raster of the ZX plane between Z=-50 to 60 cm and X=-16 to
39# 16 cm, starting at Y=-16cm and scanning the next 32cm along Y
40
41materialscan.param({ # Filename for output File
42 # Do Spherical scan?
43 # Origin of the spherical scan
44 # Number of steps in theta
45 # Minimal theta value
46 # Maximal theta value
47 # If set to true, the scan will be done uniform in cos(theta)
48 # Number of steps in theta
49 # Minimal theta value
50 # Maximal theta value
51 # Depth of the scan: 0 for scan the whole defined geometry. Any value >0
52 # will stop the ray after reaching the given distance from the start point
53 # Split output by Material names instead of by Region
54 # Specify the names of Materials to ignore in the scan.
55 # Default is Air and Vacuum
56 # Do Planar scan?
57 # Name of the plane for scanning. One of 'XY', 'XZ', 'YX', 'YZ', 'ZX',
58 # 'ZY' or 'custom' to define the plane directly
59 # Define a custom plane for the scan, only used if planar.plane='custom'.
60 # This is a list of 9 values where the first three values specify the
61 # origin, the second 3 values specify the first axis and the last 3 values
62 # specify the second axis. In this case we scan the ZX plane but the origin
63 # is not at the IP at y=-1 to create a symmetric cut view in |y|< 1 cm
64 # Origin
65 # First axis
66 # Second axis
67 # Depth of the scan: 0 for scan the whole defined geometry. Any value >0
68 # will stop the ray after reaching the given distance from the start point
69 # Number of steps along the first axis
70 # Minimum value for the first axis
71 # Maximum value for the first axis
72 # Number of steps along the second axis
73 # Minimum value for the second axis
74 # Maximum value for the second axis
75 # Split output by Material names insted of by Region
76 # Specify the names of Materials to ignore in the scan.
77 # Default is Air and Vacuum
78 'Filename': 'MaterialScan.root',
79 'spherical': True,
80 'spherical.origin': [0, 0, 0],
81 'spherical.nTheta': 1000,
82 'spherical.minTheta': 17,
83 'spherical.maxTheta': 150,
84 'spherical.cosTheta': True,
85 'spherical.nPhi': 1000,
86 'spherical.minPhi': 0,
87 'spherical.maxPhi': 360,
88 'spherical.maxDepth': 0,
89 'spherical.splitByMaterials': False,
90 'spherical.ignored': ['Air', 'Vacuum', 'G4_AIR', 'ColdAir'],
91 'planar': True,
92 'planar.plane': 'custom',
93 'planar.custom': [
94 0,
95 -16,
96 0,
97 0,
98 0,
99 1,
100 1,
101 0,
102 0,
103 ],
104 'planar.maxDepth': 32,
105 'planar.nU': 2000,
106 'planar.minU': -50.0,
107 'planar.maxU': 60,
108 'planar.nV': 2000,
109 'planar.minV': -16,
110 'planar.maxV': 16,
111 'planar.splitByMaterials': True,
112 'planar.ignored': ['Air', 'G4_AIR', 'ColdAir'],
113})
114
115# Create a path and add all modules
116main = create_path()
117main.add_module(eventinfosetter)
118main.add_module(gearbox)
119main.add_module(geometry)
120main.add_module(simulation)
121main.add_module(materialscan)
122
123# Do the MaterialScan, can take some time depending on the number of steps
124process(main)