ATLAS Offline Software
Loading...
Searching...
No Matches
trigDumpTimers.py
Go to the documentation of this file.
1#!/usr/bin/env python
2
3# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
4# @file: trigDumpTimers.py
5# @purpose: Script to dump the timing histograms from expert-monitoring.root/TIMERS
6# @author: Stewart Martin-Haugh
7
8import ROOT
9from optparse import OptionParser
10import re
11from TrigValTools.TrigRootUtils import lsroot
12
13def timing(hist):
14 mean = hist.GetMean()
15 error = hist.GetMeanError()
16 if hist.GetEntries() == 0:
17 return "0"
18 mean_plus_err = str(round(mean,3)) + " +/- " + str(round(error,3))
19 overflow = hist.GetBinContent(hist.GetNbinsX()+1)
20 if overflow == 0.0:
21 return mean_plus_err
22 else:
23 return mean_plus_err + "\tOverflow: " + str(overflow)
24
25def get_matches(pattern, exclude, noSkip, myFile):
26 names=lsroot(myFile)
27 regex = re.compile(".*" + pattern + ".*")
28 if exclude:
29 regex_exclude = re.compile(".*" + exclude + ".*")
30 for name in names:
31 if not noSkip:
32 #Run-3 timers always contain TIME or TotalTime
33 if "TIME" not in name:
34 if "TotalTime" not in name:
35 continue
36 if not regex.match(name):
37 continue
38 if exclude:
39 if regex_exclude.match(name):
40 continue
41 hist = myFile.Get(name)
42 if not hist.IsA().InheritsFrom( "TH1" ):
43 continue
44 print(name + " " + timing(hist))
45
46def main():
47 parser = OptionParser()
48 parser.add_option("-p", "--pattern", dest="pattern", type = "string", default = None,
49 help="Pattern to match histogram to")
50 parser.add_option("-x", "--exclude", dest="exclude", type = "string", default = None,
51 help="Pattern to exclude histogram from matching")
52 parser.add_option("-n", "--noSkip", dest="noSkip", action = "store_true",
53 help="Match all histograms (not just trigger timers)")
54 (options, args) = parser.parse_args()
55
56 for arg in args:
57 print(arg)
58 myFile = ROOT.TFile(arg)
59 pattern = ".*"
60 if (options.pattern):
61 pattern = options.pattern
62 get_matches(pattern, options.exclude, options.noSkip, myFile)
63
64
65if __name__ == "__main__":
66 main()
67
void print(char *figname, TCanvas *c1)
get_matches(pattern, exclude, noSkip, myFile)