Skip to content

Commit a2d4aa8

Browse files
authored
Merge branch 'master' into master
2 parents 9a60098 + 2df18fa commit a2d4aa8

File tree

352 files changed

+34647
-13228
lines changed

Some content is hidden

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

352 files changed

+34647
-13228
lines changed

.github/workflows/mega-linter.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949

5050
# Upload MegaLinter artifacts
5151
- name: Archive production artifacts
52-
uses: actions/upload-artifact@v5
52+
uses: actions/upload-artifact@v6
5353
if: success() || failure()
5454
with:
5555
name: MegaLinter reports

.github/workflows/o2-linter.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Find issues in O2 code
33
name: O2 linter
44

5-
# "on": [pull_request_target, push]
5+
#"on": [pull_request_target, push]
66
permissions: {}
77
env:
88
BRANCH_MAIN: master
@@ -47,6 +47,8 @@ jobs:
4747
fi
4848
echo "linter_ran=1" >> "$GITHUB_OUTPUT"
4949
[[ "${{ github.event_name }}" == "pull_request_target" ]] && options="-g"
50+
# Checkout the script from the base branch to prevent execution of arbitrary code in the head branch.
51+
git checkout ${{ env.BRANCH_BASE }} -- Scripts/o2_linter.py
5052
# shellcheck disable=SC2086 # Ignore unquoted options.
5153
python3 Scripts/o2_linter.py $options "${files[@]}"
5254
echo "Tip: If you allow actions in your fork repository, O2 linter will run when you push commits."

ALICE3/Core/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@ o2physics_add_library(ALICE3Core
1313
SOURCES TOFResoALICE3.cxx
1414
TrackUtilities.cxx
1515
DelphesO2TrackSmearer.cxx
16+
GeometryContainer.cxx
1617
PUBLIC_LINK_LIBRARIES O2::Framework
1718
O2Physics::AnalysisCore)
1819

1920
o2physics_target_root_dictionary(ALICE3Core
2021
HEADERS TOFResoALICE3.h
2122
TrackUtilities.h
2223
DelphesO2TrackSmearer.h
24+
GeometryContainer.h
2325
LINKDEF ALICE3CoreLinkDef.h)
2426

2527
o2physics_add_library(FastTracker

ALICE3/Core/DelphesO2TrackSmearer.cxx

Lines changed: 8 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636

3737
#include "ALICE3/Core/DelphesO2TrackSmearer.h"
3838

39+
#include "ALICE3/Core/GeometryContainer.h"
40+
3941
#include <CommonConstants/PhysicsConstants.h>
4042
#include <Framework/Logger.h>
4143

@@ -61,50 +63,21 @@ bool TrackSmearer::loadTable(int pdg, const char* filename, bool forceReload)
6163
LOG(info) << " --- LUT table for PDG " << pdg << " has been already loaded with index " << ipdg << std::endl;
6264
return false;
6365
}
64-
if (strncmp(filename, "ccdb:", 5) == 0) { // Check if filename starts with "ccdb:"
65-
LOG(info) << " --- LUT file source identified as CCDB.";
66-
std::string path = std::string(filename).substr(5); // Remove "ccdb:" prefix
67-
const std::string outPath = "/tmp/LUTs/";
68-
filename = Form("%s/%s/snapshot.root", outPath.c_str(), path.c_str());
69-
LOG(info) << " --- Local LUT filename will be: " << filename;
70-
std::ifstream checkFile(filename); // Check if file already exists
71-
if (!checkFile.is_open()) { // File does not exist, retrieve from CCDB
72-
LOG(info) << " --- CCDB source detected for PDG " << pdg << ": " << path;
73-
if (!mCcdbManager) {
74-
LOG(fatal) << " --- CCDB manager not set. Please set it before loading LUT from CCDB.";
75-
}
76-
std::map<std::string, std::string> metadata;
77-
mCcdbManager->getCCDBAccessor().retrieveBlob(path, outPath, metadata, 1);
78-
// Add CCDB handling logic here if needed
79-
LOG(info) << " --- Now retrieving LUT file from CCDB to: " << filename;
80-
if (mCleanupDownloadedFile) { // Clean up the downloaded file if needed
81-
bool status = loadTable(pdg, filename, forceReload);
82-
if (std::remove(filename) != 0) {
83-
LOG(warn) << " --- Could not remove temporary LUT file: " << filename;
84-
} else {
85-
LOG(info) << " --- Removed temporary LUT file: " << filename;
86-
}
87-
return status;
88-
}
89-
} else { // File exists, proceed to load
90-
LOG(info) << " --- LUT file already exists: " << filename << ". Skipping download.";
91-
checkFile.close();
92-
}
93-
return loadTable(pdg, filename, forceReload);
94-
}
9566

