Hi Anil,
You declare some variable to be 'double' but told the tree they were float
(/F).
Hence the problem.
Cheers,
Philippe.
-----Original Message-----
From: owner-roottalk_at_root.cern.ch [mailto:owner-roottalk_at_root.cern.ch] On
Behalf Of Anil Singh
Sent: Friday, October 12, 2007 12:04 PM
To: Roottalk
Subject: [ROOT] The Input Values and The Filled values don't match
Dear Rooters,
I am tryin to fill a tree by using the numbers from an ascii file. The root macro so written runs fine and following message appears on the screen.
>>
T->Scan("NI:JJ:E:W:X:Y:DCX:DCY:TOFF:PRIMEHITZ:ZORIG:XORIG:YORIG:EORIG:WORIG:
IORIG:KORIG")
This I supoose should have given me back the input ASCII numbers in more or
less same format. But Unfortunately the numbers are very very different from
those in the input file.A sample output from the last command is :
Where as the corresponding input lines are: (NI JJ E W X Y ......SO ON)
3 8 7.97547E-01 1.0723E-05 -1.0653E-01 7.6968E+01 -6.7464957E-03 -9.2425679E-03 4.2036E-07 1.48017E+04 1.47861E+04 -6.2064E-01 -8.8064E+00 1.5686E+01 3.3505E-02 9 3
4 8 1.26934E+02 5.3877E-07 3.6974E+01 8.1595E+00 1.0886891E-02 -6.3496462E-03 4.1806E-07 1.47924E+04 1.47922E+04 -6.2331E-01 -8.8003E+00 7.6709E+02 5.1782E-04 9 3
4 7 9.51931E+01 5.3877E-07 -7.6472E+00 -6.0541E+01 -1.1205179E-04 -1.3131483E-02 4.1805E-07 1.47924E+04 1.47922E+04 -6.2331E-01 -8.8003E+00 7.6709E+02 5.1782E-04 9 3
I have observed that first two columns have been read correctly but all the subsequent ones show very very different numbers. The ROOT macro which does this job is :
-=========================================================================== ==================
{
gROOT->Reset();
struct projectile
{
int NI;
int JJ;
double E; double W; double X; double Y;
double ZORIG; double XORIG; double YORIG; double EORIG; double WORIG; int IORIG; int KORIG;
};
projectile particle;
ifstream ff("bgas.dat",ios::in);
TFile *file = new TFile("anilQ.root","RECREATE");
TTree *T = new TTree("T","betatron cleaning tails");
T->Branch("particle",&particle.NI,"NI/I:JJ:E/F:W:X:Y:DCX:DCY:TOFF:PRIMEHITZ:
ZORIG:XORIG:YORIG:EORIG:WORIG:IORIG/I:KORIG");
while(ff.good())
{
ff>>particle.NI>>particle.JJ>>particle.E>>particle.W>>particle.X>>particle.Y >>particle.DCX>>particle.DCY>>particle.TOFF>>particle.PRIMEHITZ>>particle.ZO RIG>>particle.XORIG>>particle.YORIG>>particle.EORIG>>particle.WORIG>>particl e.IORIG>>particle.KORIG;
// cout<<particle.X<<endl;
T->Fill();
}
file->Write();
T->Print();
ff.close();
}
Can anyone explain all this to me ?
Anil
Received on Fri Oct 12 2007 - 19:33:15 CEST
This archive was generated by hypermail 2.2.0 : Sat Oct 13 2007 - 11:50:01 CEST