Trying to create multiple tree branches

Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided

Hello dear experts

I am updating my previous question.

    int i=0;
        ifs >> x >> y;
        itree->Branch("Data", &x,"(xy)/D");
        int j;
            for(j=N; j < N2; ++j)
        cout << N << "  " << i << endl;
        i = ++i;
        N = N+1024;

        if(ifs.eof()) break;


I want to create multiple tree branches automatic. I think in order to do this I have to change my tree branch name. I put " i " on front of tree itree->Fill(); like this and I hoped as the while loop goes, it changes the name . But it didn’t work.

/Users/kaan/Desktop/Sub_Zero/zsub/dataroot.c:33:13: error: use of undeclared identifier 'itree'

This is the error I got.

Dear @Goktug_Bayram ,

In C++ (and really any other programming language) you have to create/declare/define a variable before using it. In your particular case, the error tells you that you haven’t created the itree variable anywhere in your program.

In general, I would suggest you to try to frame your problem in terms of RDataFrame. If you had your input data in a csv file for example, you could do

import ROOT

df = ROOT.RDF.FromCSV("myfile.csv")
df.Snapshot("treename", "filename.root")

In turn, you just need to split your input data in 1024 lines sized CSV files and the ROOT I/O will be taken care of for you by RDataFrame.