Tmva Instructions

tmva_instructions

User Manual:

Open the PDF directly: View PDF PDF.
Page Count: 10

DownloadTmva Instructions
Open PDF In BrowserView PDF
ROOT multivariate analysis package (TMVA)
http://tmva.sourceforge.net

TMVA package
●

●

The TMVA package performs a multivariate analysis on a number of input
variables and returns a single MVA variable
TMVA is included in ROOT versions 5.30 and above, the development version
can be found at http://sourceforge.net/projects/tmva

●

All source files and examples can be found under $ROOTSYS/tmva

●

The typical TMVA analysis is divided into:

●

–

TMVAClassification: training and testing of a MVA method with included data set
($ROOTSYS/tmva/test/TMVAClassification.cxx)

–

TMVAClassificationApplication: applying MVA cut to a data set
($ROOTSYS/tmva/test/TMVAClassificationApplication.cxx)

User guide:
http://tmva.sourceforge.net/docu/TMVAUsersGuide.pdf

Preparing for MVA
●

Example MVA:
http://sabotin.ung.si/~gkukec/gkukec/tmva/tmva_example.tar.gz

●

●

●

$TMVAEX will from now on designate the folder where the above example is
extracted to
The above example trains and tests a neural network method on a data set
($TMVAEX/example.root) → check the contents of the file by opening a
TBrowser in ROOT
The data set should be saved in a ROOT file, where a tree holds input
variables:
TreeS1
Variable1
Variable2
...
TreeS2
Variable1
Variable2
...
...

Program structure ($TMVAEX/tmva_simple.cpp)
●

At the beginning, we open two root files – one for reading input variables, the
other to save the MVA output:
Tfile *ifile = Tfile::Open(“”, “READ”);
Tfile *ofile = Tfile::Open(“”, “RECREATE”);

●

Then we create a Factory class object that will take care of training and
testing (optionally, we can designate the MVA weights folder):
TMVA::Factory *factory = new TMVA::Factory(“”, ofile,
“”);
(TMVA::gConfig().GetIONames()).fWeightFileDir = “./weights”;

●

Each variable that will be used in the MVA is then added (the last argument is
the variable type F for float, I for integer):
factory­>AddVariable(“’);

Program structure ($TMVAEX/tmva_simple.cpp)
●

Each tree that will be used needs to be designated as signal or background –
in the MVA, all signal trees will be combined together:
TTree *signalTree = (TTree*)ifile­>Get(“”);
TTree *backgroundTree = (TTree*)ifile­>Get(“”);
factory­>AddSignalTree(signalTree, );
factory­>AddBackgroundTree(backgroundTree, );

●

Both trees are then prepared for training and testing:
factory­>PrepareTrainingAndTestTree(“”,
“”, “”);

●

If preselection cuts are not needed, first two arguments are left empty

●

Some options:
–

nTrain_Signal, nTrain_Background, nTest_Signal, nTest_Background:
Number of signal and background events used for training and testing – if set to 0,
half of the events will be used for training and half for testing

–

SplitMode: Selection of events for training/testing (Random, Alternate, Block)

Program structure ($TMVAEX/tmva_simple.cpp)
●

Then we select the MVA method that will be used for the analysis – more
information on each can be found:
http://tmva.sourceforge.net/optionRef.html
factory­>BookMethod(, “”, “”);

●

●

●

Some method types (with names):
–

Likelihood: TMVA::Types::kLikelihood (Likelihood, LikelihoodD,
LikelihoodPCA,...)

–

Function discrimination analysis: TMVA::Types::kFDA (FDA_GA, FDA_SA,
FDA_MC,...)

–

Artificial neural networks: TMVA::Types::kMLP (MLP, MLPBNN,...),
TMVA::Types::kCFMlpANN (CFMlpANN),...

–

Boosted decision trees: TMVA::Types::kBDT (BDT, BDTG, BDTB, BDTD,...)

See $TMVAEX/def_methods.cpp for default options for a collection of
different methods
For classification, more than one method can be used (with additional
BookMethod definitions)

Program structure ($TMVAEX/tmva_simple.cpp)
●

Train, test and evaluate the methods, then close both files:
factory­>TrainAllMethods();
factory­>TestAllMethods();
factory­>EvaluateAllMethods();
ifile­>Close();
delete factory;
ofile­>Close();

●

●

●

The output file can now be opened using a TMVA GUI with:
–

root ­l ‘TMVAGui.C(“”)’

–

./tmvagui 

Now we continue with the classification application part of the program
Wish to apply a MVA variable cut onto the data set – we create a Reader
class object and variables we will read values to:
TMVA::Reader *reader = new TMVA::Reader(“

Source Exif Data:
File Type                       : PDF
File Type Extension             : pdf
MIME Type                       : application/pdf
PDF Version                     : 1.4
Linearized                      : No
Page Count                      : 10
Creator                         : Impress
Producer                        : LibreOffice 5.1
Create Date                     : 2017:05:24 13:05:50+02:00
EXIF Metadata provided by EXIF.tools

Navigation menu