20 from argparse
import ArgumentParser
21 parser = ArgumentParser()
22 parser.add_argument(
'--file', default=
'RatesHistograms.root',
23 help=
'Input ROOT file to generate output from, run hadd first if you have more than one')
24 parser.add_argument(
'--outputTag', default=
'LOCAL',
25 help=
'Tag identifying this processing to be used in the output folder name (any underscores will be removed)')
26 parser.add_argument(
'--outputJSONFile', default=
'rates.json',
27 help=
'JSON file of rates for use with the RuleBook')
28 parser.add_argument(
'--userDetails',
29 help=
'User supplied metadata string giving any extra details about this run.')
30 parser.add_argument(
'--jira',
31 help=
'Related jira ticket number')
32 parser.add_argument(
'--amiTag',
33 help=
'AMI tag used for data reprocessing')
35 args = parser.parse_args()
36 log = logging.getLogger(
'RatesPostProcessing')
38 inputFile = ROOT.TFile(args.file,
'READ')
41 normHist = inputFile.Get(
'normalisation')
43 if normHist
is None or metadata
is None:
44 log.error(
'Cannot locate normHist, or metadata in top level of ntuple.')
47 metadata[
'normalisation'] = normHist.GetBinContent(1)
48 metadata[
'n_evts'] = normHist.GetBinContent(2)
49 metadata[
'details'] = args.userDetails
50 metadata[
'JIRA'] = args.jira
51 metadata[
'amiTag'] = args.amiTag
57 HLTTriggers =
populateTriggers(inputFile, metadata, HLTGlobalGroup,
'ChainHLT')
58 AllGlobalGroups =
populateTriggers(inputFile, metadata, HLTGlobalGroup,
'Group')
60 if not L1Triggers
or not HLTTriggers
or not AllGlobalGroups:
61 log.error(
"Failed to populate triggers")
68 log.info(
"Exporting " + args.outputJSONFile)
69 toJson(args.outputJSONFile, metadata, L1Triggers, HLTTriggers)
70 log.info(
"Exporting " + HLTTable)
71 toCSV(HLTTable, metadata, HLTTriggers)
72 log.info(
"Exporting " + L1Table)
73 toCSV(L1Table, metadata, L1Triggers)
74 log.info(
"Exporting " + GroupTable)
75 toCSV(GroupTable, metadata, AllGlobalGroups)