ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/CMSSW/PhysicsTools/PythonAnalysis/examples/interactiveExample.py
Revision: 1.3
Committed: Sat Mar 3 03:49:59 2007 UTC (18 years, 2 months ago) by hegner
Content type: text/x-python
Branch: MAIN
Changes since 1.2: +4 -11 lines
Log Message:
Updated documentation.

File Contents

# User Rev Content
1 hegner 1.1 # has to be called with python -i interactiveExample.py
2    
3 hegner 1.3 from PhysicsTools.PythonAnalysis.cmstools import *
4 hegner 1.1 from ROOT import *
5    
6     # prepare the FWLite autoloading mechanism
7     gSystem.Load("libFWCoreFWLite.so")
8     AutoLibraryLoader.enable()
9    
10     # enable support for files > 2 GB
11     gSystem.Load("libIOPoolTFileAdaptor")
12     ui = TFileAdaptorUI()
13    
14    
15     # load the example file from castor
16     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")
17    
18    
19     # access the event tree
20     print "=============================="
21     print "Loading event tree"
22 hegner 1.3 events = EventTree(theFile)
23 hegner 1.1
24 hegner 1.3 print "Start looping over some events"
25 hegner 1.1 for event in events:
26 hegner 1.3 photons = event.photons
27 hegner 1.2 print " Number of photons in event %i: %i" % (event, len(photons))
28 hegner 1.1 if event > 2: break # workaround will become obsolete
29    
30    
31    
32     #####################################################
33     # all following commands have been used interactively
34     #
35     ## accessing photons
36     # print photon[0]
37     #
38     ## looping over the photons. what's there?
39     #for photon in photons:
40     # print photon.energy()
41     #
42     ## selecting photons
43     #selectedPhotons = [p for p in photons if p.energy()> 3]
44     #
45     ## looking at the results
46     #for photon in selectedPhotons:
47     # print photon.energy()
48     #
49     ## how to find out about aliases
50     #for alias in events.getListOfAliases():
51     # print alias
52     #
53     ## how to learn about an object
54     #help(photon[0])
55     #
56     ## how to leave the session
57     #
58     # Ctrl-D
59