# Error when running TMVAGUI.C

**URL:** <https://root-forum.cern.ch/t/error-when-running-tmvagui-c/25258>\
**Category:** TMVA\
**Created:** [June 22, 2017, 3:09pm UTC](https://root-forum.cern.ch/t/error-when-running-tmvagui-c/25258 "2017-06-22T15:09:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gdule](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/g/e36b37/32.png) [@gdule](https://root-forum.cern.ch/u/gdule)\
**Post date:** [June 22, 2017, 3:09pm UTC](https://root-forum.cern.ch/t/error-when-running-tmvagui-c/25258/1 "2017-06-22T15:09:53Z")

</div>

Hello,

I was trying to analyze test.root (a BDT), using TMVAGUI.C, and this error popped up:

```auto
--- Launch TMVA GUI to view input file: test.root
Warning in <TFile::Init>: file test.root probably not closed, trying to recover
Info in <TFile::Recover>: test.root, recovered key TH2F:CorrelationMatrixS at address 214
Info in <TFile::Recover>: test.root, recovered key TH2F:CorrelationMatrixB at address 668
Info in <TFile::Recover>: test.root, recovered key TDirectoryFile:InputVariables_Id at address 1131
Info in <TFile::Recover>: test.root, recovered key TDirectoryFile:InputVariables_Deco at address 23302
Info in <TFile::Recover>: test.root, recovered key TDirectoryFile:InputVariables_PCA at address 45522
Info in <TFile::Recover>: test.root, recovered key TDirectoryFile:InputVariables_Gauss_Deco at address 68694
Info in <TFile::Recover>: test.root, recovered key TDirectoryFile:Method_BDT at address 86288
Info in <TFile::Recover>: test.root, recovered key TTree:TestTree at address 484730
Info in <TFile::Recover>: test.root, recovered key TTree:TrainTree at address 597288
Warning in <TFile::Init>: successfully recovered 9 keys
=== Note: inactive buttons indicate classifiers that were not trained, ===
=== or functionalities that were not invoked during the training ===

```

test.root is from this TMVA tutorial: [https://indico.scc.kit.edu/indico/event/48/session/4/contribution/35/material/slides/0.pdf](https://indico.scc.kit.edu/indico/event/48/session/4/contribution/35/material/slides/0.pdf)

and the relevant files:  
[test.root](https://root-forum.cern.ch/uploads/default/original/2X/b/b581844880a9bf18e983631e353b351d6c1eeb79.root) (584.2 KB)  
[TMVAGui.C](https://root-forum.cern.ch/uploads/default/original/2X/5/5df512d252ff039063c5347a7e0f675a33734b92.C) (11.6 KB)

I’ve tried to run the script from inside and outside of test.root, with no difference, and I’m not really sure whats the problem.

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [June 23, 2017, 8:57am UTC](https://root-forum.cern.ch/t/error-when-running-tmvagui-c/25258/2 "2017-06-23T08:57:23Z")

</div>

Hi

The problem is in the output file resulting from your previous macro where you trained and test TMVA methods.  
The file was not closed properly. Maybe there were some problems before completing the macro.  
You should look at its output and understand the problem. You should call

```auto
outputFile->Close();

```

after having called `factory->EvaluateAllMethods()`, as it is done in the tutorial  
tmva/TMVAClassification.C

Best Regards

Lorenzo

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [June 23, 2017, 9:00am UTC](https://root-forum.cern.ch/t/error-when-running-tmvagui-c/25258/3 "2017-06-23T09:00:06Z")

</div>

Looking better, I see that it seems you are using the macro , [trainBDT.py](http://trainBDT.py) from  
[https://www.dropbox.com/sh/scualho2zcv83hh/AAAnsm-gAqRa-5lX7uPwMH3Ga?preview=trainBDT.py](https://www.dropbox.com/sh/scualho2zcv83hh/AAAnsm-gAqRa-5lX7uPwMH3Ga?preview=trainBDT.py)

you need to add this line at the end of the macro

```auto
fout.Close()

```

Lorenzo

---

<div class="post-metadata">

**Author:** ![gdule](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/g/e36b37/32.png) [@gdule](https://root-forum.cern.ch/u/gdule)\
**Post date:** [June 23, 2017, 9:17am UTC](https://root-forum.cern.ch/t/error-when-running-tmvagui-c/25258/4 "2017-06-23T09:17:11Z")

</div>

Works like a charm!

Thank you!
