CMS 3D CMS Logo

interactiveExample.py
Go to the documentation of this file.
1 from __future__ import print_function
2 # has to be called with python -i interactiveExample.py
3 
4 from PhysicsTools.PythonAnalysis import *
5 from ROOT import *
6 
7 # prepare the FWLite autoloading mechanism
8 gSystem.Load("libFWCoreFWLite.so")
9 ROOT.FWLiteEnabler.enable()
10 
11 # enable support for files > 2 GB
12 gSystem.Load("libIOPoolTFileAdaptor")
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)
24 
25 print("Start looping over some events")
26 for event in events:
27  photons = event.photons
28  print(" Number of photons in event %i: %i" % (event, len(photons)))
29  if event > 2: break # workaround will become obsolete
30 
31 
32 
33 #####################################################
34 # all following commands have been used interactively
35 #
36 ## accessing photons
37 # print photon[0]
38 #
39 ## looping over the photons. what's there?
40 #for photon in photons:
41 # print photon.energy()
42 #
43 ## selecting photons
44 #selectedPhotons = [p for p in photons if p.energy()> 3]
45 #
46 ## looking at the results
47 #for photon in selectedPhotons:
48 # print photon.energy()
49 #
50 ## how to find out about aliases
51 #for alias in events.getListOfAliases():
52 # print alias
53 #
54 ## how to learn about an object
55 #help(photon[0])
56 #
57 ## how to leave the session
58 #
59 # Ctrl-D
60 
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66