Belle II Software development
arich_display.py
1# !/usr/bin/env python3
2
3
10
11# Script for running arich event display, DQM module, and arich reconstruction on
12# processed data (containing arichHits)
13# To process raw data first use arich/examples/arich_process_raw.py
14#
15# run as: "basf2 arich/examples/arich_display.py -- -f path2processedDatafile.sroot"
16# add "-s 1" for event display, otherwise only DQM histograms are produced
17# add "-a 1" to select only events that have extrapolated track in the arich
18# add "-r 1" to add the arich reconstruction (for cherenkov angle distribution)
19#
20# two parameters (MinHits and MaxHits) are available for DQM module (check below)
21# only events with number of hits within the range are included in DQM histograms
22# and shown in the event display (set to 5 and 40, but change according to your need)
23
24import basf2 as b2
25import os
26from optparse import OptionParser
27home = os.environ['BELLE2_LOCAL_DIR']
28
29# parameters
30parser = OptionParser()
31parser.add_option('-f', '--file', dest='filename', default='ARICHHits.root')
32parser.add_option('-s', '--display', dest='display', default=0)
33parser.add_option('-a', '--arichtrk', dest='arichtrk', default=0)
34parser.add_option('-r', '--recon', dest='recon', default=1)
35parser.add_option('-o', '--output', dest='output', default='arich_recon_ntuple.root')
36(options, args) = parser.parse_args()
37
38# create paths
39main = b2.create_path()
40displ = b2.create_path()
41
42# root input module
43input_module = b2.register_module('RootInput')
44input_module.param('inputFileName', options.filename)
45main.add_module(input_module)
46
47# Histogram manager module
48histo = b2.register_module('HistoManager')
49histo.param('histoFileName', "histograms.root") # File to save histograms
50main.add_module(histo)
51
52# build geometry if display option
53if int(options.display):
54 main.add_module('Gearbox')
55 geometry = b2.register_module('Geometry')
56 geometry.param('components', ['ARICH', 'MagneticField'])
57 main.add_module(geometry)
58
59if int(options.recon):
60 arichHits = b2.register_module('ARICHFillHits')
61 arichHits.param('MagFieldCorrection', 1)
62 main.add_module(arichHits)
63 arichreco = b2.register_module('ARICHReconstructor')
64 arichreco.param('storePhotons', 1)
65 arichreco.param('useAlignment', 1)
66 main.add_module(arichreco)
67 arichNtuple = b2.register_module('ARICHNtuple')
68 arichNtuple.param('outputFile', options.output)
69 main.add_module(arichNtuple)
70
71
72# create simple DQM histograms
73arichHists = b2.register_module('ARICHDQM')
74arichHists.param('ArichEvents', bool(options.arichtrk))
75# set hit range - include only events with hits in this range (also for event display!)
76arichHists.param('MaxHits', 100)
77arichHists.param('MinHits', 0)
78main.add_module(arichHists)
79
80# add display module if display option
81if int(options.display):
82 display = b2.register_module('Display')
83 # show arich hits
84 display.param('showARICHHits', True)
85 # show reconstructed tracks
86 display.param('showRecoTracks', True)
87 # show full geometry
88 display.param('fullGeometry', True)
89 displ.add_module(display)
90
91
92# show progress
93main.add_module('Progress')
94
95arichHists.if_value('==1', displ)
96
97# process
98b2.process(main)
99
100# print stats
101print(b2.statistics)
102
103# plot DQM histograms
104if not int(options.display):
105 com = 'root -l histograms.root ' + home + '/arich/utility/scripts/plotDQM.C'
106 os.system(com)