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