ATLAS Offline Software
plot_tot_times.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
2 from plot_times import times
3 import pylab as pl
4 import sys
5 import glob
6 from collections import defaultdict
7 import itertools
8 
9 if len(sys.argv) < 3:
10  print('Please supply an input file name stub to glob on the command line, and an output file name')
11  sys.exit(0)
12 
13 
14 stub = sys.argv[1]
15 outname = sys.argv[2]
16 if not outname.endswith('.pdf'): outname += '.pdf'
17 
18 fns = glob.glob(stub)
19 print('glob found %d files: %s for stub %s' % (len(fns), str(fns), stub))
20 if not fns:
21  print('no files found for stub', stub)
22  sys.exit()
23 
24 def get_tot(fn):
25  print('processing ', fn)
26  t = times(fn)
27  # return sum(t)/float(len(t))
28  return sum(t)
29 
30 
31 def get_nbkgd(fn):
32  print(fn)
33  x = fn.split('.')[0] # remove .log
34  toks = x.split('_')
35  x = [t for t in toks if t.startswith('b')][0]
36  x = x[1:] # remove 'b'
37  print(x)
38  return float(x)
39 
40 def plot_by_fn_type(fn_list, marker, label):
41  print('plotting', fn_list)
42 
43  tot_times = [get_tot(fn) for fn in fn_list]
44  n_bkgd = [get_nbkgd(fn) for fn in fn_list]
45  # pl.plot(n_bkgd, tot_times, marker = marker, label=label)
46  pl.plot(n_bkgd, tot_times, marker, label=label)
47 
48 fn_types = defaultdict(list)
49 
50 for fn in fns:
51  key = fn.split('_')
52  key = [k for k in key if k.startswith('j')]
53  key = '_'.join(key)
54  fn_types[key].append(fn)
55 
56 markers = itertools.cycle(('ro','bo'))
57 print()
58 print('fn_types:')
59 for k, v in fn_types.items():
60  print(k)
61  print(' ', v)
62 
63 print()
64 for k, v in fn_types.items():
65  print(k)
66  print(' ' + str(v))
67  plot_by_fn_type(v, next(markers), label=k)
68 
69 
70 pl.suptitle(outname[:-4])
71 pl.xlabel('n background')
72 pl.ylabel('tot exec time 1000 events (ns)')
73 pl.legend()
74 pl.savefig(outname)
75 pl.show()
plot_tot_times.get_tot
def get_tot(fn)
Definition: plot_tot_times.py:24
plot_tot_times.plot_by_fn_type
def plot_by_fn_type(fn_list, marker, label)
Definition: plot_tot_times.py:40
dumpHVPathFromNtuple.append
bool append
Definition: dumpHVPathFromNtuple.py:91
plot_tot_times.get_nbkgd
def get_nbkgd(fn)
Definition: plot_tot_times.py:31
convertTimingResiduals.sum
sum
Definition: convertTimingResiduals.py:55
fillPileUpNoiseLumi.next
next
Definition: fillPileUpNoiseLumi.py:52
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:25
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
str
Definition: BTagTrackIpAccessor.cxx:11
plot_times.times
def times(fn)
Definition: plot_times.py:10
python.LArMinBiasAlgConfig.float
float
Definition: LArMinBiasAlgConfig.py:65