How to apply TMVA classifier to the *.root samples for analysis?

Dear Experts,

I am quite new in TMVA.
Using the tutorial TMVAClassification.C I am able to train and test the TMVA Classifier.
Now I want to apply TMVA classifier to the *.root samples for analysis, so that I will have TMVA classifier output as one of the leaf together with all other leafs in that *.root file. I see there is an example TMVAClassificationApplication.C, but it just gives the output.

Please help me.


Please, do note that the input data is included in the TMVA output file as branches TrainTree and TestTree for training and test data respectively.

If you want to copy some object from one root file to another you can use the tool rootcp.

rootcp source.root:MethodBDT/BDT1 dest.root:BDTOutput

Would move all output for the BDT classifier named BDT1 to whatever rootfile dest represents.

If your input is spread of several files and you want to associate only a select part of the output file with each input file you could use rooteventselector which is a rootcp specifically for TTrees with extra functionality. Use e.g.

rooteventselector -f 0 -l 10000 source.root:tree dest.root

to copy the first 10000 entries in the TTree tree from file source.root to file dest.root. Use rooteventselector --help for more information.

Doing this in code instead of command line tools is possible, you’d have to create the tree structure yourself, but a bit involved. If you’d want to investigate this approach we can continue the discussion.