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