Problem with TMVA::Reader

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 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):


#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. 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
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/
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.