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