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