67+
const std::string localFilename = o2::fastsim::GeometryEntry::accessFile(filename, "./.ALICE3/LUTs/", mCcdbManager, 10);
9668
mLUTHeader[ipdg] = new lutHeader_t;
9769

98-
std::ifstream lutFile(filename, std::ifstream::binary);
70+
std::ifstream lutFile(localFilename, std::ifstream::binary);
9971
if (!lutFile.is_open()) {
100-
LOG(info) << " --- cannot open covariance matrix file for PDG " << pdg << ": " << filename << std::endl;
72+
LOG(info) << " --- cannot open covariance matrix file for PDG " << pdg << ": " << localFilename << std::endl;
10173
delete mLUTHeader[ipdg];
10274
mLUTHeader[ipdg] = nullptr;
10375
return false;
10476
}
10577
lutFile.read(reinterpret_cast<char*>(mLUTHeader[ipdg]), sizeof(lutHeader_t));
10678
if (lutFile.gcount() != sizeof(lutHeader_t)) {
10779
LOG(info) << " --- troubles reading covariance matrix header for PDG " << pdg << ": " << filename << std::endl;
80+
LOG(info) << " --- expected/detected " << sizeof(lutHeader_t) << "/" << lutFile.gcount() << std::endl;
10881
delete mLUTHeader[ipdg];
10982
mLUTHeader[ipdg] = nullptr;
11083
return false;
@@ -147,7 +120,8 @@ bool TrackSmearer::loadTable(int pdg, const char* filename, bool forceReload)
147120
mLUTEntry[ipdg][inch][irad][ieta][ipt] = new lutEntry_t;
148121
lutFile.read(reinterpret_cast<char*>(mLUTEntry[ipdg][inch][irad][ieta][ipt]), sizeof(lutEntry_t));
149122
if (lutFile.gcount() != sizeof(lutEntry_t)) {
150-
LOG(info) << " --- troubles reading covariance matrix entry for PDG " << pdg << ": " << filename << std::endl;
123+
LOG(info) << " --- troubles reading covariance matrix entry for PDG " << pdg << ": " << localFilename << std::endl;
124+
LOG(info) << " --- expected/detected " << sizeof(lutHeader_t) << "/" << lutFile.gcount() << std::endl;
151125
return false;
152126
}
153127
}

ALICE3/Core/DelphesO2TrackSmearer.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <fstream>
3434
#include <iostream>
3535
#include <map>
36+
#include <string>
3637

3738
///////////////////////////////
3839
/// DelphesO2/src/lutCovm.hh //
@@ -250,7 +251,6 @@ class TrackSmearer
250251
}
251252
void setdNdEta(float val) { mdNdEta = val; } //;
252253
void setCcdbManager(o2::ccdb::BasicCCDBManager* mgr) { mCcdbManager = mgr; } //;
253-
void setCleanupDownloadedFile(bool val) { mCleanupDownloadedFile = val; } //;
254254

255255
protected:
256256
static constexpr unsigned int nLUTs = 9; // Number of LUT available
@@ -264,7 +264,6 @@ class TrackSmearer
264264

265265
private:
266266
o2::ccdb::BasicCCDBManager* mCcdbManager = nullptr;
267-
bool mCleanupDownloadedFile = true;
268267
};
269268

270269
} // namespace delphes

ALICE3/Core/FastTracker.cxx

Lines changed: 3 additions & 176 deletions
Original file line numberDiff line numberDiff line change
@@ -24,91 +24,18 @@
2424
#include <TRandom.h>
2525
#include <TSystem.h>
2626

