18 def xAODDigest(evt, counter=False, extravars=False):
21 for i
in range(0, evt.getEntries()):
22 if (counter
and (i % 100) == 0):
23 print(
"Processing event %s" % i)
26 ei = evt.retrieve(
"xAOD::EventInfo",
"EventInfo")
27 runnbr = ei.runNumber()
28 evtnbr = ei.eventNumber()
31 evt,
"xAOD::CaloClusterContainer",
"CaloCalTopoClusters")
35 "xAOD::TrackParticleContainer",
"InDetTrackParticles")
36 nIdTracks = len(idTracks)
38 tautracks =
safeRetrieve(evt,
"xAOD::TauTrackContainer",
"TauTracks")
39 nTauTracks = len(tautracks)
40 taus =
safeRetrieve(evt,
"xAOD::TauJetContainer",
"TauJets")
44 tau1eta = taus[0].eta()
45 tau1phi = taus[0].phi()
47 tau1pt = tau1eta = tau1phi = 0
49 muons =
safeRetrieve(evt,
"xAOD::MuonContainer",
"Muons")
52 muon1pt = muons[0].
pt()
53 muon1eta = muons[0].eta()
54 muon1phi = muons[0].phi()
56 muon1pt = muon1eta = muon1phi = 0
58 electrons =
safeRetrieve(evt,
"xAOD::ElectronContainer",
"Electrons")
59 nElec = len(electrons)
61 elec1pt = electrons[0].
pt()
62 elec1eta = electrons[0].eta()
63 elec1phi = electrons[0].phi()
65 elec1pt = elec1eta = elec1phi = 0
67 photons =
safeRetrieve(evt,
"xAOD::PhotonContainer",
"Photons")
70 phot1pt = photons[0].
pt()
71 phot1eta = photons[0].eta()
72 phot1phi = photons[0].phi()
74 phot1pt = phot1eta = phot1phi = 0
77 jets =
safeRetrieve(evt,
"xAOD::JetContainer",
"AntiKt4EMPFlowJets")
81 jet1eta = jets[0].eta()
82 jet1phi = jets[0].phi()
84 jet1pt = jet1eta = jet1phi = 0
86 met =
safeRetrieve(evt,
"xAOD::MissingETContainer",
"MET_Reference_AntiKt4EMPFlow")
89 metx = met[nmet-1].mpx()
90 mety = met[nmet-1].mpy()
91 sumet = met[nmet-1].sumet()
93 metx = mety = sumet = 0
97 acc = ROOT.SG.ConstAccessor(
98 'ElementLink< xAOD::TruthParticleContainer>')(
'truthParticleLink')
100 if nElec > 0
and acc.isAvailable(electrons.at(0)):
101 for i
in range(nElec):
102 truthLink =
acc(electrons.at(i))
103 if(truthLink.isValid()):
104 pdgId = truthLink.pdgId()
108 if nPhot > 0
and acc.isAvailable(photons.at(0)):
109 for i
in range(nPhot):
110 truthLink =
acc(photons.at(i))
111 if(truthLink.isValid()):
112 pdgId = truthLink.pdgId()
116 nFakeElectrons = nElec - nTrueElectrons
117 nFakePhotons = nPhot - nTruePhotons
120 result.append((runnbr, evtnbr, nclus, nIdTracks,
121 nTauTracks, nTaus, tau1pt, tau1eta, tau1phi,
122 nMuons, muon1pt, muon1eta, muon1phi,
123 nElec, elec1pt, elec1eta, elec1phi, nTrueElectrons, nFakeElectrons,
124 nPhot, phot1pt, phot1eta, phot1phi ,nTruePhotons, nFakePhotons,
125 nJet, jet1pt, jet1eta, jet1phi, nmet, metx, mety, sumet))
127 result.append((runnbr, evtnbr, nclus, nIdTracks, nTauTracks, nTaus, nMuons,
128 nElec, nTrueElectrons, nFakeElectrons,
129 nPhot, nTruePhotons, nFakePhotons))
134 result.sort(key=
lambda er: er[0] << 32 | er[1])