6 Script to Import Calibrations into a local DB
12 from ROOT.Belle2
import SVDLocalCalibrationsImporter
13 from ROOT.Belle2
import FileSystem
20 from fnmatch
import fnmatch
21 from termcolor
import colored
23 parser = argparse.ArgumentParser(description=
"SVD Local Calibrations Importer")
24 parser.add_argument(
'--exp', metavar=
'experiment', dest=
'exp', type=int, nargs=1, help=
'Experiment Number, = 1 for GCR')
25 parser.add_argument(
'--run', metavar=
'run', dest=
'run', type=int, nargs=1, help=
'Run Number')
26 parser.add_argument(
'--cfgXML', metavar=
'config xml', dest=
'calib', type=str, nargs=1, help=
'GlobalRun Calibration XML file')
27 parser.add_argument(
'--isLocalXML', dest=
'localXml', action=
'store_const', const=
True, default=
False,
28 help=
'Add this parameter if the XML is a Local run configuration instead of a Global Run Configuration')
29 parser.add_argument(
'--nomask', dest=
'mask', action=
'store_const', default=
False, const=
True,
30 help=
'Add this parameter if the XML does not contain the attribute <masks>')
34 if(str(sys.argv[1]) ==
"help"):
38 args = parser.parse_args()
40 experiment = args.exp[0]
43 if args.calib
is not None:
44 calibfile = args.calib[0]
46 calibfile = args.calib
58 print(
'| ---> CHECK HERE: <---')
59 print(
'| experiment number = ' + str(experiment))
60 print(
'|first valid run number = ' + str(run))
61 print(
'| calibration xml = ' + str(calibfile))
62 print(
'| is a global run xml = ' + str(
not args.localXml))
63 print(
'| import masks = ' + str(
not args.mask))
64 print(
'| ---> THANKS! <---')
65 sys.stdout.write(RESET)
69 proceed = input(
"Do you want to proceed? y/n ")
70 if not str(proceed) ==
'y':
71 print(colored(str(proceed) +
' != y, therefore we exit now',
'red'))
79 use_central_database(GLOBAL_TAG)
80 use_local_database(
"localDB/database.txt",
"localDB", invertLogging=
True)
88 eventinfosetter = register_module(
'EventInfoSetter')
89 eventinfosetter.param({
'evtNumList': [1],
'expList': experiment,
'runList': run})
90 main.add_module(eventinfosetter)
93 main.add_module(
"Gearbox")
101 Module to call the importer methods for the payloads creation from XML file
102 :param calibfile: path to the xml file containing the local calibrations
103 :type calibfile: string
108 Function to call the dbImporter methods to upload the different local payloads
112 if args.calib
is not None:
114 dbImporter.importSVDNoiseCalibrationsFromXML(calibfile)
115 print(colored(
"V) Noise Imported",
'green'))
117 dbImporter.importSVDPedestalCalibrationsFromXML(calibfile)
118 print(colored(
"V) Pedestal Imported",
'green'))
120 dbImporter.importSVDCalAmpCalibrationsFromXML(calibfile)
121 print(colored(
"V) Pulse Shape Calibrations Imported",
'green'))
124 dbImporter.importSVDFADCMaskedStripsFromXML(calibfile)
125 print(colored(
"V) FADC Masked Strips Imported",
'green'))
127 print(colored(
"X) FADC Masked Strips are NOT imported.",
'red'))
128 if not args.localXml:
130 dbImporter.importSVDGlobalXMLFile(calibfile)
131 print(colored(
"V) Global Run Configuration xml payload file Imported",
'green'))
133 print(colored(
"X) Global Run Configuration xml payload file is NOT imported.",
'red'))
139 print(
"IMPORT COMPLETED, check the localDB folder and then proceeed with the upload to the central DB")