TTree

Hi everybody :slight_smile:
I have a problem with TTree. I’m trying to read the data from file, when the data are only number all ok, but if 1 column is string I have a problem, not to read it but when I plot. Following the piece of code in pyroot:

tree= TTree ("tree","tree")								                    #creeate TTree
tree.ReadFile(input_file,"source/C:HV:HV_err:R:R_err",'\t')                             # read data from file

N=tree.Draw("HV:R:HV_err:R_err","","goff")

gr = TGraphErrors(N,tree.GetV1(),tree.GetV2(),tree.GetV3(),tree.GetV4())
gr.Draw( 'AP' )

The output is always a plot with line but not with the data in the file (always the same line), why this?? (if I remove the string column work!)

Thanks in advance for your help!!

Would it be possible you send us a subset of your data file in order to run your example ?

Yes of course, this is an example: the first column is defined as source/C, and the other columns as default.

on	2008	1.5	31500000000	10000000000
off	2120.5	2.8	17300000000	6500000000
STBY	2115.09	2.45	19800000000	8900000000
on	2111.69	1.65	28800000000	2300000000

Thanks a lot!! :slight_smile:

try this
boog.dat (195 Bytes)
boog.C (498 Bytes)

No sorry, same result…

{
   TCanvas *canvas = new TCanvas("canvas","canvas");
   TTree *tree = new TTree ("tree","tree");
   tree->ReadFile("boog.dat","source/C:HV/F:HV_err/F:R/F:R_err/F");

   Int_t N = tree->Draw("HV:R:HV_err:R_err","","goff");

   Double_t *x   = tree->GetVal(0);
   Double_t *y   = tree->GetVal(1);
   Double_t *ex  = tree->GetVal(2);
   Double_t *ey  = tree->GetVal(3);

   TGraphErrors *gr = new TGraphErrors(N, x, y, ex, ey);

   gr->SetMarkerStyle(20);
   gr->Draw("AP");
}

Yes now works!! It seems that the probelm was due to the “non declaration” columns… ??
Thanks a lot!!! :slight_smile:

Yes because of the first /C all the following variables were considered as /C too