ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/dhidas/OSUAnalysis/Tools/scripts/nTupleInfo.py
Revision: 1.1
Committed: Thu Dec 1 16:28:48 2011 UTC (13 years, 5 months ago) by dhidas
Content type: text/x-python
Branch point for: dhidas, MAIN
Log Message:
Initial revision

File Contents

# User Rev Content
1 dhidas 1.1 '''
2     Created on Mar 5, 2011
3    
4     @author: lkreczko
5     '''
6     from __future__ import division
7     from ROOT import *
8    
9     def getBranchInfo(listOfBranches):
10     branches = []
11     bapp = branches.append
12     for branch in listOfBranches:
13     info = {}
14     info['name'] = branch.GetName()
15     info['totalSize'] = branch.GetTotalSize()
16     info['totalBytes'] = branch.GetTotBytes()
17     info['zippedBytes'] = branch.GetZipBytes()
18     bapp(info)
19     return branches
20    
21    
22     def printTwikiTable(branches, filesize):
23    
24     prevObj = ' '
25     info = {}
26     info['totalSize'] = 0
27     info['zippedBytes'] = 0
28     info['totalBytes'] = 0
29     for branch in sorted(branches):
30     name = branch['name']
31     size = branch['totalSize'] / 1024 / 1024 #MB
32     zipSize = branch['zippedBytes'] / 1024 / 1024#MB
33     compression = size / zipSize
34     totalBytes = branch['totalBytes'] / 1024 / 1024#MB
35     buffer = (size - totalBytes) * 1024#KB
36     fraction = zipSize / filesize * 100#%
37    
38     obj = ' '
39     if '.' in name:
40     obj = name.split('.')[0] + '.'
41     else:
42     obj = name.capitalize()
43    
44     if not name.startswith(prevObj):
45     if '.' in prevObj:
46     Osize = info['totalSize']
47     OzipSize = info['zippedBytes']
48     Ocompression = Osize / OzipSize
49     Obuffer = (size - info['totalBytes'] / 1024 / 1024) * 1024#KB
50     Ofraction = OzipSize / filesize * 100
51     print '| *Total* | %.3f | %.3f | %.2f | %.3f | %.2f%% |' % (Osize, OzipSize, Ocompression, Obuffer, Ofraction)
52     print
53     #print summary
54     print '---+++ %s' % obj.replace('.', '')
55     print '| *%s* ||||||' % obj.replace('.', '')
56     print '| *Name* | *Total Size (MB)* | *Compressed size (MB)* | *compression factor* | *Buffer (KB)* | *Fraction of file size* |'
57     info['totalSize'] = 0
58     info['zippedBytes'] = 0
59     info['totalBytes'] = 0
60     else:
61     info['totalSize'] += size
62     info['zippedBytes'] += zipSize
63     info['totalBytes'] += totalBytes
64     print '| !%s | %.3f | %.3f | %.2f | %.3f | %.2f%% |' % (name, size, zipSize, compression, buffer, fraction)
65     prevObj = obj
66    
67     if __name__ == '__main__':
68     gROOT.SetBatch(1);
69     chain = TChain("rootTupleTree/tree");
70    
71     #chain.Add("/storage/TopQuarkGroup/mc/Spring11/TTJets_TuneD6T_7TeV-madgraph-tauola_Spring11-PU_S1_START311_V1G1-v1/LQNTuple_TTJets_merged_1.root");
72     chain.Add("/storage/TopQuarkGroup/mc/fall10_7TeV_v1_e25skim/TTJets_TuneD6T_7TeV-madgraph-tauola_Fall10-START38_V12-v2/nTuple_ttjet_merged_1.root");
73     filesize = chain.GetFile().GetSize() / 1024 / 1024#MB
74    
75     branches = getBranchInfo(chain.GetListOfBranches())
76     numberOfEvents = chain.GetEntries()
77     print '---++ MC content'
78     print 'Size of event: %.3f KB' % (filesize/numberOfEvents*1024)
79     printTwikiTable(branches, filesize)
80    
81     chain = TChain("rootTupleTree/tree");
82     #chain.Add("/storage/TopQuarkGroup/data/Run2011A-PromptReco-v2/*_1.root");
83     chain.Add("/storage/TopQuarkGroup/data/Nov4ReReco_JEC_Spring_V8_36.145pb_e25skim/Run2010B/*_1.root");
84     filesize = chain.GetFile().GetSize() / 1024 / 1024#MB
85    
86     branches = getBranchInfo(chain.GetListOfBranches())
87    
88     print '---++ DATA content'
89     print 'Size of event: %.3f KB' % (filesize/numberOfEvents*1024)
90     printTwikiTable(branches, filesize)