How to redirect RooFit message into a separate file

Hello,

In my code, I do multiple fitting using loop. I want to redirect the message from RooFit and TMinuit to separates file so that I can keep track of the fit in each step, and to make my output clearer.
I tried to use:

RooMsgService::instance( ) . addStream(
		RooFit::DEBUG, RooFit::Topic(RooFit::Tracing), RooFit::OutputFile(log_path) );

before fitting.
I compile my code with g++, no syntax error was found. The program also run normally, but the messages are still printed directly into stdout, while the log files at log_path are not created.

What can I do to make it work correctly.


UPDATE
I found the solution. gSystem->RedirectOutput( log_path ) will do the trick.

for ( int i=0; i<n_loops; i++ )
{
	char* log_path = ...;
	gSystem -> RedirectOutput( log_path );
	...
	gSystem -> RedirectOutput( 0 );
}

Thank you very much,
Hoa.

1 Like

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