Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions EventFiltering/macros/getMenu.C
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@
#include "CCDB/BasicCCDBManager.h"

#include <TAxis.h>
#include <TFile.h>
#include <TGrid.h>
#include <TH1.h>
#include <TSystem.h>

#include <iostream>
#include <regex>
#include <string>

void getMenu(int runNumber, std::string baseCCDBPath = "Users/m/mpuccio/EventFiltering/OTS/Chunked/")
Expand All @@ -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<std::string> 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");
}
Loading