ATLAS Offline Software
Functions | Variables
python.comparexAODDigest Namespace Reference

Functions

def extractData (filename)
 
def compare2Files (file1, file2, ignoredColumns=None)
 
def compareDigest (filelist)
 

Variables

 parser
 
 description
 
 nargs
 
 type
 
 help
 
 action
 
 default
 
 args
 
 ignored
 
 retval
 
 ignoredColumns
 

Function Documentation

◆ compare2Files()

def python.comparexAODDigest.compare2Files (   file1,
  file2,
  ignoredColumns = None 
)

Definition at line 24 of file comparexAODDigest.py.

24 def compare2Files(file1, file2, ignoredColumns=None):
25 
26  res1,h1=extractData(file1)
27  res2,h2=extractData(file2)
28 
29 
30  if (h1 != h2):
31  print("ERROR, headers don't match")
32  print(h1)
33  print(h2)
34  return 1
35 
36  runEvts = res1.keys()
37  if len(res2) < len(res1):
38  runEvts = res2.keys()
39 
40  diffCounter=dict()
41  for h in h1[2:]:
42  diffCounter[h]=0
43 
44  # Loop over events:
45  for runEvt in runEvts:
46  values1 = res1[runEvt]
47  values2 = res2[runEvt]
48  for i, name in enumerate(h1[2:]):
49  #print (name,i,len(values1),len(values2))
50  if values1[i] != values2[i]:
51  ignored = False
52  if ignoredColumns and name in ignoredColumns:
53  ignored = True
54  suffix = ' (ignored)' if ignored else ''
55  print ("Diff: Run {} Evt {} {} {} -> {}{}".format(runEvt[0],runEvt[1],name,values1[i],values2[i],suffix))
56  diffCounter[name]+=1
57  pass
58  pass
59  pass
60 
61  print("Summary of differences:")
62  noChanges=""
63  nEvt=len(runEvts)
64  changed = False
65  for (name,count) in diffCounter.items():
66  if (count>0):
67  #print (name,":",count,"(of ",nEvt,")")
68  print ("{}: {} events (out of {})".format(name,count,nEvt))
69  if not ignoredColumns or name not in ignoredColumns:
70  changed = True
71  else:
72  noChanges+=" "+name
73  if not changed:
74  print("No changes")
75  else:
76  print("No changes for:",noChanges)
77  return changed
78 
79 

◆ compareDigest()

def python.comparexAODDigest.compareDigest (   filelist)

Definition at line 80 of file comparexAODDigest.py.

80 def compareDigest(filelist):
81  if len(filelist)<2:
82  print("Got only %i files. Can't compare")
83  return None
84 
85  runevtset=set()
86 
87  summary=dict() #key is the datestamp
88 
89  for f in filelist:
90  datestamp=f.split('/')[9]
91  print("Fond file for %s" % datestamp)
92  header=None
93  if datestamp in summary:
94  print("ERROR, duplicate date-stamp %s" % datestamp)
95  continue
96 
97  res,hdr=extractData(f)
98  if header is None:
99  header=hdr
100  elif (header!=hdr):
101  print("ERROR, headers of file %s doesn't match!" % f)
102  continue
103 
104  summary[datestamp]=res
105  runevtset |= set(res.keys())
106  pass
107 
108 
109  #collected all data, now invert the matrix, sort per run/event
110  nValues=len(header)-2
111 
112  perEvt=dict()
113  for runevt in runevtset:
114  perEvt[runevt]=[]
115  for i in range(nValues):
116  perEvt[runevt].append(set())
117 
118  for day,data in summary.items():
119  for runevt,v in data.items():
120  for i in range(nValues):
121  perEvt[runevt][i].add(v[i])
122 
123 
124  row_format ="{:>12}" * len(header)
125  #row_format+=os.linesep
126  print (row_format.format(*header))
127  for runevt,v in perEvt.items():
128  updates=[runevt[0],runevt[1]]
129  updates+=[len(x)-1 for x in v]
130  print (row_format.format(*updates))
131 
132 

◆ extractData()

def python.comparexAODDigest.extractData (   filename)

Definition at line 7 of file comparexAODDigest.py.

7 def extractData(filename):
8 
9  result=dict()
10 
11  rein=open(filename)
12  for line in rein:
13  l=line.split()
14  if l[0]=='run':
15  header=l
16  else:
17  run=int(l[0])
18  evt=int(l[1])
19  result[(run,evt)]=[float(s) for s in l[2:]]
20  rein.close()
21  return result,header
22 
23 

Variable Documentation

◆ action

python.comparexAODDigest.action

Definition at line 137 of file comparexAODDigest.py.

◆ args

python.comparexAODDigest.args

Definition at line 143 of file comparexAODDigest.py.

◆ default

python.comparexAODDigest.default

Definition at line 139 of file comparexAODDigest.py.

◆ description

python.comparexAODDigest.description

Definition at line 135 of file comparexAODDigest.py.

◆ help

python.comparexAODDigest.help

Definition at line 137 of file comparexAODDigest.py.

◆ ignored

python.comparexAODDigest.ignored

Definition at line 145 of file comparexAODDigest.py.

◆ ignoredColumns

python.comparexAODDigest.ignoredColumns

Definition at line 151 of file comparexAODDigest.py.

◆ nargs

python.comparexAODDigest.nargs

Definition at line 136 of file comparexAODDigest.py.

◆ parser

python.comparexAODDigest.parser

Definition at line 134 of file comparexAODDigest.py.

◆ retval

python.comparexAODDigest.retval

Definition at line 151 of file comparexAODDigest.py.

◆ type

python.comparexAODDigest.type

Definition at line 136 of file comparexAODDigest.py.

vtune_athena.format
format
Definition: vtune_athena.py:14
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
python.comparexAODDigest.compare2Files
def compare2Files(file1, file2, ignoredColumns=None)
Definition: comparexAODDigest.py:24
python.comparexAODDigest.extractData
def extractData(filename)
Definition: comparexAODDigest.py:7
dumpHVPathFromNtuple.append
bool append
Definition: dumpHVPathFromNtuple.py:91
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
add
bool add(const std::string &hname, TKey *tobj)
Definition: fastadd.cxx:55
CxxUtils::set
constexpr std::enable_if_t< is_bitmask_v< E >, E & > set(E &lhs, E rhs)
Convenience function to set bits in a class enum bitmask.
Definition: bitmask.h:232
Trk::open
@ open
Definition: BinningType.h:40
dbg::print
void print(std::FILE *stream, std::format_string< Args... > fmt, Args &&... args)
Definition: SGImplSvc.cxx:70
readCCLHist.float
float
Definition: readCCLHist.py:83
python.comparexAODDigest.compareDigest
def compareDigest(filelist)
Definition: comparexAODDigest.py:80