BmnRoot
Loading...
Searching...
No Matches
BmnUtils.cxx
Go to the documentation of this file.
1#include "BmnUtils.h"
2
3#include "TCanvas.h"
4#include "TSystem.h"
5
6namespace lit
7{
8
10 TCanvas* c,
11 const std::string& dir)
12{
13 if (dir == "") return;
14 gSystem->mkdir(dir.c_str(), true); // create directory if it does not exist
15 c->SaveAs(std::string(dir + std::string(c->GetTitle()) + ".eps").c_str());
16 c->SaveAs(std::string(dir + std::string(c->GetTitle()) + ".png").c_str());
17 c->SaveAs(std::string(dir + std::string(c->GetTitle()) + ".gif").c_str());
18}
19
20string FindAndReplace( const string& name, const string& oldSubstr, const string& newSubstr) {
21 string newName = name;
22 Int_t startPos = name.find(oldSubstr);
23 newName.replace(startPos, oldSubstr.size(), newSubstr);
24 return newName;
25}
26
27vector<string> Split(const string& name, char delimiter)
28{
29 vector<string> result;
30 size_t begin = 0;
31 size_t end = name.find_first_of(delimiter);
32 while (end != string::npos) {
33 string str = name.substr(begin, end - begin);
34 if (str[0] == delimiter) str.erase(0, 1);
35 result.push_back(str);
36 begin = end;
37 end = name.find_first_of(delimiter, end + 1);
38 }
39 result.push_back(name.substr(begin + 1));
40 return result;
41}
42
43}
string FindAndReplace(const string &name, const string &oldSubstr, const string &newSubstr)
Definition BmnUtils.cxx:20
void SaveCanvasAsImage(TCanvas *c, const std::string &dir)
Definition BmnUtils.cxx:9
vector< string > Split(const string &name, char delimiter)
Definition BmnUtils.cxx:27