# Problem with TMVA::Reader

**URL:** <https://root-forum.cern.ch/t/problem-with-tmva-reader/16517>\
**Category:** TMVA\
**Created:** [August 12, 2013, 10:32am UTC](https://root-forum.cern.ch/t/problem-with-tmva-reader/16517 "2013-08-12T10:32:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![stspencer](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/b5a626/32.png) [@stspencer](https://root-forum.cern.ch/u/stspencer)\
**Post date:** [August 12, 2013, 10:32am UTC](https://root-forum.cern.ch/t/problem-with-tmva-reader/16517/1 "2013-08-12T10:32:50Z")

</div>

Hi,  
I’m trying to apply a mlp trained on one set of data to another set of data using TMVA::Reader, similar to: [http://www.google.co.uk/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0CC0QFjAA&url=http%3A%2F%2Findico.cern.ch%2FmaterialDisplay.py%3FcontribId%3D37%26materialId%3Dslides%26confId%3D217511&ei=hbgIUvTUGe-b1AWV-IH4Dg&usg=AFQjCNGzl2\_FihjkLFHsZsuLPmP15vI9lg&bvm=bv.50500085,d.d2k&cad=rja](http://www.google.co.uk/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0CC0QFjAA&url=http%3A%2F%2Findico.cern.ch%2FmaterialDisplay.py%3FcontribId%3D37%26materialId%3Dslides%26confId%3D217511&ei=hbgIUvTUGe-b1AWV-IH4Dg&usg=AFQjCNGzl2_FihjkLFHsZsuLPmP15vI9lg&bvm=bv.50500085,d.d2k&cad=rja) using ROOT v5.34/03 and TMVA v4.1.3 on Red Hat Enterprise Linux. Unfortunately, when I try to run my code (which compiles):

```auto

#include <cstdlib>
#include <iostream>
#include <map>
#include <string>

#include "TChain.h"
#include "TFile.h"
#include "TTree.h"
#include "TString.h"
#include "TObjString.h"
#include "TSystem.h"
#include "TROOT.h"
#include "TMVA/Factory.h"
#include "TMVA/Tools.h"
#include "TNtuple.h"
#include "TMVA/Reader.h"

using namespace std;
int main(){
  TMVA::Tools::Instance();
  TFile *input=TFile::Open("/gam/datag/tvvd43/Tfiles/TRAINF/TMVARUNF.root");
  TTree* theTree=(TTree*)input->Get("TreeS");
  TString outfileName( "/gam/datag/tvvd43/Tfiles/TRAINU/UTESTF.root" );
  TNtuple* ntuple_response=new TNtuple("ntuple","ntuple","out");
  TFile* outputFile = TFile::Open(outfileName,"RECREATE");
  TMVA::Reader *reader=new TMVA::Reader("!Color");

  Float_t G,a,b,c,d,e,f,g,h,l,difference;
  
  reader->AddVariable("G",&G);
  reader->AddVariable("a",&a);
  reader->AddVariable("b",&b);
  reader->AddVariable("c",&c);
  reader->AddVariable("d",&d);
  reader->AddVariable("e",&e);
  reader->AddVariable("f",&f);
  reader->AddVariable("g",&g);
  reader->AddVariable("h",&h);
  reader->AddVariable("l",&l);
  reader->AddVariable("difference",&difference);

  //Train signal and background on a third each
  reader->BookMVA("MLP classifier","/gam/datag/tvvd43/Tfiles/TRAINU/weights/TMVAClassification_MLP.weights.xml");
  
  for(Long64_t ievt=0;ievt<theTree->GetEntries();ievt++){
    theTree->GetEntry(ievt);
    Float_t localG=G;
    Float_t locala=a;
    Float_t localb=b;
    Float_t localc=c;
    Float_t locald=d;
    Float_t locale=e;
    Float_t localf=f;
    Float_t localg=g;
    Float_t localh=h;
    Float_t locall=l;
    Float_t localdifference=difference;
    Double_t out=reader->EvaluateMVA("MLP classifier");
    ntuple_response->Fill(out);
    cout<<"out:"<<out<<"\n";
  }
  ntuple_response->Write();
  outputFile->Close();

  std::cout << "==> Wrote root file: " << outputFile->GetName() << std::endl;
  std::cout << "==> TMVAClassification is done!" << std::endl;

  delete reader;
  
  return 1;
}
```

I get a segmentation fault. Here’s the trace from gdb:

— Reader : Booking “MLP classifier” of type “MLP” from /gam/datag/tvvd43/Tfiles/TRAINU/weights/TMVAClassification\_MLP.weights.xml.  
— MethodBase : Reading weight file: /gam/datag/tvvd43/Tfiles/TRAINU/weights/TMVAClassification\_MLP.weights.xml  
— MLP : Read method “MLP” of type “MLP”  
— MLP : MVA method was trained with TMVA Version: 4.1.3  
— MLP : MVA method was trained with ROOT Version: 5.34/03  
— DataSetInfo : Added class “Signal” with internal class number 0  
— DataSetInfo : Added class “Background” with internal class number 1  
— MLP : Building Network  
— MLP : Initializing weights  
— Reader : Booked classifier “MLP” of type: “MLP”

\*\*\* Break \*\*\* segmentation violation

# =========================================================== There was a crash. This is the entire stack trace of all threads:

# #0 0x00000034112abf9e in waitpid () from /lib64/libc.so.6 #1 0x000000341123e899 in do\_system () from /lib64/libc.so.6 #2 0x00007f9442d17c18 in TUnixSystem::StackTrace() () from /gam/opt/root-v5-34-03/lib/libCore.so.5.34 #3 0x00007f9442d16a93 in TUnixSystem::DispatchSignals(ESignals) () from /gam/opt/root-v5-34-03/lib/libCore.so.5.34 #4 #5 0x0000000000401658 in main ()

# The lines below might hint at the cause of the crash. If they do not help you then please submit a bug report at [root.cern.ch/bugs](http://root.cern.ch/bugs). Please post the ENTIRE stack trace from above as an attachment in addition to anything else that might help us fixing this issue.

# #5 0x0000000000401658 in main ()

[tvvd43@green3 tvvd43]$ gdb ./neuralnetUtestF  
GNU gdb (GDB) Red Hat Enterprise Linux (7.2-60.el6)  
Copyright © 2010 Free Software Foundation, Inc.  
License GPLv3+: GNU GPL version 3 or later [http://gnu.org/licenses/gpl.html](http://gnu.org/licenses/gpl.html)  
This is free software: you are free to change and redistribute it.  
There is NO WARRANTY, to the extent permitted by law. Type "show copying"  
and “show warranty” for details.  
This GDB was configured as “x86\_64-redhat-linux-gnu”.  
For bug reporting instructions, please see:  
[http://www.gnu.org/software/gdb/bugs/](http://www.gnu.org/software/gdb/bugs/)…  
Reading symbols from /gam/home/tvvd43/neuralnetUtestF…(no debugging symbols found)…done.  
(gdb) run  
Starting program: /gam/home/tvvd43/neuralnetUtestF  
[Thread debugging using libthread\_db enabled]  
— Reader : Booking “MLP classifier” of type “MLP” from /gam/datag/tvvd43/Tfiles/TRAINU/weights/TMVAClassification\_MLP.weights.xml.  
— MethodBase : Reading weight file: /gam/datag/tvvd43/Tfiles/TRAINU/weights/TMVAClassification\_MLP.weights.xml  
— MLP : Read method “MLP” of type “MLP”  
— MLP : MVA method was trained with TMVA Version: 4.1.3  
— MLP : MVA method was trained with ROOT Version: 5.34/03  
— DataSetInfo : Added class “Signal” with internal class number 0  
— DataSetInfo : Added class “Background” with internal class number 1  
— MLP : Building Network  
— MLP : Initializing weights  
— Reader : Booked classifier “MLP” of type: “MLP”

Program received signal SIGSEGV, Segmentation fault.  
0x0000000000401658 in main ()  
Missing separate debuginfos, use: debuginfo-install freetype-2.3.11-14.el6\_3.1.x86\_64 glibc-2.12-1.80.el6\_3.5.x86\_64 keyutils-libs-1.4-4.el6.x86\_64 krb5-libs-1.10.3-10.el6\_4.3.x86\_64 libcom\_err-1.41.12-12.el6.x86\_64 libgcc-4.4.6-4.el6.x86\_64 libselinux-2.0.94-5.3.el6.x86\_64 libstdc+±4.4.6-4.el6.x86\_64 openssl-1.0.0-27.el6\_4.2.x86\_64 zlib-1.2.3-29.el6.x86\_64

I apologise if I’m being noobish, I’m new to root. Any help would be much appreciated.
