Creat a simple Tree?

I got some data which has the form below:
id=abcd
apple 0 13 8 8 2 4 9 48 0 …(many events)
(let’s say this is event 1)
id=abcd
apple 0 1 0 1 22 154 376 506 528 480 421 37…(many events)
(let’s say this is event 2)
.
.
(event n)

the id is repeated but the events of apple is different every time.
How can I create a tree with id=abcd and branches ‘apple’ with event 1,event 2…event n ?
Thanks a lot.

Hi,

You would need to parse the file (see TTree::ReadFile and TTree::ReadStream) for some inspiration into an object of a class looking like:class Record { std::string fId; // filled with 'abcd' std::string fEventType; // filled with apple std::vector<int> fData; // filled with the value };and for which you would generate, compile and link a dictionary and then use with something like:[code]TFile *file = new TFile(“output.root”,“RECREATE”);
TTree *tree = new TTree(“Event”,"");
Record rec;
tree->Branch(“rec.”,&rec);

// open text file
while ( data_in_text_file)
{
rec.fData.clear();
// set the member of ‘rec’ with the proper values.

tree->Fill();
}
file->Write();
[/code]

Cheers,
Philippe.