ATLAS Offline Software
Loading...
Searching...
No Matches
ilumi2histo Namespace Reference

Functions

 ilumi2histo (ifile, ofile, relunc=3.2)
 Read in a ilumicalc file and output a file with a histogram that contains the luminosity per run.

Variables

 parser = argparse.ArgumentParser()
 read options
 help
 dest
 default
 config = parser.parse_args()

Function Documentation

◆ ilumi2histo()

ilumi2histo.ilumi2histo ( ifile,
ofile,
relunc = 3.2 )

Read in a ilumicalc file and output a file with a histogram that contains the luminosity per run.

Definition at line 6 of file ilumi2histo.py.

6def ilumi2histo(ifile, ofile, relunc=3.2):
7 """!
8 Read in a ilumicalc file and output a file with a histogram that contains the
9 luminosity per run.
10 """
11 lumi_map = {}
12
13 try:
14 m_file = TFile.Open(ifile,'read')
15
16 for k in m_file.GetListOfKeys():
17 if '_intlumi' in k.GetName():
18
19 run = m_file.Get(k.GetName()).GetTitle().split()[-1]
20
21 #OLD WAY (look at histogram title)
22 #if not 'Delivered' in m_file.Get(k.GetName()).GetTitle():
23 # print 'WARNING : No lumi provided for run ',run
24 # continue
25 #lumi = m_file.Get(k.GetName()).GetTitle().split('=')[1]
26 #lumi = float(lumi.split('/')[0])
27
28
29 #NEW WAY (look at last filled bin)
30 h = m_file.Get(k.GetName())
31 lumi = h.GetBinContent( h.GetNbinsX()-9 )
32
33 lumi_map[run] = float(lumi)*1e-6
34
35 except IOError as e:
36 print('IlumiCalc file not found!')
37 print(os.strerror(e.errno))
38
39
40 lumi_histo = TH1F('lumi_histo',';;Int. Luminosity [pb]',len(lumi_map.keys()),0.,float(len(lumi_map.keys())))
41 lumi_histo.Sumw2()
42
43 ib=1
44 lsrt = lumi_map.keys()
45 lsrt.sort()
46 for k in lsrt:
47 lumi_histo.SetBinContent(ib, float(lumi_map[k]))
48 if relunc > 0:
49 lumi_histo.SetBinError(ib, float(lumi_map[k])*float(relunc)/100.)
50 lumi_histo.GetXaxis().SetBinLabel(ib, k)
51 ib+=1
52
53 lumi_histo.SaveAs(ofile)
54
55
void print(char *figname, TCanvas *c1)
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:177

Variable Documentation

◆ config

ilumi2histo.config = parser.parse_args()

Definition at line 64 of file ilumi2histo.py.

◆ default

ilumi2histo.default

Definition at line 60 of file ilumi2histo.py.

◆ dest

ilumi2histo.dest

Definition at line 60 of file ilumi2histo.py.

◆ help

ilumi2histo.help

Definition at line 60 of file ilumi2histo.py.

◆ parser

ilumi2histo.parser = argparse.ArgumentParser()

read options

Definition at line 59 of file ilumi2histo.py.