Belle II Software development
ARICHCosmicTestData.py
1#!/usr/bin/env python3
2
3
10
11# Script for ARICH cosmics data simple analysis
12# reads arich raw data, stores arichHits and arichDigits into the output root file,
13# makes and displays DQM histograms, runs the event display
14#
15# run as: "basf2 ARICHCosmicTestData.py -- -f path2datafile.sroot"
16# add "-s 1" for event display
17#
18# two parameters (MinHits and MaxHits) are available for DQM module (check below)
19# only events with number of hits within the range are included in DQM histograms
20# and shown in the event display (set to 5 and 40, but change accoring your need)
21
22import basf2 as b2
23import os
24from optparse import OptionParser
25home = os.environ['BELLE2_LOCAL_DIR']
26
27
28b2.conditions.override_globaltags()
29b2.conditions.append_globaltag("332_COPY-OF_GT_gen_prod_004.11_Master-20171213-230000")
30
31# parameters
32parser = OptionParser()
33parser.add_option(
34 '-f',
35 '--file',
36 dest='filename',
37 default='/ghi/fs01/belle2/bdata/users/tkonno/cosmic/cosmic.0002.00951.HLT3.f00000.root')
38parser.add_option('-o', '--output', dest='output', default='ARICHHits.root')
39parser.add_option('-d', '--debug', dest='debug', default=0)
40parser.add_option('-s', '--display', dest='display', default=0)
41(options, args) = parser.parse_args()
42
43# create paths
44main = b2.create_path()
45displ = b2.create_path()
46
47
48# root input module
49input_module = b2.register_module('RootInput')
50input_module.param('inputFileName', options.filename)
51# input_module.param('entrySequences',['5100:5300']) # select subrange of events
52main.add_module(input_module)
53
54# Histogram manager module
55histo = b2.register_module('HistoManager')
56histo.param('histoFileName', "histograms.root") # File to save histograms
57main.add_module(histo)
58
59
60# build geometry if display option
61if int(options.display):
62 main.add_module('Gearbox')
63 geometry = b2.register_module('Geometry')
64 geometry.param('components', ['ARICH'])
65 main.add_module(geometry)
66
67# unpack raw data
68unPacker = b2.register_module('ARICHUnpacker')
69unPacker.param('debug', int(options.debug))
70main.add_module(unPacker)
71
72# create ARICHHits from ARICHDigits
73main.add_module('ARICHFillHits')
74
75# create simple DQM histograms
76arichHists = b2.register_module('ARICHDQM')
77arichHists.param('MaxHits', 40)
78arichHists.param('MinHits', 5)
79main.add_module(arichHists)
80
81# add display module if display option
82if int(options.display):
83 display = b2.register_module('Display')
84 # show arich hits
85 display.param('showARICHHits', True)
86 # show full geometry
87 display.param('fullGeometry', True)
88 displ.add_module(display)
89
90# store dataobjects
91output = b2.register_module('RootOutput')
92output.param('outputFileName', options.output)
93branches = ['ARICHDigits', 'ARICHHits']
94output.param('branchNames', branches)
95main.add_module(output)
96
97# show progress
98main.add_module('Progress')
99
100arichHists.if_value('==1', displ)
101
102# process
103b2.process(main)
104
105# print stats
106print(b2.statistics)
107
108# plot DQM histograms
109if not int(options.display):
110 com = 'root -l histograms.root ' + home + '/arich/utility/scripts/plotDQM.C'
111 os.system(com)