Skip to content

Commit 44785ac

Browse files
authored
Merge branch 'AliceO2Group:master' into master
2 parents 78fce6e + 7ee1064 commit 44785ac

File tree

221 files changed

+14270
-6809
lines changed

Some content is hidden

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

221 files changed

+14270
-6809
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

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: 6 additions & 33 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,42 +63,13 @@ 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-
filename = Form("%s/%s/snapshot.root", mOutPath.c_str(), path.c_str());
68-
LOG(info) << " --- Local LUT filename will be: " << filename;
69-
std::ifstream checkFile(filename); // Check if file already exists
70-
if (!checkFile.is_open()) { // File does not exist, retrieve from CCDB
71-
LOG(info) << " --- CCDB source detected for PDG " << pdg << ": " << path;
72-
if (!mCcdbManager) {
73-
LOG(fatal) << " --- CCDB manager not set. Please set it before loading LUT from CCDB.";
74-
}
75-
std::map<std::string, std::string> metadata;
76-
mCcdbManager->getCCDBAccessor().retrieveBlob(path, mOutPath, metadata, 1);
77-
// Add CCDB handling logic here if needed
78-
LOG(info) << " --- Now retrieving LUT file from CCDB to: " << filename;
79-
if (mCleanupDownloadedFile) { // Clean up the downloaded file if needed
80-
bool status = loadTable(pdg, filename, forceReload);
81-
if (std::remove(filename) != 0) {
82-
LOG(warn) << " --- Could not remove temporary LUT file: " << filename;
83-
} else {
84-
LOG(info) << " --- Removed temporary LUT file: " << filename;
85-
}
86-
return status;
87-
}
88-
} else { // File exists, proceed to load
89-
LOG(info) << " --- LUT file already exists: " << filename << ". Skipping download.";
90-
checkFile.close();
91-
}
92-
return loadTable(pdg, filename, forceReload);
93-
}
9466

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

97-
std::ifstream lutFile(filename, std::ifstream::binary);
70+
std::ifstream lutFile(localFilename, std::ifstream::binary);
9871
if (!lutFile.is_open()) {
99-
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;
10073
delete mLUTHeader[ipdg];
10174
mLUTHeader[ipdg] = nullptr;
10275
return false;
@@ -147,7 +120,7 @@ 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;
151124
LOG(info) << " --- expected/detected " << sizeof(lutHeader_t) << "/" << lutFile.gcount() << std::endl;
152125
return false;
153126
}

ALICE3/Core/DelphesO2TrackSmearer.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,6 @@ class TrackSmearer
251251
}
252252
void setdNdEta(float val) { mdNdEta = val; } //;
253253
void setCcdbManager(o2::ccdb::BasicCCDBManager* mgr) { mCcdbManager = mgr; } //;
254-
void setCleanupDownloadedFile(bool val) { mCleanupDownloadedFile = val; } //;
255-
void setDownloadPath(const std::string& path) { mOutPath = path; } //;
256254

257255
protected:
258256
static constexpr unsigned int nLUTs = 9; // Number of LUT available
@@ -266,8 +264,6 @@ class TrackSmearer
266264

267265
private:
268266
o2::ccdb::BasicCCDBManager* mCcdbManager = nullptr;
269-
bool mCleanupDownloadedFile = true; // Flag to cleanup the LUT after it's used
270-
std::string mOutPath = "./.ALICE3/LUTs/"; // Path where to download LUTs from CCDB
271267
};
272268

273269
} // namespace delphes

ALICE3/Core/FastTracker.cxx

