Hi,
I’ve searched the forum for a similar problem, but couldn’t find a solution, if there is any.
My problem is that I try to split one relatively big TTree into a large numbers of smaller trees. The main tree contains data from a pixelated detector and I want to have a separate tree saved in a separate file for every pixel data. The part of the code where I am doing this is as following:
…
TFile *ff = new TFile(fname,“read”);
TTree oldtree = (TTree)ff->Get(tree_name);
TFile **ff_pix;
TTree newtree;
ff_pix = new TFile[nPixInLoop];
newtree = new TTree[nPixInLoop];
for (Int_t m = 0; m < nPixInLoop; m++)
{
ff_pix[m] = TFile::Open(fname2,“recreate”);
newtree[m] = oldtree->CloneTree(0);
}
cout << “Starting to spit the data” << endl;
for (Long64_t i = 0; i < nentries; i++)
{
oldtree->GetEntry(i);
Int_t pixel = Int_t(channel+0.5);
newtree[pixel]->Fill();
}
…
When running the code, it fails after some time on filling the new tree (newtree[pixel]->Fill()) with the following error:
Exception: bad allocation
Error: Symbol G__exception is not defined in current scope …
Error: type G__exception not defined FILE:C: …
*** Interpreter error recovered ***
The physical size of the trees is not big - the main tree is 200-300 Mb, and each pixel tree could be 5-10 Mb in the end. I have a new PC with lots of memory, so I wouldn’t expect a memory problem anyway. The problem usually happens either when I am trying to split data for many pixels simultaneously (I have a total of 500 pixels) or if one of the pixels has much more data than the others. Ideally, I’d like to perform this split for all 500 pixels in just one loop.
Thanks for the help!