plot_timing_data.py
Go to the documentation of this file.
1 #!/bin/env python
2 
3 from ROOT import *
4 
5 import code
6 
7 gROOT.Macro('~/rootlogon.C')
8 
9 gs = [] # globals
10 
11 times = {} # Map from tuple to list of times
12 
13 
14 def time_format(hrs):
15  if hrs < 1: return str(int(hrs*60+.5))+'m'
16  return str(int(hrs))+'h'+str(int(hrs*60+.5)%60)+'m'
17 
18 # Skips blank entries without superfluous spaces
20  if len(vec) == 0: return ''
21  if len(vec) == 1: return vec[0]
22  if vec[0] == '': return join_with_spaces(vec[1:])
23  return vec[0]+' '+join_with_spaces(vec[1:])
24 
25 
26 for line in open('timing_data.txt'):
27  try:
28  fname, time = line[:-1].split(' ')
29  except:
30  print 'Invalid line:'
31  print ' ', line
32  continue
33 
34  det = ''
35  if 'fd' in fname or 'fardet' in fname: det = 'Far detector'
36  if 'nd' in fname or 'neardet' in fname: det = 'Near detector'
37  if det == '': print 'Unknown detector: ', fname
38 
39  datamc = ''
40  if 'sim' in fname: datamc = 'MC'
41  if 'data' in fname: datamc = 'Data'
42  if datamc == '': print 'Unknown data/MC: ', fname
43 
44  horn = ''
45  if 'fhc' in fname: horn = 'FHC'
46  if 'rhc' in fname: horn = 'RHC'
47  if 'cosmics' in fname or 't02' in fname: horn = 'Cosmics'
48  if 't00' in fname: horn = 'NuMI'
49  if horn == '': print 'Unknown horn: ', fname
50 
51  swap = ''
52  if 'swap' in fname: swap = 'fluxswap'
53  if 'nonswap' in fname: swap = 'nonswap'
54  if 'tau' in fname: swap = 'tau'
55  if datamc != 'Data' and horn != 'Cosmics' and swap == '':
56  print 'Unknown swap ', fname
57 
58  version = ''
59  if 'v1' in fname: version = 'v1'
60  if 'v2' in fname: version = 'v2'
61  if 'v3' in fname: version = 'v3'
62  if 'v4' in fname: version = 'v4'
63  if 'v5' in fname: version = 'v5'
64  if 'v6' in fname: version = 'v6'
65  if 'v7' in fname: version = 'v7'
66  if 'v8' in fname: version = 'v8'
67  if 'v9' in fname: version = 'v9'
68  if version == '': print 'Unknown version ', fname
69 
70  release = ''
71  if 'S' in fname:
72  release = fname[fname.find('S'):fname.find('S')+9]
73  else:
74  release = fname[fname.find('FA'):fname.find('FA')+10]
75  if release == '': print 'Unknown release ', fname
76 
77  mrcc = ''
78  if 'mrcclemsum' in fname: mrcc = 'MRCC'
79  if 'mrelemsum' in fname: mrcc = 'MRE'
80 
81  special = ''
82  if 'geojittered' in fname: special = 'geojittered'
83  if 'nomask' in fname: special = 'nomask'
84  if 'calib_shift_nominal' in fname: special = 'calib_shift_nominal'
85  if 'calib_shift_cell' in fname: special = 'calib_shift_cell'
86  if 'calib_shift20pc' in fname: special = 'calib_shift20pc'
87  if 'calib_shift20dn' in fname: special = 'calib_shift20dn'
88  if 'calib_shift_slope20up' in fname: special = 'calib_shift_slope20up'
89  if 'calib_shift_slope20dn' in fname: special = 'calib_shift_slope20dn'
90  if 'FTF_BIC' in fname: special = 'FTF_BIC'
91  if 'QGSP_BIC_HP' in fname: special = 'QGSP_BIC_HP'
92 
93  title = join_with_spaces([det, horn, swap, special, mrcc, release, datamc])
94 
95  times.setdefault(title, []).append(float(time)/(60*60)) # convert to hours
96 
97 total_time = 0
98 
99 for title in times:
100  fname = 'plots/'+title.lower().replace(' ', '_')
101 
102  gs.append(TCanvas())
103  c = gs[-1]
104 
105  gs.append(TH1F('', title+';Hours to process through LEM;Number of files', 24*60, 0, 24))
106  h = gs[-1]
107 
108  for t in times[title]:
109  h.Fill(t)
110  total_time += t
111  h.Draw()
112 
113  mean = h.GetMean()
114 
115 # rebin = int((3*mean)/100)
116 # if rebin > 1: h.Rebin(rebin)
117 
118 # gPad.SetLogy(True)
119 # gPad.Print(fname+'_log.eps')
120 # gPad.SetLogy(False)
121 
122  h.GetXaxis().SetRangeUser(0, mean*3)
123 
124  gs.append(TLatex(.6, .8, 'Total files '+str(len(times[title]))))
125  lat = gs[-1]
126  lat.SetNDC()
127  lat.Draw()
128 
129  gs.append(TLatex(.6, .7, 'Average time '+time_format(mean)))
130  lat = gs[-1]
131  lat.SetNDC()
132  lat.Draw()
133 
134  gPad.Print(fname+'.eps')
135  gPad.Print(fname+'.png')
136 
137  c.Update()
138 
139 
140  print title, len(times[title]), mean
141 
142 
143 print 'Total hours', total_time
144 
145 # Just want the console to hang around so the user can look at the plots
146 # without them disappearing. Ctrl-D or "exit()" to quit.
147 code.interact(local = locals())
void split(double tt, double *fr)
def join_with_spaces(vec)
procfile open("FD_BRL_v0.txt")