Lines changed: 3 additions & 195 deletions
Original file line numberDiff line numberDiff line change
@@ -24,110 +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-
LOG(info) << "Parsing TEnv configuration file: " << filename;
42-
TEnv env(filename.c_str());
43-
THashList* table = env.GetTable();
44-
layers.clear();
45-
for (int i = 0; i < table->GetEntries(); ++i) {
46-
const std::string key = table->At(i)->GetName();
47-
// key should contain exactly one dot
48-
if (key.find('.') == std::string::npos || key.find('.') != key.rfind('.')) {
49-
LOG(fatal) << "Key " << key << " does not contain exactly one dot";
50-
continue;
51-
}
52-
const std::string firstPart = key.substr(0, key.find('.'));
53-
if (std::find(layers.begin(), layers.end(), firstPart) == layers.end()) {
54-
layers.push_back(firstPart);
55-
}
56-
}
57-
env.Print();
58-
// Layers
59-
for (const auto& layer : layers) {
60-
LOG(info) << " Reading layer " << layer;
61-
for (int i = 0; i < table->GetEntries(); ++i) {
62-
const std::string key = table->At(i)->GetName();
63-
if (key.find(layer + ".") == 0) {
64-
const std::string paramName = key.substr(key.find('.') + 1);
65-
const std::string value = env.GetValue(key.c_str(), "");
66-
configMap[layer][paramName] = value;
67-
}
68-
}
69-
}
70-
return configMap;
71-
}
72-
73-
void GeometryContainer::init(o2::framework::InitContext& initContext)
74-
{
75-
std::vector<std::string> detectorConfiguration;
76-
const bool found = common::core::getTaskOptionValue(initContext, "on-the-fly-detector-geometry-provider", "detectorConfiguration", detectorConfiguration, false);
77-
if (!found) {
78-
LOG(fatal) << "Could not retrieve detector configuration from OnTheFlyDetectorGeometryProvider task.";
79-
return;
80-
}
81-
LOG(info) << "Size of detector configuration: " << detectorConfiguration.size();
82-
for (const auto& configFile : detectorConfiguration) {
83-
LOG(info) << "Detector geometry configuration file used: " << configFile;
84-
addEntry(configFile);
85-
}
86-
}
87-
88-
std::map<std::string, std::string> GeometryContainer::GeometryEntry::getConfiguration(const std::string& layerName) const
89-
{
90-
auto it = mConfigurations.find(layerName);
91-
if (it != mConfigurations.end()) {
92-
return it->second;
93-
} else {
94-
LOG(fatal) << "Layer " << layerName << " not found in geometry configurations.";
95-
return {};
96-
}
97-
}
98-
99-
bool GeometryContainer::GeometryEntry::hasValue(const std::string& layerName, const std::string& key) const
100-
{
101-
auto layerIt = mConfigurations.find(layerName);
102-
if (layerIt != mConfigurations.end()) {
103-
auto keyIt = layerIt->second.find(key);
104-
return keyIt != layerIt->second.end();
105-
}
106-
return false;
107-
}
108-
109-
std::string GeometryContainer::GeometryEntry::getValue(const std::string& layerName, const std::string& key, bool require) const
110-
{
111-
auto layer = getConfiguration(layerName);
112-
auto entry = layer.find(key);
113-
if (entry != layer.end()) {
114-
return layer.at(key);
115-
} else if (require) {
116-
LOG(fatal) << "Key " << key << " not found in layer " << layerName << " configurations.";
117-
return "";
118-
} else {
119-
return "";
120-
}
121-
}
122-
123-
void GeometryContainer::GeometryEntry::replaceValue(const std::string& layerName, const std::string& key, const std::string& value)
124-
{
125-
if (!hasValue(layerName, key)) { // check that the key exists
126-
LOG(fatal) << "Key " << key << " does not exist in layer " << layerName << ". Cannot replace value.";
127-
}
128-
setValue(layerName, key, value);
129-
}
130-
13139
// +-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+
13240

13341
DetLayer* FastTracker::AddLayer(TString name, float r, float z, float x0, float xrho, float resRPhi, float resZ, float eff, int type)
@@ -188,106 +96,6 @@ void FastTracker::Print()
18896
LOG(info) << "+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+";
18997
}
19098

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

336-
void FastTracker::AddGenericDetector(GeometryContainer::GeometryEntry configMap, o2::ccdb::BasicCCDBManager* ccdbManager)
144+
void FastTracker::AddGenericDetector(o2::fastsim::GeometryEntry configMap, o2::ccdb::BasicCCDBManager* ccdbManager)
337145
{
338146
// Layers
339147
for (const auto& layer : configMap.getLayerNames()) {

0 commit comments

Comments
 (0)