Reading a tree in SlaveBegin

Hello,

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 :

p->AddInput(fcp->Get(“CellProp”));

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;
td->Print();
for (uint i = 0; i < td->GetEntries(); i++) {
std::cout << "Building the cell property map, cell " << i << std::endl;
td->GetEntry(i);
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/libRIO.so
#7 0x0000002a976d0f01 in TBasket::ReadBasketBuffers ()
from /usr/local/rootaf/root_v5.26.00b/lib/libTree.so
#8 0x0000002a976da44d in TBranch::GetBasket ()
from /usr/local/rootaf/root_v5.26.00b/lib/libTree.so
#9 0x0000002a976de732 in TBranch::GetEntry ()
from /usr/local/rootaf/root_v5.26.00b/lib/libTree.so
#10 0x0000002a9772a819 in TTree::GetEntry ()
from /usr/local/rootaf/root_v5.26.00b/lib/libTree.so
#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).

Thanks,

Jean-Baptiste.

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.

Gerri

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.

Jean-Baptiste
crash.txt (7.22 KB)

Hello Gerri,

I tried this :

p = TProof::Open(“ccapl0001.in2p3.fr”,“workers=1”);
p->AddInput(new TNamed(“isData”,“isData”));
//p->SetInputDataFile(“cpC1.root”);
TDSet *t = new TDSet(“CollectionTree”,“CollectionTree”);
t->Add(“root://ccxrasn001:1094//xrootd/users/d/devivie/user10.YuNakahama.AnaperiodB.physics_L1Calo.PhysCont.AOD.repro04_v01_aa0t0/user10.YuNakahama.AnaperiodB.physics_L1Calo.PhysCont.AOD.repro04_v01_aa0t0.AANT._00009.root”);
p->Process(t,“pipo.C+”);

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

std::cout << “Print the input list” << std::endl;
fInput->Print();
std::cout << “Print done” << std::endl;

Then, it is OK. If I uncomment the line

//p->SetInputDataFile(“cpC1.root”);

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

What am I doing wrong ?

Thanks a lot,

Jean-Baptiste.