BluetAnalyzer/main.cc

58 lines
1.5 KiB
C++
Raw Normal View History

2024-11-23 16:56:50 +08:00
#include "BluetAnalyzer.hh"
2024-11-24 21:12:20 +08:00
#include "clipp.h"
#include "stringhandle.hh"
2024-11-23 16:56:50 +08:00
#include "iostream"
using namespace std;
2024-11-24 21:12:20 +08:00
const string datapath = "/home/liuyihui/BluetAnalyzer/data";
2024-11-23 16:56:50 +08:00
int main(int argc, char **argv) {
2024-11-24 21:12:20 +08:00
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;
2024-11-23 16:56:50 +08:00
return 1;
}
2024-11-24 21:12:20 +08:00
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]);
}
}
2024-11-23 16:56:50 +08:00
BluetAnalyzer *bluet = new BluetAnalyzer();
bluet->readCutParameters(cfgfile);
bluet->defineFitFunctions();
bluet->defineHistograms();
bluet->readTreeData(runfiles);
bluet->FillHistograms();
bluet->postOperations();
bluet->saveHistograms();
2024-11-23 16:56:50 +08:00
bluet->drawHistograms();
return 0;
}