ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/CMSSW/PhysicsTools/PythonAnalysis/scripts/edmDumpEventContent
Revision: 1.5
Committed: Tue Jul 20 19:45:47 2010 UTC (14 years, 9 months ago) by cplager
Branch: MAIN
CVS Tags: HEAD
Changes since 1.4: +0 -0 lines
State: FILE REMOVED
Log Message:
removing old version from old home

File Contents

# User Rev Content
1 lsexton 1.1 #!/usr/bin/env python
2    
3     import sys
4     import copy
5 cplager 1.4 import optparse
6     import re
7 lsexton 1.1
8    
9     class Branch(object):
10     pass
11    
12    
13     def branchType(branch):
14     type = cmstools.ROOT.branchToClass(branch).GetName()
15     if "edm::Wrapper" in type:
16     type = type.replace("edm::Wrapper<","").rstrip(">")
17     return type
18    
19    
20     def dumpBranches(filename):
21 cplager 1.4 events = cmstools.EventTree (filename)
22 lsexton 1.1 listOfBranches = events._tree.GetListOfBranches()
23 cplager 1.4 trailingDotRE = re.compile (r'\.$')
24 lsexton 1.1 branches = []
25 cplager 1.4 regexList = []
26     # are we asked to filter this list?
27     for regexString in options.regex:
28     #print "adding", regexString
29     regexList.append( re.compile( regexString, re.IGNORECASE ) )
30 lsexton 1.1 for branch in listOfBranches:
31 cplager 1.4 # print branch.GetName()
32     tmpBranch = Branch()
33     tmpBranch.fullname = branch.GetName()
34     tmpBranch.name = trailingDotRE.sub ('', tmpBranch.fullname)
35     if "EventAux" in tmpBranch.fullname:
36     continue
37     #print "found", tmpBranch.name
38     parts = tmpBranch.fullname.split("_")
39     tmpBranch.module = parts [1]
40     tmpBranch.label = parts [2]
41     tmpBranch.process = parts [3]
42     tmpBranch.type = branchType(branch)
43     tmpBranch.cpp = events.cppCode (tmpBranch.fullname)
44     # are there any matches to the regexList?
45     found = False
46     for regex in regexList:
47     # search the branch name
48     if regex.search (tmpBranch.name):
49     found = True
50     break
51     # search the type
52     if regex.search (tmpBranch.cpp):
53     found = True
54     break
55     # if there is a list and no matches
56     if regexList and not found:
57     continue
58     branches.append( copy.copy(tmpBranch) )
59     for branch in branches:
60     #continue
61     if options.name:
62     print branch.name
63     elif options.all:
64     print '%-30s %-20s %-10s %-15s : %s' % \
65     (branch.type,
66     '"' + branch.module + '"',
67     '"' + branch.label + '"',
68     '"' + branch.process + '"',
69     branch.name)
70     else:
71     print '%-30s %-20s %-10s %-15s' % \
72     (branch.type,
73     '"' + branch.module + '"',
74     '"' + branch.label + '"',
75     '"' + branch.process + '"')
76 lsexton 1.1
77    
78    
79     if __name__ == "__main__":
80    
81 cplager 1.4 parser = optparse.OptionParser \
82     ("usage: %prog [options] templates.root" \
83     "\nPrints out info on edm file.")
84     parser.add_option ('--name', dest='name', action='store_true',
85     help='print out only branch names')
86     parser.add_option ('--all', dest='all', action='store_true',
87     help='Print out everything: type, module, label, '\
88     'process, and branch name')
89     parser.add_option ("--regex", dest='regex', action="append",
90     type="string", default=[],
91     help="Filter results based on regex")
92     options, args = parser.parse_args()
93     if not args:
94     print parser.print_usage()
95     sys.exit()
96     try:
97     import PhysicsTools.PythonAnalysis as cmstools
98     ## # to let ROOT understand we are in batch mode
99     ## sys.argv.append( '-b-' )
100     import ROOT
101     ROOT.gROOT.SetBatch() # setting batch mode
102     ROOT.gSystem.Load("libFWCoreFWLite.so")
103     ROOT.AutoLibraryLoader.enable()
104     filename = args[0]
105     dumpBranches (filename)
106     except:
107     "Could not read %s" %filename
108 lsexton 1.1
109