Belle II Software  release-08-01-10
SVDCalibrationMonitor.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 
4 
11 
12 """
13 SVD Local Calibration Monitor Script
14 usage:
15 > open this file and edit the file:
16 . GLOBAL_TAG = xxx
17 . you can add also a local database uncommenting the relative line
18 Then execute the script:
19 > basf2 SVDLocalCalibrationMonitor.py --exp EXP --run RUN --local --cluster --cog
20 where:
21 local -> local calibration (from xml)
22 cluster -> cluster parameters
23 cog -> cog calibration parameters
24 """
25 
26 import basf2 as b2
27 import argparse
28 
29 
30 parser = argparse.ArgumentParser(description="SVD Calibration Monitor")
31 parser.add_argument('--exp', metavar='expNumber', dest='exp', type=int, nargs=1, help='Experiment Number')
32 parser.add_argument('--run', metavar='runNumber', dest='run', type=int, nargs=1, help='Run Number')
33 parser.add_argument('--local', dest='doLocal', action='store_const', const=True,
34  default=False, help='produce Local Calibration Monitor plots')
35 parser.add_argument('--cog6', dest='doCoG6', action='store_const', const=True,
36  default=False, help='produce CoG6 Calibration Monitor plots')
37 parser.add_argument('--cog3', dest='doCoG3', action='store_const', const=True,
38  default=False, help='produce CoG3 Calibration Monitor plots')
39 parser.add_argument('--els3', dest='doELS3', action='store_const', const=True,
40  default=False, help='produce ELS3 Calibration Monitor plots')
41 parser.add_argument('--cluster', dest='doCluster', action='store_const', const=True,
42  default=False, help='produce Cluster Calibration Monitor plots')
43 parser.print_help()
44 print('')
45 args = parser.parse_args()
46 RunList = args.run
47 ExpList = args.exp
48 
49 
50 b2.conditions.prepend_globaltag("online")
51 b2.conditions.prepend_globaltag("svd_basic")
52 b2.conditions.prepend_globaltag("data_reprocessing_prompt")
53 b2.conditions.prepend_globaltag("svd_onlySVDinGeoConfiguration")
54 
55 myLocalDB = None
56 
57 if myLocalDB is not None:
58  b2.conditions.testing_payloads = [str(myLocalDB)]
59 else:
60  b2.B2INFO("No local DB provided, monitoring payloads from GTs.")
61 
62 if myLocalDB is not None:
63  filenameLocal = "SVDLocalCalibrationMonitor_experiment" + \
64  str(ExpList[0]) + "_run" + str(RunList[0]) + "_fromLocalDB" + str(myLocalDB) + ".root"
65  filenameCoG = "SVDCoGTimeCalibrationMonitor_experiment" + \
66  str(ExpList[0]) + "_run" + str(RunList[0]) + "_fromLocalDB" + str(myLocalDB) + ".root"
67  filenameCluster = "SVDClusterCalibrationMonitor_experiment" + \
68  str(ExpList[0]) + "_run" + str(RunList[0]) + "_fromLocalDB" + str(myLocalDB) + ".root"
69 else:
70  filenameLocal = "SVDLocalCalibrationMonitor_experiment" + str(ExpList[0]) + "_run" + str(RunList[0]) + ".root"
71  filenameCoG6 = "SVDCoG6TimeCalibrationMonitor_experiment" + str(ExpList[0]) + "_run" + str(RunList[0]) + ".root"
72  filenameCoG3 = "SVDCoG3TimeCalibrationMonitor_experiment" + str(ExpList[0]) + "_run" + str(RunList[0]) + ".root"
73  filenameELS3 = "SVDELS3TimeCalibrationMonitor_experiment" + str(ExpList[0]) + "_run" + str(RunList[0]) + ".root"
74  filenameCluster = "SVDClusterCalibrationMonitor_experiment" + str(ExpList[0]) + "_run" + str(RunList[0]) + ".root"
75 
76 main = b2.create_path()
77 
78 eventinfosetter = b2.register_module('EventInfoSetter')
79 eventinfosetter.param({'evtNumList': [1], 'expList': ExpList, 'runList': RunList})
80 main.add_module(eventinfosetter)
81 main.add_module("Gearbox")
82 main.add_module("Geometry")
83 
84 # add calibration monitor modules
85 if args.doLocal:
86  local = b2.register_module('SVDLocalCalibrationsMonitor')
87  local. param('outputFileName', filenameLocal)
88  main.add_module(local)
89 
90 if args.doCoG6:
91  time = b2.register_module('SVDTimeCalibrationsMonitor')
92  time.set_name("SVDTimeCalibrationsMonitor_CoG6")
93  time.param('outputFileName', filenameCoG6)
94  time.param('timeAlgo', "CoG6")
95  main.add_module(time)
96 
97 if args.doCoG3:
98  time = b2.register_module('SVDTimeCalibrationsMonitor')
99  time.set_name("SVDTimeCalibrationsMonitor_CoG3")
100  time.param('outputFileName', filenameCoG3)
101  time.param('timeAlgo', "CoG3")
102  main.add_module(time)
103 
104 if args.doELS3:
105  time = b2.register_module('SVDTimeCalibrationsMonitor')
106  time.set_name("SVDTimeCalibrationsMonitor_ELS3")
107  time.param('outputFileName', filenameELS3)
108  time.param('timeAlgo', "ELS3")
109  main.add_module(time)
110 
111 if args.doCluster:
112  cluster = b2.register_module('SVDClusterCalibrationsMonitor')
113  cluster. param('outputFileName', filenameCluster)
114  main.add_module(cluster)
115 
116 # process single event
117 b2.print_path(main)
118 b2.process(main)