Pcanal ,please help me???

too much colum how to fill tree
i have data that is made of 131 column, the first column is time,the other is data.So i want to draw each of the data vs time. I want to use tree.

FILE *fp;
fp=fopen(“data.txt”,“r”);
float column[131];
TTree *tree=new TTree(“tree”,“data from ascii file”);
tree->Branch(“column[0]”,&column[0],“column[0]/F”);
tree->Branch(“column[1]”,&column[1],“column[1]/F”);
……
tree->Branch(“column[130]”,&column[130],“column[130]/F”);

while(!feof(fp))
{
fscanf(fp,"%f %f %f……“,&column[0],&column[1],……,&column[130]);
tree->Fill();
}
it is so diffcult to write 130 branch and fscanf(fp,"%f %f %f……“,&column[0],&column[1],……,&column[130]);
please tell me if there is a easy way ?
for example loop?

What is the problem? What are the error messages? Which version of ROOT are you using? Did you try compiling your code (with ACLiC for example)?
Did you try TTree::ReadFile?

Cheers,
Philippe

[quote=“pcanal”]What is the problem? What are the error messages? Which version of ROOT are you using? Did you try compiling your code (with ACLiC for example)?
Did you try TTree::ReadFile?

Cheers,
Philippe[/quote]
130 Column,I must write 130 branches,it is so diffcult.
LOOP ?
for(i=0;i<130>Branch(“column[i]”,&column[i],“column[i]/F”);
ok?
Thanks!
TTree::ReadFile?
It must write 130 variables .I can’t bear.
Loop can do it?

Please disable the HTML in your post when copy pasting code.

Nonetheless, your code would work with the following tweak:tree->Branch(Form("column_%d",&column[i],"column_%d/F"); Cheers,
Philippe

[quote=“pcanal”]Please disable the HTML in your post when copy pasting code.

Nonetheless, your code would work with the following tweak:tree->Branch(Form("column_%d",&column[i],"column_%d/F"); Cheers,
Philippe[/quote]

what is the meaning of Form?

tree->Branch(Form(“column_%d”,&column[i],“column_%d/F”);

why there is a “{”, please tell me why i can’t run my programm?
fq.txt (5.74 KB)
plot.c (740 Bytes)

My apologies for the typo. I meant:

Philippe