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")
45if __name__ ==
"__main__":
46 parser = get_argument_parser()
47 args = parser.parse_args()
48 if not os.path.exists(args.filename):
49 B2FATAL(f
"Input filename {args.filename} does not exist")
57 with open(args.filename)
as f:
58 for i, line
in enumerate(f, 1):
71 exp, run, runtype, starttime, stoptime, receivedNevent, acceptedNevent,
72 sentNevent, runlength, trigger_rate, pxd, svd, cdc, top, arich, ecl,
77 info.setRunType(int(runtype))
78 info.setStartTime(int(starttime))
79 info.setStopTime(int(stoptime))
80 info.setReceivedNevent(int(receivedNevent))
81 info.setAcceptedNevent(int(acceptedNevent))
82 info.setSentNevent(int(sentNevent))
83 info.setRunLength(int(runlength))
84 info.setTriggerRate(float(trigger_rate))
85 info.setBelle2Detector(*[int(e)
for e
in (pxd, svd, cdc, top, arich, ecl, klm)])
86 info.setBadRun(int(badrun))
89 B2DEBUG(100, f
"Exp: {exp}\tRun: {run}\t RunType: {runtype} ...")
92 except Exception
as e:
93 B2ERROR(f
"Problem reading line {i}: {e}. Skipping ...")
103 B2INFO(f
"Imported {imported} RunInfo objects")
105 B2FATAL(f
"{errors} errors occurred")
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.