Histogram from ntuple in PyROOT

ROOT Version: root 6.14.04-x86_64-slc6-gcc62-opt

Hello,
I am a newbie to PyROOT, and I am trying to extract the jet size from a branch inside a tree and fill a histogram with the size of jets per event. I am writing the following code, but I do not know how to access the “specific variable” from the branch-

treeName = "CollectionTree"

ch = ROOT.TChain(treeName)
for i in range(1,len(sys.argv)) :
    ch.Add(sys.argv[i])
    print sys.argv[i]

t = ROOT.xAOD.MakeTransientTree( ch )
fOut = ROOT.TFile.Open("fastsim.root","NEW")
h_jet_size = ROOT.TH1F("AntiKtEMPFlow","",40,0,40);
h_jet_size.GetYaxis().SetTitle("Number of Events")

for entry in xrange( t.GetEntries() ):
   t.GetEntry(entry)
   ievent +=1
   #Fill here...

fOut.Write()
fOut.Close()

I have attached a screenshot of the tree, branches and leaves, I would like to make the histogram of the “size” of the AntiKtEmPFlowJets branch.
Thank for your help !

Using

    t.mainbranch.subbranch

might work for you

   t = ROOT.xAOD.MakeTransientTree( ch )

Since you are leveraging the extra tools provided by ATLAS to read thoses files, you might be able to find more information on how best to read them on the collaboration web sites.

Cheers,
Philippe.

Dear Philippe,
Yes, indeed that is the case, I will look into the specific frameworks which will be able to read this format.
Thank you for the suggestion :slight_smile:

Best,
Shreya

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.