13Script to Import Calibrations into a local DB
17from ROOT.Belle2
import SVDLocalCalibrationsImporter
20from termcolor
import colored
21from basf2
import conditions
as b2conditions
23parser = argparse.ArgumentParser(description=
"SVD Local Calibrations Importer")
24parser.add_argument(
'--exp', metavar=
'experiment', dest=
'exp', type=int, nargs=1, help=
'Experiment Number, = 1 for GCR')
25parser.add_argument(
'--run', metavar=
'run', dest=
'run', type=int, nargs=1, help=
'Run Number')
26parser.add_argument(
'--cfgXML', metavar=
'config xml', dest=
'calib', type=str, nargs=1, help=
'GlobalRun Calibration XML file')
27parser.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')
29parser.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>')
34if(str(sys.argv[1]) ==
"help"):
38args = parser.parse_args()
40experiment = args.exp[0]
43if args.calib
is not None:
44 calibfile = args.calib[0]
46 calibfile = args.calib
58print(
'| ---> CHECK HERE: <---')
59print(
'| experiment number = ' + str(experiment))
60print(
'|first valid run number = ' + str(run))
61print(
'| calibration xml = ' + str(calibfile))
62print(
'| is a global run xml = ' + str(
not args.localXml))
63print(
'| import masks = ' + str(
not args.mask))
64print(
'| ---> THANKS! <---')
65sys.stdout.write(RESET)
69proceed = input(
"Do you want to proceed? y/n ")
70if not str(proceed) ==
'y':
71 print(colored(str(proceed) +
' != y, therefore we exit now',
'red'))
74b2conditions.prepend_globaltag(
"svd_basic")
78main = b2.create_path()
82eventinfosetter = b2.register_module(
'EventInfoSetter')
83eventinfosetter.param({
'evtNumList': [1],
'expList': experiment,
'runList': run})
84main.add_module(eventinfosetter)
87main.add_module(
"Gearbox")
94 Module to call the importer methods for the payloads creation
from XML file
95 :param calibfile: path to the xml file containing the local calibrations
96 :type calibfile: string
101 Function to call the dbImporter methods to upload the different local payloads
105 if args.calib
is not None:
107 dbImporter.importSVDNoiseCalibrationsFromXML(calibfile)
108 print(colored(
"V) Noise Imported",
'green'))
110 dbImporter.importSVDPedestalCalibrationsFromXML(calibfile)
111 print(colored(
"V) Pedestal Imported",
'green'))
113 dbImporter.importSVDCalAmpCalibrationsFromXML(calibfile)
114 print(colored(
"V) Pulse Shape Calibrations Imported",
'green'))
117 dbImporter.importSVDFADCMaskedStripsFromXML(calibfile)
118 print(colored(
"V) FADC Masked Strips Imported",
'green'))
120 print(colored(
"X) FADC Masked Strips are NOT imported.",
'red'))
121 if not args.localXml:
123 dbImporter.importSVDGlobalXMLFile(calibfile)
124 print(colored(
"V) Global Run Configuration xml payload file Imported",
'green'))
126 print(colored(
"X) Global Run Configuration xml payload file is NOT imported.",
'red'))
133print(
"IMPORT COMPLETED, check the localDB folder and then proceeed with the upload to the central DB")