3 from __future__
import print_function
4 from FWCore.PythonUtilities.XML2Python
import xml2obj
5 from FWCore.PythonUtilities.LumiList
import LumiList
6 from pprint
import pprint
13 if __name__ ==
'__main__':
15 parser = optparse.OptionParser (
"Usage: %prog [--options] job1.fjr [job2.fjr...]")
16 parser.add_option (
'--output', dest=
'output', type=
'string',
17 help=
'Save output to file OUTPUT')
18 (options, args) = parser.parse_args()
20 raise RuntimeError(
"Must provide at least one input file")
25 obj = xml2obj (filename=fjr)
27 print(
"'%s' is not an framework job report. Skipping." % fjr)
29 for inputFile
in obj.InputFile:
31 runObjects = inputFile.Runs.Run
32 for run
in runObjects:
33 runNumber = int (run.ID)
34 runList = runsLumisDict.setdefault (runNumber, [])
35 for lumiPiece
in run.LumiSection:
36 lumi = int (lumiPiece.ID)
40 if isinstance(inputFile.Runs, str):
41 runObjects = [inputFile.Runs]
43 runObjects = inputFile.Runs
45 for runObject
in runObjects:
47 runs = ast.literal_eval(runObject)
48 for (run, lumis)
in runs.items():
49 runList = runsLumisDict.setdefault (
int(run), [])
54 print(
"Run missing in '%s'. Skipping." % fjr)
57 jsonList = LumiList (runsAndLumis = runsLumisDict)
59 jsonList.writeJSON (options.output)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)