CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/PhysicsTools/PythonAnalysis/examples/interactiveExample.py

Go to the documentation of this file.
00001 # has to be called with python -i interactiveExample.py
00002 
00003 from PhysicsTools.PythonAnalysis import *
00004 from ROOT import *
00005 
00006 # prepare the FWLite autoloading mechanism
00007 gSystem.Load("libFWCoreFWLite.so")
00008 AutoLibraryLoader.enable()
00009 
00010 # enable support for files > 2 GB
00011 gSystem.Load("libIOPoolTFileAdaptor")
00012 ui = TFileAdaptorUI()
00013 
00014 
00015 # load the example file from castor
00016 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")
00017 
00018 
00019 # access the event tree
00020 print "=============================="
00021 print "Loading event tree"
00022 events = EventTree(theFile)
00023 
00024 print "Start looping over some events"
00025 for event in events:
00026       photons = event.photons
00027       print "  Number of photons in event %i: %i" % (event, len(photons))
00028       if event > 2: break  # workaround will become obsolete 
00029 
00030 
00031 
00032 #####################################################
00033 # all following commands have been used interactively
00034 #
00035 ## accessing photons 
00036 # print photon[0]
00037 #
00038 ## looping over the photons. what's there?
00039 #for photon in photons:
00040 #  print photon.energy() 
00041 #
00042 ## selecting photons
00043 #selectedPhotons = [p for p in photons if p.energy()> 3]
00044 #
00045 ## looking at the results
00046 #for photon in selectedPhotons:
00047 #  print photon.energy()
00048 #
00049 ## how to find out about aliases
00050 #for alias in events.getListOfAliases():
00051 #  print alias
00052 #
00053 ## how to learn about an object
00054 #help(photon[0])  
00055 #
00056 ## how to leave the session
00057 #
00058 # Ctrl-D
00059