Proof: CloneTree to workers

I’m runing PROOF using some TTree t1 on file f1. I have some other TTree t2 on a file f2. t1 and t2 have different structures. t1 contains events to be analyzed, while t2 contains some other information that helps decide if the event from t1 should be analyzed or ignored. (*)

I can open f2 and get a pointer to t2 on Selector::Begin(), but I want every worker to have a copy of t2 (which is small) so every worker can “query” the Tree (either by using Draw or RDataFrame::Filter). However by running t2->CloneTree() on Selector::SlaveBegin() it crashes. I think it may be a race condition due to all the workers trying to access the file at the same time. How can I fix this?

Snippets of code:

class Selector : TSelector {

TFile *f1;
TFile *f2;
TTree *t1;
TTree *t2;
TTree *t2Clon;


f2 = TFile::Open("t2.root" /*from SetParameter*/,"READ");
t2 = (TTree*)f2->Get("t2");
t2Clon = t2->CloneTree();   // it fails (around) here 

@ganis I think you may know the answer :slight_smile:

(*) t2 is a “Golden Tree” or “Golden ROOT”, the same content as the so called “Golden Json”

Begin is not run on the slave, ‘t2’ is certainly empty or meaningless in SlaveBegin, hene the crash.
If the tree is small you can add it to input list and retrieve it from there inside SlaveBegin. Check also AddInputData, optimized to move data to slaves. Otherwise, I suggest to re-load the tree in SlaveBegin, move of copy the code form Begin in there. This assumes that the slave can ‘see’ the file.

G Ganis

Thank you @ganis. Additional question. How can I retrieve TBits object from fInput without a name?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.