Not able to retrieve UserInfo() objects from TTreeReader.GetTree() , version 6.08/04

Hi,
I have created a Selector, using MakeSelector function on a chain.
Chain consists of 10 different files, in which there is same tree but
with different UserInfo() objects in each file. I am trying to access
these objects by doing,
MyClass* Myclassptr = (MyClass*)fReader.GetTree() -> GetUserInfo()->FindObject(“MyclassObjectName”) ;
in Notify() and Process() function of created TSelector.
It always fails.
I checked for the existence of object in UserInfoList using root terminal as well as TBrowser.

How does it fail?

Cheers,
Philippe.

Sorry… did not make it clear…
It always returns null pointer… so code crashes…
I also did the same task with option “=legacy” in MakeSelector
i.e. using the old way of reading tree by creating TBraches
instead of TTreeReader …
That approach works fine…
I should also mention that I am not using Proof…
I am trying to write code that works in both sequential and parallel modes…
so for sequential mode i am doing,
TChain chain = new TChain(“TreeName”) ;
// — Add Files to tha chain -----
TList
SelInputs = new TList()
// — Add all the input objects/parameters to the SelInputs ----
TSelector *selector = TSelector::GetSelector(“path to selector macro”) ;
selector -> SetInputList(SelInputs)
chain -> Process(selector)

Hi,

Try this:

TTree* treeOrChain = fReader.GetTree();
TTree* currentTree = treeOrChain->GetTree();
MyClass* Myclassptr = (MyClass*)currentTree->GetUserInfo()->FindObject("MyclassObjectName");

I hope the variable names explain what’s going on :slight_smile:

Cheers, Axel.

Okay.
I will try this. I thought fReader.GetTree() always returns the current tree pointer.
I have little doubt regarding flow of calls to TSelector functions.
According to last post in https://root-forum.cern.ch/t/load-ttree-from-file-and-store-in-different-file/13130/11 GetTree() should return valid pointer only after
tree/ at least one entry of tree has been loaded. Now first call to fReader.SetLocalEntry(entry) after opening a new file in a TChain would only occur in Process(). So question is whether, tree/chain is already loaded before Notify() gets called ?

The tree is available through TTreeReader::GetTree()->GetTree() when Notify() is called.

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