ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/CMSSW/PhysicsTools/PythonAnalysis/python/cmstools.py
Revision: 1.3
Committed: Sun Oct 15 18:10:33 2006 UTC (18 years, 6 months ago) by hegner
Content type: text/x-python
Branch: MAIN
Changes since 1.2: +0 -8 lines
Log Message:
removed double import of root

File Contents

# User Rev Content
1 hegner 1.1 """Python helper tools for CMS FWLite
2    
3     benedikt.hegner@cern.ch
4    
5     """
6    
7     ### define tab completion
8     try:
9     import readline, cmscompleter
10     readline.parse_and_bind('tab: complete')
11     except:
12     print 'WARNING: Could not load tab completion'
13    
14    
15     ### workaround iterator generators for ROOT classes
16     def all(container):
17    
18     # loop over ROOT::TTree and similar
19     if hasattr(container,'GetEntries'):
20     try:
21     entries = container.GetEntries()
22     for entry in xrange(entries):
23     yield entry
24     except:
25     pass
26    
27     # loop over std::vectors and similar
28     elif hasattr(container, 'size'):
29     try:
30     entries = container.size()
31     for entry in xrange(entries):
32     yield container[entry]
33     except:
34     pass