forked from uwcms/FinalStateAnalysis
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprint_FSAPattuples.py
More file actions
executable file
·157 lines (131 loc) · 6.22 KB
/
print_FSAPattuples.py
File metadata and controls
executable file
·157 lines (131 loc) · 6.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#!/usr/bin/env python
# Tai Sakuma <sakuma@fnal.gov>
import ROOT
import sys
import math
import json
import re
from optparse import OptionParser
ROOT.gROOT.SetBatch(1)
##____________________________________________________________________________||
parser = OptionParser()
parser.add_option('-i', '--inputPath', default = './corrMet.root', action = 'store', type = 'string')
(options, args) = parser.parse_args(sys.argv)
inputPath = options.inputPath
##____________________________________________________________________________||
def main():
printHeader()
if getNEvents(inputPath):
count(inputPath)
##____________________________________________________________________________||
def printHeader():
print '%6s' % 'run',
print '%10s' % 'lumi',
print '%9s' % 'event',
print '%35s' % 'module',
print '%15s' % 'pt',
print '%10s' % 'eta',
print '%10s' % 'phi',
print
##____________________________________________________________________________||
def count(inputPath):
files = [inputPath]
events = Events(files)
handlePatMETs = Handle("std::vector<pat::MET>")
handlePFMETs = Handle("std::vector<reco::PFMET>")
handleLeafCand = Handle("std::vector<reco::LeafCandidate>")
handlePatJets = Handle("std::vector<pat::Jet>")
handlePFJets = Handle("std::vector<reco::PFJet>")
METCollections = (
("pfMet", "", "RECO", handlePFMETs ),
("patPfMet", "", "TUPLE", handlePatMETs ),
("patPfMetT1", "", "TUPLE", handlePatMETs ),
("systematicsMET", "metType1", "TUPLE", handleLeafCand),
("systematicsMET", "metsJESUp", "TUPLE", handleLeafCand),
("systematicsMET", "metsJESDown", "TUPLE", handleLeafCand),
("systematicsMET", "metsFullJESUp", "TUPLE", handleLeafCand),
("systematicsMET", "metsFullJESDown", "TUPLE", handleLeafCand),
("systematicsMET", "metsUESUp", "TUPLE", handleLeafCand),
("systematicsMET", "metsUESDown", "TUPLE", handleLeafCand),
("systematicsMET", "metsFullUESUp", "TUPLE", handleLeafCand),
("systematicsMET", "metsFullUESDown", "TUPLE", handleLeafCand),
# #("patPfMetT0rtTxy", "", "TUPLE", handlePatMETs ),
# #("patPfMetT0rtT1Txy", "", "TUPLE", handlePatMETs ),
# #("patPfMetT0pcTxy", "", "TUPLE", handlePatMETs ),
# #("patPfMetT0pcT1Txy", "", "TUPLE", handlePatMETs ),
# #("patPfMetT1xy", "", "TUPLE", handlePatMETs ),
# ("patType1CorrectedPFMetTOM", "", "TUPLE", handlePatMETs ),
# ("patType1CorrectedPFMetElectronEnDown" , "", "TUPLE", handlePatMETs ),
# ("patType1CorrectedPFMetElectronEnUp" , "", "TUPLE", handlePatMETs ),
# ("patType1CorrectedPFMetJetEnDown" , "", "TUPLE", handlePatMETs ),
# ("patType1CorrectedPFMetJetEnUp" , "", "TUPLE", handlePatMETs ),
# ("patType1CorrectedPFMetJetResDown" , "", "TUPLE", handlePatMETs ),
# ("patType1CorrectedPFMetJetResUp" , "", "TUPLE", handlePatMETs ),
# ("patType1CorrectedPFMetMuonEnDown" , "", "TUPLE", handlePatMETs ),
# ("patType1CorrectedPFMetMuonEnUp" , "", "TUPLE", handlePatMETs ),
# ("patType1CorrectedPFMetTauEnDown" , "", "TUPLE", handlePatMETs ),
# ("patType1CorrectedPFMetTauEnUp" , "", "TUPLE", handlePatMETs ),
# ("patType1CorrectedPFMetUnclusteredEnDown" , "", "TUPLE", handlePatMETs ),
# ("patType1CorrectedPFMetUnclusteredEnUp" , "", "TUPLE", handlePatMETs ),
)
JetCollections = (
("ak5PFJets", "", "RECO" , handlePFJets),
("patJetsMET", "", "TUPLE" , handlePatJets),
("patJets", "", "TUPLE" , handlePatJets),
# ("selectedPatJets", "", "TUPLE", handlePatJets),
# ("selectedPatJetsAK5chsPF", "", "TUPLE", handlePatJets),
# ("smearedPatJets", "", "TUPLE", handlePatJets),
# ("selectedPatJetsForMETtype1p2CorrTOM", "", "TUPLE", handlePatJets),
# ("patJetsForMETSyst", "", "TUPLE" , handlePatJets),
)
for event in events:
run = event.eventAuxiliary().run()
lumi = event.eventAuxiliary().luminosityBlock()
eventId = event.eventAuxiliary().event()
for METCollection in METCollections:
handle = METCollection[3]
event.getByLabel(METCollection[0:3], handle)
met = handle.product().front()
print '%6d' % run,
print '%10d' % lumi,
print '%9d' % eventId,
print '%35s' % METCollection[0],
print '%10.8f' % met.pt(),
print '%10.3f' % met.eta(),
print '%10.2f' % met.phi(),
print
for JetCollection in JetCollections:
handle = JetCollection[3]
event.getByLabel(JetCollection[0:3], handle)
for i in range (handle.product().size()):
jet = handle.product().at(i)
if jet.pt() > 20:
print '%6d' % run,
print '%10d' % lumi,
print '%9d' % eventId,
print '%35s' % JetCollection[0],
print '%10.8f' % jet.pt(),
print '%10.3f' % jet.eta(),
print '%10.2f' % jet.phi(),
print
print
##____________________________________________________________________________||
def getNEvents(inputPath):
file = ROOT.TFile.Open(inputPath)
events = file.Get('Events')
return events.GetEntries()
##____________________________________________________________________________||
def loadLibraries():
argv_org = list(sys.argv)
sys.argv = [e for e in sys.argv if e != '-h']
ROOT.gSystem.Load("libFWCoreFWLite")
ROOT.AutoLibraryLoader.enable()
ROOT.gSystem.Load("libDataFormatsFWLite")
ROOT.gSystem.Load("libDataFormatsPatCandidates")
sys.argv = argv_org
##____________________________________________________________________________||
loadLibraries()
from DataFormats.FWLite import Events, Handle
##____________________________________________________________________________||
if __name__ == '__main__':
main()