27+
#include <chrono>
2728
#include <fstream>
2829
#include <map>
2930
#include <string>
31+
#include <thread>
3032
#include <vector>
3133

3234
namespace o2
3335
{
3436
namespace fastsim
3537
{
3638

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-
11239
// +-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+
11340

11441
DetLayer* FastTracker::AddLayer(TString name, float r, float z, float x0, float xrho, float resRPhi, float resZ, float eff, int type)
@@ -169,106 +96,6 @@ void FastTracker::Print()
16996
LOG(info) << "+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+";
17097
}
17198

172-
void FastTracker::AddSiliconALICE3v4(std::vector<float> pixelResolution)
173-
{
174-
LOG(info) << " ALICE 3: Adding v4 tracking layers";
175-
float x0IT = 0.001; // 0.1%
176-
float x0OT = 0.005; // 0.5%
177-
float xrhoIB = 1.1646e-02; // 50 mum Si
178-
float xrhoOT = 1.1646e-01; // 500 mum Si
179-
float eff = 1.00;
180-
181-
float resRPhiIT = pixelResolution[0];
182-
float resZIT = pixelResolution[1];
183-
float resRPhiOT = pixelResolution[2];
184-
float resZOT = pixelResolution[3];
185-
186-
AddLayer("bpipe0", 0.48, 250, 0.00042, 2.772e-02, 0.0f, 0.0f, 0.0f, 0); // 150 mum Be
187-
AddLayer("ddd0", 0.5, 250, x0IT, xrhoIB, resRPhiIT, resZIT, eff, 1);
188-
AddLayer("ddd1", 1.2, 250, x0IT, xrhoIB, resRPhiIT, resZIT, eff, 1);
189-
AddLayer("ddd2", 2.5, 250, x0IT, xrhoIB, resRPhiIT, resZIT, eff, 1);
190-
AddLayer("bpipe1", 5.7, 250, 0.0014, 9.24e-02, 0.0f, 0.0f, 0.0f, 0); // 500 mum Be
191-
AddLayer("ddd3", 7., 250, x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1);
192-
AddLayer("ddd4", 10., 250, x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1);
193-
AddLayer("ddd5", 13., 250, x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1);
194-
AddLayer("ddd6", 16., 250, x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1);
195-
AddLayer("ddd7", 25., 250, x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1);
196-
AddLayer("ddd8", 40., 250, x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1);
197-
AddLayer("ddd9", 45., 250, x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1);
198-
}
199-
200-
void FastTracker::AddSiliconALICE3v2(std::vector<float> pixelResolution)
201-
{
202-
LOG(info) << "ALICE 3: Adding v2 tracking layers;";
203-
float x0IT = 0.001; // 0.1%
204-
float x0OT = 0.01; // 1.0%
205-
float xrhoIB = 2.3292e-02; // 100 mum Si
206-
float xrhoOT = 2.3292e-01; // 1000 mum Si
207-
float eff = 1.00;
208-
209-
float resRPhiIT = pixelResolution[0];
210-
float resZIT = pixelResolution[1];
211-
float resRPhiOT = pixelResolution[2];
212-
float resZOT = pixelResolution[3];
213-
214-
AddLayer("bpipe0", 0.48, 250, 0.00042, 2.772e-02, 0.0f, 0.0f, 0.0f, 0); // 150 mum Be
215-
AddLayer("B00", 0.5, 250, x0IT, xrhoIB, resRPhiIT, resZIT, eff, 1);
216-
AddLayer("B01", 1.2, 250, x0IT, xrhoIB, resRPhiIT, resZIT, eff, 1);
217-
AddLayer("B02", 2.5, 250, x0IT, xrhoIB, resRPhiIT, resZIT, eff, 1);
218-
AddLayer("bpipe1", 3.7, 250, 0.0014, 9.24e-02, 0.0f, 0.0f, 0.0f, 0); // 500 mum Be
219-
AddLayer("B03", 3.75, 250, x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1);
220-
AddLayer("B04", 7., 250, x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1);
221-
AddLayer("B05", 12., 250, x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1);
222-
AddLayer("B06", 20., 250, x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1);
223-
AddLayer("B07", 30., 250, x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1);
224-
AddLayer("B08", 45., 250, x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1);
225-
AddLayer("B09", 60., 250, x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1);
226-
AddLayer("B10", 80., 250, x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1);
227-
}
228-
229-
void FastTracker::AddSiliconALICE3(float scaleX0VD, std::vector<float> pixelResolution)
230-
{
231-
float x0Pipe0 = 0.001592; // 200 um AlBe
232-
float x0VDL0 = 0.00076; // 30 um Si + 50 um glue + carbon foam 0.03%
233-
float x0VDL1 = 0.00096; // 30 um Si + 50 um glue + carbon foam 0.05%
234-
float x0VDL2 = 0.00167; // 30 um Si + 50 um glue + carbon foam 0.05% + 0.07% Be case
235-
float x0Coldplate = 0.02f; // (1.5 mm Al2O3 2%)
236-
float x0Pipe1 = 0.0023f; // 800 um Be
237-
float x0OT = 0.01; // 1.0%
238-
float x0iTOF = x0OT * 3.;
239-
240-
float resRPhiVD = pixelResolution[0];
241-
float resZVD = pixelResolution[1];
242-
float resRPhiOT = pixelResolution[2];
243-
float resZOT = pixelResolution[3];
244-
245-
float xrhoPipe0 = 0;
246-
float xrhoVDL0 = 0;
247-
float xrhoVDL1 = 0;
248-
float xrhoVDL2 = 0;
249-
float xrhoColdplate = 0;
250-
float xrhoPipe1 = 0;
251-
float xrhoOT = 2.3292e-01;
252-
float xrhoiTOF = 0.03;
253-
float eff = 1.00;
254-
255-
AddLayer("bpipe0", 0.48, 250, x0Pipe0, xrhoPipe0, 0.0f, 0.0f, 0.0f, 0);
256-
AddLayer("B00", 0.5, 250, x0VDL0 * scaleX0VD, xrhoVDL0, resRPhiVD, resZVD, eff, 1);
257-
AddLayer("B01", 1.2, 250, x0VDL1 * scaleX0VD, xrhoVDL1, resRPhiVD, resZVD, eff, 1);
258-
AddLayer("B02", 2.5, 250, x0VDL2 * scaleX0VD, xrhoVDL2, resRPhiVD, resZVD, eff, 1);
259-
AddLayer("coldplate", 2.6, 250, x0Coldplate, xrhoColdplate, 0.0f, 0.0f, 0.0f, 0);
260-
AddLayer("bpipe1", 5.7, 250, x0Pipe1, xrhoPipe1, 0.0f, 0.0f, 0.0f, 0);
261-
AddLayer("B03", 7., 250, x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1);
262-
AddLayer("B04", 9., 250, x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1);
263-
AddLayer("B05", 12., 250, x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1);
264-
AddLayer("iTOF", 19, 250, x0iTOF, xrhoiTOF, resRPhiOT, resZOT, eff, 0);
265-
AddLayer("B06", 20., 250, x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1);
266-
AddLayer("B07", 30., 250, x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1);
267-
AddLayer("B08", 45., 250, x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1);
268-
AddLayer("B09", 60., 250, x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1);
269-
AddLayer("B10", 80., 250, x0OT, xrhoOT, resRPhiOT, resZOT, eff, 1);
270-
}
271-
27299
void FastTracker::AddTPC(float phiResMean, float zResMean)
273100
{
274101
LOG(info) << " Adding standard time projection chamber";
@@ -314,7 +141,7 @@ void FastTracker::AddTPC(float phiResMean, float zResMean)
314141
}
315142
}
316143

317-
void FastTracker::AddGenericDetector(GeometryContainer::GeometryEntry configMap, o2::ccdb::BasicCCDBManager* ccdbManager)
144+
void FastTracker::AddGenericDetector(o2::fastsim::GeometryEntry configMap, o2::ccdb::BasicCCDBManager* ccdbManager)
318145
{
319146
// Layers
320147
for (const auto& layer : configMap.getLayerNames()) {

0 commit comments

Comments
 (0)