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