TWiki> General Web>Lhcb? >TMVA (revision 1)EditAttach

Using the TMVA Tool in ROOT

This page describes how to use the TMVA tool, which is a tool for performing a Multivariate analysis in root. More details can be found in the TMVA manual here This page will focus on using TMVA with a Boosted Decision Tree (BDT), but other techniques work in a similar way. For more detailed code see the test code available locally in:
or from lxplus:
The TMVA tool is split into two stages: the training stage, and the application stage.

The Training Stage

First you need to load the TMVA libraries so ROOT can interpret them.
You need to make an output file which will contain the restults from the TMVA.
 TFile* outputFile = TFile::Open(outfileName, "RECREATE"); 
You need to declare a TMVA Factory, which carries out the analysis for you.
 TMVA::Factory *factory = new TMVA::Factory("TMVAClassification",outputFile,"V:!Silent:Color:Transformations=I:DrawProgressBar:AnalysisType=Classification"); 
You can specify the configuration options here, including the verbosity level of the output. For the list of transformations, use I (the identity transformation) to get plots of input variables for signal and background. This is very useful for comparisons. All the options are available here:

You need to have 2 samples for the TMVA, one background sample and one signal sample. You can apply cuts to the samples to ensure they are signal and background. For example, you might want to match the signal to MCTruth, and cut on the reconstructed mass of the background to ensure it is in the sideband. It is important that the signal and background represent the real signal and background as closely as possible for optimal performance of the BDT. This means you might want to cut on your trigger lines before the BDT, so that only signal which passes the trigger is used for training.

  Double_t signalWeight = 1.0;
  Double_t backgroundWeight=1.0;
  TFile* signal = new TFile("/home/lhdata1/BdEtapKs/Rhog/MonteC/Stripping20/MC11-magall-BdetapKs-rhog-DD-stripping20-2.root");
  TTree* sigTree = (TTree*)(signal->Get("tree"));
  TFile* data = new TFile("/home/lhdata1/BdEtapKs/Rhog/data/2012/Stripping20/data2012-magup-Bhadron-B2XEtaB2etapKSDDLine-stripping20-20mil.root");
  TTree* dataTree = (TTree*)(data->Get("DecayTreeTuple/DecayTree"));

  TCut mycuts="(B0_TRUEID==511||B0_TRUEID==-511)";
  TCut mycutb="B0_MM>5400."; 

The Application Stage

-- JamesMccarthy - 23 Nov 2012

Edit | Attach | Watch | Print version | History: r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r1 - 23 Nov 2012 - _47C_61UK_47O_61eScience_47OU_61Birmingham_47L_61ParticlePhysics_47CN_61james_32mccarthy?
This site is powered by the TWiki collaboration platform Powered by Perl This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback