ATLAS Offline Software
Functions
python.ParseTrkSummary Namespace Reference

Functions

def getCollectionName (line)
 
def parseSummaryFile (filename='trkSummary.txt', makePlots=False)
 
def plotSummariesForCollection (filename='test.png', collection='MooreTracks', summaries=[], times=[])
 

Function Documentation

◆ getCollectionName()

def python.ParseTrkSummary.getCollectionName (   line)

Definition at line 5 of file ParseTrkSummary.py.

5 def getCollectionName(line):
6  begin = line.find("=")
7  collection = line[begin+2:]
8  #print ("Line:", line)
9  #print ("collection: '%s'" % collection.strip())
10  return collection.strip()
11 
12 # To use this, do e.g.
13 # summary = ParseTrkSummary.parseSummaryFile()
14 # summary.get('MooreTracks').get('Trk/Evt')

◆ parseSummaryFile()

def python.ParseTrkSummary.parseSummaryFile (   filename = 'trkSummary.txt',
  makePlots = False 
)

Definition at line 15 of file ParseTrkSummary.py.

15 def parseSummaryFile(filename='trkSummary.txt', makePlots=False):
16  import os
17  filename=os.path.expanduser(filename)
18  if filename.endswith('.gz'):
19  import gzip
20  fh = gzip.open(filename,'r')
21  else:
22  fh = open(filename,'r')
23 
24  collectionName=""
25  lineIt = iter(fh)
26  summary = dict()
27  while True:
28  try:
29  line = lineIt.next()
30  if line[0]!='>' and line[0]!='|':#Ignore most lines with minimal overhead (safe since empty lines still have '\n')
31  continue
32  if line[0:4]==">>>>":
33  collectionName = getCollectionName(line)
34  #print ("collection: '%s'" % collectionName)
35  continue
36 
37  if line[0:2]=="||":
38  firstline=line.strip().removeprefix("||")
39  # get rid of spaces around each 'key', where we get the keys by splitting the line at the '||' boundaries
40  keys = [key.strip() for key in firstline.split("||")]
41  nextLine = lineIt.next()
42  secondline=nextLine.strip().removeprefix("||")
43  # get rid of spaces around each 'value', where we get the values by splitting the line at the '||' boundaries
44  values = [float(value.strip()) for value in secondline.split("||")]
45  info = dict(zip(keys,values))
46  summary[collectionName]=info
47 
48  except StopIteration:
49  break
50  print ("Found data for the following collections: ", summary.keys())
51  if makePlots:
52  from PmbUtils.ValuePerDomainCalcUtils import PlottableResult, JobListPlotter, TimeLabel
53  title = 'MooreTracks ( %s events)' % int(summary['MooreTracks'].get('Events'))
54  result = PlottableResult(summary['MooreTracks'].keys(), title=title)
55  # We don't want the large values of the following to dominate the results (and anyway, they're redundant)
56  exclusions = ["Events", "Tracks"]
57  for key in summary['MooreTracks'].keys():
58  if (key not in exclusions):
59  result.addPoint(colname=key, value=summary['MooreTracks'].get(key), time=TimeLabel(label="Now",sortvalue=0))
60  JobListPlotter().produceTimeDevelopmentPlot(result,"test.png")
61  return summary
62 

◆ plotSummariesForCollection()

def python.ParseTrkSummary.plotSummariesForCollection (   filename = 'test.png',
  collection = 'MooreTracks',
  summaries = [],
  times = [] 
)

Definition at line 63 of file ParseTrkSummary.py.

63 def plotSummariesForCollection(filename='test.png', collection='MooreTracks', summaries=[], times=[]):
64  from PmbUtils.ValuePerDomainCalcUtils import PlottableResult, JobListPlotter, TimeLabel
65  firstSummary = summaries[0]
66 
67  title = '%s ( %s events)' % (collection, int(firstSummary[collection].get('Events')) )
68  print ('Making plot for %s with %s summaries' % (title, len(summaries)))
69  result = PlottableResult(firstSummary[collection].keys(), title=title)
70  i=0
71  for summary in summaries:
72  i+=1
73  # We don't want the large values of the following to dominate the results (and anyway, they're redundant)
74  exclusions = ["Events", "Tracks"]
75  for key in summary[collection].keys():
76  if (key not in exclusions):
77  print (i)
78  result.addPoint(colname=key, value=summary[collection].get(key), time=TimeLabel(label=times[i],sortvalue=i))
79  print ("result.getNColumns()", result.getNColumns())
80  print ("result.getTimes()", result.getTimes())
81  JobListPlotter().produceTimeDevelopmentPlot(result,filename)
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
python.ParseTrkSummary.getCollectionName
def getCollectionName(line)
Definition: ParseTrkSummary.py:5
python.ParseTrkSummary.plotSummariesForCollection
def plotSummariesForCollection(filename='test.png', collection='MooreTracks', summaries=[], times=[])
Definition: ParseTrkSummary.py:63
python.ParseTrkSummary.parseSummaryFile
def parseSummaryFile(filename='trkSummary.txt', makePlots=False)
Definition: ParseTrkSummary.py:15
Trk::open
@ open
Definition: BinningType.h:40
get
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition: hcg.cxx:127
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:798
readCCLHist.float
float
Definition: readCCLHist.py:83