BluetAnalyzer/main.cc

58 lines
1.5 KiB
C++

#include "BluetAnalyzer.hh"
#include "clipp.h"
#include "stringhandle.hh"
#include "iostream"
using namespace std;
const string datapath = "/home/liuyihui/BluetAnalyzer/data";
int main(int argc, char **argv) {
string cfgfile;
string datafile;
vector<string> ranges;
vector<string> runfiles;
Long_t rl, rr;
auto cfg = clipp::value("config file", cfgfile);
auto data =
(clipp::option("-f", "--file") & clipp::value("data file", datafile),
clipp::option("-r", "--range") &
clipp::values("number1 number2", ranges));
if (!clipp::parse(argc, const_cast<char **>(argv), cfg & data)) {
cerr << clipp::make_man_page(cfg & data, argv[0]) << endl;
return 1;
}
if (ranges.size() == 0) {
runfiles.push_back(datafile);
} else {
std::vector<std::string> ifiles;
bluet::GetAllFiles(datapath, ifiles);
rl = stoll(ranges[0]);
rr = stoll(ranges[1]);
for (size_t j = 0; j < ifiles.size(); j++) {
if (bluet::SplitString(ifiles[j], '.')[4] != string("root"))
continue;
long long number = stoll(bluet::SplitString(ifiles[j], '.')[2]);
if (number >= rl && number <= rr)
runfiles.push_back(datapath + "/" + ifiles[j]);
}
}
BluetAnalyzer *bluet = new BluetAnalyzer();
bluet->readCutParameters(cfgfile);
bluet->defineFitFunctions();
bluet->defineHistograms();
bluet->readTreeData(runfiles);
bluet->FillHistograms();
bluet->postOperations();
bluet->saveHistograms();
bluet->drawHistograms();
return 0;
}