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