ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/CMSSW/PhysicsTools/PythonAnalysis/examples/interactiveExample.py
Revision: 1.2
Committed: Wed Nov 1 11:17:59 2006 UTC (18 years, 6 months ago) by hegner
Content type: text/x-python
Branch: MAIN
CVS Tags: V00-01-03, V00-01-02
Changes since 1.1: +1 -1 lines
Log Message:
increased verbosity

File Contents

# User Rev Content
1 hegner 1.1 # example used in november CSA06 tutorial
2     # has to be called with python -i interactiveExample.py
3    
4     from cmstools import *
5     from ROOT import *
6    
7     # prepare the FWLite autoloading mechanism
8     gSystem.Load("libFWCoreFWLite.so")
9     AutoLibraryLoader.enable()
10    
11     # enable support for files > 2 GB
12     gSystem.Load("libIOPoolTFileAdaptor")
13     ui = TFileAdaptorUI()
14    
15    
16     # load the example file from castor
17     theFile = TFile.Open("castor:/castor/cern.ch/cms/store/CSA06/CSA06-106-os-Jets-0/AOD/CMSSW_1_0_6-AODSIM-H15a59ba7b4c3d9e291172f60a399301f/1025/96C3197B-0264-DB11-9A9C-00304885AD72.root")
18    
19    
20     # access the event tree
21     print "=============================="
22     print "Loading event tree"
23     events = EventTree(theFile.Get("Events"))
24    
25     # access the products inside the tree
26     # aliases can be used directly
27     print "Registering photon branch"
28     photonBranch = events.branch("photons")
29    
30     # loop over 4 events
31     print "Start looping over four events"
32     for event in events:
33     photons = photonBranch()
34 hegner 1.2 print " Number of photons in event %i: %i" % (event, len(photons))
35 hegner 1.1 if event > 2: break # workaround will become obsolete
36    
37    
38    
39     #####################################################
40     # all following commands have been used interactively
41     #
42     ## accessing photons
43     # print photon[0]
44     #
45     ## looping over the photons. what's there?
46     #for photon in photons:
47     # print photon.energy()
48     #
49     ## selecting photons
50     #selectedPhotons = [p for p in photons if p.energy()> 3]
51     #
52     ## looking at the results
53     #for photon in selectedPhotons:
54     # print photon.energy()
55     #
56     ## how to find out about aliases
57     #for alias in events.getListOfAliases():
58     # print alias
59     #
60     ## how to learn about an object
61     #help(photon[0])
62     #
63     ## how to leave the session
64     #
65     # Ctrl-D
66