EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CbmLitUtils.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file CbmLitUtils.cxx
1 #include "CbmLitUtils.h"
2 
3 #include "TCanvas.h"
4 #include "TSystem.h"
5 
6 namespace 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 
21  const string& name,
22  const string& oldSubstr,
23  const string& newSubstr)
24 {
25  string newName = name;
26  Int_t startPos = name.find(oldSubstr);
27  newName.replace(startPos, oldSubstr.size(), newSubstr);
28  return newName;
29 }
30 
31 vector<string> Split(
32  const string& name,
33  char delimiter)
34 {
35  vector<string> result;
36  Int_t begin = 0;
37  Int_t end = name.find_first_of(delimiter);
38  while (end != string::npos) {
39  string str = name.substr(begin, end - begin);
40  if (str[0] == delimiter) str.erase(0, 1);
41  result.push_back(str);
42  begin = end;
43  end = name.find_first_of(delimiter, end + 1);
44  }
45  result.push_back(name.substr(begin + 1));
46  return result;
47 }
48 
49 }