13 SVD Database importer.
14 Script to Import Calibrations into a local DB
18 from ROOT.Belle2
import SVDLocalCalibrationsImporter
21 from termcolor
import colored
22 from basf2
import conditions
as b2conditions
24 parser = argparse.ArgumentParser(description=
"SVD Local Calibrations Importer")
25 parser.add_argument(
'--exp', metavar=
'experiment', dest=
'exp', type=int, nargs=1, help=
'Experiment Number, = 1 for GCR')
26 parser.add_argument(
'--run', metavar=
'run', dest=
'run', type=int, nargs=1, help=
'Run Number')
27 parser.add_argument(
'--cfgXML', metavar=
'config xml', dest=
'calib', type=str, nargs=1, help=
'GlobalRun Calibration XML file')
28 parser.add_argument(
'--isLocalXML', dest=
'localXml', action=
'store_const', const=
True, default=
False,
29 help=
'Add this parameter if the XML is a Local run configuration instead of a Global Run Configuration')
30 parser.add_argument(
'--nomask', dest=
'mask', action=
'store_const', default=
False, const=
True,
31 help=
'Add this parameter if the XML does not contain the attribute <masks>')
35 if(str(sys.argv[1]) ==
"help"):
39 args = parser.parse_args()
41 experiment = args.exp[0]
44 if args.calib
is not None:
45 calibfile = args.calib[0]
47 calibfile = args.calib
59 print(
'| ---> CHECK HERE: <---')
60 print(
'| experiment number = ' + str(experiment))
61 print(
'|first valid run number = ' + str(run))
62 print(
'| calibration xml = ' + str(calibfile))
63 print(
'| is a global run xml = ' + str(
not args.localXml))
64 print(
'| import masks = ' + str(
not args.mask))
65 print(
'| ---> THANKS! <---')
66 sys.stdout.write(RESET)
70 proceed = input(
"Do you want to proceed? y/n ")
71 if not str(proceed) ==
'y':
72 print(colored(str(proceed) +
' != y, therefore we exit now',
'red'))
75 b2conditions.prepend_globaltag(
"svd_basic")
79 main = b2.create_path()
83 eventinfosetter = b2.register_module(
'EventInfoSetter')
84 eventinfosetter.param({
'evtNumList': [1],
'expList': experiment,
'runList': run})
85 main.add_module(eventinfosetter)
88 main.add_module(
"Gearbox")
95 Module to call the importer methods for the payloads creation from XML file
96 :param calibfile: path to the xml file containing the local calibrations
97 :type calibfile: string
102 Function to call the dbImporter methods to upload the different local payloads
106 if args.calib
is not None:
108 dbImporter.importSVDNoiseCalibrationsFromXML(calibfile)
109 print(colored(
"V) Noise Imported",
'green'))
111 dbImporter.importSVDPedestalCalibrationsFromXML(calibfile)
112 print(colored(
"V) Pedestal Imported",
'green'))
114 dbImporter.importSVDCalAmpCalibrationsFromXML(calibfile)
115 print(colored(
"V) Pulse Shape Calibrations Imported",
'green'))
118 dbImporter.importSVDFADCMaskedStripsFromXML(calibfile)
119 print(colored(
"V) FADC Masked Strips Imported",
'green'))
121 print(colored(
"X) FADC Masked Strips are NOT imported.",
'red'))
122 if not args.localXml:
124 dbImporter.importSVDGlobalXMLFile(calibfile)
125 print(colored(
"V) Global Run Configuration xml payload file Imported",
'green'))
127 print(colored(
"X) Global Run Configuration xml payload file is NOT imported.",
'red'))
134 print(
"IMPORT COMPLETED, check the localDB folder and then proceeed with the upload to the central DB")