#include "BluetAnalyzer.hh" #include "clipp.h" #include "stringhandle.hh" #include "iostream" using namespace clipp; using namespace std; const string datapath = "/home/liuyihui/BluetAnalyzer/data"; int main(int argc, char **argv) { string cfgfile; string datafile; string outputfile = "bluetAnalyzer.root"; bool draw = false; vector ranges; vector runfiles; Long_t rl, rr; auto cfg = value("config file", cfgfile); auto data = ((required("-f", "--file").doc("data file path") & value("data file", datafile)) | (required("-r", "--range").doc("data file number range") & values("number1 number2", ranges))); auto output = (option("-o", "--output") .doc("output file path, default: bluetAnalyzer.root") & value("output file", outputfile), option("-d", "--draw").doc("draw histograms").set(draw, true)); auto cmd = (cfg & data & output); auto fmt = doc_formatting{}.first_column(4); if (!parse(argc, const_cast(argv), cmd)) { cerr << make_man_page(cmd, "BluetAnalyzer", fmt) .prepend_section("DESCRIPTION", " Program for MTPC Data Analysis.") << endl; return 1; } if (ranges.size() == 0) { runfiles.push_back(datafile); } else { std::vector 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(outputfile); if (draw) bluet->drawHistograms(); return 0; }