13Script to Import Calibrations into a local DB
19from termcolor
import colored
20from basf2
import conditions
as b2conditions
22parser = argparse.ArgumentParser(description=
"SVD Local Calibrations Importer")
23parser.add_argument(
'--exp', metavar=
'experiment', dest=
'exp', type=int, nargs=1, help=
'Experiment Number, = 1 for GCR')
24parser.add_argument(
'--run', metavar=
'run', dest=
'run', type=int, nargs=1, help=
'Run Number')
25parser.add_argument(
'--cfgXML', metavar=
'config xml', dest=
'calib', type=str, nargs=1, help=
'GlobalRun Calibration XML file')
26parser.add_argument(
'--isLocalXML', dest=
'localXml', action=
'store_const', const=
True, default=
False,
27 help=
'Add this parameter if the XML is a Local run configuration instead of a Global Run Configuration')
28parser.add_argument(
'--nomask', dest=
'mask', action=
'store_const', default=
False, const=
True,
29 help=
'Add this parameter if the XML does not contain the attribute <masks>')
33if (str(sys.argv[1]) ==
"help"):
37args = parser.parse_args()
39experiment = args.exp[0]
42if args.calib
is not None:
43 calibfile = args.calib[0]
45 calibfile = args.calib
57print(
'| ---> CHECK HERE: <---')
58print(
'| experiment number = ' + str(experiment))
59print(
'|first valid run number = ' + str(run))
60print(
'| calibration xml = ' + str(calibfile))
61print(
'| is a global run xml = ' + str(
not args.localXml))
62print(
'| import masks = ' + str(
not args.mask))
63print(
'| ---> THANKS! <---')
64sys.stdout.write(RESET)
68proceed = input(
"Do you want to proceed? y/n ")
69if not str(proceed) ==
'y':
70 print(colored(str(proceed) +
' != y, therefore we exit now',
'red'))
73b2conditions.prepend_globaltag(
"svd_basic")
77main = b2.create_path()
81eventinfosetter = b2.register_module(
'EventInfoSetter')
82eventinfosetter.param({
'evtNumList': [1],
'expList': experiment,
'runList': run})
83main.add_module(eventinfosetter)
86main.add_module(
"Gearbox")
93 Module to call the importer methods for the payloads creation
from XML file
94 :param calibfile: path to the xml file containing the local calibrations
95 :type calibfile: string
100 Function to call the dbImporter methods to upload the different local payloads
103 from ROOT
import Belle2
104 from ROOT.Belle2
import SVDLocalCalibrationsImporter
108 if args.calib
is not None:
110 dbImporter.importSVDNoiseCalibrationsFromXML(calibfile)
111 print(colored(
"V) Noise Imported",
'green'))
113 dbImporter.importSVDPedestalCalibrationsFromXML(calibfile)
114 print(colored(
"V) Pedestal Imported",
'green'))
116 dbImporter.importSVDCalAmpCalibrationsFromXML(calibfile)
117 print(colored(
"V) Pulse Shape Calibrations Imported",
'green'))
120 dbImporter.importSVDFADCMaskedStripsFromXML(calibfile)
121 print(colored(
"V) FADC Masked Strips Imported",
'green'))
123 print(colored(
"X) FADC Masked Strips are NOT imported.",
'red'))
124 if not args.localXml:
126 dbImporter.importSVDGlobalXMLFile(calibfile)
127 print(colored(
"V) Global Run Configuration xml payload file Imported",
'green'))
129 print(colored(
"X) Global Run Configuration xml payload file is NOT imported.",
'red'))
136print(
"IMPORT COMPLETED, check the localDB folder and then proceeed with the upload to the central DB")