diff --git a/EventFiltering/macros/getMenu.C b/EventFiltering/macros/getMenu.C index 692ebe396f3..d73861b9cb8 100644 --- a/EventFiltering/macros/getMenu.C +++ b/EventFiltering/macros/getMenu.C @@ -12,8 +12,13 @@ #include "CCDB/BasicCCDBManager.h" #include +#include +#include #include +#include +#include +#include #include void getMenu(int runNumber, std::string baseCCDBPath = "Users/m/mpuccio/EventFiltering/OTS/Chunked/") @@ -29,3 +34,43 @@ void getMenu(int runNumber, std::string baseCCDBPath = "Users/m/mpuccio/EventFil std::cout << "Id " << i - 2 << ": " << axis->GetBinLabel(i) << "\n"; } } + +void getMenu(std::string period) +{ + std::regex pattern(R"(LHC(\d{2})[A-Za-z]{1,2})"); + std::smatch match; + + int year{2000}; + if (std::regex_match(period, match, pattern)) { + std::cout << "Year = " << match[1] << std::endl; + year += std::stoi(match[1]); + } else { + std::cout << "Invalid format" << std::endl; + } + gSystem->Exec(Form("alien_find /alice/data/%i/%s/ ctf_skim_full/AnalysisResults_fullrun.root > list_tmp.txt", year, period.data())); + + std::ifstream file("list_tmp.txt"); + if (!file) { + std::cerr << "Error: could not open file\n"; + return; + } + + std::string firstLine; + if (!std::getline(file, firstLine)) { + std::cerr << "Error: file is empty or read failed\n"; + return; + } + + std::cout << "First line: " << firstLine << '\n'; + TGrid::Connect("alien://"); + TFile* scalersFile = TFile::Open((std::string("alien://") + firstLine).data(), "READ"); + TH1D* counters = (TH1D*)scalersFile->Get("central-event-filter-task/scalers/mFiltered"); + TAxis* axis = counters->GetXaxis(); + + std::vector binLabels(axis->GetNbins() - 2); // skip first and last bins + for (int i = 2; i < axis->GetNbins(); ++i) { + binLabels[i - 1] = axis->GetBinLabel(i); + std::cout << "Id " << i - 2 << ": " << axis->GetBinLabel(i) << "\n"; + } + gSystem->Exec("rm list_tmp.txt"); +}