CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
example.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 """
4 Example L1TNtuple analysis program
5 """
6 
7 
8 import ROOT
9 
10 
11 # apparently not needed...
12 # ROOT.gSystem.Load("libL1TriggerL1TNtuples")
13 
14 ROOT.PyConfig.IgnoreCommandLineOptions = True
15 ROOT.gROOT.SetBatch(1)
16 ROOT.TH1.SetDefaultSumw2(True)
17 ROOT.gStyle.SetOptStat(0)
18 
19 
20 def eventLoop(filename):
21  f = ROOT.TFile(filename)
22 
23  treeL1 = f.Get("l1NtupleProducer/L1Tree")
24  treeTow = f.Get("l1CaloTowerTreeProducer/L1CaloTowerTree")
25 # tree_l1ex = f.Get("l1ExtraTreeProducer/L1ExtraTree")
26  treeL1up = f.Get("l1UpgradeTreeProducer/L1UpgradeTree")
27 
28  treeJet = f.Get("l1JetRecoTreeProducer/JetRecoTree")
29 # treeEG = f.Get("l1EGRecoTreeProducer/EGRecoTree")
30 # treeTau = f.Get("l1TauRecoTreeProducer/TauRecoTree")
31 # treeMu = f.Get("l1MuonRecoTreeProducer/MuonRecoTree")
32 
33  treeL1.AddFriend(treeTow)
34 # treeL1.AddFriend(treeL1ex)
35  treeL1.AddFriend(treeL1up)
36  treeL1.AddFriend(treeJet)
37 
38 
39  for jentry, event in enumerate(tree):
40  if jentry >= nevents:
41  break
42 
43  event = treeL1.Event
44  eventSim = treeL1.Simulation
45  eventRCT = treeL1.RCT
46  eventGCT = treeL1.GCT
47  eventDTTF = treeL1.DTTF
48  eventCSCTF = treeL1.CSCTF
49  eventGMT = treeL1.GMT
50  eventGT = treeL1.GT
51 
52  eventCaloTP = treeTow.CaloTP
53  eventTower = treeTow.L1CaloTower
54 
55  eventL1Up = treeL1up.L1Upgrade
56 
57  eventJet = treeJet.Jet
58 
59 # eventEG = treeEG.EG
60 
61 # eventTau = treeTau.Tau
62 
63 # eventMuon = treeMu.Mu
64 
65 
66  # Print hists to file
67  c = ROOT.TCanvas()
68 
69 
70  h.Draw("")
71  h.SetTitleOffset(0.55, 'Z')
72  c.Print("plot.pdf")
73 
74  f.Close() # make sure I go last! otherwise your hists will be NoneType
75 
76 
77 if __name__ == "__main__":
78  towercorr()
def eventLoop
Definition: example.py:20