Dataloader doesn't see friend when cut is applied in AddTree

Dear experts,

I am trying to use MultiClass classification with some of the input variables stored in friend trees. Things run smoothly when I add the input trees to dataloader without any cuts.

But when I do apply a cut while adding the input tree, dataloader doesn’t seem to see the friends attached to the input tree on which I am applying the cut. Consequently, TMVA complains during training and sets those variables to zero. Is this to be expected?

The necessary material to reproduce the problem is located in my public AFS space at : /afs/cern.ch/user/a/avenkate/public/tmva_minimal

The TMVA scripts are TMVAClassification_minimal.C and TMVAClassification_minimal_withoutCut.C, with the former being the problematic one. In the latter, the cut has been removed. I have cut down the input ROOT files drastically to reduce training time.

The respective logs of running TMVA are also present: log_withCut.txt and log_withoutCut.txt respectively.

The relevant ROOT version is ROOT 6.20/04.

I would appreciate any light that could be shed on this.

Thanks,
Arvind.

Hi,
Thank you for reporting this problem. I can reproduce with your data and script. I will investigate it and let you know
Cheers
Lorenzo

The problem seems to be caused by using TChain.
If you are using TTree directly and not TChain for passing the input data , it seems to work fine.
I have open a JIRA item for this, see
https://sft.its.cern.ch/jira/browse/ROOT-10778

Lorenzo

Hi Lorenzo,

Thanks for taking a look. So it’s not a TMVA problem, but has to do with TChain itself. Interesting.

For my use case, I have hundreds on input files which have to be chained together. Hence, my use of TChain. For now, would I be able to get around this problem by type-casting the TChain I make from all the files into a TTree? Something along the lines of:

TChain *myChain = new TChain("DecayTree");
myChain->Add("...");//add necessary files

TTree *myTree = (TTree*)myChain;// do the typecast

And then would I be able to use myTree as the input tree along with the cut in AddTree? Typically when I create a new TTree like above, ROOT will complain that it needs a TFile to put it into… Will I also need to create a temporary ROOT file just to store the tree?

Thanks,
Arvind.

Hi,

The approach I suggested in the above post doesn’t work. Even after I type cast the TChain into TTree, ROOT still doesn’t see the columns in the friend tree.

However, as Lorenzo said, if I start with TTrees instead of TChains, the problem isn’t there. It just doesn’t work for my use case.

Arvind

Hi,

The problem is in copyTree for TChain that is used inside TMVA internally when you provide a cut.
This above will not work, because effectivly you will pass still a pointer to a TChain just casted in the base TTree class.

What will work if you avoid using friends tree or you create yourself a tree applying the cut before using TMVA. Maybe our TTree expert, @pcanal, can offer a better workaround

Lorenzo

Hi Lorenzo,

Thanks for the clarification. The approach you suggest is exactly what I’m doing now. It just adds more time and steps to my workflow. Not a deal breaker, though

Arvind.