12Simple script to import RunInfo from the DAQ database into conditions
14As input you need a file which contains on each line the following
15fields separated by whitespace::
17exp run runtype StartTime StopTime receivedNevent AcceptedNevent sentNevent runLength
18TriggerRate PXDflag SVDflag CDCflag TOPflag ARICHflag ECLflag KLMflag BadRun
24from ROOT
import PyConfig
26PyConfig.IgnoreCommandLineOptions =
True
28PyConfig.StartGuiThread =
False
30from ROOT
import Belle2
31from basf2
import B2FATAL, B2ERROR, B2DEBUG, B2INFO
34def get_argument_parser():
35 """Function returning the argument parser. Done this way for the automatic
36 documentation in sphinx
"""
39 parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
40 parser.add_argument(
"filename", help=
"Filename containing the run information, "
41 "one run per line with the values separated by whitespace")
49if __name__ ==
"__main__":
50 parser = get_argument_parser()
51 args = parser.parse_args()
52 if not os.path.exists(args.filename):
53 B2FATAL(f
"Input filename {args.filename} does not exist")
61 with open(args.filename)
as f:
62 for i, line
in enumerate(f, 1):
75 exp, run, runtype, starttime, stoptime, receivedNevent, acceptedNevent,
76 sentNevent, runlength, trigger_rate, pxd, svd, cdc, top, arich, ecl,
81 info.setRunType(int(runtype))
82 info.setStartTime(int(starttime))
83 info.setStopTime(int(stoptime))
84 info.setReceivedNevent(int(receivedNevent))
85 info.setAcceptedNevent(int(acceptedNevent))
86 info.setSentNevent(int(sentNevent))
87 info.setRunLength(int(runlength))
88 info.setTriggerRate(float(trigger_rate))
89 info.setBelle2Detector(*[int(e)
for e
in (pxd, svd, cdc, top, arich, ecl, klm)])
90 info.setBadRun(int(badrun))
93 B2DEBUG(100, f
"Exp: {exp}\tRun: {run}\t RunType: {runtype} ...")
96 except Exception
as e:
97 B2ERROR(f
"Problem reading line {i}: {e}. Skipping ...")
107 B2INFO(f
"Imported {imported} RunInfo objects")
109 B2FATAL(f
"{errors} errors occured")
A class that describes the interval of experiments/runs for which an object in the database is valid.
Database object for Run Information.
static Database & Instance()
Instance of a singleton Database.