Home | News | Documentation | Download

How to recompile cxx TMVA code on Centos7

Dear TMVA Experts,
I would like to recompile my code which was written for TMVA using the .cxx files and Makefile.arch. I successfully recompiled and run the setup using TMVA-v4.2.0 and SLC6, but I am not able to use this Makefile with ROOT 6.20.00 and Centos7.

Please point me to some instructions how to recompile my .cxx code with any ROOT version that can be used with Centos7.

My old setup using SLC6:
Download: http://sourceforge.net/projects/tmva
edit src/KDEKernel.cxx, add #include TMath.h
localSetupROOT --rootVersion=6.02.12-x86_64-slc6-gcc48-opt
cd TMVA-v4.2.0
cd test
source setup.sh
mv TMVAClassification.cxx TMVAClassification.cxx_orig
mv TMVAClassificationApplication.cxx TMVAClassificationApplication.cxx_orig

Copy my code to folder TEST

cp TEST/TMVAClassification.cxx .
cp TEST/TMVAClassificationApplication.cxx .
cp TEST/mvaeffs_temp.C .
cd …/lib
ln -s …/src/TMVA_Dict*.pcm .


The standalone version in sourceforge of TMVA is an old version not anymore maintained, and it will not work with newer ROOT versions (e.g. 6.20)

You should use the TMVA library provided directly within ROOT


Hi Lorenzo,
I was able to run the test jobs for TMVAClassification.C and .py versions, but I am not sure how to re-run my .cxx code. Is there some prescription how to compile and run the .cxx files (that worked well with previous TMVA/ROOT versions).
Many thanks in advance,


After having adapted your code to the new version of TMVA (e.g. using now the DataLoader class), see example code in tutorials/tmva/TMVAClassification.C, you need to compile your .cxx files setting the include flags and library flags to ROOT.
You can use for example root-config

 g++ `root-config --cflags --libs` -lTMVA my_file.cxx


Hi Lorenzo,
Many thanks for the instructions. I will try to migrate to DataLoader in the next iteration. For the time being I managed to compile my code by sourcing the older ROOT version (root 6.02.12-x86_64-slc6-gcc48-opt) and makefile below (slightly modified from current in tutorials/tmva). I will try to run my setup like this now, as it is already validated, and the change to DataLoader might need some extra checks, which can introduce delay. However, in future I will make sure to have code based on DataLoader.
Many thanks for your help!

BINS = TMVAClassification

CXX = g++
CCFLAGS = (shell root-config --cflags) -ggdb -I/(ROOTSYS)

LD = g++

LIBS = $(shell root-config --libs) -lMLP -lMinuit -lTreePlayer -lTMVA -lXMLIO -lMLP -lm

default : $(BINS)

(BINS): % : %.cxx @echo -n "Building @ … "
(CXX) (CCFLAGS) < (LIBS) -o $@
@echo “Done”

rm -f *.o $(BINS)