8 Read in a ilumicalc file and output a file with a histogram that contains the
14 m_file = TFile.Open(ifile,
'read')
16 for k
in m_file.GetListOfKeys():
17 if '_intlumi' in k.GetName():
19 run = m_file.Get(k.GetName()).GetTitle().
split()[-1]
30 h = m_file.Get(k.GetName())
31 lumi = h.GetBinContent( h.GetNbinsX()-9 )
33 lumi_map[run] =
float(lumi)*1e-6
36 print(
'IlumiCalc file not found!')
37 print(os.strerror(e.errno))
40 lumi_histo =
TH1F(
'lumi_histo',
';;Int. Luminosity [pb]',len(lumi_map.keys()),0.,
float(len(lumi_map.keys())))
44 lsrt = lumi_map.keys()
47 lumi_histo.SetBinContent(ib,
float(lumi_map[k]))
49 lumi_histo.SetBinError(ib,
float(lumi_map[k])*
float(relunc)/100.)
50 lumi_histo.GetXaxis().SetBinLabel(ib, k)
53 lumi_histo.SaveAs(ofile)
56 if __name__ ==
'__main__':
59 parser = argparse.ArgumentParser()
60 parser.add_argument(
'--ifile', help=
'input ilumicalc file', dest=
'ifile', default=
'')
61 parser.add_argument(
'--ofile', help=
'output file', dest=
'ofile', default=
'ilumi2histo.root')
62 parser.add_argument(
'--relunc', help=
'luminosity relative uncertainty [%]', dest=
'relunc', default=3.2)
64 config = parser.parse_args()
67 sys.exit(
'** You need to provide an iLumiCalc input file!')
70 ilumi2histo(config.ifile, config.ofile, config.relunc)