Skip to content

Commit 3cd726c

Browse files
committed
only load lut if requested and move lut cleanup to geo provider
1 parent 4f62c9e commit 3cd726c

File tree

8 files changed

+129
-106
lines changed

8 files changed

+129
-106
lines changed

ALICE3/Core/DelphesO2TrackSmearer.cxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ bool TrackSmearer::loadTable(int pdg, const char* filename, bool forceReload)
7474
}
7575
std::map<std::string, std::string> metadata;
7676
mCcdbManager->getCCDBAccessor().retrieveBlob(path, mOutPath, metadata, 1);
77+
7778
// Add CCDB handling logic here if needed
7879
LOG(info) << " --- Now retrieving LUT file from CCDB to: " << filename;
7980
if (mCleanupDownloadedFile) { // Clean up the downloaded file if needed

ALICE3/Core/DelphesO2TrackSmearer.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,17 @@ class TrackSmearer
239239
return "proton";
240240
case 1000010020:
241241
return "deuteron";
242+
243+
244+
245+
246+
247+
248+
249+
250+
251+
252+
242253
case 1000010030:
243254
return "triton";
244255
case 1000020030:

ALICE3/Core/FastTracker.cxx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,20 @@ std::map<std::string, std::map<std::string, std::string>> GeometryContainer::par
7575
void GeometryContainer::init(o2::framework::InitContext& initContext)
7676
{
7777
std::vector<std::string> detectorConfiguration;
78-
const bool found = common::core::getTaskOptionValue(initContext, "on-the-fly-detector-geometry-provider", "detectorConfiguration", detectorConfiguration, false);
79-
if (!found) {
78+
const bool foundDetectorConfiguration = common::core::getTaskOptionValue(initContext, "on-the-fly-detector-geometry-provider", "detectorConfiguration", detectorConfiguration, false);
79+
if (!foundDetectorConfiguration) {
8080
LOG(fatal) << "Could not retrieve detector configuration from OnTheFlyDetectorGeometryProvider task.";
8181
return;
8282
}
8383
LOG(info) << "Size of detector configuration: " << detectorConfiguration.size();
84+
85+
bool cleanLutWhenLoaded;
86+
const bool foundCleanLutWhenLoaded = common::core::getTaskOptionValue(initContext, "on-the-fly-detector-geometry-provider", "cleanLutWhenLoaded", cleanLutWhenLoaded, false);
87+
if (!foundDetectorConfiguration) {
88+
LOG(fatal) << "Could not retrieve foundCleanLutWhenLoaded option from OnTheFlyDetectorGeometryProvider task.";
89+
return;
90+
}
91+
8492
for (std::string& configFile : detectorConfiguration) {
8593
if (configFile.rfind("ccdb:", 0) == 0) {
8694
LOG(info) << "ccdb source detected from on-the-fly-detector-geometry-provider";
@@ -107,6 +115,7 @@ void GeometryContainer::init(o2::framework::InitContext& initContext)
107115

108116
LOG(info) << "Detector geometry configuration file used: " << configFile;
109117
addEntry(configFile);
118+
setLutCleanupSetting(cleanLutWhenLoaded);
110119
}
111120
}
112121

ALICE3/Core/FastTracker.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,14 @@ class GeometryContainer
7575

7676
// Add a geometry entry from a configuration file
7777
void addEntry(const std::string& filename) { entries.emplace_back(filename); }
78+
void setLutCleanupSetting(const bool cleanLutWhenLoaded) { mCleanLutWhenLoaded = cleanLutWhenLoaded; }
7879

7980
// Getters
8081
int getNumberOfConfigurations() const { return entries.size(); }
8182
const std::vector<GeometryEntry>& getEntries() const { return entries; }
8283
const GeometryEntry& getEntry(const int id) const { return entries.at(id); }
8384
GeometryEntry getGeometryEntry(const int id) const { return entries.at(id); }
85+
bool cleanLutWhenLoaded() const { return mCleanLutWhenLoaded; }
8486

8587
// Get configuration maps
8688
std::map<std::string, std::map<std::string, std::string>> getConfigurations(const int id) const { return entries.at(id).getConfigurations(); }
@@ -92,6 +94,7 @@ class GeometryContainer
9294

9395
private:
9496
std::vector<GeometryEntry> entries;
97+
bool mCleanLutWhenLoaded = true;
9598
};
9699

97100
// +-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+

ALICE3/TableProducer/OTF/onTheFlyDetectorGeometryProvider.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
struct OnTheFlyDetectorGeometryProvider {
3131
o2::framework::HistogramRegistry histos{"Histos", {}, o2::framework::OutputObjHandlingPolicy::AnalysisObject};
32+
o2::framework::Configurable<bool> cleanLutWhenLoaded{"cleanLutWhenLoaded", true, "clean LUTs after being loaded to save disk space"};
3233
o2::framework::Configurable<std::vector<std::string>> detectorConfiguration{"detectorConfiguration",
3334
std::vector<std::string>{"$O2PHYSICS_ROOT/share/alice3/a3geometry_v3.ini"},
3435
"Paths of the detector geometry configuration files"};
@@ -64,7 +65,7 @@ struct OnTheFlyDetectorGeometryProvider {
6465
}
6566
detectorConfiguration.value[idx] = configFile; // Update the filename to the local file
6667
}
67-
LOG(info) << "Adding " << configFile << "geometry container";
68+
LOG(info) << "Adding " << configFile << " to geometry container";
6869
geometryContainer.addEntry(configFile);
6970
idx++;
7071
}

ALICE3/TableProducer/OTF/onTheFlyRichPid.cxx

Lines changed: 50 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ struct OnTheFlyRichPid {
129129
Configurable<float> bRichRefractiveIndexSector20{"bRichRefractiveIndexSector20", 1.03, "barrel RICH refractive index central(s)-20 and central(s)+20"}; // central(s)-20 and central(s)+20
130130
Configurable<float> bRICHPixelSize{"bRICHPixelSize", 0.1, "barrel RICH pixel size (cm)"};
131131
Configurable<float> bRichGapRefractiveIndex{"bRichGapRefractiveIndex", 1.000283, "barrel RICH gap refractive index"};
132-
Configurable<bool> cleanLutWhenLoaded{"cleanLutWhenLoaded", true, "clean LUTs after being loaded to save disk space"};
133132

134133
o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrNONE;
135134

@@ -292,59 +291,59 @@ struct OnTheFlyRichPid {
292291
mGeoContainer.init(initContext);
293292

294293
const int nGeometries = mGeoContainer.getNumberOfConfigurations();
295-
mMagneticField = mGeoContainer.getFloatValue(0, "global", "magneticfield");
296-
297294
pRandomNumberGenerator.SetSeed(0); // fully randomize
295+
mMagneticField = mGeoContainer.getFloatValue(0, "global", "magneticfield");
298296

299-
for (int icfg = 0; icfg < nGeometries; ++icfg) {
300-
const std::string histPath = "Configuration_" + std::to_string(icfg) + "/";
301-
mSmearer.emplace_back(std::make_unique<o2::delphes::DelphesO2TrackSmearer>());
302-
mSmearer[icfg]->setCleanupDownloadedFile(cleanLutWhenLoaded.value);
303-
mSmearer[icfg]->setCcdbManager(ccdb.operator->());
304-
mSmearer[icfg]->setDownloadPath("./.ALICE3/RICHPID/");
305-
std::map<std::string, std::string> globalConfiguration = mGeoContainer.getConfiguration(icfg, "global");
306-
for (const auto& entry : globalConfiguration) {
307-
int pdg = 0;
308-
if (entry.first.find("lut") != 0) {
309-
continue;
310-
}
311-
if (entry.first.find("lutEl") != std::string::npos) {
312-
pdg = kElectron;
313-
} else if (entry.first.find("lutMu") != std::string::npos) {
314-
pdg = kMuonMinus;
315-
} else if (entry.first.find("lutPi") != std::string::npos) {
316-
pdg = kPiPlus;
317-
} else if (entry.first.find("lutKa") != std::string::npos) {
318-
pdg = kKPlus;
319-
} else if (entry.first.find("lutPr") != std::string::npos) {
320-
pdg = kProton;
321-
} else if (entry.first.find("lutDe") != std::string::npos) {
322-
pdg = o2::constants::physics::kDeuteron;
323-
} else if (entry.first.find("lutTr") != std::string::npos) {
324-
pdg = o2::constants::physics::kTriton;
325-
} else if (entry.first.find("lutHe3") != std::string::npos) {
326-
pdg = o2::constants::physics::kHelium3;
327-
} else if (entry.first.find("lutAl") != std::string::npos) {
328-
pdg = o2::constants::physics::kAlpha;
329-
}
297+
if (flagRICHLoadDelphesLUTs) {
298+
for (int icfg = 0; icfg < nGeometries; ++icfg) {
299+
mSmearer.emplace_back(std::make_unique<o2::delphes::DelphesO2TrackSmearer>());
300+
mSmearer[icfg]->setCleanupDownloadedFile(mGeoContainer.cleanLutWhenLoaded());
301+
mSmearer[icfg]->setCcdbManager(ccdb.operator->());
302+
mSmearer[icfg]->setDownloadPath("./.ALICE3/RICHPID/");
303+
std::map<std::string, std::string> globalConfiguration = mGeoContainer.getConfiguration(icfg, "global");
304+
for (const auto& entry : globalConfiguration) {
305+
int pdg = 0;
306+
if (entry.first.find("lut") != 0) {
307+
continue;
308+
}
309+
if (entry.first.find("lutEl") != std::string::npos) {
310+
pdg = kElectron;
311+
} else if (entry.first.find("lutMu") != std::string::npos) {
312+
pdg = kMuonMinus;
313+
} else if (entry.first.find("lutPi") != std::string::npos) {
314+
pdg = kPiPlus;
315+
} else if (entry.first.find("lutKa") != std::string::npos) {
316+
pdg = kKPlus;
317+
} else if (entry.first.find("lutPr") != std::string::npos) {
318+
pdg = kProton;
319+
} else if (entry.first.find("lutDe") != std::string::npos) {
320+
pdg = o2::constants::physics::kDeuteron;
321+
} else if (entry.first.find("lutTr") != std::string::npos) {
322+
pdg = o2::constants::physics::kTriton;
323+
} else if (entry.first.find("lutHe3") != std::string::npos) {
324+
pdg = o2::constants::physics::kHelium3;
325+
} else if (entry.first.find("lutAl") != std::string::npos) {
326+
pdg = o2::constants::physics::kAlpha;
327+
}
330328

331-
std::string filename = entry.second;
332-
if (pdg == 0) {
333-
LOG(fatal) << "Unknown LUT entry " << entry.first << " for global configuration";
334-
}
335-
LOG(info) << "Loading LUT for pdg " << pdg << " for config " << icfg << " from provided file '" << filename << "'";
336-
if (filename.empty()) {
337-
LOG(warning) << "No LUT file passed for pdg " << pdg << ", skipping.";
338-
}
339-
// strip from leading/trailing spaces
340-
filename.erase(0, filename.find_first_not_of(" "));
341-
filename.erase(filename.find_last_not_of(" ") + 1);
342-
if (filename.empty()) {
343-
LOG(warning) << "No LUT file passed for pdg " << pdg << ", skipping.";
344-
}
345-
bool success = mSmearer[icfg]->loadTable(pdg, filename.c_str());
346-
if (!success) {
347-
LOG(fatal) << "Having issue with loading the LUT " << pdg << " " << filename;
329+
std::string filename = entry.second;
330+
if (pdg == 0) {
331+
LOG(fatal) << "Unknown LUT entry " << entry.first << " for global configuration";
332+
}
333+
LOG(info) << "Loading LUT for pdg " << pdg << " for config " << icfg << " from provided file '" << filename << "'";
334+
if (filename.empty()) {
335+
LOG(warning) << "No LUT file passed for pdg " << pdg << ", skipping.";
336+
}
337+
// strip from leading/trailing spaces
338+
filename.erase(0, filename.find_first_not_of(" "));
339+
filename.erase(filename.find_last_not_of(" ") + 1);
340+
if (filename.empty()) {
341+
LOG(warning) << "No LUT file passed for pdg " << pdg << ", skipping.";
342+
}
343+
bool success = mSmearer[icfg]->loadTable(pdg, filename.c_str());
344+
if (!success) {
345+
LOG(fatal) << "Having issue with loading the LUT " << pdg << " " << filename;
346+
}
348347
}
349348
}
350349
}

ALICE3/TableProducer/OTF/onTheFlyTofPid.cxx

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ struct OnTheFlyTofPid {
128128
Configurable<int> nBinsMult{"nBinsMult", 200, "number of bins in multiplicity"};
129129
Configurable<float> maxMultRange{"maxMultRange", 1000.f, "upper limit in multiplicity plots"};
130130
} plotsConfig;
131-
Configurable<bool> cleanLutWhenLoaded{"cleanLutWhenLoaded", true, "clean LUTs after being loaded to save disk space"};
132131

133132
o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrNONE;
134133

@@ -154,56 +153,57 @@ struct OnTheFlyTofPid {
154153
mMagneticField = mGeoContainer.getFloatValue(0, "global", "magneticfield");
155154

156155
pRandomNumberGenerator.SetSeed(0); // fully randomize
156+
if (simConfig.flagTOFLoadDelphesLUTs) {
157+
for (int icfg = 0; icfg < nGeometries; ++icfg) {
158+
const std::string histPath = "Configuration_" + std::to_string(icfg) + "/";
159+
mSmearer.emplace_back(std::make_unique<o2::delphes::DelphesO2TrackSmearer>());
160+
mSmearer[icfg]->setCleanupDownloadedFile(mGeoContainer.cleanLutWhenLoaded());
161+
mSmearer[icfg]->setCcdbManager(ccdb.operator->());
162+
mSmearer[icfg]->setDownloadPath("./.ALICE3/TOFPID/");
163+
std::map<std::string, std::string> globalConfiguration = mGeoContainer.getConfiguration(icfg, "global");
164+
for (const auto& entry : globalConfiguration) {
165+
int pdg = 0;
166+
if (entry.first.find("lut") != 0) {
167+
continue;
168+
}
169+
if (entry.first.find("lutEl") != std::string::npos) {
170+
pdg = kElectron;
171+
} else if (entry.first.find("lutMu") != std::string::npos) {
172+
pdg = kMuonMinus;
173+
} else if (entry.first.find("lutPi") != std::string::npos) {
174+
pdg = kPiPlus;
175+
} else if (entry.first.find("lutKa") != std::string::npos) {
176+
pdg = kKPlus;
177+
} else if (entry.first.find("lutPr") != std::string::npos) {
178+
pdg = kProton;
179+
} else if (entry.first.find("lutDe") != std::string::npos) {
180+
pdg = o2::constants::physics::kDeuteron;
181+
} else if (entry.first.find("lutTr") != std::string::npos) {
182+
pdg = o2::constants::physics::kTriton;
183+
} else if (entry.first.find("lutHe3") != std::string::npos) {
184+
pdg = o2::constants::physics::kHelium3;
185+
} else if (entry.first.find("lutAl") != std::string::npos) {
186+
pdg = o2::constants::physics::kAlpha;
187+
}
157188

158-
for (int icfg = 0; icfg < nGeometries; ++icfg) {
159-
const std::string histPath = "Configuration_" + std::to_string(icfg) + "/";
160-
mSmearer.emplace_back(std::make_unique<o2::delphes::DelphesO2TrackSmearer>());
161-
mSmearer[icfg]->setCleanupDownloadedFile(cleanLutWhenLoaded.value);
162-
mSmearer[icfg]->setCcdbManager(ccdb.operator->());
163-
mSmearer[icfg]->setDownloadPath("./.ALICE3/TOFPID/");
164-
std::map<std::string, std::string> globalConfiguration = mGeoContainer.getConfiguration(icfg, "global");
165-
for (const auto& entry : globalConfiguration) {
166-
int pdg = 0;
167-
if (entry.first.find("lut") != 0) {
168-
continue;
169-
}
170-
if (entry.first.find("lutEl") != std::string::npos) {
171-
pdg = kElectron;
172-
} else if (entry.first.find("lutMu") != std::string::npos) {
173-
pdg = kMuonMinus;
174-
} else if (entry.first.find("lutPi") != std::string::npos) {
175-
pdg = kPiPlus;
176-
} else if (entry.first.find("lutKa") != std::string::npos) {
177-
pdg = kKPlus;
178-
} else if (entry.first.find("lutPr") != std::string::npos) {
179-
pdg = kProton;
180-
} else if (entry.first.find("lutDe") != std::string::npos) {
181-
pdg = o2::constants::physics::kDeuteron;
182-
} else if (entry.first.find("lutTr") != std::string::npos) {
183-
pdg = o2::constants::physics::kTriton;
184-
} else if (entry.first.find("lutHe3") != std::string::npos) {
185-
pdg = o2::constants::physics::kHelium3;
186-
} else if (entry.first.find("lutAl") != std::string::npos) {
187-
pdg = o2::constants::physics::kAlpha;
188-
}
189-
190-
std::string filename = entry.second;
191-
if (pdg == 0) {
192-
LOG(fatal) << "Unknown LUT entry " << entry.first << " for global configuration";
193-
}
194-
LOG(info) << "Loading LUT for pdg " << pdg << " for config " << icfg << " from provided file '" << filename << "'";
195-
if (filename.empty()) {
196-
LOG(warning) << "No LUT file passed for pdg " << pdg << ", skipping.";
197-
}
198-
// strip from leading/trailing spaces
199-
filename.erase(0, filename.find_first_not_of(" "));
200-
filename.erase(filename.find_last_not_of(" ") + 1);
201-
if (filename.empty()) {
202-
LOG(warning) << "No LUT file passed for pdg " << pdg << ", skipping.";
203-
}
204-
bool success = mSmearer[icfg]->loadTable(pdg, filename.c_str());
205-
if (!success) {
206-
LOG(fatal) << "Having issue with loading the LUT " << pdg << " " << filename;
189+
std::string filename = entry.second;
190+
if (pdg == 0) {
191+
LOG(fatal) << "Unknown LUT entry " << entry.first << " for global configuration";
192+
}
193+
LOG(info) << "Loading LUT for pdg " << pdg << " for config " << icfg << " from provided file '" << filename << "'";
194+
if (filename.empty()) {
195+
LOG(warning) << "No LUT file passed for pdg " << pdg << ", skipping.";
196+
}
197+
// strip from leading/trailing spaces
198+
filename.erase(0, filename.find_first_not_of(" "));
199+
filename.erase(filename.find_last_not_of(" ") + 1);
200+
if (filename.empty()) {
201+
LOG(warning) << "No LUT file passed for pdg " << pdg << ", skipping.";
202+
}
203+
bool success = mSmearer[icfg]->loadTable(pdg, filename.c_str());
204+
if (!success) {
205+
LOG(fatal) << "Having issue with loading the LUT " << pdg << " " << filename;
206+
}
207207
}
208208
}
209209
}

ALICE3/TableProducer/OTF/onTheFlyTracker.cxx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ struct OnTheFlyTracker {
117117
Configurable<bool> processUnreconstructedTracks{"processUnreconstructedTracks", false, "process (smear) unreco-ed tracks"};
118118
Configurable<bool> doExtraQA{"doExtraQA", false, "do extra 2D QA plots"};
119119
Configurable<bool> extraQAwithoutDecayDaughters{"extraQAwithoutDecayDaughters", false, "remove decay daughters from qa plots (yes/no)"};
120-
Configurable<bool> cleanLutWhenLoaded{"cleanLutWhenLoaded", true, "clean LUTs after being loaded to save disk space"};
121120
Configurable<std::string> primaryVertexOption{"primaryVertexOption", "pvertexer.maxChi2TZDebris=10;pvertexer.acceptableScale2=9;pvertexer.minScale2=2;pvertexer.timeMarginVertexTime=1.3;;pvertexer.maxChi2TZDebris=40;pvertexer.maxChi2Mean=12;pvertexer.maxMultRatDebris=1.;pvertexer.addTimeSigma2Debris=1e-2;pvertexer.meanVertexExtraErrSelection=0.03;", "Option for the primary vertexer"};
122121

123122
struct : ConfigurableGroup {
@@ -316,7 +315,7 @@ struct OnTheFlyTracker {
316315
for (int icfg = 0; icfg < nGeometries; ++icfg) {
317316
const std::string histPath = "Configuration_" + std::to_string(icfg) + "/";
318317
mSmearer.emplace_back(std::make_unique<o2::delphes::DelphesO2TrackSmearer>());
319-
mSmearer[icfg]->setCleanupDownloadedFile(cleanLutWhenLoaded.value);
318+
mSmearer[icfg]->setCleanupDownloadedFile(mGeoContainer.cleanLutWhenLoaded());
320319
mSmearer[icfg]->setCcdbManager(ccdb.operator->());
321320
mSmearer[icfg]->setDownloadPath("./.ALICE3/Tracker/");
322321
std::map<std::string, std::string> globalConfiguration = mGeoContainer.getConfiguration(icfg, "global");

0 commit comments

Comments
 (0)