Belle II Software  release-08-01-10
DQMHistAnalysisSVDMiraBelle_test.py
1 # !/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 
11 
12 # script to test module which create monitoring variables for SVD
13 #
14 # Usage: basf2 DQMHistAnalysisSVDMiraBelle_test.py input_files
15 # input_files: one of the raw dqm files placed under /group/belle2/phase3/dqm/dqmsrv1/
16 #
17 # i.e basf2 DQMHistAnalysisSVDMiraBelle_test.py /group/belle2/phase3/dqm/dqmsrv1/e0018/dqmhisto/erecodqm_e0018r001313.root
18 # Output file in format: mon_e0018r001313_online.root contains moniotring variables which can be pinted by script:
19 # dqm/analysis/examples/printDQMFile.C
20 
21 import basf2 as b2
22 import os
23 import sys
24 import re
25 
26 argv = sys.argv
27 if len(argv) < 2:
28  print('\nUsage: %s input_filename\n' % argv[0])
29  exit(1)
30 inputFile = sys.argv[1]
31 
32 directory, fileName = os.path.split(inputFile)
33 exp_nr = int(re.findall(r'\d+', fileName)[0])
34 run_nr = int(re.findall(r'\d+', fileName)[1])
35 
36 # Set log level
37 b2.set_log_level(b2.LogLevel.INFO)
38 
39 # Create main path
40 main = b2.create_path()
41 
42 # Load histograms from file
43 main.add_module('DQMHistAnalysisInputRootFile',
44  Experiment=0,
45  RunList=[0],
46  FileList=[inputFile],
47  EventsList=[1],
48  SelectHistograms=["SVDExpReco/*",
49  "SVDClsTrk/*",
50  "SVDEfficiency/*"],
51  EventInterval=1,
52  NullHistogramMode=False)
53 # main.add_module("DQMHistAutoCanvas") # Plot all Histo from Input not needed
54 
55 # Run analysis module
56 main.add_module('DQMHistAnalysisSVDOnMiraBelle')
57 
58 # Save canvases based on histograms used to prepare monitoring variables and monitoring variables to root file
59 main.add_module('DQMHistAnalysisOutputMonObj',
60  exp=exp_nr,
61  run=run_nr)
62 
63 # Process the events
64 b2.print_path(main)
65 b2.process(main)
66 
67 # print out the summary
68 print(b2.statistics)