ATLAS Offline Software
sizes.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
2 
3 import ROOT
4 import AtlasStyle
5 import ami
6 import sys
7 import datetime
8 
9 c1 = ROOT.TCanvas('c1', '', 400, 400)
10 
11 location = '/disk/homedisk/home/sjh2/public_web/twiki/'
12 derivationTag = 'p1851'
13 
14 def printTable(out, stream, quantity, topq1Only=False):
15  toGB = 1.
16  if quantity == 'totalSize':
17  toGB = 1. / 1000. / 1000. / 1000.
18 
19  primaryxAOD = ami.askAmi('data12_8TeV.*' + stream + '.merge.AOD.r572*_p1751_p2309', quantity)
20  topq1_round1 = ami.askAmi('data12_8TeV.*' + stream + '*DAOD_TOPQ1*' + derivationTag, quantity)
21 
22  topq2_round1 = {}
23  if not topq1Only:
24  topq2_round1 = ami.askAmi('data12_8TeV.*' + stream + '*DAOD_TOPQ2*' + derivationTag, quantity)
25 
26  h_topq1_frac = ROOT.TH1D('h_topq1_frac', ';TOPQ1 Size / Primary Size [%];Number of datasets', 20, 0, 10)
27  h_topq2_frac = ROOT.TH1D('h_topq2_frac', ';TOPQ2 Size / Primary Size [%];Number of datasets', 20, 0, 1)
28 
29  h_topq1_abs = ROOT.TH1D('h_topq1_abs', ';TOPQ1 Size [GB];Number of datasets', 20, 0, 200)
30  h_topq2_abs = ROOT.TH1D('h_topq2_abs', ';TOPQ2 Size [GB];Number of datasets', 30, 0, 15)
31 
32  out.write('---+ !%s\n' % stream)
33  if not topq1Only:
34  out.write('| *%s* | *%s* | *%s* | *%s* | *%s* | *%s* |\n' % ('Primary xAOD name', 'Size [GB]', 'TOPQ1 size [GB]', '%', 'TOPQ2 size [GB]', '%'))
35  else:
36  out.write('| *%s* | *%s* | *%s* | *%s* |\n' % ('Primary xAOD name', 'Size [GB]', 'TOPQ1 size [GB]', '%'))
37 
38  tot_prim = 0
39  tot_topq1 = 0
40  tot_topq2 = 0
41  for k in sorted(primaryxAOD.keys()):
42  primaryNum = primaryxAOD[k] * toGB
43 
44  topq1_name = k.replace('AOD', 'DAOD_TOPQ1') + '_' + derivationTag
45  topq1Num = -1
46  if topq1_round1.has_key(topq1_name):
47  topq1Num = topq1_round1[topq1_name] * toGB
48 
49  topq2_name = k.replace('AOD', 'DAOD_TOPQ2') + '_' + derivationTag
50  topq2Num = -1
51  if topq2_round1.has_key(topq2_name):
52  topq2Num = topq2_round1[topq2_name] * toGB
53 
54  note = ''
55 
56  cstart = '%RED%'
57  cend = "%ENDCOLOR%"
58 
59  topq1Frac = 0
60  topq2Frac = 0
61  if topq1Num > 0:
62  tot_prim += primaryNum
63  tot_topq1 += topq1Num
64  topq1Frac = 100. * topq1Num / primaryNum
65  h_topq1_frac.Fill(topq1Frac)
66  h_topq1_abs.Fill(topq1Num)
67  cstart= ''
68  cend = ''
69  topq1Num = cstart + ('%4.2f' % topq1Num) + cend
70  topq1Frac = cstart + ('%4.2f' % topq1Frac) + cend
71  else:
72  topq1Num = cstart + '-' + cend
73  topq1Frac = cstart + '-' + cend
74 
75  if topq2Num > 0:
76  tot_topq2 += topq2Num
77  topq2Frac = 100. * topq2Num / primaryNum
78  h_topq2_frac.Fill(topq2Frac)
79  h_topq2_abs.Fill(topq2Num)
80  cstart = ''
81  cend = ''
82  topq2Num = cstart + ('%4.2f' % topq2Num) + cend
83  topq2Frac = cstart + ('%4.2f' % topq2Frac) + cend
84  else:
85  topq2Num = cstart + '-' + cend
86  topq2Frac = cstart + '-' + cend
87 
88  k = cstart + k + cend
89  primaryNum = cstart + ('%4.2f' % primaryNum) + cend
90 
91  if not topq1Only:
92  txt = '| %s | %s | %s | %s | %s | %s |\n' % (k, primaryNum, topq1Num, topq1Frac, topq2Num, topq2Frac)
93  else:
94  txt = '| %s | %s | %s | %s |\n' % (k, primaryNum, topq1Num, topq1Frac)
95 
96  out.write(txt)
97 
98  if not topq1Only:
99  txt = '| total (only include primary that have derivation) | %4.2f | %4.2f | %4.2f | %4.2f | %4.2f |\n' % (tot_prim, tot_topq1, 100. * tot_topq1 / tot_prim, tot_topq2, 100. * tot_topq2 / tot_prim)
100  else:
101  txt = '| total (only include primary that have derivation) | %4.2f | %4.2f | %4.2f |\n' % (tot_prim, tot_topq1, 100. * tot_topq1 / tot_prim)
102 
103  out.write(txt)
104  out.write('\n')
105 
106  name = stream + '_topq1_abs.gif'
107  h_topq1_abs.SetFillColor(ROOT.kRed)
108  h_topq1_abs.Draw('hist')
109  c1.Print(location + name)
110  out.write('http://epweb2.ph.bham.ac.uk/user/head/twiki/%s\n' % name)
111 
112  name = stream + '_topq1_frac.gif'
113  h_topq1_frac.SetFillColor(ROOT.kRed)
114  h_topq1_frac.Draw('hist')
115  c1.Print(location + name)
116  out.write('http://epweb2.ph.bham.ac.uk/user/head/twiki/%s\n' % name)
117 
118  if not topq1Only:
119  name = stream + '_topq2_abs.gif'
120  h_topq2_abs.SetFillColor(ROOT.kRed)
121  h_topq2_abs.Draw('hist')
122  c1.Print(location + name)
123  out.write('http://epweb2.ph.bham.ac.uk/user/head/twiki/%s\n' % name)
124 
125  name = stream + '_topq2_frac.gif'
126  h_topq2_frac.SetFillColor(ROOT.kRed)
127  h_topq2_frac.Draw('hist')
128  c1.Print(location + name)
129  out.write('http://epweb2.ph.bham.ac.uk/user/head/twiki/%s\n' % name)
130 
131 if __name__ == "__main__":
132  qunatityFromAmi = 'totalEvents'
133  qunatityFromAmi = 'totalSize'
134 
135  out = open(location + 'derivation_progress.html', 'w')
136  out.write('%TOC%\n')
137 
138  d_string = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
139 
140  out.write('---+ Introduction\n')
141  txt = '''
142  Generated: %s
143 
144  Hello, this page lists the most recent round of top derivations for DC14 (2012 Period B, about 5 fb-1).
145 
146  For more information on which containers are kept and the cuts that are applied in TOPQ1, and TOPQ2, see TopDerivations)
147 
148  The p-tag used for this page is %s
149 
150  You can find derivations on rucio with:
151  =rucio list-dids data12_8TeV:*DAOD_TOPQ1*p1851= (or =TOPQ2=)
152 
153  ''' % (d_string, derivationTag)
154  out.write(txt + '\n')
155 
156  printTable(out, 'Egamma', qunatityFromAmi)
157  printTable(out, 'Muons', qunatityFromAmi)
158  printTable(out, 'JetTauEtmiss', qunatityFromAmi, True)
159  out.close()
DerivationFramework::TriggerMatchingUtils::sorted
std::vector< typename T::value_type > sorted(T begin, T end)
Helper function to create a sorted vector from an unsorted one.
Trk::open
@ open
Definition: BinningType.h:40
python.sizes.printTable
def printTable(out, stream, quantity, topq1Only=False)
Definition: sizes.py:14