Skip to content

Commit 9c06de7

Browse files
committed
Add small script for logging the output of the trees. Can be used to check the impact of changes in the framework on the output variables
1 parent fc8a99f commit 9c06de7

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

test/compare_output.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#Loop over all branches in the two output trees and get Mean and RMS. Can be used to compare it to another (previous) output file to see impact of changes
2+
# Use it like: python compare_output.py <file1.root> -b
3+
# Use it like: python compare_output.py <file2.root> -b
4+
# Check diff with: diff <file1.log> <file2.log>
5+
6+
from ROOT import TFile, TTree, TH1
7+
8+
import sys
9+
10+
def compare_output():
11+
fileName = sys.argv[1]
12+
outfileName = fileName[:-4] + "log"
13+
output = open(outfileName, "w")
14+
file = TFile(fileName, 'READ')
15+
tree = file.Get('btagana/ttree')
16+
if(tree):
17+
for branch in tree.GetListOfBranches():
18+
branchname = branch.GetName()
19+
tree.Draw(branchname + '>>hist')
20+
mean = file.Get('hist').GetMean()
21+
rms = file.Get('hist').GetRMS()
22+
output.write('{}: {} {}\n'.format(branchname, mean, rms))
23+
24+
tree = file.Get('btaganaFatJets/ttree')
25+
if(tree):
26+
for branch in tree.GetListOfBranches():
27+
branchname = branch.GetName()
28+
tree.Draw(branchname + '>>hist')
29+
mean = file.Get('hist').GetMean()
30+
rms = file.Get('hist').GetRMS()
31+
output.write('{}: {} {}\n'.format(branchname, mean, rms))
32+
33+
output.close()
34+
print('Output written to {}'.format(outfileName))
35+
36+
37+
if __name__ == '__main__':
38+
compare_output()
39+

0 commit comments

Comments
 (0)