Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
compareNtuple.py
Go to the documentation of this file.
1 #!/bin/env python
2 
3 # Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
4 
5 import os,sys
6 sys.argv += [ '-b' ] # tell ROOT to not use graphics
7 from ROOT import TFile,TTree
8 from PROCTools.diffTAGTree import diffTTree
9 #import re
10 
11 os.environ['STAGE_SVCCLASS']="atlascerngroupdisk"
12 os.environ['STAGE_HOST']="castoratlast3"
13 
14 ignoreTrees=set(("CollectionMetadata",))
15 
16 if __name__ == "__main__":
17  if len(sys.argv)<4 or sys.argv[1]=="-h" or sys.argv[1]=="--help":
18  print ("Usage: compareNtuple.py ntuple1 ntuple2")
19  print (" Example: compareTCTs.py /castor/cern.ch/user/m/mlimper/ntuple1.root /castor/cern.ch/user/m/mlimper/ntuple2.root")
20  sys.exit(-1)
21 
22  rName = sys.argv[1]
23  vName = sys.argv[2]
24 
25  if rName.startswith("/castor"):
26  rFile=TFile.Open("root://castoratlas/"+rName)
27  else:
28  rFile=TFile.Open(rName)
29 
30  if vName.startswith("/castor"):
31  vFile=TFile.Open("root://castoratlas/"+vName)
32  else:
33  vFile=TFile.Open(vName)
34 
35  if rFile is None:
36  print ("Failed to open reference file",rName)
37 
38  if vFile is None:
39  print ("Failed to open validation file",vName)
40 
41  rKeys=set()
42  for k in rFile.GetListOfKeys():
43  rKeys.add(k.GetName())
44  vKeys=set()
45  for k in vFile.GetListOfKeys():
46  vKeys.add(k.GetName())
47  #print (rKeys)
48  #print (vKeys)
49  keys=rKeys & vKeys
50  keys -= ignoreTrees
51 
52  if len(keys)==0:
53  print ("ERROR no common trees names found in files",rName,vName)
54 
55  nGood=0
56  nBad=0
57  for k in keys:
58  rTree=rFile.Get(k)
59  vTree=vFile.Get(k)
60  if not isinstance(rTree,TTree):
61  continue
62  if not isinstance(vTree,TTree):
63  continue
64  print ("Comparing TTree",k)
65  (good,bad)=diffTTree(rTree,vTree)
66  nGood+=good
67  nBad+=bad
68 
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
python.diffTAGTree.diffTTree
def diffTTree(tOld, tNew, details=None)
Definition: diffTAGTree.py:12