You’re trying to retrieve parts of a decomposed object (which was written with splitlevel >= 1).
I’d say this kind of games is reserved for “advanced users” only, so you’re asking for trouble.
You’ better have a look at an “analysis skeleton”: Header files for Trees
from ROOT import *
import sys, glob
gROOT.ProcessLine(
"struct var_t {\
Int_t Event_;\
Float_t Weight[1];\
};")
files = ["/afs/cern.ch/user/s/shilpi/public/B-4p-0-1-v1510_14TEV_50PileUp_101175088.root"]
# files = ["file1.root", "file2.root"]
chain = TChain("Delphes")
for file in files:
print "Adding file: " + file
chain.Add(file)
chain.SetMakeClass(1)
chain.SetBranchStatus("*", 0)
entries = chain.GetEntries()
print "Number of entries = " + str(entries)
var = var_t()
chain.SetBranchStatus("Event", 1)
chain.SetBranchAddress("Event", AddressOf(var, "Event_"))
chain.SetBranchStatus("Event.Weight", 1)
chain.SetBranchAddress("Event.Weight", AddressOf(var, "Weight"))
wei = 0
for i in range(entries):
chain.GetEntry(i)
if var.Event_ == 1:
print "Weight = " + str(var.Weight[0])
wei += var.Weight[0]
elif var.Event_ > 1: # note: var.Event_ == 0 is o.k. ("do nothing")
print "Fatal: Entry = " + str(i) + " -> Event_ = " + str(var.Event_)
quit()
print "Sum of all weights = " + str(wei)