Belle II Software  release-08-01-10
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 # mypath.add_module("DQMHistAutoCanvas") # Plot all Histo from Input not needed
39 
40 dqmEff = b2.register_module('DQMHistAnalysisEventT0')
41 dqmEff.set_log_level(b2.LogLevel.INFO)
42 dqmEff.param("printCanvas", True)
43 mypath.add_module(dqmEff)
44 
45 outroot = b2.register_module('DQMHistAnalysisOutputMonObj')
46 outroot.param('ProcID', 'online') # set processing ID
47 outroot.param('exp', exp_nr)
48 outroot.param('run', run_nr)
49 outroot.param('nevt', nevt)
50 outroot.param('TreeFile', 'run_tree_eventT0.root')
51 mypath.add_module(outroot)
52 
53 # Process the events
54 b2.print_path(mypath)
55 b2.process(mypath)
56 
57 # print out the summary
58 print(b2.statistics)