ATLAS Offline Software
Loading...
Searching...
No Matches
validateFlowElements.py
Go to the documentation of this file.
1#!/usr/bin/env python
2#python script to read the xAOD file
3import os
4import sys
5import ROOT
6import collections
7from pprint import pprint
8import argparse
9def ReadMyxAOD(evt):
10 result=[]
11 for i in range(0,evt.getEntries()):
12 evt.getEntry(i)
13
14
15
16 acc_chargedFE_muon=ROOT.SG.ConstAccessor(
17 "vector<ElementLink<xAOD::MuonContainer>>"
18 )("FE_MuonLinks") # accessor matches type in the aux branch
19 acc_neutralFE_muon=ROOT.SG.ConstAccessor(
20 "vector<ElementLink<xAOD::MuonContainer>>"
21 )("FE_MuonLinks") # accessor matches type in the aux branch
22
23 chargedFEcont=evt.retrieve("xAOD::FlowElementContainer","JetETMissChargedParticleFlowObjects")
24 nchargedFE=chargedFEcont.size()
25 try:
26 for cfe in chargedFEcont:
27 cfe_pt=cfe.p4().Pt()
28 print("Charged Flow Element Pt(): {}".format(cfe_pt))
29 if (acc_chargedFE_muon.isAvailable(cfe)):
30 auxcont_cfe=acc_charged_FE_muon(cfe)
31 for itr in range(0,auxcont_cfe.size()):
32 auxlink=auxcont_cfe[itr]
33 if(auxlink.isValid()):
34 print("Got a link to a muon")
35 else:
36 print("No auxdata retrieved")
37 except:
38 print("Problem in accessing charged FE container")
39
40 try:
41 neutralFEcont=evt.retrieve("xAOD::FlowElementContainer","JetETMissNeutralParticleFlowObjects")
42 print("\n")
43 nneutralFE=neutralFEcont.size()
44 for nfe in neutralFEcont:
45 nfe_pt=nfe.p4().Pt()
46 print("Neutral Flow Element Pt(): {}".format(cfe_pt))
47 if (acc_neutralFE_muon.isAvailable(cfe)):
48 auxcont_nfe=acc_neutral_FE_muon(cfe)
49 for itr in range(0,auxcont_nfe.size()):
50 auxlink=auxcont_nfe[itr]
51 if(auxlink.isValid()):
52 print("Got a link to a muon")
53 else:
54 print("No auxdata retrieved")
55 except:
56 print("No neutral FE container accessible")
57 nneutralFE=0
58
59 outputdict={"nChargedFE":nchargedFE,"nNeutralFE":nneutralFE}
60 result.append(outputdict)
61 return result
62
63def main():
64 parser=argparse.ArgumentParser("validateFlowElements.py - script to read xAOD and dump a nice histogram of the efraction")
65 parser.add_argument("--f",dest="files",action="store",default="",help='Input file (default = "")')
66 opts=parser.parse_args()
67 if(opts.files==""):
68 print("No file specified")
69 sys.exit(-1)
70
71 evt=ROOT.POOL.TEvent(ROOT.POOL.TEvent.kClassAccess)
72 stat=evt.readFrom(opts.files)
73
74 result=ReadMyxAOD(evt)
75 print("\n Printing output")
76 for item in result:
77 print(item)
78
79if __name__=="__main__":
80 main()
if(febId1==febId2)
void print(char *figname, TCanvas *c1)