I have a ROOT file that contains an index created using TTree::BuildIndex. If I access the file using a TTree, such as:
TFile f(“myfile.root”);
TTree t = (TTree)f.Get(“MyTree”);
t->GetEntryWithIndex(100, 10);
this works fine… If instead, I create a TChain containing only this file, it seems GetEntryWithIndex does not work:
TChain *c = new TChain(“MyTree”);
c->Add(“myfile.root”);
c->GetEntryWithIndex(100,10);
returns -1
is that expected behavior? Is there an acceptable why to use indices with TChains?..if I first call BuildIndex - it seems the index is created and I can use the GetEntryWIthIndex call just fine…
Is the index initially unavailable since there is no guarantee that all files in a TChain will have an index?
So I’m using ROOT 4.02.00 on Red Hat Linux…in case it makes a difference.
Ok, one more question… if I then add 2 files to the same TChain and then call BuildIndex…calling GetEntryNumberWithIndex consistently returns -1, even for entries I know should exist…while it works just fine if I just have the one file in the TChain.
Humm … not really … but then again we are not yet really support any sort of index on the chains … I was hoping callin BuildIndex was working … but it looks like it does not really . Anyway if you send me your 2 files I will check whether there is an easy fix.
The CVS repository was updated so that you can now create the TTree index for a TChain object. Note that the creation of the TTree index currently requires all the indices to be fit in memory (aka the memory needed is proportional to the number of entries in the chain!).
Hi,
I’m not using ROOT 5.10/00 on Windows. I have a TChain that actually only contains one ROOT file for readng. While preparing to read, I check to see in a TTreeIndex exists and if not build one:
if (!m_mcTree->GetTreeIndex())
m_mcTree->BuildIndex("m_runId", "m_eventId");
This is a standalone application and we link to a smaller subset of ROOT libraries:
At run time, I receive the following error message:
Error in : dictionary of class TTreeIndex not found
and when it comes time to delete the TChain object, a segmentation fault occurs that points to TTreePlayer. If I remove the line concerning BuildIndex, my run completes just fine.
Clearly I’m doing some wrong when trying to create and use an index…incidentally, the file should in fact have an index - one was created and written to the file when it was initially created - yet it seems GetTreeIndex consistently returns no index exists.
Did you run ‘gmake map’ or ‘gmake install’ on your ROOT installation?
If you did not, this will solve your problem.
If you did and it still fails, please send us a complete example reproducing the problem.
This is on windows and I’m using the binary distribution from the ROOT home page. I do not see this problem on Linux.
I did find a work-around… I explicitly load TreePlayer library if running on windows…and that seems to work just fine. I just don’t understand why TreePlayer is not automatically loaded.