Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-11-25 02:29:51

0001 # has to be called with python -i interactiveExample.py
0002 
0003 from PhysicsTools.PythonAnalysis import *
0004 from ROOT import gSystem, TFile
0005 
0006 # prepare the FWLite autoloading mechanism
0007 gSystem.Load("libFWCoreFWLite.so")
0008 ROOT.FWLiteEnabler.enable()
0009 
0010 # enable support for files > 2 GB
0011 gSystem.Load("libIOPoolTFileAdaptor")
0012 ui = TFileAdaptorUI()
0013 
0014 
0015 # load the example file from castor
0016 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")
0017 
0018 
0019 # access the event tree
0020 print("==============================")
0021 print("Loading event tree")
0022 events = EventTree(theFile)
0023 
0024 print("Start looping over some events")
0025 for event in events:
0026       photons = event.photons
0027       print("  Number of photons in event %i: %i" % (event, len(photons)))
0028       if event > 2: break  # workaround will become obsolete
0029 
0030 
0031 
0032 #####################################################
0033 # all following commands have been used interactively
0034 #
0035 ## accessing photons
0036 # print photon[0]
0037 #
0038 ## looping over the photons. what's there?
0039 #for photon in photons:
0040 #  print photon.energy()
0041 #
0042 ## selecting photons
0043 #selectedPhotons = [p for p in photons if p.energy()> 3]
0044 #
0045 ## looking at the results
0046 #for photon in selectedPhotons:
0047 #  print photon.energy()
0048 #
0049 ## how to find out about aliases
0050 #for alias in events.getListOfAliases():
0051 #  print alias
0052 #
0053 ## how to learn about an object
0054 #help(photon[0])
0055 #
0056 ## how to leave the session
0057 #
0058 # Ctrl-D
0059