From 5f0c7a108c699ab53ecea3fddb22ed81a61dc35e Mon Sep 17 00:00:00 2001 From: Maximiliano Puccio Date: Tue, 11 Nov 2025 14:40:38 +0100 Subject: [PATCH 1/2] Get menu for period --- EventFiltering/macros/getMenu.C | 91 +++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/EventFiltering/macros/getMenu.C b/EventFiltering/macros/getMenu.C index 692ebe396f3..2df7a819c1e 100644 --- a/EventFiltering/macros/getMenu.C +++ b/EventFiltering/macros/getMenu.C @@ -12,9 +12,17 @@ #include "CCDB/BasicCCDBManager.h" #include +#include +#include #include +#include +#include +#include #include +#include +#include +#include void getMenu(int runNumber, std::string baseCCDBPath = "Users/m/mpuccio/EventFiltering/OTS/Chunked/") { @@ -29,3 +37,86 @@ void getMenu(int runNumber, std::string baseCCDBPath = "Users/m/mpuccio/EventFil std::cout << "Id " << i - 2 << ": " << axis->GetBinLabel(i) << "\n"; } } + +std::vector getMenuForPeriod(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 << "Invalid format for period: " << period << std::endl; + return {}; + } + + year += std::stoi(match[1]); + gSystem->Exec(Form("alien_find /alice/data/%i/%s/ ctf_skim_full/AnalysisResults_fullrun.root > list_tmp_%s.txt", year, period.data(), period.data())); + + std::ifstream file(Form("list_tmp_%s.txt", period.data())); + if (!file) { + std::cerr << "Error: could not open file for period " << period << "\n"; + return {}; + } + + std::string firstLine; + if (!std::getline(file, firstLine)) { + std::cerr << "Error: file is empty or read failed for period " << period << "\n"; + return {}; + } + + 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); + for (int i = 2; i < axis->GetNbins(); ++i) { + binLabels[i - 2] = axis->GetBinLabel(i); + } + + scalersFile->Close(); + delete scalersFile; + gSystem->Exec(Form("rm list_tmp_%s.txt", period.data())); + + return binLabels; +} + +void getMenu(std::string periods) +{ + std::stringstream ss(periods); + std::string period; + std::vector periodList; + + // Parse comma-separated periods + while (std::getline(ss, period, ',')) { + // Trim whitespace + period.erase(0, period.find_first_not_of(" \t")); + period.erase(period.find_last_not_of(" \t") + 1); + periodList.push_back(period); + } + + std::map, std::vector> menuGroups; + + // Get menus for each period + for (const auto& p : periodList) { + auto menu = getMenuForPeriod(p); + if (!menu.empty()) { + menuGroups[menu].push_back(p); + } + } + + // Report different menus + int menuId = 1; + for (const auto& [menu, periods] : menuGroups) { + std::cout << "\n=== Menu " << menuId++ << " (periods: "; + for (size_t i = 0; i < periods.size(); ++i) { + std::cout << periods[i]; + if (i < periods.size() - 1) std::cout << ", "; + } + std::cout << ") ===\n"; + + for (size_t i = 0; i < menu.size(); ++i) { + std::cout << "Id " << i << ": " << menu[i] << "\n"; + } + } +} From d4528f021a880746d26e40041eec86a5eb685a72 Mon Sep 17 00:00:00 2001 From: ALICE Action Bot Date: Tue, 11 Nov 2025 13:41:17 +0000 Subject: [PATCH 2/2] Please consider the following formatting changes --- EventFiltering/macros/getMenu.C | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/EventFiltering/macros/getMenu.C b/EventFiltering/macros/getMenu.C index 2df7a819c1e..02386a68870 100644 --- a/EventFiltering/macros/getMenu.C +++ b/EventFiltering/macros/getMenu.C @@ -19,9 +19,9 @@ #include #include -#include -#include #include +#include +#include #include void getMenu(int runNumber, std::string baseCCDBPath = "Users/m/mpuccio/EventFiltering/OTS/Chunked/") @@ -111,7 +111,8 @@ void getMenu(std::string periods) std::cout << "\n=== Menu " << menuId++ << " (periods: "; for (size_t i = 0; i < periods.size(); ++i) { std::cout << periods[i]; - if (i < periods.size() - 1) std::cout << ", "; + if (i < periods.size() - 1) + std::cout << ", "; } std::cout << ") ===\n";