Belle II Software development
prepareCanvasesWithHistograms.py
1#!/usr/bin/env python3
2
3
10
11import basf2 as b2
12import sys
13argv = sys.argv
14
15if len(argv) < 3:
16 print()
17 print('v 1.0 / Feb. 7, 2021 / by your colleague')
18 print()
19 print('This script processes histograms from selected (or all) branches/folders and prepares canvases')
20 print()
21 print('To make this script work, first build dqm package b2code-package-add daq; scons')
22 print()
23 print('For more information see https://xwiki.desy.de/xwiki/rest/p/a331d')
24 print()
25 print(f'Usage: {argv[0]} input_filename output_filename')
26 print()
27 exit(1)
28
29b2.set_log_level(b2.LogLevel.INFO)
30
31# Create main path
32main = b2.create_path()
33
34# Modules
35inroot = b2.register_module('DQMHistAnalysisInputRootFile')
36inroot.param('InputRootFile', argv[1])
37
38# you can select which branches/folders to process, leave blank to process all branches/folders
39# inroot.param('SelectFolders', ['TRGTOP'])
40
41# you can select which histograms to process, leave blank to include all
42# inroot.param('SelectHistograms', ['TRGTOP/h_*'])
43
44main.add_module(inroot)
45main.add_module("DQMHistAutoCanvas") # Plot all Histo from Input
46
47outroot = b2.register_module('DQMHistAnalysisOutputFile')
48
49outroot.param('SaveHistos', False) # don't save histograms
50outroot.param('SaveCanvases', True) # save canvases
51
52outroot.param('HistoFile', argv[2])
53main.add_module(outroot)
54
55b2.print_path(main)
56
57# Process all events
58b2.process(main)