Belle II Software development
ARICHBtest.py
1#!/usr/bin/env python3
2
3
10
11#
12# Usage:
13# basf2 arich/examples/ARICHBtest2011.py --
14# -r 102 -n 10000
15#
16import basf2 as b2
17from optparse import OptionParser
18import os
19import os.path
20import sys
21
22b2.set_log_level(b2.LogLevel.INFO)
23
24outroot = 'arichbtest.root'
25
26parser = OptionParser()
27parser.add_option('-r', '--run', dest='runno', default='068',
28 help='analyse runno')
29parser.add_option('-p', '--path', dest='path',
30 default='/afs/f9.ijs.si/data/belle/data/beamtests/2011/run',
31 help='datapath')
32
33parser.add_option('-y', '--year', dest='year', default='2011',
34 help='beam test year')
35
36parser.add_option('-t', '--track-mask', dest='mask', default='0x5',
37 help='track mask 4 bits')
38
39parser.add_option('-m', '--avgagel', dest='avgagel', default='0',
40 help='average thc calculation based on the mean agel')
41
42parser.add_option(
43 '-o',
44 '--output',
45 dest='output',
46 default=outroot,
47 help='Output filename',
48 metavar='FILE',
49)
50
51parser.add_option('-n', '--neve', dest='neve', default=20000,
52 help='Number of events to process')
53
54(options, args) = parser.parse_args()
55
56fname = options.path + '/run' + options.runno + '.dat'
57
58if not os.path.isfile(fname):
59 print('File does not exist:')
60 print(fname)
61 fname += '.gz'
62 print('Appending .gz...')
63if not os.path.isfile(fname):
64 print('File does not exist:')
65 print(fname)
66 sys.exit(-1)
67
68if options.output == outroot:
69 outroot = 'run_' + options.runno + '.root'
70else:
71 outroot = options.output
72
73mask = int(options.mask, 16)
74runno = int(options.runno) # needed for geoarich module
75
76print('TrackMask:' + options.mask)
77
78# this variable is called from GeoARICHBtest2011Creator
79averageagel = int(options.avgagel)
80
81eventinfosetter = b2.register_module('EventInfoSetter')
82eventinfosetter.param('evtNumList', [int(options.neve)])
83eventinfosetter.param('runList', [int(options.runno)])
84eventinfosetter.param('expList', [1])
85
86# Load XML parameters
87paramloader = b2.register_module('Gearbox')
88
89xmlgeometry = 'file://%s/arich/modules/arichBtest/data/%s/arichBtest%s.xml' \
90 % (os.getcwd(), options.year, options.year)
91paramloader.param('fileName', xmlgeometry)
92print(xmlgeometry)
93paramloader.param('fileName', xmlgeometry)
94
95# paramloader.param('Backends', ['sql:'])
96# paramloader.param('Filename',
97# 'mysql://basf2:belle2@f9lab02.ijs.si:3306/b2config');
98# paramloader.param('Filename',
99# 'pgsql://basf2:belle2@f9lab02.ijs.si:5432/b2config');
100# paramloader.param('Filename', 'oracle://basf2:belle2@/f9lab02')
101# paramloader.param('Filename',
102# 'file:///afs/f9.ijs.si/home/rok/public_html/basf2/public/Belle2.xml');
103# paramloader.param('Filename',
104# 'file:///net/f9pc137/data0/belle2/rok/local/basf2/test/Belle2-merged.xml');
105# Create Geometry
106geobuilder = b2.register_module('Geometry')
107geobuilder.param('components', ['ARICHBtest'])
108
109btest = b2.register_module('arichBtest')
110btest.param('mwpcTrackMask', [mask])
111# btest.param('Filename', 'arich/modules/arichBtest/data/2011/track.dat')
112btest.param('runList', [fname])
113btest.param('outputFileName', outroot)
114momentum = 120.0
115if options.year == '2013':
116 momentum = 3.0
117print('Beam momentum ' + str(momentum))
118btest.param('beamMomentum', momentum)
119
120# Simulation module
121g4sim = b2.register_module('FullSim')
122# This line is necessary if you want to simulate Cerenkov photons!
123# By default optical processes are not registered.
124g4sim.param('RegisterOptics', 1)
125# To speed up the simulation you can propagate
126# only a selected fraction of photons.
127# By default all photons are propagated.
128g4sim.param('PhotonFraction', 0.3)
129# Set up the visualization
130g4sim.param('EnableVisualization', True)
131# Here you can select visualization driver and visualization commands.
132# This creates VRML file,
133# change VRML2FILE to HepRepFile to create HepRep file.
134g4sim.param('UICommandsAtIdle', ['/vis/open VRML2FILE', '/vis/drawVolume',
135 '/vis/scene/add/axes 0 0 0 100 mm'])
136
137# Saves the geometry as a Root file
138geosaver = b2.register_module('ExportGeometry')
139geosaver.param('Filename', 'Belle2Geo.root')
140
141arichrec = b2.register_module('ARICHReconstructor')
142arichrec.param('inputTrackType', 1)
143arichrec.param('beamtest', 3)
144arichrec.param('trackPositionResolution', 0.0)
145arichrec.param('trackAngleResolution', 0.0)
146
147profile = b2.register_module('Profile')
148profile.param('outputFileName', 'profileusage.ps')
149
150main = b2.create_path()
151main.add_module(eventinfosetter)
152main.add_module(paramloader)
153# main.add_module(profile)
154main.add_module(geobuilder)
155main.add_module(btest)
156main.add_module(arichrec)
157# main.add_module(g4sim)
158main.add_module(geosaver)
159
160b2.process(main)
161
162# Print basic event statistics to stdout
163print('Event Statistics:')
164print(b2.statistics)