Belle II Software  release-06-01-15
eventT0DQMAnalysisExample.py
1 # !/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 
11 
12 # illustrative run:
13 # basf2 eventT0DQMAnalysisEfficiency.py dqm_e0014r000921.root 100
14 
15 import basf2 as b2
16 import sys
17 import re
18 from basf2 import conditions as b2conditions
19 
20 mypath = b2.Path()
21 inputFile = sys.argv[1]
22 exp_nr = int(re.findall(r'\d+', inputFile)[0])
23 run_nr = int(re.findall(r'\d+', inputFile)[1])
24 nevt = int(sys.argv[2]) # number of events
25 
26 # setup database
27 b2conditions.reset()
28 b2conditions.override_globaltags()
29 b2conditions.globaltags = ["online"]
30 
31 inroot = b2.register_module('DQMHistAnalysisInputRootFile')
32 inroot.param('FileList', inputFile)
33 inroot.param('SelectHistograms', ['EventT0*/*'])
34 inroot.param('Experiment', exp_nr)
35 inroot.param('RunList', [run_nr])
36 inroot.param('EventsList', [nevt])
37 mypath.add_module(inroot)
38 
39 dqmEff = b2.register_module('DQMHistAnalysisEventT0')
40 dqmEff.set_log_level(b2.LogLevel.INFO)
41 dqmEff.param("printCanvas", True)
42 mypath.add_module(dqmEff)
43 
44 outroot = b2.register_module('DQMHistAnalysisOutputMonObj')
45 outroot.param('ProcID', 'online') # set processing ID
46 outroot.param('exp', exp_nr)
47 outroot.param('run', run_nr)
48 outroot.param('nevt', nevt)
49 outroot.param('TreeFile', 'run_tree_eventT0.root')
50 mypath.add_module(outroot)
51 
52 # Process the events
53 b2.print_path(mypath)
54 b2.process(mypath)
55 
56 # print out the summary
57 print(b2.statistics)