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