It’s been a week that I started to use PyROOT . I have a root file which contains of 1000 entry and 97 branches and each branch is a vector .
Jet = 8
Jet_E = (vector<float>*)0x430b780
Jet_Px = (vector<float>*)0x432d380
Jet_Py = (vector<float>*)0x4336230
Jet_Pz = (vector<float>*)0x433f0e0
Jet_Eta = (vector<float>*)0x4347f90
Jet_Phi = (vector<float>*)0x4350e40
Jet_PT = (vector<float>*)0x4359cf0
Jet_Btag = (vector<int>*)0x4362ba0
Jet_NTracks = (vector<int>*)0x436ba50
Jet_EHoverEE = (vector<float>*)0x4374900
Jet_size = 8
...
Electron = 0
Electron_E = (vector<float>*)0x438d530
Electron_Px = (vector<float>*)0x4396560
Electron_Py = (vector<float>*)0x439f590
Electron_Pz = (vector<float>*)0x43a85c0
.....
I need to pass the entry number as a parameter to my function and it returns me the numpy array containing all branches. I managed to do that by first call tree.GetEntry(i)
and then irritate over each branch :
gp1 = np.append(gp1,np.array(t.TauJet_Px).reshape(k,1),axis=1)
gp1 = np.append(gp1,np.array(t.TauJet_Py).reshape(k,1),axis=1)
gp1 = np.append(gp1,np.array(t.TauJet_Pz).reshape(k,1),axis=1)
gp1 = np.append(gp1,np.array(t.TauJet_Eta).reshape(k,1),axis=1)
...
p2 = np.append(gp2,np.array(t.Jet_Px).reshape(k,1),axis=1)
gp2 = np.append(gp2,np.array(t.Jet_Py).reshape(k,1),axis=1)
gp2 = np.append(gp2,np.array(t.Jet_Pz).reshape(k,1),axis=1)
gp2 = np.append(gp2,np.array(t.Jet_Eta).reshape(k,1),axis=1)
..
and at the end :
record_list.append([gp1,gp2,gp3,gp4,gp5,gp6,gp7,gp8])
but it’s kinf of slow and ugly.
I also try stuffs that discussed in this page ( Locate like command ) but none of them helped much.
Also using :
br=tree.GetBranch('X')
nb=br.GetEntry(i)
I dont get any vector ! just single value!
Can you give me some hint ?
Thanks