Skip to content

Commit d2a23a6

Browse files
authored
Merge branch 'AliceO2Group:master' into master
2 parents 3230328 + 51db1b8 commit d2a23a6

473 files changed

Lines changed: 34272 additions & 13561 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/labeler.yml

Lines changed: 51 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,89 @@
11
---
2-
alice3:
2+
infrastructure:
33
- changed-files:
4-
- any-glob-to-any-file: ['ALICE3/**']
4+
- any-glob-to-any-file:
5+
- ".checkov.yml"
6+
- ".clang-format"
7+
- ".clang-tidy"
8+
- ".flake8"
9+
- ".git-blame-ignore-revs"
10+
- ".github/**"
11+
- ".gitignore"
12+
- ".mega-linter.yml"
13+
- ".pre-commit-config.yaml"
14+
- "cmake/**"
15+
- "CMakeLists.txt"
16+
- "CODEOWNERS"
17+
- "COPYING"
18+
- "cppcheck_config"
19+
- "CPPLINT.cfg"
20+
- "dependencies/**"
21+
- "o2linter_config"
22+
- "packaging/**"
23+
- "pyproject.toml"
24+
- "README.md"
525

6-
common:
26+
datamodel:
727
- changed-files:
8-
- any-glob-to-any-file: ['Common/**']
28+
- any-glob-to-any-file: ["DataModel/**", "**/DataModel/**"]
929

10-
infrastructure:
30+
alice3:
1131
- changed-files:
12-
- any-glob-to-any-file:
13-
- '.clang-format'
14-
- '.clang-tidy'
15-
- '.flake8'
16-
- '.github/**'
17-
- '.checkov.yml'
18-
- '.mega-linter.yml'
19-
- '.pre-commit-config.yaml'
20-
- 'cmake/**'
21-
- 'CODEOWNERS'
22-
- 'CPPLINT.cfg'
23-
- 'dependencies/**'
24-
- 'packaging/**'
25-
- 'pyproject.toml'
32+
- any-glob-to-any-file: ["ALICE3/**"]
2633

27-
datamodel:
34+
common:
2835
- changed-files:
29-
- any-glob-to-any-file: ['DataModel/**', '**/DataModel/**']
36+
- any-glob-to-any-file: ["Common/**"]
3037

3138
dpg:
3239
- changed-files:
33-
- any-glob-to-any-file: ['DPG/**']
40+
- any-glob-to-any-file: ["DPG/**"]
3441

3542
pwgcf:
3643
- changed-files:
37-
- any-glob-to-any-file: ['PWGCF/**', '*/PWGCF/**']
44+
- any-glob-to-any-file: ["PWGCF/**", "*/PWGCF/**"]
3845

3946
pwgdq:
4047
- changed-files:
41-
- any-glob-to-any-file: ['PWGDQ/**', '*/PWGDQ/**']
48+
- any-glob-to-any-file: ["PWGDQ/**", "*/PWGDQ/**"]
4249

4350
pwgem:
4451
- changed-files:
45-
- any-glob-to-any-file: ['PWGEM/**', '*/PWGEM/**']
52+
- any-glob-to-any-file: ["PWGEM/**", "*/PWGEM/**"]
4653

4754
pwghf:
4855
- changed-files:
49-
- any-glob-to-any-file: ['PWGHF/**', '*/PWGHF/**']
56+
- any-glob-to-any-file: ["PWGHF/**", "*/PWGHF/**"]
5057

5158
pwgje:
5259
- changed-files:
53-
- any-glob-to-any-file: ['PWGJE/**', '*/PWGJE/**']
60+
- any-glob-to-any-file: ["PWGJE/**", "*/PWGJE/**"]
5461

5562
pwglf:
5663
- changed-files:
57-
- any-glob-to-any-file: ['PWGLF/**', '*/PWGLF/**', 'PWGMM/**', '*/PWGMM/**']
64+
- any-glob-to-any-file:
65+
["PWGLF/**", "*/PWGLF/**", "PWGMM/**", "*/PWGMM/**"]
66+
67+
pwgmm:
68+
- changed-files:
69+
- any-glob-to-any-file: ["PWGMM/**", "*/PWGMM/**"]
5870

5971
pwgud:
6072
- changed-files:
61-
- any-glob-to-any-file: ['PWGUD/**', '*/PWGUD/**']
73+
- any-glob-to-any-file: ["PWGUD/**", "*/PWGUD/**"]
74+
75+
scripts:
76+
- changed-files:
77+
- any-glob-to-any-file: ["Scripts/**"]
78+
79+
tools:
80+
- changed-files:
81+
- any-glob-to-any-file: ["Tools/**"]
6282

6383
trigger:
6484
- changed-files:
65-
- any-glob-to-any-file: ['EventFiltering/**']
85+
- any-glob-to-any-file: ["EventFiltering/**"]
6686

