Belle II Software  release-05-01-25
SVDCalibrationMonitor.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 
4 """
5 SVD Local Calibration Monitor Script
6 usage:
7 > open this file and edit the file:
8 . GLOBAL_TAG = xxx
9 . you can add also a local database uncommenting the relative line
10 Then execute the script:
11 > basf2 SVDLocalCalibrationMonitor.py --exp EXP --run RUN --local --cluster --cog
12 where:
13 local -> local calibration (from xml)
14 cluster -> cluster parameters
15 cog -> cog calibration parameters
16 """
17 
18 from basf2 import *
19 import ROOT
20 import argparse
21 from basf2 import conditions
22 
23 
24 parser = argparse.ArgumentParser(description="SVD Calibration Monitor")
25 parser.add_argument('--exp', metavar='expNumber', dest='exp', type=int, nargs=1, help='Experiment Number')
26 parser.add_argument('--run', metavar='runNumber', dest='run', type=int, nargs=1, help='Run Number')
27 parser.add_argument('--local', dest='doLocal', action='store_const', const=True,
28  default=False, help='produce Local Calibration Monitor plots')
29 parser.add_argument('--cog', dest='doCoG', action='store_const', const=True,
30  default=False, help='produce CoG Calibration Monitor plots')
31 parser.add_argument('--cluster', dest='doCluster', action='store_const', const=True,
32  default=False, help='produce Cluster Calibration Monitor plots')
33 parser.print_help()
34 print('')
35 args = parser.parse_args()
36 RunList = args.run
37 ExpList = args.exp
38 
39 
40 conditions.override_globaltags()
41 # conditions.globaltags = ["svd_offlineCalibrations", "svd_loadedOnFADC", "Reco_master_patch_rel5", "online"]
42 
43 myLocalDB = None
44 # if you want to use the localdb and not the occupancy paylaods on a GT uncomment-out the following line:
45 conditions.globaltags = ["svd_loadedOnFADC", "Reco_master_patch_rel5", "online"]
46 """
47  "svd_basic", "svd_loadedOnFADC",
48  "data_reprocessing_prompt_rel4_patchb",
49  "giulia_CDCEDepToADCConversions_rel4_patch"]
50 """
51 
52 localDB_tag = "" # "_notRegistered"
53 myLocalDB = "/home/belle2/zani/svd/current_master/exp"+str(ExpList[0])\
54  + "/run"+str(RunList[0]) + "/calibration_results"+str(localDB_tag)\
55  + "/SVDOccupancyAndHotStrips/outputdb/database.txt"
56 print('Your are plotting occupancy from payloads belongin to the local DB:')
57 print('')
58 print(myLocalDB)
59 print('')
60 
61 # -- end of localDB setup --
62 
63 # if(myLocalDB != "none"):
64 if myLocalDB is not None:
65  conditions.testing_payloads = [str(myLocalDB)]
66 else:
67  B2INFO("No local DB provided, monitoring payloads from GTs.")
68 
69 # TO BE USED before release 04, with previous database version:
70 # reset_database()
71 # use_database_chain()
72 # uncomment if using a local database:
73 # use_local_database(str(myLocalDB)+"database.txt", str(myLocalDB), invertLogging=True)
74 # use_local_database("localDB/database.txt", "localDB", invertLogging=True)
75 # use_central_database(GLOBAL_TAG)
76 
77 if myLocalDB is not None:
78  filenameLocal = "SVDLocalCalibrationMonitor_experiment" + \
79  str(ExpList[0]) + "_run" + str(RunList[0]) + "_fromLocalDB"+str(localDB_tag)+".root"
80 else:
81  filenameLocal = "SVDLocalCalibrationMonitor_experiment" + str(ExpList[0]) + "_run" + str(RunList[0]) + ".root"
82 filenameCoG = "SVDCoGTimeCalibrationMonitor_experiment" + str(ExpList[0]) + "_run" + str(RunList[0]) + ".root"
83 filenameCluster = "SVDClusterCalibrationMonitor_experiment" + str(ExpList[0]) + "_run" + str(RunList[0]) + ".root"
84 
85 
86 main = create_path()
87 
88 eventinfosetter = register_module('EventInfoSetter')
89 eventinfosetter.param({'evtNumList': [1], 'expList': ExpList, 'runList': RunList})
90 main.add_module(eventinfosetter)
91 main.add_module("Gearbox")
92 main.add_module("Geometry")
93 
94 # add calibration monitor modules
95 
96 
97 if args.doLocal:
98  local = register_module('SVDLocalCalibrationsMonitor')
99  local. param('outputFileName', filenameLocal)
100  main.add_module(local)
101 
102 if args.doCoG:
103  cog = register_module('SVDCoGTimeCalibrationsMonitor')
104  cog. param('outputFileName', filenameCoG)
105  main.add_module(cog)
106 
107 if args.doCluster:
108  cluster = register_module('SVDClusterCalibrationsMonitor')
109  cluster. param('outputFileName', filenameCluster)
110  main.add_module(cluster)
111 
112 # process single event
113 print_path(main)
114 process(main)