Logo ROOT   6.18/05
Reference Guide
RooHelpers.cxx
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#include "RooHelpers.h"
18
19namespace RooHelpers {
20
21/// Tokenise the string by splitting at the characters in delims.
22/// Consecutive delimiters are collapsed, so that no delimiters will appear in the
23/// tokenised strings, and no emtpy strings are returned.
24std::vector<std::string> tokenise(const std::string &str, const std::string &delims) {
25 std::vector<std::string> tokens;
26
27 auto beg = str.find_first_not_of(delims, 0);
28 auto end = str.find_first_of(delims, beg);
29 do {
30 tokens.emplace_back(str.substr(beg, end-beg));
31 beg = str.find_first_not_of(delims, end);
32 end = str.find_first_of(delims, beg);
33 } while (beg != std::string::npos);
34
35 return tokens;
36}
37
38
39
41 std::ostringstream()
42{
43 auto& msg = RooMsgService::instance();
44 _oldKillBelow = msg.globalKillBelow();
45 msg.setGlobalKillBelow(level);
46 for (int i = 0; i < msg.numStreams(); ++i) {
47 _oldConf.push_back(msg.getStream(i));
48 msg.getStream(i).removeTopic(topics);
49 msg.setStreamStatus(i, true);
50 }
51
52 _thisStream = msg.addStream(level,
53 RooFit::Topic(topics),
55 objectName ? RooFit::ObjectName(objectName) : RooCmdArg());
56}
57
59 auto& msg = RooMsgService::instance();
60 msg.setGlobalKillBelow(_oldKillBelow);
61 for (unsigned int i = 0; i < _oldConf.size(); ++i) {
62 msg.getStream(i) = _oldConf[i];
63 }
64 msg.deleteStream(_thisStream);
65}
66
67
68
69
70}
RooCmdArg is a named container for two doubles, two integers two object points and three string point...
Definition: RooCmdArg.h:27
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
static RooMsgService & instance()
Return reference to singleton instance.
RooCmdArg OutputStream(std::ostream &os)
RooCmdArg Topic(Int_t topic)
RooCmdArg ObjectName(const char *name)
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