Skip to content

Commit 61f9eaa

Browse files
committed
Get menu for period
1 parent ba02103 commit 61f9eaa

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

EventFiltering/macros/getMenu.C

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,13 @@
1212
#include "CCDB/BasicCCDBManager.h"
1313

1414
#include <TAxis.h>
15+
#include <TFile.h>
16+
#include <TGrid.h>
1517
#include <TH1.h>
18+
#include <TSystem.h>
1619

20+
#include <iostream>
21+
#include <regex>
1722
#include <string>
1823

1924
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
2934
std::cout << "Id " << i - 2 << ": " << axis->GetBinLabel(i) << "\n";
3035
}
3136
}
37+
38+
void getMenu(std::string period)
39+
{
40+
std::regex pattern(R"(LHC(\d{2})[A-Za-z]{1,2})");
41+
std::smatch match;
42+
43+
int year{2000};
44+
if (std::regex_match(period, match, pattern)) {
45+
std::cout << "Year = " << match[1] << std::endl;
46+
year += std::stoi(match[1]);
47+
} else {
48+
std::cout << "Invalid format" << std::endl;
49+
}
50+
gSystem->Exec(Form("alien_find /alice/data/%i/%s/ ctf_skim_full/AnalysisResults_fullrun.root > list_tmp.txt", year, period.data()));
51+
52+
std::ifstream file("list_tmp.txt");
53+
if (!file) {
54+
std::cerr << "Error: could not open file\n";
55+
return;
56+
}
57+
58+
std::string firstLine;
59+
if (!std::getline(file, firstLine)) {
60+
std::cerr << "Error: file is empty or read failed\n";
61+
return;
62+
}
63+
64+
std::cout << "First line: " << firstLine << '\n';
65+
TGrid::Connect("alien://");
66+
TFile* scalersFile = TFile::Open((std::string("alien://") + firstLine).data(), "READ");
67+
TH1D* counters = (TH1D*)scalersFile->Get("central-event-filter-task/scalers/mFiltered");
68+
TAxis* axis = counters->GetXaxis();
69+
70+
std::vector<std::string> binLabels(axis->GetNbins() - 2); // skip first and last bins
71+
for (int i = 2; i < axis->GetNbins(); ++i) {
72+
binLabels[i - 1] = axis->GetBinLabel(i);
73+
std::cout << "Id " << i - 2 << ": " << axis->GetBinLabel(i) << "\n";
74+
}
75+
gSystem->Exec("rm list_tmp.txt");
76+
}

0 commit comments

Comments
 (0)