Reading a tree in SlaveBegin


I would like to read a tree to initialise some variables in the SlaveBegin method of a TSelector. I used AddInput to put the tree in the input object list :


In SlaveBegin, I am trying to do this :

TTree td = (TTree)fInput->FindObject(“CellProp”);
std::cout << "Building the cell property map, ncells = " << td->GetEntries() << std::endl;
for (uint i = 0; i < td->GetEntries(); i++) {
std::cout << "Building the cell property map, cell " << i << std::endl;
std::cout << "Building the cell property map cell got entry " << i << std::endl;

The number of entries and td->Print() are OK, But there is a crash at the line “td->GetEntry(i);” :

#6 0x0000002a96cbd1b0 in TFile::GetCacheRead ()
from /usr/local/rootaf/root_v5.26.00b/lib/
#7 0x0000002a976d0f01 in TBasket::ReadBasketBuffers ()
from /usr/local/rootaf/root_v5.26.00b/lib/
#8 0x0000002a976da44d in TBranch::GetBasket ()
from /usr/local/rootaf/root_v5.26.00b/lib/
#9 0x0000002a976de732 in TBranch::GetEntry ()
from /usr/local/rootaf/root_v5.26.00b/lib/
#10 0x0000002a9772a819 in TTree::GetEntry ()
from /usr/local/rootaf/root_v5.26.00b/lib/
#11 0x0000002a98323db8 in anaAlig::SlaveBegin ()

What am I doing wrong ? (This is working properly in a non proof session, where I do not use AddInput but open directly a file that contains this tree in SlaveBegin; I am using root_v5.26.00b).



Hi JB,

just a quick guess: since your tree was initialized on the master, the slaves have access to the tree object but can not read the file.

– Remi

Hi Jean-Baptiste,

The problem, I think, is due to the fact the TFile::Get does not load all the TTree in memory but just
what is needed to read it via GetEntry. Therefore what you distribute via the input list is not the full
TTree but, basically, only the header.

Try the following (‘CellProp.root’ is here the name of the file with the CellProp TTree; change accordingly):

  root [] p->SetInputDataFile("CellProp.root")

instead of AddInput(fcp->Get(“CellProp”)) . This distributes the file and makes its content available via
the input list (so no change should be needed in the TSelector).
If this works then we see how to adapt your code.


Hello Gerri,

Thanks for your help. I tried just to add the line to send the file, but doing nothing with it for the time being. I see this :

Info in TProof::SendInputDataFile: broadcasting cpC1.root

but then, there is a crash (I attached the trace back). Maybe there is something wrong in my code.

crash.txt (7.22 KB)

Hello Gerri,

I tried this :

p = TProof::Open(“”,“workers=1”);
p->AddInput(new TNamed(“isData”,“isData”));
TDSet *t = new TDSet(“CollectionTree”,“CollectionTree”);

where pipo is a default selector, with only this in SlaveBegin :

std::cout << “Print the input list” << std::endl;
std::cout << “Print done” << std::endl;

Then, it is OK. If I uncomment the line


then, there is a crash, with the traceback similar to the one in my previous mail.

What am I doing wrong ?

Thanks a lot,