Suppress all ROOT info/warning/error output

Hi,

I have some fitting routine loading histos from file and fitting them with some function.For some fits ROOT prints a message like

Function Parameters = { A=128.69 m_{0}=2.98209 #sigma=0.00219597 #Gamma=0.0318 }

The full output of 16 fits e.g. reads like

          |       e1          |        e2          |      e3          |
-------------------------------------------------------------------------
Function Parameters = { A=100.198 m_{0}=2.98162 #sigma=8.12351e-05 #Gamma=0.0318 }
E4180 M701  | 16.54% +-  0.13% | 16.13% +-  0.00% | 16.43% +-  0.00%
Function Parameters = { A=34.4757 m_{0}=2.98134 #sigma=0.00450494 #Gamma=0.0318 }
Function Parameters = { A=36.4717 m_{0}=2.98133 #sigma=0.00523338 #Gamma=0.0318 AG=-4.78166 mG=2.97 sG=0.164906 }
E4180 M702  |  5.63% +-  0.08% |  5.55% +-  0.00% |  5.57% +-  0.00%
Function Parameters = { A=80.7291 m_{0}=2.98205 #sigma=0.00462516 #Gamma=0.0318 }
Function Parameters = { A=74.8985 m_{0}=2.98162 #sigma=0.00242446 #Gamma=0.0318 AG=46.8612 mG=3.00172 sG=0.05 }
E4180 M703  | 13.36% +-  0.12% | 13.00% +-  0.00% | 13.04% +-  0.00%
E4180 M704  | 25.25% +-  0.16% | 24.61% +-  0.00% | 25.11% +-  0.00%
E4180 M705  | 16.95% +-  0.13% | 16.54% +-  0.00% | 16.84% +-  0.00%
E4180 M706  | 21.50% +-  0.15% | 21.51% +-  0.00% | 21.62% +-  0.00%
Function Parameters = { A=128.69 m_{0}=2.98209 #sigma=0.00219597 #Gamma=0.0318 }
E4180 M707  | 20.88% +-  0.14% | 20.72% +-  0.00% | 20.72% +-  0.00%
E4180 M708  | 10.43% +-  0.10% | 10.14% +-  0.00% | 10.34% +-  0.00%
E4180 M709  | 15.07% +-  0.12% | 15.04% +-  0.00% | 15.07% +-  0.00%
Function Parameters = { A=143.318 m_{0}=2.98183 #sigma=0.00342335 #Gamma=0.0318 }
Function Parameters = { A=149.076 m_{0}=2.98183 #sigma=0.00420869 #Gamma=0.0318 AG=-17.9109 mG=2.97 sG=0.128257 }
E4180 M710  | 22.96% +-  0.15% | 23.08% +-  0.00% | 23.07% +-  0.00%
Function Parameters = { A=120.842 m_{0}=2.98216 #sigma=0.00252351 #Gamma=0.0318 }
Function Parameters = { A=115.08 m_{0}=2.98195 #sigma=0.000124329 #Gamma=0.0318 AG=45.3727 mG=2.99636 sG=0.05 }
E4180 M711  | 20.25% +-  0.14% | 19.46% +-  0.00% | 19.48% +-  0.00%
E4180 M712  | 17.20% +-  0.13% | 17.11% +-  0.00% | 17.18% +-  0.00%
E4180 M713  | 11.15% +-  0.11% | 10.85% +-  0.00% | 11.08% +-  0.00%
E4180 M714  | 48.36% +-  0.22% | 45.19% +-  0.00% | 45.20% +-  0.00%
E4180 M715  | 24.64% +-  0.16% | 23.74% +-  0.00% | 24.44% +-  0.00%
E4180 M716  | 20.23% +-  0.14% | 19.93% +-  0.00% | 20.14% +-  0.00%

The core of the fitting routine (inside loops) looks like

TH1F *hmct = (TH1F*)f->Get(Form("hmct%d%02d", im, ic));
hmct->GetListOfFunctions()->Clear();

TF1 fsig1("fsig1","[0]*TMath::Voigt(x-[1],[2],[3])");
fsig1.SetParNames("A","m_{0}","#sigma","#Gamma");
fsig1.SetParameters(hmct->GetMaximum(),2.983,0.010,0.0318);
fsig1.FixParameter(3,0.0318);

TF1 fsig2("fsig2","[0]*TMath::Voigt(x-[1],[2],[3])+gaus(4)");
fsig2.SetParNames("A","m_{0}","#sigma","#Gamma","AG","mG","sG");
fsig2.SetParameters(hmct->GetMaximum(),2.983,0.010,0.0318,hmct->GetMaximum()/20,3.1,0.06);
fsig2.FixParameter(3,0.0318);
fsig2.SetParLimits(5,2.97,3.15);
fsig2.SetParLimits(6,0.05,0.5);

hmct->Fit("fsig1","q", "", fitlowlim, fithighlim );
hmct->Fit("fsig1","mq", "",fitlowlim, fithighlim );

hmct->Fit("fsig2","q0", "", fitlowlim, fithighlim );
hmct->Fit("fsig2","mq", "", fitlowlim, fithighlim );


My questions:
–> What is the reason for the print-out?
–> Is there a way to switch of all ROOT info/warning etc printout?

In the macro I already used (which I found somewhere I don’t remember)

gROOT->ProcessLine( "gErrorIgnoreLevel = 4001;");	
gROOT->ProcessLine( "gPrintViaErrorHandler = kTRUE;");
gErrorIgnoreLevel = 4001;	

if (RooMsgService::instance().numStreams()>0)
{
	RooMsgService::instance().deleteStream(0);
	RooMsgService::instance().deleteStream(1);
}

Best regards and thanks for any help,
Klaus


ROOT Version: 6.06/02
Platform: Debian GNU/Linux 8 (jessie)
Compiler: Not Provided


Dear Klaus,

You can try with TSystem::RedirectOutput . For example:

 // From now on redirect any printout to file 'mylogfile.txt' ...
 gSystem->RedirectOutput("mylogfile.txt", "a");
 ...
 // Restore printouts on the screen
 gSystem->RedirectOutput(0,0);

G Ganis

1 Like

Furthermore when you are on a linux system and want to get rid of the output completly without even storing it in a file, you can make use of the /dev/null pseudo file whichs content is always being deleted.

gSystem->RedirectOutput("/dev/null");

Will make all output being lost in nirvana.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.