# Writing part of the TMVA screen output in a file

**URL:** <https://root-forum.cern.ch/t/writing-part-of-the-tmva-screen-output-in-a-file/49990>\
**Category:** TMVA\
**Created:** [May 16, 2022, 3:24pm UTC](https://root-forum.cern.ch/t/writing-part-of-the-tmva-screen-output-in-a-file/49990 "2022-05-16T15:24:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Saumyenk](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/3bc359/32.png) [@Saumyenk](https://root-forum.cern.ch/u/Saumyenk)\
**Post date:** [May 16, 2022, 3:24pm UTC](https://root-forum.cern.ch/t/writing-part-of-the-tmva-screen-output-in-a-file/49990/1 "2022-05-16T15:24:30Z")

</div>

Hi  
I am doing BDT analysis with multiple backgrounds and multiple points in the signal phase-space (one at a time). Currently, I am optimising the analysis with the following line

```auto
TMVA::mvaeffs(DataLoaderName,outfileName,sig_evt,bkg_evt,true,"RooStats::AsimovSignificance(S,B+0.01)");

```

So, I wanted to know if the responses (like the one below) to the above line can be written in an ASCII file for different signal files.

 ![image](https://root-forum.cern.ch/uploads/default/original/3X/3/e/3eb308b4ba72cab62864eb5ffb622af2d31c43cc.png)

Or, maybe if it is possible all the signal files be fed ad analysed and printed in a similar table with each row having info on each signal file.

Appreciate any help.

Regards,  
Saumyen

---

<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:** [May 16, 2022, 4:11pm UTC](https://root-forum.cern.ch/t/writing-part-of-the-tmva-screen-output-in-a-file/49990/2 "2022-05-16T16:11:45Z")

</div>

Hi,

You can alway re-direct the output to a file, or alternatively you can take the original code from [root/mvaeffs.cxx at master · root-project/root · GitHub](https://github.com/root-project/root/blob/master/tmva/tmvagui/src/mvaeffs.cxx)  
and create a similar functions, and customise as you prefer.

Lorenzo

---

<div class="post-metadata">

**Author:** ![Saumyenk](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/3bc359/32.png) [@Saumyenk](https://root-forum.cern.ch/u/Saumyenk)\
**Post date:** [May 17, 2022, 10:11am UTC](https://root-forum.cern.ch/t/writing-part-of-the-tmva-screen-output-in-a-file/49990/3 "2022-05-17T10:11:13Z")

</div>

Thank you so much @moneta for the help.

So, I tried writing a function exactly the same as `TMVA::StatDialogMVAEffs::PrintResults` just with the modification that it prints in a given file instead of the screen (using `cout`). The first few lines are as follows:

```auto
void TMVA::StatDialogMVAEffs::WriteResults( const MethodInfo* info )
{
   ofstream fout;
   fout.open("/home/saumyen/significance.txt",ios::app);

```

Just wanted to know if I want to give the file name as an argument like `void TMVA::StatDialogMVAEffs::WriteResults( const MethodInfo* info, TString fOut){`  
and want to feed it via the function `TMVA::mvaeffs` (adding an extra argument), how should I do this?

Could you please help me with this?

Thanks again.

Regards,  
Saumyen

---

<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:** [May 17, 2022, 3:38pm UTC](https://root-forum.cern.ch/t/writing-part-of-the-tmva-screen-output-in-a-file/49990/4 "2022-05-17T15:38:03Z")

</div>

Hi,  
You can add the string representing the fileName as a new data member of the StatDialogMVAEffs and you pass it in the constructor of the class.  
For example:

```auto
void TMVA::mvaeffs(TString dataset, TString fin, Float_t nsignal, Float_t nbackground, Bool_t useTMVAStyle,TString formula, String fileOut) 
{
....................
......................
StatDialogMVAEffs* gGui = new StatDialogMVAEffs(dataset,
      (graphicsClient) ? graphicsClient->GetRoot() : nullptr, nsignal, nbackground, fileOut);
.....................
}

```

and you modiffy the class StatDialogMVAEffs to add the snew data member that can then be used in your new function WriteResults.

Lorenzo
