# Problem with TMVA package. Factory methods are not known

**URL:** <https://root-forum.cern.ch/t/problem-with-tmva-package-factory-methods-are-not-known/26749>\
**Category:** TMVA\
**Created:** [October 31, 2017, 11:09am UTC](https://root-forum.cern.ch/t/problem-with-tmva-package-factory-methods-are-not-known/26749 "2017-10-31T11:09:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![p73](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/p73/32/14141_2.png) [@p73](https://root-forum.cern.ch/u/p73)\
**Post date:** [October 31, 2017, 11:09am UTC](https://root-forum.cern.ch/t/problem-with-tmva-package-factory-methods-are-not-known/26749/1 "2017-10-31T11:09:12Z")

</div>

I am trying to use `TMVA` algorithms for classification problem. Here is my program:

```auto
#ifndef TMVACLASSIFICATION_C                                                        
#define TMVACLASSIFICATION_C
 
#include "TMVA/Types.h"
 
void TMVAClassification()
{
    TFile* outFile = new TFile("../Data/TMVA/kNN/kNN_Classification.root", "RECREATE");
    
    TFile* sigSrc = new TFile("../Data/tr_ph_selected.root");
    TFile* bkgSrc = new TFile("../Data/tr_ph_selected_mhg.root");
    //Get trees from files
    TTree* sigTree = (TTree*)sigSrc->Get("selected");
    TTree* bkgTree = (TTree*)bkgSrc->Get("selected");
    //Weights of trees
    Double_t sigWeight = 1.0;
    Double_t bkgWeight = 1.0;
    //Create Factory objects
    TMVA::Factory* factory =
        new TMVA::Factory( "EtotPtotClf", outFile,
        "AnalysisType=Classification:VarTransform=N,G,D" );
    //Add trees to the analysis
    factory->AddSignalTree( sigTree, sigWeight );
    factory->AddBackgroundTree( bkgTreeTrain, bkgWeight );
    //Add varibles of interest
    factory->AddVariable( "eTotal", "Total Energy of Photons", "MeV", 'F' );
    factory->AddVariable( "pTotal", "Total Momentum of Photons", "MeV/c", 'F' );
    //Preparing trees for processing
    TMVA::Factory::PrepareTrainingAndTestTree();
    //Book method!!! Let's use k Nearest Neighbors method! What's up? =)
    factory->BookMethod( TMVA::Types::kNN, "kNN", "nkKK=40")
    //Train methods
    factory->TrainAllMethods();
    //Test methods
    factory->TestAllMethods();
    //Evaluate methods
    factory->EvaluateAllMethods();
}
#endif              

```

When I try to compile the above macro I get

> error:  
> no member named ‘AddSignalTree’ in ‘TMVA::Factory’  
> factory-\>AddSignalTree( sigTree, sigWeight );

There are similar errors there? What should I do?

* * *

I am using

```auto
   ------------------------------------------------------------
  | Welcome to ROOT 6.08/02 http://root.cern.ch |
  | (c) 1995-2016, The ROOT Team |
  | Built for linuxx8664gcc |
  | From tag v6-08-02, 2 December 2016 |
  | Try '.help', '.demo', '.license', '.credits', '.quit'/'.q' |
   ------------------------------------------------------------

```

---

<div class="post-metadata">

**Author:** ![p73](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/p73/32/14141_2.png) [@p73](https://root-forum.cern.ch/u/p73)\
**Post date:** [October 31, 2017, 12:14pm UTC](https://root-forum.cern.ch/t/problem-with-tmva-package-factory-methods-are-not-known/26749/2 "2017-10-31T12:14:43Z")

</div>

I have found that I should use `DataLoader` object because of the recent ROOT version. Everything is OK now.  
Should I delete this question or provide working code?

---

<div class="post-metadata">

**Author:** ![eguiraud](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eguiraud/32/32217_2.png) [@eguiraud](https://root-forum.cern.ch/u/eguiraud)\
**Post date:** [October 31, 2017, 3:01pm UTC](https://root-forum.cern.ch/t/problem-with-tmva-package-factory-methods-are-not-known/26749/3 "2017-10-31T15:01:27Z")

</div>

You solved your problem, so I marked it as solved 🙂

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [November 14, 2017, 3:01pm UTC](https://root-forum.cern.ch/t/problem-with-tmva-package-factory-methods-are-not-known/26749/4 "2017-11-14T15:01:29Z")

</div>

Closed on November 14, 2017, 3:01pm UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
