Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:33:13

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