ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/CMSSW/PhysicsTools/PythonAnalysis/python/cmstools.py
Revision: 1.1
Committed: Wed Mar 22 13:40:36 2006 UTC (19 years, 1 month ago) by hegner
Content type: text/x-python
Branch: MAIN
CVS Tags: CMSSW_0_6_1, CMSSW_0_7_0_pre2, CMSSW_0_7_0_pre1, CMSSW_0_6_0, CMSSW_0_6_0_pre7, CMSSW_0_6_0_pre6, CMSSW_0_6_0_pre5, CMSSW_0_6_0_pre4, CMSSW_0_6_0_pre3, CMSSW_0_6_0_pre2, V00-00-03, V00-00-02
Log Message:
New helper classes implemented

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
35    
36    
37     ### prepare the environment
38     ### (will be changed for ROOT 5.10)
39     print 'Loading FWLite...'
40     from ROOT import *
41     gSystem.Load('libPhysicsToolsFWLite')
42     AutoLibraryLoader.enable()