6787
tutorial:
6888
- changed-files:
69-
- any-glob-to-any-file: ['Tutorials/**']
89+
- any-glob-to-any-file: ["Tutorials/**"]

.github/workflows/mega-linter.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
id: ml
3939
# You can override MegaLinter flavor used to have faster performances
4040
# More info at https://megalinter.io/flavors/
41-
uses: oxsecurity/megalinter@v9.1.0
41+
uses: oxsecurity/megalinter@v9.2.0
4242
env:
4343
# All available variables are described in documentation:
4444
# https://megalinter.io/configuration/

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
# See https://pre-commit.com/hooks.html for more hooks
33
repos:
44
- repo: https://github.com/pre-commit/pre-commit-hooks
5-
rev: v5.0.0
5+
rev: v6.0.0
66
hooks:
77
- id: trailing-whitespace
88
- id: end-of-file-fixer
99
- repo: https://github.com/pre-commit/mirrors-clang-format
10-
rev: v20.1.5 # clang-format version
10+
rev: v21.1.8 # clang-format version
1111
hooks:
1212
- id: clang-format
1313
- repo: https://github.com/cpplint/cpplint

ALICE3/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ add_subdirectory(Core)
1414
# add_subdirectory(DataModel)
1515
add_subdirectory(Tasks)
1616
add_subdirectory(TableProducer)
17-
# add_subdirectory(Tools)
17+
add_subdirectory(Macros)

