{ "cells": [ { "cell_type": "markdown", "id": "b3da38cb", "metadata": {}, "source": [ "# TMVAClassificationApplication\n", "This macro provides a simple example on how to use the trained classifiers\n", "within an analysis module\n", "- Project : TMVA - a Root-integrated toolkit for multivariate data analysis\n", "- Package : TMVA\n", "- Executable: TMVAClassificationApplication\n", "\n", "\n", "\n", "**Author:** Andreas Hoecker \n", "This notebook tutorial was automatically generated with ROOTBOOK-izer from the macro found in the ROOT repository on Tuesday, May 19, 2026 at 08:23 PM." ] }, { "cell_type": "code", "execution_count": 1, "id": "d6a38d4f", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:24:02.250271Z", "iopub.status.busy": "2026-05-19T20:24:02.250140Z", "iopub.status.idle": "2026-05-19T20:24:02.275997Z", "shell.execute_reply": "2026-05-19T20:24:02.275306Z" } }, "outputs": [], "source": [ "%%cpp -d\n", "#include \n", "#include \n", "#include \n", "#include \n", "#include \n", "\n", "#include \"TFile.h\"\n", "#include \"TTree.h\"\n", "#include \"TString.h\"\n", "#include \"TSystem.h\"\n", "#include \"TROOT.h\"\n", "#include \"TStopwatch.h\"\n", "\n", "#include \"TMVA/Tools.h\"\n", "#include \"TMVA/Reader.h\"\n", "#include \"TMVA/MethodCuts.h\"\n", "\n", "using namespace TMVA;" ] }, { "cell_type": "markdown", "id": "e053d665", "metadata": {}, "source": [ " Arguments are defined. " ] }, { "cell_type": "code", "execution_count": 2, "id": "88f97380", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:24:02.277478Z", "iopub.status.busy": "2026-05-19T20:24:02.277355Z", "iopub.status.idle": "2026-05-19T20:24:02.714692Z", "shell.execute_reply": "2026-05-19T20:24:02.701439Z" } }, "outputs": [], "source": [ "TString myMethodList = \"\";" ] }, { "cell_type": "markdown", "id": "87cd085f", "metadata": {}, "source": [ "---------------------------------------------------------------\n", "This loads the library" ] }, { "cell_type": "code", "execution_count": 3, "id": "7b35c895", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:24:02.741167Z", "iopub.status.busy": "2026-05-19T20:24:02.741017Z", "iopub.status.idle": "2026-05-19T20:24:02.957162Z", "shell.execute_reply": "2026-05-19T20:24:02.956656Z" } }, "outputs": [], "source": [ "TMVA::Tools::Instance();" ] }, { "cell_type": "markdown", "id": "b0db4268", "metadata": {}, "source": [ "Default MVA methods to be trained + tested" ] }, { "cell_type": "code", "execution_count": 4, "id": "0c659c6b", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:24:02.980799Z", "iopub.status.busy": "2026-05-19T20:24:02.980657Z", "iopub.status.idle": "2026-05-19T20:24:03.187053Z", "shell.execute_reply": "2026-05-19T20:24:03.186683Z" } }, "outputs": [], "source": [ "std::map Use;" ] }, { "cell_type": "markdown", "id": "fe0f90de", "metadata": {}, "source": [ "Cut optimisation" ] }, { "cell_type": "code", "execution_count": 5, "id": "9d99916e", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:24:03.216418Z", "iopub.status.busy": "2026-05-19T20:24:03.216270Z", "iopub.status.idle": "2026-05-19T20:24:03.540717Z", "shell.execute_reply": "2026-05-19T20:24:03.540331Z" } }, "outputs": [], "source": [ "Use[\"Cuts\"] = 1;\n", "Use[\"CutsD\"] = 1;\n", "Use[\"CutsPCA\"] = 0;\n", "Use[\"CutsGA\"] = 0;\n", "Use[\"CutsSA\"] = 0;" ] }, { "cell_type": "markdown", "id": "352d777a", "metadata": {}, "source": [ "1-dimensional likelihood (\"naive Bayes estimator\")" ] }, { "cell_type": "code", "execution_count": 6, "id": "623ee867", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:24:03.566852Z", "iopub.status.busy": "2026-05-19T20:24:03.566691Z", "iopub.status.idle": "2026-05-19T20:24:03.779273Z", "shell.execute_reply": "2026-05-19T20:24:03.778889Z" } }, "outputs": [], "source": [ "Use[\"Likelihood\"] = 1;\n", "Use[\"LikelihoodD\"] = 0; // the \"D\" extension indicates decorrelated input variables (see option strings)\n", "Use[\"LikelihoodPCA\"] = 1; // the \"PCA\" extension indicates PCA-transformed input variables (see option strings)\n", "Use[\"LikelihoodKDE\"] = 0;\n", "Use[\"LikelihoodMIX\"] = 0;" ] }, { "cell_type": "markdown", "id": "cf7d4ca4", "metadata": {}, "source": [ "Mutidimensional likelihood and Nearest-Neighbour methods" ] }, { "cell_type": "code", "execution_count": 7, "id": "1e84c6a3", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:24:03.797655Z", "iopub.status.busy": "2026-05-19T20:24:03.797472Z", "iopub.status.idle": "2026-05-19T20:24:04.006949Z", "shell.execute_reply": "2026-05-19T20:24:04.006375Z" } }, "outputs": [], "source": [ "Use[\"PDERS\"] = 1;\n", "Use[\"PDERSD\"] = 0;\n", "Use[\"PDERSPCA\"] = 0;\n", "Use[\"PDEFoam\"] = 1;\n", "Use[\"PDEFoamBoost\"] = 0; // uses generalised MVA method boosting\n", "Use[\"KNN\"] = 1; // k-nearest neighbour method" ] }, { "cell_type": "markdown", "id": "e739cbb7", "metadata": {}, "source": [ "Linear Discriminant Analysis" ] }, { "cell_type": "code", "execution_count": 8, "id": "d35d29ab", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:24:04.009260Z", "iopub.status.busy": "2026-05-19T20:24:04.009134Z", "iopub.status.idle": "2026-05-19T20:24:04.214789Z", "shell.execute_reply": "2026-05-19T20:24:04.214407Z" } }, "outputs": [], "source": [ "Use[\"LD\"] = 1; // Linear Discriminant identical to Fisher\n", "Use[\"Fisher\"] = 0;\n", "Use[\"FisherG\"] = 0;\n", "Use[\"BoostedFisher\"] = 0; // uses generalised MVA method boosting\n", "Use[\"HMatrix\"] = 0;" ] }, { "cell_type": "markdown", "id": "c7182d83", "metadata": {}, "source": [ "Function Discriminant analysis" ] }, { "cell_type": "code", "execution_count": 9, "id": "88de342b", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:24:04.217195Z", "iopub.status.busy": "2026-05-19T20:24:04.217072Z", "iopub.status.idle": "2026-05-19T20:24:04.422930Z", "shell.execute_reply": "2026-05-19T20:24:04.422398Z" } }, "outputs": [], "source": [ "Use[\"FDA_GA\"] = 1; // minimisation of user-defined function using Genetics Algorithm\n", "Use[\"FDA_SA\"] = 0;\n", "Use[\"FDA_MC\"] = 0;\n", "Use[\"FDA_MT\"] = 0;\n", "Use[\"FDA_GAMT\"] = 0;\n", "Use[\"FDA_MCMT\"] = 0;" ] }, { "cell_type": "markdown", "id": "08609462", "metadata": {}, "source": [ "Neural Networks (all are feed-forward Multilayer Perceptrons)" ] }, { "cell_type": "code", "execution_count": 10, "id": "1a371738", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:24:04.424793Z", "iopub.status.busy": "2026-05-19T20:24:04.424668Z", "iopub.status.idle": "2026-05-19T20:24:04.628788Z", "shell.execute_reply": "2026-05-19T20:24:04.628295Z" } }, "outputs": [], "source": [ "Use[\"MLP\"] = 0; // Recommended ANN\n", "Use[\"MLPBFGS\"] = 0; // Recommended ANN with optional training method\n", "Use[\"MLPBNN\"] = 1; // Recommended ANN with BFGS training method and bayesian regulator\n", "Use[\"CFMlpANN\"] = 0; // Depreciated ANN from ALEPH\n", "Use[\"TMlpANN\"] = 0; // ROOT's own ANN\n", "Use[\"DNN_CPU\"] = 0; // CUDA-accelerated DNN training.\n", "Use[\"DNN_GPU\"] = 0; // Multi-core accelerated DNN." ] }, { "cell_type": "markdown", "id": "59d11ea0", "metadata": {}, "source": [ "Support Vector Machine" ] }, { "cell_type": "code", "execution_count": 11, "id": "d2a5c03c", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:24:04.630650Z", "iopub.status.busy": "2026-05-19T20:24:04.630503Z", "iopub.status.idle": "2026-05-19T20:24:04.836227Z", "shell.execute_reply": "2026-05-19T20:24:04.835874Z" } }, "outputs": [], "source": [ "Use[\"SVM\"] = 1;" ] }, { "cell_type": "markdown", "id": "a3658e8e", "metadata": {}, "source": [ "Boosted Decision Trees" ] }, { "cell_type": "code", "execution_count": 12, "id": "33fdf76f", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:24:04.856653Z", "iopub.status.busy": "2026-05-19T20:24:04.856486Z", "iopub.status.idle": "2026-05-19T20:24:05.065416Z", "shell.execute_reply": "2026-05-19T20:24:05.064821Z" } }, "outputs": [], "source": [ "Use[\"BDT\"] = 1; // uses Adaptive Boost\n", "Use[\"BDTG\"] = 0; // uses Gradient Boost\n", "Use[\"BDTB\"] = 0; // uses Bagging\n", "Use[\"BDTD\"] = 0; // decorrelation + Adaptive Boost\n", "Use[\"BDTF\"] = 0; // allow usage of fisher discriminant for node splitting" ] }, { "cell_type": "markdown", "id": "ccd77343", "metadata": {}, "source": [ "Friedman's RuleFit method, ie, an optimised series of cuts (\"rules\")" ] }, { "cell_type": "code", "execution_count": 13, "id": "f32c5f46", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:24:05.067326Z", "iopub.status.busy": "2026-05-19T20:24:05.067185Z", "iopub.status.idle": "2026-05-19T20:24:05.302659Z", "shell.execute_reply": "2026-05-19T20:24:05.280667Z" } }, "outputs": [], "source": [ "Use[\"RuleFit\"] = 1;" ] }, { "cell_type": "markdown", "id": "1ea54951", "metadata": {}, "source": [ "---------------------------------------------------------------" ] }, { "cell_type": "code", "execution_count": 14, "id": "a97c2c63", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:24:05.310130Z", "iopub.status.busy": "2026-05-19T20:24:05.309948Z", "iopub.status.idle": "2026-05-19T20:24:05.515922Z", "shell.execute_reply": "2026-05-19T20:24:05.515600Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "==> Start TMVAClassificationApplication\n" ] } ], "source": [ "Use[\"Plugin\"] = 0;\n", "Use[\"Category\"] = 0;\n", "Use[\"SVM_Gauss\"] = 0;\n", "Use[\"SVM_Poly\"] = 0;\n", "Use[\"SVM_Lin\"] = 0;\n", "\n", "std::cout << std::endl;\n", "std::cout << \"==> Start TMVAClassificationApplication\" << std::endl;" ] }, { "cell_type": "markdown", "id": "44de9f89", "metadata": {}, "source": [ "Select methods (don't look at this code - not of interest)" ] }, { "cell_type": "code", "execution_count": 15, "id": "3dce1601", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:24:05.523180Z", "iopub.status.busy": "2026-05-19T20:24:05.523060Z", "iopub.status.idle": "2026-05-19T20:24:05.725384Z", "shell.execute_reply": "2026-05-19T20:24:05.724796Z" } }, "outputs": [], "source": [ "if (myMethodList != \"\") {\n", " for (std::map::iterator it = Use.begin(); it != Use.end(); it++) it->second = 0;\n", "\n", " std::vector mlist = gTools().SplitString( myMethodList, ',' );\n", " for (UInt_t i=0; i::iterator it = Use.begin(); it != Use.end(); it++) {\n", " std::cout << it->first << \" \";\n", " }\n", " std::cout << std::endl;\n", " return;\n", " }\n", " Use[regMethod] = 1;\n", " }\n", "}" ] }, { "cell_type": "markdown", "id": "736b565b", "metadata": {}, "source": [ "--------------------------------------------------------------------------------------------------" ] }, { "cell_type": "markdown", "id": "00654da1", "metadata": {}, "source": [ "Create the Reader object" ] }, { "cell_type": "code", "execution_count": 16, "id": "5ae36439", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:24:05.727091Z", "iopub.status.busy": "2026-05-19T20:24:05.726964Z", "iopub.status.idle": "2026-05-19T20:24:05.933079Z", "shell.execute_reply": "2026-05-19T20:24:05.932630Z" } }, "outputs": [], "source": [ "TMVA::Reader *reader = new TMVA::Reader( \"!Color:!Silent\" );" ] }, { "cell_type": "markdown", "id": "7079f9b1", "metadata": {}, "source": [ "Create a set of variables and declare them to the reader\n", "- the variable names MUST corresponds in name and type to those given in the weight file(s) used" ] }, { "cell_type": "code", "execution_count": 17, "id": "18cbf323", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:24:05.943361Z", "iopub.status.busy": "2026-05-19T20:24:05.943227Z", "iopub.status.idle": "2026-05-19T20:24:06.145283Z", "shell.execute_reply": "2026-05-19T20:24:06.144848Z" } }, "outputs": [], "source": [ "Float_t var1, var2;\n", "Float_t var3, var4;\n", "reader->AddVariable( \"myvar1 := var1+var2\", &var1 );\n", "reader->AddVariable( \"myvar2 := var1-var2\", &var2 );\n", "reader->AddVariable( \"var3\", &var3 );\n", "reader->AddVariable( \"var4\", &var4 );" ] }, { "cell_type": "markdown", "id": "e9c2291d", "metadata": {}, "source": [ "Spectator variables declared in the training have to be added to the reader, too" ] }, { "cell_type": "code", "execution_count": 18, "id": "e55f3729", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:24:06.154363Z", "iopub.status.busy": "2026-05-19T20:24:06.154228Z", "iopub.status.idle": "2026-05-19T20:24:06.356370Z", "shell.execute_reply": "2026-05-19T20:24:06.355791Z" } }, "outputs": [], "source": [ "Float_t spec1,spec2;\n", "reader->AddSpectator( \"spec1 := var1*2\", &spec1 );\n", "reader->AddSpectator( \"spec2 := var1*3\", &spec2 );\n", "\n", "Float_t Category_cat1, Category_cat2, Category_cat3;\n", "if (Use[\"Category\"]){\n", " // Add artificial spectators for distinguishing categories\n", " reader->AddSpectator( \"Category_cat1 := var3<=0\", &Category_cat1 );\n", " reader->AddSpectator( \"Category_cat2 := (var3>0)&&(var4<0)\", &Category_cat2 );\n", " reader->AddSpectator( \"Category_cat3 := (var3>0)&&(var4>=0)\", &Category_cat3 );\n", "}" ] }, { "cell_type": "markdown", "id": "0e8fc51f", "metadata": {}, "source": [ "Book the MVA methods" ] }, { "cell_type": "code", "execution_count": 19, "id": "8eaca9ef", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:24:06.358557Z", "iopub.status.busy": "2026-05-19T20:24:06.358416Z", "iopub.status.idle": "2026-05-19T20:24:06.563773Z", "shell.execute_reply": "2026-05-19T20:24:06.562590Z" } }, "outputs": [], "source": [ "TString dir = \"dataset/weights/\";\n", "TString prefix = \"TMVAClassification\";" ] }, { "cell_type": "markdown", "id": "b09b96c2", "metadata": {}, "source": [ "Book method(s)" ] }, { "cell_type": "code", "execution_count": 20, "id": "c2e533e0", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:24:06.565666Z", "iopub.status.busy": "2026-05-19T20:24:06.565500Z", "iopub.status.idle": "2026-05-19T20:24:06.901304Z", "shell.execute_reply": "2026-05-19T20:24:06.890417Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " : Booking \"BDT method\" of type \"BDT\" from dataset/weights/TMVAClassification_BDT.weights.xml.\n", " : Reading weight file: dataset/weights/TMVAClassification_BDT.weights.xml\n", "
DataSetInfo : [Default] : Added class \"Signal\"\n", "
DataSetInfo : [Default] : Added class \"Background\"\n", " : Booked classifier \"BDT\" of type: \"BDT\"\n", " : Booking \"Cuts method\" of type \"Cuts\" from dataset/weights/TMVAClassification_Cuts.weights.xml.\n", " : Reading weight file: dataset/weights/TMVAClassification_Cuts.weights.xml\n", " : Read cuts optimised using sample of MC events\n", " : Reading 100 signal efficiency bins for 4 variables\n", " : Booked classifier \"Cuts\" of type: \"Cuts\"\n", " : Booking \"CutsD method\" of type \"Cuts\" from dataset/weights/TMVAClassification_CutsD.weights.xml.\n", " : Reading weight file: dataset/weights/TMVAClassification_CutsD.weights.xml\n", " : Read cuts optimised using sample of MC events\n", " : Reading 100 signal efficiency bins for 4 variables\n", " : Booked classifier \"CutsD\" of type: \"Cuts\"\n", " : Booking \"FDA_GA method\" of type \"FDA\" from dataset/weights/TMVAClassification_FDA_GA.weights.xml.\n", " : Reading weight file: dataset/weights/TMVAClassification_FDA_GA.weights.xml\n", " : User-defined formula string : \"(0)+(1)*x0+(2)*x1+(3)*x2+(4)*x3\"\n", " : TFormula-compatible formula string: \"[0]+[1]*[5]+[2]*[6]+[3]*[7]+[4]*[8]\"\n", " : Booked classifier \"FDA_GA\" of type: \"FDA\"\n", " : Booking \"KNN method\" of type \"KNN\" from dataset/weights/TMVAClassification_KNN.weights.xml.\n", " : Reading weight file: dataset/weights/TMVAClassification_KNN.weights.xml\n", " : Creating kd-tree with 2000 events\n", " : Computing scale factor for 1d distributions: (ifrac, bottom, top) = (80%, 10%, 90%)\n", "
ModulekNN : Optimizing tree for 4 variables with 2000 values\n", " : Class 1 has 1000 events\n", " : Class 2 has 1000 events\n", " : Booked classifier \"KNN\" of type: \"KNN\"\n", " : Booking \"LD method\" of type \"LD\" from dataset/weights/TMVAClassification_LD.weights.xml.\n", " : Reading weight file: dataset/weights/TMVAClassification_LD.weights.xml\n", " : Booked classifier \"LD\" of type: \"LD\"\n", " : Booking \"Likelihood method\" of type \"Likelihood\" from dataset/weights/TMVAClassification_Likelihood.weights.xml.\n", " : Reading weight file: dataset/weights/TMVAClassification_Likelihood.weights.xml\n", " : Booked classifier \"Likelihood\" of type: \"Likelihood\"\n", " : Booking \"LikelihoodPCA method\" of type \"Likelihood\" from dataset/weights/TMVAClassification_LikelihoodPCA.weights.xml.\n", " : Reading weight file: dataset/weights/TMVAClassification_LikelihoodPCA.weights.xml\n", " : Booked classifier \"LikelihoodPCA\" of type: \"Likelihood\"\n", " : Booking \"MLPBNN method\" of type \"MLP\" from dataset/weights/TMVAClassification_MLPBNN.weights.xml.\n", " : Reading weight file: dataset/weights/TMVAClassification_MLPBNN.weights.xml\n", "
MLPBNN : Building Network. \n", " : Initializing weights\n", " : Booked classifier \"MLPBNN\" of type: \"MLP\"\n", " : Booking \"PDEFoam method\" of type \"PDEFoam\" from dataset/weights/TMVAClassification_PDEFoam.weights.xml.\n", " : Reading weight file: dataset/weights/TMVAClassification_PDEFoam.weights.xml\n", " : Read foams from file: dataset/weights/TMVAClassification_PDEFoam.weights_foams.root\n", " : Booked classifier \"PDEFoam\" of type: \"PDEFoam\"\n", " : Booking \"PDERS method\" of type \"PDERS\" from dataset/weights/TMVAClassification_PDERS.weights.xml.\n", " : Reading weight file: dataset/weights/TMVAClassification_PDERS.weights.xml\n", " : signal and background scales: 0.001 0.001\n", " : Booked classifier \"PDERS\" of type: \"PDERS\"\n", " : Booking \"RuleFit method\" of type \"RuleFit\" from dataset/weights/TMVAClassification_RuleFit.weights.xml.\n", " : Reading weight file: dataset/weights/TMVAClassification_RuleFit.weights.xml\n", " : Booked classifier \"RuleFit\" of type: \"RuleFit\"\n", " : Booking \"SVM method\" of type \"SVM\" from dataset/weights/TMVAClassification_SVM.weights.xml.\n", " : Reading weight file: dataset/weights/TMVAClassification_SVM.weights.xml\n", " : Booked classifier \"SVM\" of type: \"SVM\"\n" ] } ], "source": [ "for (std::map::iterator it = Use.begin(); it != Use.end(); it++) {\n", " if (it->second) {\n", " TString methodName = TString(it->first) + TString(\" method\");\n", " TString weightfile = dir + prefix + TString(\"_\") + TString(it->first) + TString(\".weights.xml\");\n", " reader->BookMVA( methodName, weightfile );\n", " }\n", "}" ] }, { "cell_type": "markdown", "id": "f3d951e0", "metadata": {}, "source": [ "Book output histograms" ] }, { "cell_type": "code", "execution_count": 21, "id": "b5671024", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:24:06.915306Z", "iopub.status.busy": "2026-05-19T20:24:06.915131Z", "iopub.status.idle": "2026-05-19T20:24:07.119662Z", "shell.execute_reply": "2026-05-19T20:24:07.119069Z" } }, "outputs": [], "source": [ "UInt_t nbin = 100;\n", "TH1F *histLk(0);\n", "TH1F *histLkD(0);\n", "TH1F *histLkPCA(0);\n", "TH1F *histLkKDE(0);\n", "TH1F *histLkMIX(0);\n", "TH1F *histPD(0);\n", "TH1F *histPDD(0);\n", "TH1F *histPDPCA(0);\n", "TH1F *histPDEFoam(0);\n", "TH1F *histPDEFoamErr(0);\n", "TH1F *histPDEFoamSig(0);\n", "TH1F *histKNN(0);\n", "TH1F *histHm(0);\n", "TH1F *histFi(0);\n", "TH1F *histFiG(0);\n", "TH1F *histFiB(0);\n", "TH1F *histLD(0);\n", "TH1F *histNn(0);\n", "TH1F *histNnbfgs(0);\n", "TH1F *histNnbnn(0);\n", "TH1F *histNnC(0);\n", "TH1F *histNnT(0);\n", "TH1F *histBdt(0);\n", "TH1F *histBdtG(0);\n", "TH1F *histBdtB(0);\n", "TH1F *histBdtD(0);\n", "TH1F *histBdtF(0);\n", "TH1F *histRf(0);\n", "TH1F *histSVMG(0);\n", "TH1F *histSVMP(0);\n", "TH1F *histSVML(0);\n", "TH1F *histFDAMT(0);\n", "TH1F *histFDAGA(0);\n", "TH1F *histCat(0);\n", "TH1F *histPBdt(0);\n", "TH1F *histDnnGpu(0);\n", "TH1F *histDnnCpu(0);\n", "\n", "if (Use[\"Likelihood\"]) histLk = new TH1F( \"MVA_Likelihood\", \"MVA_Likelihood\", nbin, -1, 1 );\n", "if (Use[\"LikelihoodD\"]) histLkD = new TH1F( \"MVA_LikelihoodD\", \"MVA_LikelihoodD\", nbin, -1, 0.9999 );\n", "if (Use[\"LikelihoodPCA\"]) histLkPCA = new TH1F( \"MVA_LikelihoodPCA\", \"MVA_LikelihoodPCA\", nbin, -1, 1 );\n", "if (Use[\"LikelihoodKDE\"]) histLkKDE = new TH1F( \"MVA_LikelihoodKDE\", \"MVA_LikelihoodKDE\", nbin, -0.00001, 0.99999 );\n", "if (Use[\"LikelihoodMIX\"]) histLkMIX = new TH1F( \"MVA_LikelihoodMIX\", \"MVA_LikelihoodMIX\", nbin, 0, 1 );\n", "if (Use[\"PDERS\"]) histPD = new TH1F( \"MVA_PDERS\", \"MVA_PDERS\", nbin, 0, 1 );\n", "if (Use[\"PDERSD\"]) histPDD = new TH1F( \"MVA_PDERSD\", \"MVA_PDERSD\", nbin, 0, 1 );\n", "if (Use[\"PDERSPCA\"]) histPDPCA = new TH1F( \"MVA_PDERSPCA\", \"MVA_PDERSPCA\", nbin, 0, 1 );\n", "if (Use[\"KNN\"]) histKNN = new TH1F( \"MVA_KNN\", \"MVA_KNN\", nbin, 0, 1 );\n", "if (Use[\"HMatrix\"]) histHm = new TH1F( \"MVA_HMatrix\", \"MVA_HMatrix\", nbin, -0.95, 1.55 );\n", "if (Use[\"Fisher\"]) histFi = new TH1F( \"MVA_Fisher\", \"MVA_Fisher\", nbin, -4, 4 );\n", "if (Use[\"FisherG\"]) histFiG = new TH1F( \"MVA_FisherG\", \"MVA_FisherG\", nbin, -1, 1 );\n", "if (Use[\"BoostedFisher\"]) histFiB = new TH1F( \"MVA_BoostedFisher\", \"MVA_BoostedFisher\", nbin, -2, 2 );\n", "if (Use[\"LD\"]) histLD = new TH1F( \"MVA_LD\", \"MVA_LD\", nbin, -2, 2 );\n", "if (Use[\"MLP\"]) histNn = new TH1F( \"MVA_MLP\", \"MVA_MLP\", nbin, -1.25, 1.5 );\n", "if (Use[\"MLPBFGS\"]) histNnbfgs = new TH1F( \"MVA_MLPBFGS\", \"MVA_MLPBFGS\", nbin, -1.25, 1.5 );\n", "if (Use[\"MLPBNN\"]) histNnbnn = new TH1F( \"MVA_MLPBNN\", \"MVA_MLPBNN\", nbin, -1.25, 1.5 );\n", "if (Use[\"CFMlpANN\"]) histNnC = new TH1F( \"MVA_CFMlpANN\", \"MVA_CFMlpANN\", nbin, 0, 1 );\n", "if (Use[\"TMlpANN\"]) histNnT = new TH1F( \"MVA_TMlpANN\", \"MVA_TMlpANN\", nbin, -1.3, 1.3 );\n", "if (Use[\"DNN_GPU\"]) histDnnGpu = new TH1F(\"MVA_DNN_GPU\", \"MVA_DNN_GPU\", nbin, -0.1, 1.1);\n", "if (Use[\"DNN_CPU\"]) histDnnCpu = new TH1F(\"MVA_DNN_CPU\", \"MVA_DNN_CPU\", nbin, -0.1, 1.1);\n", "if (Use[\"BDT\"]) histBdt = new TH1F( \"MVA_BDT\", \"MVA_BDT\", nbin, -0.8, 0.8 );\n", "if (Use[\"BDTG\"]) histBdtG = new TH1F( \"MVA_BDTG\", \"MVA_BDTG\", nbin, -1.0, 1.0 );\n", "if (Use[\"BDTB\"]) histBdtB = new TH1F( \"MVA_BDTB\", \"MVA_BDTB\", nbin, -1.0, 1.0 );\n", "if (Use[\"BDTD\"]) histBdtD = new TH1F( \"MVA_BDTD\", \"MVA_BDTD\", nbin, -0.8, 0.8 );\n", "if (Use[\"BDTF\"]) histBdtF = new TH1F( \"MVA_BDTF\", \"MVA_BDTF\", nbin, -1.0, 1.0 );\n", "if (Use[\"RuleFit\"]) histRf = new TH1F( \"MVA_RuleFit\", \"MVA_RuleFit\", nbin, -2.0, 2.0 );\n", "if (Use[\"SVM_Gauss\"]) histSVMG = new TH1F( \"MVA_SVM_Gauss\", \"MVA_SVM_Gauss\", nbin, 0.0, 1.0 );\n", "if (Use[\"SVM_Poly\"]) histSVMP = new TH1F( \"MVA_SVM_Poly\", \"MVA_SVM_Poly\", nbin, 0.0, 1.0 );\n", "if (Use[\"SVM_Lin\"]) histSVML = new TH1F( \"MVA_SVM_Lin\", \"MVA_SVM_Lin\", nbin, 0.0, 1.0 );\n", "if (Use[\"FDA_MT\"]) histFDAMT = new TH1F( \"MVA_FDA_MT\", \"MVA_FDA_MT\", nbin, -2.0, 3.0 );\n", "if (Use[\"FDA_GA\"]) histFDAGA = new TH1F( \"MVA_FDA_GA\", \"MVA_FDA_GA\", nbin, -2.0, 3.0 );\n", "if (Use[\"Category\"]) histCat = new TH1F( \"MVA_Category\", \"MVA_Category\", nbin, -2., 2. );\n", "if (Use[\"Plugin\"]) histPBdt = new TH1F( \"MVA_PBDT\", \"MVA_BDT\", nbin, -0.8, 0.8 );" ] }, { "cell_type": "markdown", "id": "53f560c2", "metadata": {}, "source": [ "PDEFoam also returns per-event error, fill in histogram, and also fill significance" ] }, { "cell_type": "code", "execution_count": 22, "id": "38086def", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:24:07.121228Z", "iopub.status.busy": "2026-05-19T20:24:07.121107Z", "iopub.status.idle": "2026-05-19T20:24:07.323281Z", "shell.execute_reply": "2026-05-19T20:24:07.322705Z" } }, "outputs": [], "source": [ "if (Use[\"PDEFoam\"]) {\n", " histPDEFoam = new TH1F( \"MVA_PDEFoam\", \"MVA_PDEFoam\", nbin, 0, 1 );\n", " histPDEFoamErr = new TH1F( \"MVA_PDEFoamErr\", \"MVA_PDEFoam error\", nbin, 0, 1 );\n", " histPDEFoamSig = new TH1F( \"MVA_PDEFoamSig\", \"MVA_PDEFoam significance\", nbin, 0, 10 );\n", "}" ] }, { "cell_type": "markdown", "id": "f3002f4f", "metadata": {}, "source": [ "Book example histogram for probability (the other methods are done similarly)" ] }, { "cell_type": "code", "execution_count": 23, "id": "3745613b", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:24:07.325274Z", "iopub.status.busy": "2026-05-19T20:24:07.325148Z", "iopub.status.idle": "2026-05-19T20:24:07.527057Z", "shell.execute_reply": "2026-05-19T20:24:07.526695Z" } }, "outputs": [], "source": [ "TH1F *probHistFi(0), *rarityHistFi(0);\n", "if (Use[\"Fisher\"]) {\n", " probHistFi = new TH1F( \"MVA_Fisher_Proba\", \"MVA_Fisher_Proba\", nbin, 0, 1 );\n", " rarityHistFi = new TH1F( \"MVA_Fisher_Rarity\", \"MVA_Fisher_Rarity\", nbin, 0, 1 );\n", "}" ] }, { "cell_type": "markdown", "id": "302a6044", "metadata": {}, "source": [ "Prepare input tree (this must be replaced by your data source)\n", "in this example, there is a toy tree with signal and one with background events\n", "we'll later on use only the \"signal\" events for the test in this example." ] }, { "cell_type": "code", "execution_count": 24, "id": "e8d9aa85", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:24:07.528850Z", "iopub.status.busy": "2026-05-19T20:24:07.528738Z", "iopub.status.idle": "2026-05-19T20:24:07.735138Z", "shell.execute_reply": "2026-05-19T20:24:07.734648Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "--- TMVAClassificationApp : Using input file: /github/home/ROOT-CI/build/tutorials/machine_learning/data/tmva_class_example.root\n" ] } ], "source": [ "TFile *input(nullptr);\n", "TString fname = gROOT->GetTutorialDir() + \"/machine_learning/data/tmva_class_example.root\";\n", "if (!gSystem->AccessPathName( fname )) {\n", " input = TFile::Open( fname ); // check if file in local directory exists\n", "}\n", "if (!input) {\n", " std::cout << \"ERROR: could not open data file\" << std::endl;\n", " exit(1);\n", "}\n", "std::cout << \"--- TMVAClassificationApp : Using input file: \" << input->GetName() << std::endl;" ] }, { "cell_type": "markdown", "id": "2694507c", "metadata": {}, "source": [ "Event loop" ] }, { "cell_type": "markdown", "id": "c0acc0b3", "metadata": {}, "source": [ "Prepare the event tree\n", "- Here the variable names have to corresponds to your tree\n", "- You can use the same variables as above which is slightly faster,\n", "but of course you can use different ones and copy the values inside the event loop" ] }, { "cell_type": "code", "execution_count": 25, "id": "e13fee50", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:24:07.736690Z", "iopub.status.busy": "2026-05-19T20:24:07.736533Z", "iopub.status.idle": "2026-05-19T20:24:07.938967Z", "shell.execute_reply": "2026-05-19T20:24:07.938478Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "--- Select signal sample\n" ] } ], "source": [ "std::cout << \"--- Select signal sample\" << std::endl;\n", "TTree* theTree = (TTree*)input->Get(\"TreeS\");\n", "Float_t userVar1, userVar2;\n", "theTree->SetBranchAddress( \"var1\", &userVar1 );\n", "theTree->SetBranchAddress( \"var2\", &userVar2 );\n", "theTree->SetBranchAddress( \"var3\", &var3 );\n", "theTree->SetBranchAddress( \"var4\", &var4 );" ] }, { "cell_type": "markdown", "id": "f5476427", "metadata": {}, "source": [ "Efficiency calculator for cut method" ] }, { "cell_type": "code", "execution_count": 26, "id": "856727ae", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:24:07.940221Z", "iopub.status.busy": "2026-05-19T20:24:07.940105Z", "iopub.status.idle": "2026-05-19T20:24:08.875084Z", "shell.execute_reply": "2026-05-19T20:24:08.874332Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "--- Processing: 6000 events\n", "--- ... Processing event: 0\n", " : Rebuilding Dataset Default\n", "--- ... Processing event: 1000\n", "--- ... Processing event: 2000\n", "--- ... Processing event: 3000\n", "--- ... Processing event: 4000\n", "--- ... Processing event: 5000\n" ] } ], "source": [ "Int_t nSelCutsGA = 0;\n", "Double_t effS = 0.7;\n", "\n", "std::vector vecVar(4); // vector for EvaluateMVA tests\n", "\n", "std::cout << \"--- Processing: \" << theTree->GetEntries() << \" events\" << std::endl;\n", "TStopwatch sw;\n", "sw.Start();\n", "for (Long64_t ievt=0; ievtGetEntries();ievt++) {\n", "\n", " if (ievt%1000 == 0) std::cout << \"--- ... Processing event: \" << ievt << std::endl;\n", "\n", " theTree->GetEntry(ievt);\n", "\n", " var1 = userVar1 + userVar2;\n", " var2 = userVar1 - userVar2;\n", "\n", " // Return the MVA outputs and fill into histograms\n", "\n", " if (Use[\"CutsGA\"]) {\n", " // Cuts is a special case: give the desired signal efficiency\n", " Bool_t passed = reader->EvaluateMVA( \"CutsGA method\", effS );\n", " if (passed) nSelCutsGA++;\n", " }\n", "\n", " if (Use[\"Likelihood\" ]) histLk ->Fill( reader->EvaluateMVA( \"Likelihood method\" ) );\n", " if (Use[\"LikelihoodD\" ]) histLkD ->Fill( reader->EvaluateMVA( \"LikelihoodD method\" ) );\n", " if (Use[\"LikelihoodPCA\"]) histLkPCA ->Fill( reader->EvaluateMVA( \"LikelihoodPCA method\" ) );\n", " if (Use[\"LikelihoodKDE\"]) histLkKDE ->Fill( reader->EvaluateMVA( \"LikelihoodKDE method\" ) );\n", " if (Use[\"LikelihoodMIX\"]) histLkMIX ->Fill( reader->EvaluateMVA( \"LikelihoodMIX method\" ) );\n", " if (Use[\"PDERS\" ]) histPD ->Fill( reader->EvaluateMVA( \"PDERS method\" ) );\n", " if (Use[\"PDERSD\" ]) histPDD ->Fill( reader->EvaluateMVA( \"PDERSD method\" ) );\n", " if (Use[\"PDERSPCA\" ]) histPDPCA ->Fill( reader->EvaluateMVA( \"PDERSPCA method\" ) );\n", " if (Use[\"KNN\" ]) histKNN ->Fill( reader->EvaluateMVA( \"KNN method\" ) );\n", " if (Use[\"HMatrix\" ]) histHm ->Fill( reader->EvaluateMVA( \"HMatrix method\" ) );\n", " if (Use[\"Fisher\" ]) histFi ->Fill( reader->EvaluateMVA( \"Fisher method\" ) );\n", " if (Use[\"FisherG\" ]) histFiG ->Fill( reader->EvaluateMVA( \"FisherG method\" ) );\n", " if (Use[\"BoostedFisher\"]) histFiB ->Fill( reader->EvaluateMVA( \"BoostedFisher method\" ) );\n", " if (Use[\"LD\" ]) histLD ->Fill( reader->EvaluateMVA( \"LD method\" ) );\n", " if (Use[\"MLP\" ]) histNn ->Fill( reader->EvaluateMVA( \"MLP method\" ) );\n", " if (Use[\"MLPBFGS\" ]) histNnbfgs ->Fill( reader->EvaluateMVA( \"MLPBFGS method\" ) );\n", " if (Use[\"MLPBNN\" ]) histNnbnn ->Fill( reader->EvaluateMVA( \"MLPBNN method\" ) );\n", " if (Use[\"CFMlpANN\" ]) histNnC ->Fill( reader->EvaluateMVA( \"CFMlpANN method\" ) );\n", " if (Use[\"TMlpANN\" ]) histNnT ->Fill( reader->EvaluateMVA( \"TMlpANN method\" ) );\n", " if (Use[\"DNN_GPU\"]) histDnnGpu->Fill(reader->EvaluateMVA(\"DNN_GPU method\"));\n", " if (Use[\"DNN_CPU\"]) histDnnCpu->Fill(reader->EvaluateMVA(\"DNN_CPU method\"));\n", " if (Use[\"BDT\" ]) histBdt ->Fill( reader->EvaluateMVA( \"BDT method\" ) );\n", " if (Use[\"BDTG\" ]) histBdtG ->Fill( reader->EvaluateMVA( \"BDTG method\" ) );\n", " if (Use[\"BDTB\" ]) histBdtB ->Fill( reader->EvaluateMVA( \"BDTB method\" ) );\n", " if (Use[\"BDTD\" ]) histBdtD ->Fill( reader->EvaluateMVA( \"BDTD method\" ) );\n", " if (Use[\"BDTF\" ]) histBdtF ->Fill( reader->EvaluateMVA( \"BDTF method\" ) );\n", " if (Use[\"RuleFit\" ]) histRf ->Fill( reader->EvaluateMVA( \"RuleFit method\" ) );\n", " if (Use[\"SVM_Gauss\" ]) histSVMG ->Fill( reader->EvaluateMVA( \"SVM_Gauss method\" ) );\n", " if (Use[\"SVM_Poly\" ]) histSVMP ->Fill( reader->EvaluateMVA( \"SVM_Poly method\" ) );\n", " if (Use[\"SVM_Lin\" ]) histSVML ->Fill( reader->EvaluateMVA( \"SVM_Lin method\" ) );\n", " if (Use[\"FDA_MT\" ]) histFDAMT ->Fill( reader->EvaluateMVA( \"FDA_MT method\" ) );\n", " if (Use[\"FDA_GA\" ]) histFDAGA ->Fill( reader->EvaluateMVA( \"FDA_GA method\" ) );\n", " if (Use[\"Category\" ]) histCat ->Fill( reader->EvaluateMVA( \"Category method\" ) );\n", " if (Use[\"Plugin\" ]) histPBdt ->Fill( reader->EvaluateMVA( \"P_BDT method\" ) );\n", "\n", " // Retrieve also per-event error\n", " if (Use[\"PDEFoam\"]) {\n", " Double_t val = reader->EvaluateMVA( \"PDEFoam method\" );\n", " Double_t err = reader->GetMVAError();\n", " histPDEFoam ->Fill( val );\n", " histPDEFoamErr->Fill( err );\n", " if (err>1.e-50) histPDEFoamSig->Fill( val/err );\n", " }\n", "\n", " // Retrieve probability instead of MVA output\n", " if (Use[\"Fisher\"]) {\n", " probHistFi ->Fill( reader->GetProba ( \"Fisher method\" ) );\n", " rarityHistFi->Fill( reader->GetRarity( \"Fisher method\" ) );\n", " }\n", "}" ] }, { "cell_type": "markdown", "id": "34f60dbd", "metadata": {}, "source": [ "Get elapsed time" ] }, { "cell_type": "code", "execution_count": 27, "id": "5078d244", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:24:08.876561Z", "iopub.status.busy": "2026-05-19T20:24:08.876434Z", "iopub.status.idle": "2026-05-19T20:24:09.084157Z", "shell.execute_reply": "2026-05-19T20:24:09.083415Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "--- End of event loop: Real time 0:00:00, CP time 0.650\n" ] } ], "source": [ "sw.Stop();\n", "std::cout << \"--- End of event loop: \"; sw.Print();" ] }, { "cell_type": "markdown", "id": "6dc111c6", "metadata": {}, "source": [ "Get efficiency for cuts classifier" ] }, { "cell_type": "code", "execution_count": 28, "id": "401dd34e", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:24:09.085628Z", "iopub.status.busy": "2026-05-19T20:24:09.085490Z", "iopub.status.idle": "2026-05-19T20:24:09.288479Z", "shell.execute_reply": "2026-05-19T20:24:09.287197Z" } }, "outputs": [], "source": [ "if (Use[\"CutsGA\"]) std::cout << \"--- Efficiency for CutsGA method: \" << double(nSelCutsGA)/theTree->GetEntries()\n", " << \" (for a required signal efficiency of \" << effS << \")\" << std::endl;\n", "\n", "if (Use[\"CutsGA\"]) {\n", "\n", " // test: retrieve cuts for particular signal efficiency\n", " TMVA::MethodCuts* mcuts = dynamic_cast(reader->FindMVA( \"CutsGA method\" ));\n", "\n", " if (mcuts) {\n", " std::vector cutsMin;\n", " std::vector cutsMax;\n", " mcuts->GetCuts( 0.7, cutsMin, cutsMax );\n", " std::cout << \"--- -------------------------------------------------------------\" << std::endl;\n", " std::cout << \"--- Retrieve cut values for signal efficiency of 0.7 from Reader\" << std::endl;\n", " for (UInt_t ivar=0; ivarGetInputVar(ivar)\n", " << \"\\\" <= \"\n", " << cutsMax[ivar] << std::endl;\n", " }\n", " std::cout << \"--- -------------------------------------------------------------\" << std::endl;\n", " }\n", "}" ] }, { "cell_type": "markdown", "id": "dc0d106e", "metadata": {}, "source": [ "Write histograms" ] }, { "cell_type": "code", "execution_count": 29, "id": "cbb7831b", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:24:09.290462Z", "iopub.status.busy": "2026-05-19T20:24:09.290283Z", "iopub.status.idle": "2026-05-19T20:24:09.499364Z", "shell.execute_reply": "2026-05-19T20:24:09.498114Z" } }, "outputs": [], "source": [ "TFile *target = new TFile( \"TMVApp.root\",\"RECREATE\" );\n", "if (Use[\"Likelihood\" ]) histLk ->Write();\n", "if (Use[\"LikelihoodD\" ]) histLkD ->Write();\n", "if (Use[\"LikelihoodPCA\"]) histLkPCA ->Write();\n", "if (Use[\"LikelihoodKDE\"]) histLkKDE ->Write();\n", "if (Use[\"LikelihoodMIX\"]) histLkMIX ->Write();\n", "if (Use[\"PDERS\" ]) histPD ->Write();\n", "if (Use[\"PDERSD\" ]) histPDD ->Write();\n", "if (Use[\"PDERSPCA\" ]) histPDPCA ->Write();\n", "if (Use[\"KNN\" ]) histKNN ->Write();\n", "if (Use[\"HMatrix\" ]) histHm ->Write();\n", "if (Use[\"Fisher\" ]) histFi ->Write();\n", "if (Use[\"FisherG\" ]) histFiG ->Write();\n", "if (Use[\"BoostedFisher\"]) histFiB ->Write();\n", "if (Use[\"LD\" ]) histLD ->Write();\n", "if (Use[\"MLP\" ]) histNn ->Write();\n", "if (Use[\"MLPBFGS\" ]) histNnbfgs ->Write();\n", "if (Use[\"MLPBNN\" ]) histNnbnn ->Write();\n", "if (Use[\"CFMlpANN\" ]) histNnC ->Write();\n", "if (Use[\"TMlpANN\" ]) histNnT ->Write();\n", "if (Use[\"DNN_GPU\"]) histDnnGpu->Write();\n", "if (Use[\"DNN_CPU\"]) histDnnCpu->Write();\n", "if (Use[\"BDT\" ]) histBdt ->Write();\n", "if (Use[\"BDTG\" ]) histBdtG ->Write();\n", "if (Use[\"BDTB\" ]) histBdtB ->Write();\n", "if (Use[\"BDTD\" ]) histBdtD ->Write();\n", "if (Use[\"BDTF\" ]) histBdtF ->Write();\n", "if (Use[\"RuleFit\" ]) histRf ->Write();\n", "if (Use[\"SVM_Gauss\" ]) histSVMG ->Write();\n", "if (Use[\"SVM_Poly\" ]) histSVMP ->Write();\n", "if (Use[\"SVM_Lin\" ]) histSVML ->Write();\n", "if (Use[\"FDA_MT\" ]) histFDAMT ->Write();\n", "if (Use[\"FDA_GA\" ]) histFDAGA ->Write();\n", "if (Use[\"Category\" ]) histCat ->Write();\n", "if (Use[\"Plugin\" ]) histPBdt ->Write();" ] }, { "cell_type": "markdown", "id": "7bc12019", "metadata": {}, "source": [ "Write also error and significance histos" ] }, { "cell_type": "code", "execution_count": 30, "id": "bb1d4bbb", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:24:09.501336Z", "iopub.status.busy": "2026-05-19T20:24:09.501156Z", "iopub.status.idle": "2026-05-19T20:24:09.707707Z", "shell.execute_reply": "2026-05-19T20:24:09.707105Z" } }, "outputs": [], "source": [ "if (Use[\"PDEFoam\"]) { histPDEFoam->Write(); histPDEFoamErr->Write(); histPDEFoamSig->Write(); }" ] }, { "cell_type": "markdown", "id": "e253263e", "metadata": {}, "source": [ "Write also probability hists" ] }, { "cell_type": "code", "execution_count": 31, "id": "2e6d20b3", "metadata": { "collapsed": false, "execution": { "iopub.execute_input": "2026-05-19T20:24:09.712764Z", "iopub.status.busy": "2026-05-19T20:24:09.712598Z", "iopub.status.idle": "2026-05-19T20:24:09.924588Z", "shell.execute_reply": "2026-05-19T20:24:09.923860Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "--- Created root file: \"TMVApp.root\" containing the MVA output histograms\n", "==> TMVAClassificationApplication is done!\n", "\n" ] } ], "source": [ "if (Use[\"Fisher\"]) { if (probHistFi != 0) probHistFi->Write(); if (rarityHistFi != 0) rarityHistFi->Write(); }\n", "target->Close();\n", "\n", "std::cout << \"--- Created root file: \\\"TMVApp.root\\\" containing the MVA output histograms\" << std::endl;\n", "\n", "delete reader;\n", "\n", "std::cout << \"==> TMVAClassificationApplication is done!\" << std::endl << std::endl;" ] } ], "metadata": { "kernelspec": { "display_name": "ROOT C++", "language": "c++", "name": "root" }, "language_info": { "codemirror_mode": "text/x-c++src", "file_extension": ".C", "mimetype": " text/x-c++src", "name": "c++" } }, "nbformat": 4, "nbformat_minor": 5 }