|
ROOT
Reference Guide |
|
Go to the documentation of this file.
53 #include <sys/types.h>
82 _devnull =
new ofstream(
"/dev/null") ;
84 _levelNames[
DEBUG]=
"DEBUG" ;
85 _levelNames[
INFO]=
"INFO" ;
87 _levelNames[
WARNING]=
"WARNING" ;
88 _levelNames[
ERROR]=
"ERROR" ;
89 _levelNames[
FATAL]=
"FATAL" ;
94 _topicNames[
Fitting]=
"Fitting" ;
97 _topicNames[
Eval]=
"Eval" ;
98 _topicNames[
Caching]=
"Caching" ;
102 _topicNames[
Tracing]=
"Tracing" ;
116 _globMinLevel =
DEBUG ;
117 _lastMsgLevel =
DEBUG ;
119 delete _debugWorkspace;
120 _debugWorkspace =
nullptr;
123 for (
auto item : _files) {
142 map<string,ostream*>::iterator iter = _files.begin() ;
143 for (; iter != _files.end() ; ++iter) {
144 delete iter->second ;
147 if (_debugWorkspace) {
148 delete _debugWorkspace ;
170 if (!_debugWorkspace) {
173 return _debugWorkspace ;
210 pc.defineInt(
"prefix",
"Prefix",0,
kTRUE) ;
212 pc.defineInt(
"topic",
"Topic",0,0xFFFFF) ;
213 pc.defineString(
"objName",
"ObjectName",0,
"") ;
214 pc.defineString(
"className",
"ClassName",0,
"") ;
215 pc.defineString(
"baseClassName",
"BaseClassName",0,
"") ;
216 pc.defineString(
"tagName",
"LabelName",0,
"") ;
217 pc.defineString(
"outFile",
"OutputFile",0,
"") ;
218 pc.defineObject(
"outStream",
"OutputStream",0,0) ;
219 pc.defineMutex(
"OutputFile",
"OutputStream") ;
229 const char* objName =
pc.getString(
"objName") ;
230 const char* className =
pc.getString(
"className") ;
231 const char* baseClassName =
pc.getString(
"baseClassName") ;
232 const char* tagName =
pc.getString(
"tagName") ;
233 const char* outFile =
pc.getString(
"outFile") ;
234 Bool_t prefix =
pc.getInt(
"prefix") ;
237 ostream* os =
nullptr;
250 newStream.
topic = topic ;
251 newStream.
objectName = (objName ? objName :
"" ) ;
252 newStream.
className = (className ? className :
"" ) ;
253 newStream.
baseClassName = (baseClassName ? baseClassName :
"" ) ;
254 newStream.
tagName = (tagName ? tagName :
"" ) ;
255 newStream.
color = color ;
256 newStream.
prefix = prefix ;
270 }
else if (
string(outFile).size()>0) {
273 ostream* os2 = _files[
"outFile"] ;
278 os2 =
new ofstream(outFile) ;
281 cout <<
"RooMsgService::addReportingStream ERROR: cannot open output log file " << outFile <<
" reverting stream to stdout" << endl ;
283 newStream.
os = &cout ;
289 _files[
"outFile"] = os2 ;
297 newStream.
os = &cout ;
303 _streams.push_back(newStream) ;
306 return _streams.size()-1 ;
316 vector<StreamConfig>::iterator iter = _streams.begin() ;
320 if (iter->minLevel==
DEBUG) {
324 _streams.erase(iter) ;
334 if (id<0 || id>=
static_cast<Int_t>(_streams.size())) {
335 cout <<
"RooMsgService::setStreamStatus() ERROR: invalid stream ID " <<
id << endl ;
340 if (_streams[
id].minLevel==
DEBUG) {
341 _debugCount += flag ? 1 : -1 ;
344 _streams[
id].active = flag ;
354 if (id<0 || id>=
static_cast<Int_t>(_streams.size())) {
355 cout <<
"RooMsgService::getStreamStatus() ERROR: invalid stream ID " <<
id << endl ;
358 return _streams[
id].active ;
379 _streamsSaved.push(_streams) ;
389 _streams = _streamsSaved.top() ;
390 _streamsSaved.pop() ;
400 return (activeStream(
self,topic,level)>=0) ;
409 return (activeStream(
self,topic,level)>=0) ;
418 if (level<_globMinLevel)
return -1 ;
419 for (
UInt_t i=0 ; i<_streams.size() ; i++) {
420 if (_streams[i].match(level,topic,
self)) {
433 if (level<_globMinLevel)
return -1 ;
434 for (
UInt_t i=0 ; i<_streams.size() ; i++) {
435 if (_streams[i].match(level,topic,
self)) {
448 if (!active)
return kFALSE ;
449 if (level<minLevel)
return kFALSE ;
450 if (!(topic&top))
return kFALSE ;
452 if (universal)
return kTRUE ;
454 if (objectName.size()>0 && objectName != obj->
GetName())
return kFALSE ;
455 if (className.size()>0 && className != obj->IsA()->
GetName())
return kFALSE ;
456 if (baseClassName.size()>0 && !obj->IsA()->
InheritsFrom(baseClassName.c_str()))
return kFALSE ;
468 if (!active)
return kFALSE ;
469 if (level<minLevel)
return kFALSE ;
470 if (!(topic&top))
return kFALSE ;
472 if (universal)
return kTRUE ;
474 if (objectName.size()>0 && objectName != obj->
GetName())
return kFALSE ;
475 if (className.size()>0 && className != obj->IsA()->
GetName())
return kFALSE ;
476 if (baseClassName.size()>0 && !obj->IsA()->
InheritsFrom(baseClassName.c_str()))
return kFALSE ;
494 Int_t as = activeStream(
self,topic,level) ;
501 (*_streams[
as].os).flush() ;
505 (*_streams[
as].os) << endl ;
507 _lastMsgLevel=level ;
509 if (_streams[
as].prefix && !skipPrefix) {
513 (*_streams[
as].os) <<
"[#" <<
as <<
"] " << _levelNames[level] <<
":" << _topicNames[topic] <<
" -- " ;
515 return (*_streams[
as].os) ;
531 Int_t as = activeStream(
self,topic,level) ;
537 (*_streams[
as].os).flush() ;
539 if (_streams[
as].prefix && !skipPrefix) {
543 (*_streams[
as].os) <<
"[#" <<
as <<
"] " << _levelNames[level] <<
":" << _topicNames[topic] <<
" -- " ;
545 return (*_streams[
as].os) ;
557 if (
TString(options).Contains(
"V") ||
TString(options).Contains(
"v")) {
561 cout << (activeOnly?
"Active Message streams":
"All Message streams") << endl ;
562 for (
UInt_t i=0 ; i<_streams.size() ; i++) {
565 if (activeOnly && !_streams[i].active) {
570 map<int,string>::const_iterator is = _levelNames.find(_streams[i].minLevel) ;
571 cout <<
"[" << i <<
"] MinLevel = " << is->second ;
573 cout <<
" Topic = " ;
574 if (_streams[i].topic != 0xFFFFF) {
575 map<int,string>::const_iterator iter = _topicNames.begin() ;
576 while(iter!=_topicNames.end()) {
577 if (iter->first & _streams[i].topic) {
578 cout << iter->second <<
" " ;
587 if (_streams[i].objectName.size()>0) {
588 cout <<
" ObjectName = " << _streams[i].objectName ;
590 if (_streams[i].className.size()>0) {
591 cout <<
" ClassName = " << _streams[i].className ;
593 if (_streams[i].baseClassName.size()>0) {
594 cout <<
" BaseClassName = " << _streams[i].baseClassName ;
596 if (_streams[i].tagName.size()>0) {
597 cout <<
" TagLabel = " << _streams[i].tagName ;
601 if (!activeOnly && !_streams[i].active) {
602 cout <<
" (NOT ACTIVE)" ;
RooCmdArg is a named container for two doubles, two integers two object points and three string point...
void deleteStream(Int_t id)
Delete stream with given unique ID code.
Bool_t isActive(const RooAbsArg *self, RooFit::MsgTopic facility, RooFit::MsgLevel level)
Check if logging is active for given object/topic/RooFit::MsgLevel combination.
char * Form(const char *fmt,...)
void setStreamStatus(Int_t id, Bool_t active)
(De)Activate stream with given unique ID
virtual ~RooMsgService()
Destructor.
std::ostream & log(const RooAbsArg *self, RooFit::MsgLevel level, RooFit::MsgTopic facility, Bool_t forceSkipPrefix=kFALSE)
Log error message associated with RooAbsArg object self at given level and topic.
static constexpr double pc
void restoreState()
Restore last saved state of message service.
MsgTopic
Topics for a RooMsgService::StreamConfig in RooMsgService.
MsgLevel
Verbosity level for RooMsgService::StreamConfig in RooMsgService.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Class RooCmdConfig is a configurable parser for RooCmdArg named arguments.
Bool_t getStreamStatus(Int_t id) const
Get activation status of stream with given unique ID.
virtual const char * GetName() const
Returns name of object.
Bool_t match(RooFit::MsgLevel level, RooFit::MsgTopic facility, const RooAbsArg *obj)
Determine if message from given object at given level on given topic is logged.
RooMsgService()
Constructor.
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
virtual int GetPid()
Get process id.
void saveState()
Save current state of message service.
void Print(Option_t *options=0) const
Print configuration of message service.
RooLinkedList is an collection class for internal use, storing a collection of RooAbsArg pointers in ...
Int_t addStream(RooFit::MsgLevel level, const RooCmdArg &arg1=RooCmdArg(), const RooCmdArg &arg2=RooCmdArg(), const RooCmdArg &arg3=RooCmdArg(), const RooCmdArg &arg4=RooCmdArg(), const RooCmdArg &arg5=RooCmdArg(), const RooCmdArg &arg6=RooCmdArg())
Add a message logging stream for message with given RooFit::MsgLevel or higher.
RooFit::MsgLevel minLevel
std::string baseClassName
R__EXTERN TSystem * gSystem
static Roo_reg_AGKInteg1D instance
The class RooMsgService is a singleton that organizes messages generated in RooFit.
The RooWorkspace is a persistable container for RooFit projects.
Mother of all ROOT objects.
RooCmdArg Topic(Int_t topic)
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
RooWorkspace * debugWorkspace()
static Bool_t anyDebug()
Returns true if any debug level stream is active.
virtual const char * GetName() const
Returns name of object.
Int_t activeStream(const RooAbsArg *self, RooFit::MsgTopic facility, RooFit::MsgLevel level)
Find appropriate logging stream for message from given object with given topic and message level.
Wrap an object into a TObject. Sometimes needed to avoid reinterpret_cast or enable RTTI.
static RooMsgService & instance()
Return reference to singleton instance.
Bool_t getAttribute(const Text_t *name) const
Check if a named attribute is set. By default, all attributes are unset.