ATLAS Offline Software
validateFlowElements.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 #python script to read the xAOD file
3 import os
4 import sys
5 import ROOT
6 import collections
7 from pprint import pprint
8 import argparse
9 def 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 
38  try:
39  neutralFEcont=evt.retrieve("xAOD::FlowElementContainer","JetETMissNeutralParticleFlowObjects")
40  print("\n")
41  nneutralFE=neutralFEcont.size()
42  for nfe in neutralFEcont:
43  nfe_pt=nfe.p4().Pt()
44  print("Neutral Flow Element Pt(): {}".format(cfe_pt))
45  if (acc_neutralFE_muon.isAvailable(cfe)):
46  auxcont_nfe=acc_neutral_FE_muon(cfe)
47  for itr in range(0,auxcont_nfe.size()):
48  auxlink=auxcont_nfe[itr]
49  if(auxlink.isValid()):
50  print("Got a link to a muon")
51  else:
52  print("No auxdata retrieved")
53  except:
54  print("No charged FE container accessible")
55  nneutralFE=0
56 
57  outputdict={"nChargedFE":nchargedFE,"nNeutralFE":nneutralFE}
58  result.append(outputdict)
59  return result
60 
61 def main():
62  parser=argparse.ArgumentParser("validateFlowElements.py - script to read xAOD and dump a nice histogram of the efraction")
63  parser.add_argument("--f",dest="files",action="store",default="",help='Input file (default = "")')
64  opts=parser.parse_args()
65  if(opts.files==""):
66  print("No file specified")
67  sys.exit(-1)
68 
69  evt=ROOT.POOL.TEvent(ROOT.POOL.TEvent.kClassAccess)
70  stat=evt.readFrom(opts.files)
71 
72  result=ReadMyxAOD(evt)
73  print("\n Printing output")
74  for item in result:
75  print(item)
76 
77 if __name__=="__main__":
78  main()
vtune_athena.format
format
Definition: vtune_athena.py:14
validateFlowElements.main
def main()
Definition: validateFlowElements.py:61
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
Prompt::Def::Pt
@ Pt
Definition: VarHolder.h:76
Muon::print
std::string print(const MuPatSegment &)
Definition: MuonTrackSteering.cxx:28
if
if(febId1==febId2)
Definition: LArRodBlockPhysicsV0.cxx:569
validateFlowElements.ReadMyxAOD
def ReadMyxAOD(evt)
Definition: validateFlowElements.py:9