-
Notifications
You must be signed in to change notification settings - Fork 0
/
Utils.h
46 lines (43 loc) · 1.44 KB
/
Utils.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <iostream>
#include <string>
#include "gammacombo.h"
#include "hfag_gammacombo.h"
#include "RooRealVar.h"
std::vector<char*> &split(const std::string &s, char delim, std::vector<char*> &elems) {
std::stringstream ss(s);
std::string item;
while (std::getline(ss, item, delim)) {
char *cstr = new char[item.length() + 1];
strcpy(cstr, item.c_str());
elems.push_back(cstr);
}
return elems;
}
std::vector<char*> split(const std::string &s, char delim) {
std::vector<char*> elems;
split(s, delim, elems);
return elems;
}
namespace gammacombo_utils {
inline std::ostream* getCout() {
return &std::cout;
}
inline RooRealVar* toRooRealVar(RooAbsArg* arg){
return (RooRealVar*) arg;
}
inline RooAbsArg* extractFromRooArgSet(RooArgSet* set, std::string name) {
return &((*set)[TString(name)]);
}
GammaComboEngine& getGammaComboEngine(const char* argv_str){
std::string argv_full_str("gammacombo ");
argv_full_str += argv_str;
std::vector<char*> argv = split(argv_full_str, ' ');
return loadMainGammaComboEngine(argv.size(), &argv[0]);
}
GammaComboEngine& getHfagGammaComboEngine(const char* argv_str){
std::string argv_full_str("hfag_gammacombo ");
argv_full_str += argv_str;
std::vector<char*> argv = split(argv_full_str, ' ');
return loadHfagGammaComboEngine(argv.size(), &argv[0]);
}
}