Belle II Software  release-05-01-25
SVDDetectorConfigurationImporter.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 
4 """
5 SVD Detector Configuration Importer.
6 Script to the configuration parameters, Local and Global, into a local DB
7 """
8 
9 from basf2 import *
10 import ROOT
11 from ROOT.Belle2 import SVDDetectorConfigurationImporter
12 from ROOT.Belle2 import FileSystem
13 import os
14 import sys
15 import glob
16 import subprocess
17 import interactive
18 import argparse
19 from fnmatch import fnmatch
20 from termcolor import colored
21 
22 parser = argparse.ArgumentParser(description="SVD Detector Configuration Importer")
23 parser.add_argument('--exp', metavar='experiment', dest='exp', type=int, nargs=1, help='Experiment Number, = 1 for GCR')
24 parser.add_argument('--run', metavar='run', dest='run', type=int, nargs=1, help='Run Number')
25 parser.add_argument('--cfgXML', metavar='config xml', dest='calib', type=str, nargs=1, help='GlobalRun Calibration XML file')
26 
27 print('')
28 
29 if(str(sys.argv[1]) == "help"):
30  parser.print_help()
31  exit(1)
32 
33 args = parser.parse_args()
34 
35 experiment = args.exp[0]
36 run = args.run[0]
37 
38 if args.calib is not None:
39  calibfile = args.calib[0]
40 else:
41  calibfile = args.calib
42 
43 
44 RED = "\033[1;31m"
45 BLUE = "\033[1;34m"
46 CYAN = "\033[1;36m"
47 GREEN = "\033[0;32m"
48 RESET = "\033[0;0m"
49 BOLD = "\033[;1m"
50 BLEU = "\033[34m"
51 REVERSE = "\033[;7m"
52 sys.stdout.write(RED)
53 print('| ---> CHECK HERE: <---')
54 print('| experiment number = ' + str(experiment))
55 print('|first valid run number = ' + str(run))
56 print('| global xml = ' + str(calibfile))
57 print('| ---> THANKS! <---')
58 sys.stdout.write(RESET)
59 
60 print('')
61 
62 proceed = input("Do you want to proceed? y/n ")
63 if not str(proceed) == 'y':
64  print(colored(str(proceed) + ' != y, therefore we exit now', 'red'))
65  exit(1)
66 
67 reset_database()
68 use_database_chain()
69 # central DB needed for the channel mapping DB object
70 # GLOBAL_TAG = "vxd_commissioning_20181030"
71 GLOBAL_TAG = "online"
72 use_central_database(GLOBAL_TAG)
73 use_local_database("localDB_test/database.txt", "localDB_test", invertLogging=True)
74 
75 # local tag and database needed for commissioning
76 
77 main = create_path()
78 
79 
80 # Event info setter - execute single event
81 eventinfosetter = register_module('EventInfoSetter')
82 eventinfosetter.param({'evtNumList': [1], 'expList': experiment, 'runList': run})
83 main.add_module(eventinfosetter)
84 
85 # Gearbox - access to xml files
86 main.add_module("Gearbox")
87 
88 run = int(run)
89 
90 
92  '''detector configuration importer'''
93 
94  def beginRun(self):
95  '''begin run'''
96 
97  # call the importer class
98  configImporterToDB = SVDDetectorConfigurationImporter(experiment, run, experiment, -1)
99  if args.calib is not None:
100  # import SVDGlobalConfigParameters dbobject: ZS, latency, mask, APV clock units
101  configImporterToDB.importSVDGlobalConfigParametersFromXML(calibfile)
102  print(colored("V) Global Detector Configuration parameters: (ZS, latency, mask, APVClock units) Imported", 'green'))
103  # import SVDLocalConfigParameters dbobject: calibration peak and time units, date
104  configImporterToDB.importSVDLocalConfigParametersFromXML(calibfile)
105  print(colored("V) Local Detector Configuration parameters Imported", 'green'))
106  else:
107  print(colored("X) Detector Configuration parameters are not NOT imported.", 'red'))
108 
109 
110 main.add_module(configImporterToDBModule())
111 
112 process(main)
113 
114 print("IMPORT COMPLETED, check the localDB folder and then proceeed with the upload to the central DB")
SVDDetectorConfigurationImporter
Definition: SVDDetectorConfigurationImporter.py:1
SVDDetectorConfigurationImporter.configImporterToDBModule.beginRun
def beginRun(self)
Definition: SVDDetectorConfigurationImporter.py:94
SVDDetectorConfigurationImporter.configImporterToDBModule
Definition: SVDDetectorConfigurationImporter.py:91