Logo ROOT   6.18/05
Reference Guide
RooHelpers.h
Go to the documentation of this file.
1// Author: Stephan Hageboeck, CERN 01/2019
2
3/*****************************************************************************
4 * RooFit
5 * Authors: *
6 * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu *
7 * DK, David Kirkby, UC Irvine, dkirkby@uci.edu *
8 * *
9 * Copyright (c) 2000-2019, Regents of the University of California *
10 * and Stanford University. All rights reserved. *
11 * *
12 * Redistribution and use in source and binary forms, *
13 * with or without modification, are permitted according to the terms *
14 * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
15 *****************************************************************************/
16
17#ifndef ROOFIT_ROOFITCORE_INC_ROOHELPERS_H_
18#define ROOFIT_ROOFITCORE_INC_ROOHELPERS_H_
19
20#include "RooMsgService.h"
21
22#include <sstream>
23
24namespace RooHelpers {
25
26/// Switches the message service to verbose while the instance alive.
28 public:
30 auto& msg = RooMsgService::instance();
31 fOldKillBelow = msg.globalKillBelow();
32 msg.setGlobalKillBelow(RooFit::DEBUG);
33 fOldConf = msg.getStream(0);
34 msg.getStream(0).minLevel= RooFit::DEBUG;
35 msg.setStreamStatus(0, true);
36 }
37
39 auto& msg = RooMsgService::instance();
40 msg.setGlobalKillBelow(fOldKillBelow);
41 msg.getStream(0) = fOldConf;
42 msg.setStreamStatus(0, true);
43 }
44
45 private:
48};
49
50
51/// Hijacks all messages with given level and topic (and optionally object name) while alive.
52/// Use like ostringstream afterwards. Useful for unit tests and debugging.
53class HijackMessageStream : public std::ostringstream {
54 public:
55 HijackMessageStream(RooFit::MsgLevel level, RooFit::MsgTopic topics, const char* objectName = nullptr);
56
57 virtual ~HijackMessageStream();
58
59 private:
61 std::vector<RooMsgService::StreamConfig> _oldConf;
63};
64
65std::vector<std::string> tokenise(const std::string &str, const std::string &delims);
66
67}
68
69#endif /* ROOFIT_ROOFITCORE_INC_ROOHELPERS_H_ */
int Int_t
Definition: RtypesCore.h:41
Hijacks all messages with given level and topic (and optionally object name) while alive.
Definition: RooHelpers.h:53
RooFit::MsgLevel _oldKillBelow
Definition: RooHelpers.h:60
HijackMessageStream(RooFit::MsgLevel level, RooFit::MsgTopic topics, const char *objectName=nullptr)
Definition: RooHelpers.cxx:40
std::vector< RooMsgService::StreamConfig > _oldConf
Definition: RooHelpers.h:61
Switches the message service to verbose while the instance alive.
Definition: RooHelpers.h:27
RooFit::MsgLevel fOldKillBelow
Definition: RooHelpers.h:46
RooMsgService::StreamConfig fOldConf
Definition: RooHelpers.h:47
static RooMsgService & instance()
Return reference to singleton instance.
std::vector< std::string > tokenise(const std::string &str, const std::string &delims)
Tokenise the string by splitting at the characters in delims.
Definition: RooHelpers.cxx:24