Hi, wlav:
I used the following script to read a tree but seems there is some problem:
from ROOT import *
import re, array
from array import array
gROOT.ProcessLine(
“struct staff_t {
Float_t e1;
Float_t e2;
Float_t e3;
Float_t e4;
Float_t e5;
Float_t e6;
Float_t e7;
Float_t e8;
Float_t e9;
Float_t e10;
Float_t e11;
Float_t e12;
Float_t e13;
Float_t e14;
Float_t e15;
Float_t e16;
Float_t e17;
Float_t e18;
Float_t e19;
Float_t e20;
Float_t e21;
Float_t e22;
Int_t type;
}” )
def main():
fout = TFile("…/ntuple/SinglePhotonPt70.root",“read”)
tree_shape = fout.Get(“shape”)
staff = staff_t()
tree_shape.SetBranchAddress(“e17”,AddressOf(staff,“e17”))
tree_shape.SetBranchAddress(“e18”,AddressOf(staff,“e18”))
ntrain = 200
tree_shape.GetEntry(3)
print staff.e17
fout.Close()
if name == ‘main’:
main()
[qing1981] /home/qing/mlp/HG/frontandrear/row0/train > python train.py
-2.0
But running directly in ROOT enviroment I see:
root [8] TFile *f = new TFile(“SinglePhotonPt70.root”,“r”)
root [8] TTree shape = f->Get(“shape”)
root [7] shape.Show(3)
======> EVENT:3
e1 = 0.000301376
e2 = 6.96881e-05
e3 = 0.000457254
e4 = 0.00300541
e5 = 0.00195023
e6 = 0
e7 = 0.000273012
e8 = 0.000194536
e9 = 0
e10 = 0
e11 = 0
e12 = 0.000434826
e13 = 0
e14 = 0.000269296
e15 = 0.000755217
e16 = 0.00070135
e17 = 0.0011846
e18 = 0.00373352
e19 = 0.00198983
e20 = 0.000322323
e21 = 0
e22 = 0
type = 1
They give different values, one is -2.0 , the other is 0.0011846, any idea?
Thanks,Gang