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