ALICE3/Core/DelphesO2TrackSmearer.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ bool TrackSmearer::loadTable(int pdg, const char* filename, bool forceReload)
6666
std::string path = std::string(filename).substr(5); // Remove "ccdb:" prefix
6767
const std::string outPath = "/tmp/LUTs/";
6868
filename = Form("%s/%s/snapshot.root", outPath.c_str(), path.c_str());
69+
LOG(info) << " --- Local LUT filename will be: " << filename;
6970
std::ifstream checkFile(filename); // Check if file already exists
7071
if (!checkFile.is_open()) { // File does not exist, retrieve from CCDB
7172
LOG(info) << " --- CCDB source detected for PDG " << pdg << ": " << path;
@@ -166,9 +167,9 @@ lutEntry_t* TrackSmearer::getLUTEntry(const int pdg, const float nch, const floa
166167
{
167168
const int ipdg = getIndexPDG(pdg);
168169
if (!mLUTHeader[ipdg]) {
169-
LOG(error) << " --- getLUTEntry: LUT header not loaded for pdg=" << pdg << ". Returning nullptr.";
170170
return nullptr;
171171
}
172+
172173
auto inch = mLUTHeader[ipdg]->nchmap.find(nch);
173174
auto irad = mLUTHeader[ipdg]->radmap.find(radius);
174175
auto ieta = mLUTHeader[ipdg]->etamap.find(eta);
@@ -290,7 +291,6 @@ bool TrackSmearer::smearTrack(O2Track& o2track, lutEntry_t* lutEntry, float inte
290291

291292
bool TrackSmearer::smearTrack(O2Track& o2track, int pdg, float nch)
292293
{
293-
294294
auto pt = o2track.getPt();
295295
switch (pdg) {
296296
case o2::constants::physics::kHelium3:

ALICE3/Core/FastTracker.cxx

Lines changed: 101 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,18 @@
1111

1212
#include "FastTracker.h"
1313

14-
#include "ReconstructionDataFormats/TrackParametrization.h"
14+
#include "Common/Core/TableHelper.h"
15+
16+
#include <ReconstructionDataFormats/TrackParametrization.h>
1517

16-
#include "TMath.h"
17-
#include "TMatrixD.h"
18-
#include "TMatrixDSymEigen.h"
19-
#include "TRandom.h"
2018
#include <TEnv.h>
2119
#include <THashList.h>
20+
#include <TMath.h>
21+
#include <TMatrixD.h>
22+
#include <TMatrixDSymEigen.h>
2223
#include <TObject.h>
24+
#include <TRandom.h>
25+
#include <TSystem.h>
2326

2427
#include <fstream>
2528
#include <map>
@@ -31,6 +34,81 @@ namespace o2
3134
namespace fastsim
3235
{
3336

37+
std::map<std::string, std::map<std::string, std::string>> GeometryContainer::parseTEnvConfiguration(std::string filename, std::vector<std::string>& layers)
38+
{
39+
std::map<std::string, std::map<std::string, std::string>> configMap;
40+
filename = gSystem->ExpandPathName(filename.c_str());
41+
TEnv env(filename.c_str());
42+
THashList* table = env.GetTable();
43+
layers.clear();
44+
for (int i = 0; i < table->GetEntries(); ++i) {
45+
const std::string key = table->At(i)->GetName();
46+
// key should contain exactly one dot
47+
if (key.find('.') == std::string::npos || key.find('.') != key.rfind('.')) {
48+
LOG(fatal) << "Key " << key << " does not contain exactly one dot";
49+
continue;
50+
}
51+
const std::string firstPart = key.substr(0, key.find('.'));
52+
if (std::find(layers.begin(), layers.end(), firstPart) == layers.end()) {
53+
layers.push_back(firstPart);
54+
}
55+
}
56+
env.Print();
57+
// Layers
58+
for (const auto& layer : layers) {
59+
LOG(info) << " Reading layer " << layer;
60+
for (int i = 0; i < table->GetEntries(); ++i) {
61+
const std::string key = table->At(i)->GetName();
62+
if (key.find(layer + ".") == 0) {
63+
const std::string paramName = key.substr(key.find('.') + 1);
64+
const std::string value = env.GetValue(key.c_str(), "");
65+
configMap[layer][paramName] = value;
66+
}
67+
}
68+
}
69+
return configMap;
70+
}
71+
72+
void GeometryContainer::init(o2::framework::InitContext& initContext)
73+
{
74+
std::vector<std::string> detectorConfiguration;
75+
const bool found = common::core::getTaskOptionValue(initContext, "on-the-fly-detector-geometry-provider", "detectorConfiguration", detectorConfiguration, false);
76+
if (!found) {
77+
LOG(fatal) << "Could not retrieve detector configuration from OnTheFlyDetectorGeometryProvider task.";
78+
return;
79+
}
80+
LOG(info) << "Size of detector configuration: " << detectorConfiguration.size();
81+
for (const auto& configFile : detectorConfiguration) {
82+
LOG(info) << "Detector geometry configuration file used: " << configFile;
83+
addEntry(configFile);
84+
}
85+
}
86+
87+
std::map<std::string, std::string> GeometryContainer::GeometryEntry::getConfiguration(const std::string& layerName) const
88+
{
89+
auto it = mConfigurations.find(layerName);
90+
if (it != mConfigurations.end()) {
91+
return it->second;
92+
} else {
93+
LOG(fatal) << "Layer " << layerName << " not found in geometry configurations.";
94+
return {};
95+
}
96+
}
97+
98+
std::string GeometryContainer::GeometryEntry::getValue(const std::string& layerName, const std::string& key, bool require) const
99+
{
100+
auto layer = getConfiguration(layerName);
101+
auto entry = layer.find(key);
102+
if (entry != layer.end()) {
103+
return layer.at(key);
104+
} else if (require) {
105+
LOG(fatal) << "Key " << key << " not found in layer " << layerName << " configurations.";
106+
return "";
107+
} else {
108+
return "";
109+
}
110+
}
111+
34112
// +-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+
35113

36114
DetLayer* FastTracker::AddLayer(TString name, float r, float z, float x0, float xrho, float resRPhi, float resZ, float eff, int type)
@@ -236,81 +314,33 @@ void FastTracker::AddTPC(float phiResMean, float zResMean)
236314
}
237315
}
238316

239-
void FastTracker::AddGenericDetector(std::string filename, o2::ccdb::BasicCCDBManager* ccdbManager)
317+
void FastTracker::AddGenericDetector(GeometryContainer::GeometryEntry configMap, o2::ccdb::BasicCCDBManager* ccdbManager)
240318
{
241-
LOG(info) << " Adding generic detector from file " << filename;
242-
// If the filename starts with ccdb: then take the file from the ccdb
243-
if (filename.rfind("ccdb:", 0) == 0) {
244-
std::string ccdbPath = filename.substr(5); // remove "ccdb:" prefix
245-
if (ccdbManager == nullptr) {
246-
LOG(fatal) << "CCDB manager is null, cannot retrieve file " << ccdbPath;
247-
return;
248-
}
249-
const std::string outPath = "/tmp/DetGeo/";
250-
filename = Form("%s/%s/snapshot.root", outPath.c_str(), ccdbPath.c_str());
251-
std::ifstream checkFile(filename); // Check if file already exists
252-
if (!checkFile.is_open()) { // File does not exist, retrieve from CCDB
253-
LOG(info) << " --- CCDB source detected for detector geometry " << filename;
254-
std::map<std::string, std::string> metadata;
255-
ccdbManager->getCCDBAccessor().retrieveBlob(ccdbPath, outPath, metadata, 1);
256-
// Add CCDB handling logic here if needed
257-
LOG(info) << " --- Now retrieving geometry configuration from CCDB to: " << filename;
258-
} else { // File exists, proceed to load
259-
LOG(info) << " --- Geometry configuration file already exists: " << filename << ". Skipping download.";
260-
checkFile.close();
261-
}
262-
AddGenericDetector(filename, nullptr);
263-
return;
264-
}
265-
266-
TEnv env(filename.c_str());
267-
THashList* table = env.GetTable();
268-
std::vector<std::string> layers;
269-
for (int i = 0; i < table->GetEntries(); ++i) {
270-
const std::string key = table->At(i)->GetName();
271-
// key should contain exactly one dot
272-
if (key.find('.') == std::string::npos || key.find('.') != key.rfind('.')) {
273-
LOG(fatal) << "Key " << key << " does not contain exactly one dot";
319+
// Layers
320+
for (const auto& layer : configMap.getLayerNames()) {
321+
if (layer.find("global") != std::string::npos) { // Layers with global tag are skipped
322+
LOG(info) << " Skipping global configuration entry " << layer;
274323
continue;
275324
}
276-
const std::string firstPart = key.substr(0, key.find('.'));
277-
if (std::find(layers.begin(), layers.end(), firstPart) == layers.end()) {
278-
layers.push_back(firstPart);
279-
}
280-
}
281-
// env.Print();
282-
// Layers
283-
for (const auto& layer : layers) {
284-
LOG(info) << " Reading layer " << layer;
285325

286-
auto getKey = [&layer, &env](const std::string& name, const bool required = true) {
287-
std::string key = layer + "." + name;
288-
if (!env.Defined(key.c_str())) {
289-
if (required) {
290-
LOG(fatal) << "Key " << key << " not defined in configuration file";
291-
}
292-
LOG(debug) << "Key " << key << " not defined in configuration file, getting the default value";
293-
}
294-
LOG(debug) << " Getting key " << key << " from configuration file";
295-
return key;
296-
};
297-
const float r = env.GetValue(getKey("r").c_str(), -1.0f);
326+
LOG(info) << " Reading layer " << layer;
327+
const float r = configMap.getFloatValue(layer, "r");
298328
LOG(info) << " Layer " << layer << " has radius " << r;
299-
const float z = env.GetValue(getKey("z").c_str(), -1.0f);
300-
const float x0 = env.GetValue(getKey("x0").c_str(), 0.0f);
301-
const float xrho = env.GetValue(getKey("xrho").c_str(), 0.0f);
302-
const float resRPhi = env.GetValue(getKey("resRPhi").c_str(), 0.0f);
303-
const float resZ = env.GetValue(getKey("resZ").c_str(), 0.0f);
304-
const float eff = env.GetValue(getKey("eff").c_str(), 0.0f);
305-
const int type = env.GetValue(getKey("type").c_str(), 0);
306-
const char* deadPhiRegions = env.GetValue(getKey("deadPhiRegions", false).c_str(), "");
329+
const float z = configMap.getFloatValue(layer, "z");
330+
const float x0 = configMap.getFloatValue(layer, "x0");
331+
const float xrho = configMap.getFloatValue(layer, "xrho");
332+
const float resRPhi = configMap.getFloatValue(layer, "resRPhi");
333+
const float resZ = configMap.getFloatValue(layer, "resZ");
334+
const float eff = configMap.getFloatValue(layer, "eff");
335+
const int type = configMap.getIntValue(layer, "type");
336+
const std::string deadPhiRegions = configMap.getValue(layer, "deadPhiRegions", false);
307337

308338
// void AddLayer(TString name, float r, float z, float x0, float xrho, float resRPhi = 0.0f, float resZ = 0.0f, float eff = 0.0f, int type = 0);
309339
LOG(info) << " Adding layer " << layer << " r=" << r << " z=" << z << " x0=" << x0 << " xrho=" << xrho << " resRPhi=" << resRPhi << " resZ=" << resZ << " eff=" << eff << " type=" << type << " deadPhiRegions=" << deadPhiRegions;
310340

311341
DetLayer* addedLayer = AddLayer(layer.c_str(), r, z, x0, xrho, resRPhi, resZ, eff, type);
312-
if (strlen(deadPhiRegions) > 0) { // Taking it as ccdb path or local file
313-
// Check if it begins with ccdb:
342+
if (!deadPhiRegions.empty()) { // Taking it as ccdb path or local file
343+
// Check if it begins with ccdb:
314344
if (std::string(deadPhiRegions).rfind("ccdb:", 0) == 0) {
315345
std::string ccdbPath = std::string(deadPhiRegions).substr(5); // remove "ccdb:" prefix
316346
if (ccdbManager == nullptr) {
@@ -321,7 +351,7 @@ void FastTracker::AddGenericDetector(std::string filename, o2::ccdb::BasicCCDBMa
321351
addedLayer->setDeadPhiRegions(g);
322352
} else {
323353
// Taking it as local file
324-
TFile infile(deadPhiRegions, "READ");
354+
TFile infile(deadPhiRegions.c_str(), "READ");
325355
if (!infile.IsOpen()) {
326356
LOG(fatal) << "Cannot open dead phi regions file " << deadPhiRegions;
327357
return;

0 commit comments

Comments
 (0)