17 from optparse
import OptionParser
22 b2.set_log_level(b2.LogLevel.INFO)
24 outroot =
'arichbtest.root'
26 parser = OptionParser()
27 parser.add_option(
'-r',
'--run', dest=
'runno', default=
'068',
29 parser.add_option(
'-p',
'--path', dest=
'path',
30 default=
'/afs/f9.ijs.si/data/belle/data/beamtests/2011/run',
33 parser.add_option(
'-y',
'--year', dest=
'year', default=
'2011',
34 help=
'beam test year')
36 parser.add_option(
'-t',
'--track-mask', dest=
'mask', default=
'0x5',
37 help=
'track mask 4 bits')
39 parser.add_option(
'-m',
'--avgagel', dest=
'avgagel', default=
'0',
40 help=
'average thc calculation based on the mean agel')
47 help=
'Output filename',
51 parser.add_option(
'-n',
'--neve', dest=
'neve', default=20000,
52 help=
'Number of events to process')
54 (options, args) = parser.parse_args()
56 fname = options.path +
'/run' + options.runno +
'.dat'
58 if not os.path.isfile(fname):
59 print(
'File does not exist:')
62 print(
'Appending .gz...')
63 if not os.path.isfile(fname):
64 print(
'File does not exist:')
68 if options.output == outroot:
69 outroot =
'run_' + options.runno +
'.root'
71 outroot = options.output
73 mask = int(options.mask, 16)
74 runno = int(options.runno)
76 print(
'TrackMask:' + options.mask)
79 averageagel = int(options.avgagel)
81 eventinfosetter = b2.register_module(
'EventInfoSetter')
82 eventinfosetter.param(
'evtNumList', [int(options.neve)])
83 eventinfosetter.param(
'runList', [int(options.runno)])
84 eventinfosetter.param(
'expList', [1])
87 paramloader = b2.register_module(
'Gearbox')
89 xmlgeometry =
'file://%s/arich/modules/arichBtest/data/%s/arichBtest%s.xml' \
90 % (os.getcwd(), options.year, options.year)
91 paramloader.param(
'fileName', xmlgeometry)
93 paramloader.param(
'fileName', xmlgeometry)
106 geobuilder = b2.register_module(
'Geometry')
107 geobuilder.param(
'components', [
'ARICHBtest'])
109 btest = b2.register_module(
'arichBtest')
110 btest.param(
'mwpcTrackMask', [mask])
112 btest.param(
'runList', [fname])
113 btest.param(
'outputFileName', outroot)
115 if options.year ==
'2013':
117 print(
'Beam momentum ' + str(momentum))
118 btest.param(
'beamMomentum', momentum)
121 g4sim = b2.register_module(
'FullSim')
124 g4sim.param(
'RegisterOptics', 1)
128 g4sim.param(
'PhotonFraction', 0.3)
130 g4sim.param(
'EnableVisualization',
True)
134 g4sim.param(
'UICommandsAtIdle', [
'/vis/open VRML2FILE',
'/vis/drawVolume',
135 '/vis/scene/add/axes 0 0 0 100 mm'])
138 geosaver = b2.register_module(
'ExportGeometry')
139 geosaver.param(
'Filename',
'Belle2Geo.root')
141 arichrec = b2.register_module(
'ARICHReconstructor')
142 arichrec.param(
'inputTrackType', 1)
143 arichrec.param(
'beamtest', 3)
144 arichrec.param(
'trackPositionResolution', 0.0)
145 arichrec.param(
'trackAngleResolution', 0.0)
147 profile = b2.register_module(
'Profile')
148 profile.param(
'outputFileName',
'profileusage.ps')
150 main = b2.create_path()
151 main.add_module(eventinfosetter)
152 main.add_module(paramloader)
154 main.add_module(geobuilder)
155 main.add_module(btest)
156 main.add_module(arichrec)
158 main.add_module(geosaver)
163 print(
'Event Statistics:')