Skip to content

Commit 84691a4

Browse files
committed
Update
1 parent 49703cf commit 84691a4

File tree

4 files changed

+113
-118
lines changed

4 files changed

+113
-118
lines changed

ALICE3/Core/FastTracker.cxx

Lines changed: 42 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,29 @@ void GeometryContainer::init(o2::framework::InitContext& initContext)
4646
}
4747
}
4848

49+
std::map<std::string, std::string> GeometryContainer::GeometryEntry::getConfiguration(const std::string& layerName) const
50+
{
51+
auto it = mConfigurations.find(layerName);
52+
if (it != mConfigurations.end()) {
53+
return it->second;
54+
} else {
55+
LOG(fatal) << "Layer " << layerName << " not found in geometry configurations.";
56+
return {};
57+
}
58+
}
59+
60+
std::string GeometryContainer::GeometryEntry::getValue(const std::string& layerName, const std::string& key) const
61+
{
62+
auto layer = getConfiguration(layerName);
63+
auto entry = layer.find(key);
64+
if (entry != layer.end()) {
65+
return layer.at(key);
66+
} else {
67+
LOG(fatal) << "Key " << key << " not found in layer " << layerName << " configurations.";
68+
return "";
69+
}
70+
}
71+
4972
// +-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+-~-<*>-~-+
5073

5174
DetLayer* FastTracker::AddLayer(TString name, float r, float z, float x0, float xrho, float resRPhi, float resZ, float eff, int type)
@@ -251,30 +274,31 @@ void FastTracker::AddTPC(float phiResMean, float zResMean)
251274
}
252275
}
253276

254-
void FastTracker::AddGenericDetector(std::map<std::string, std::map<std::string, std::string>> configMap, o2::ccdb::BasicCCDBManager* ccdbManager)
277+
void FastTracker::AddGenericDetector(GeometryContainer::GeometryEntry configMap, o2::ccdb::BasicCCDBManager* ccdbManager)
255278
{
256279
// Layers
257-
for (const auto& layer : configMap) {
258-
if (layer.first.find("global") != std::string::npos) { // Layers with global tag are skipped
259-
LOG(info) << " Skipping global configuration entry " << layer.first;
280+
for (const auto& layer : configMap.getLayerNames()) {
281+
if (layer.find("global") != std::string::npos) { // Layers with global tag are skipped
282+
LOG(info) << " Skipping global configuration entry " << layer;
260283
continue;
261284
}
262-
LOG(info) << " Reading layer " << layer.first;
263-
const float r = std::stof(layer.second.at("r"));
264-
LOG(info) << " Layer " << layer.first << " has radius " << r;
265-
const float z = std::stof(layer.second.at("z"));
266-
const float x0 = std::stof(layer.second.at("x0"));
267-
const float xrho = std::stof(layer.second.at("xrho"));
268-
const float resRPhi = std::stof(layer.second.at("resRPhi"));
269-
const float resZ = std::stof(layer.second.at("resZ"));
270-
const float eff = std::stof(layer.second.at("eff"));
271-
const int type = std::stoi(layer.second.at("type"));
272-
const std::string deadPhiRegions = layer.second.at("deadPhiRegions");
285+
286+
LOG(info) << " Reading layer " << layer;
287+
const float r = configMap.getFloatValue(layer, "r");
288+
LOG(info) << " Layer " << layer << " has radius " << r;
289+
const float z = configMap.getFloatValue(layer, "z");
290+
const float x0 = configMap.getFloatValue(layer, "x0");
291+
const float xrho = configMap.getFloatValue(layer, "xrho");
292+
const float resRPhi = configMap.getFloatValue(layer, "resRPhi");
293+
const float resZ = configMap.getFloatValue(layer, "resZ");
294+
const float eff = configMap.getFloatValue(layer, "eff");
295+
const int type = configMap.getIntValue(layer, "type");
296+
const std::string deadPhiRegions = configMap.getValue(layer, "deadPhiRegions");
273297

274298
// 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);
275-
LOG(info) << " Adding layer " << layer.first << " r=" << r << " z=" << z << " x0=" << x0 << " xrho=" << xrho << " resRPhi=" << resRPhi << " resZ=" << resZ << " eff=" << eff << " type=" << type << " deadPhiRegions=" << deadPhiRegions;
299+
LOG(info) << " Adding layer " << layer << " r=" << r << " z=" << z << " x0=" << x0 << " xrho=" << xrho << " resRPhi=" << resRPhi << " resZ=" << resZ << " eff=" << eff << " type=" << type << " deadPhiRegions=" << deadPhiRegions;
276300

277-
DetLayer* addedLayer = AddLayer(layer.first.c_str(), r, z, x0, xrho, resRPhi, resZ, eff, type);
301+
DetLayer* addedLayer = AddLayer(layer.c_str(), r, z, x0, xrho, resRPhi, resZ, eff, type);
278302
if (!deadPhiRegions.empty()) { // Taking it as ccdb path or local file
279303
// Check if it begins with ccdb:
280304
if (std::string(deadPhiRegions).rfind("ccdb:", 0) == 0) {
@@ -297,7 +321,7 @@ void FastTracker::AddGenericDetector(std::map<std::string, std::map<std::string,
297321
addedLayer->setDeadPhiRegions(g);
298322
}
299323
} else {
300-
LOG(debug) << " No dead phi regions for layer " << layer.first;
324+
LOG(debug) << " No dead phi regions for layer " << layer;
301325
}
302326
}
303327
}

ALICE3/Core/FastTracker.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,18 @@ class GeometryContainer
8686
mConfigurations = GeometryContainer::parseTEnvConfiguration(filename);
8787
}
8888
std::map<std::string, std::map<std::string, std::string>> getConfigurations() const { return mConfigurations; }
89+
std::map<std::string, std::string> getConfiguration(const std::string& layerName) const;
90+
std::vector<std::string> getLayerNames() const
91+
{
92+
std::vector<std::string> layerNames;
93+
for (const auto& layer : mConfigurations) {
94+
layerNames.push_back(layer.first);
95+
}
96+
return layerNames;
97+
}
98+
std::string getValue(const std::string& layerName, const std::string& key) const;
99+
float getFloatValue(const std::string& layerName, const std::string& key) const { return std::stof(getValue(layerName, key)); }
100+
int getIntValue(const std::string& layerName, const std::string& key) const { return std::stoi(getValue(layerName, key)); }
89101

90102
private:
91103
std::string name; // Filename of the geometry
@@ -95,6 +107,8 @@ class GeometryContainer
95107
void addEntry(const std::string& filename) { entries.emplace_back(filename); }
96108
const std::vector<GeometryEntry>& getEntries() const { return entries; }
97109
const GeometryEntry& getEntry(const int id) const { return entries.at(id); }
110+
std::map<std::string, std::map<std::string, std::string>> getConfigurations(const int id) const { return entries.at(id).getConfigurations(); }
111+
std::map<std::string, std::string> getConfiguration(const int id, const std::string& layerName) const { return entries.at(id).getConfiguration(layerName); }
98112

99113
private:
100114
std::vector<GeometryEntry> entries;
@@ -151,7 +165,7 @@ class FastTracker
151165
*
152166
* @param configMap Configuration map describing the detector.
153167
*/
154-
void AddGenericDetector(std::map<std::string, std::map<std::string, std::string>> configMap, o2::ccdb::BasicCCDBManager* ccdbManager = nullptr);
168+
void AddGenericDetector(GeometryContainer::GeometryEntry configMap, o2::ccdb::BasicCCDBManager* ccdbManager = nullptr);
155169

156170
void Print();
157171

ALICE3/TableProducer/OTF/onTheFlyTracker.cxx

Lines changed: 55 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -110,19 +110,6 @@ struct OnTheFlyTracker {
110110
Configurable<bool> doExtraQA{"doExtraQA", false, "do extra 2D QA plots"};
111111
Configurable<bool> extraQAwithoutDecayDaughters{"extraQAwithoutDecayDaughters", false, "remove decay daughters from qa plots (yes/no)"};
112112

113-
struct : ConfigurableGroup {
114-
std::string prefix = "lookUpTables"; // JSON group name
115-
Configurable<std::vector<std::string>> lutEl{"lutEl", std::vector<std::string>{"lutCovm.el.dat "}, "LUT for electrons (if emtpy no LUT is taken)"};
116-
Configurable<std::vector<std::string>> lutMu{"lutMu", std::vector<std::string>{"lutCovm.mu.dat "}, "LUT for muons (if emtpy no LUT is taken)"};
117-
Configurable<std::vector<std::string>> lutPi{"lutPi", std::vector<std::string>{"lutCovm.pi.dat "}, "LUT for pions (if emtpy no LUT is taken)"};
118-
Configurable<std::vector<std::string>> lutKa{"lutKa", std::vector<std::string>{"lutCovm.ka.dat "}, "LUT for kaons (if emtpy no LUT is taken)"};
119-
Configurable<std::vector<std::string>> lutPr{"lutPr", std::vector<std::string>{"lutCovm.pr.dat "}, "LUT for protons (if emtpy no LUT is taken)"};
120-
Configurable<std::vector<std::string>> lutDe{"lutDe", std::vector<std::string>{" "}, "LUT for deuterons (if emtpy no LUT is taken)"};
121-
Configurable<std::vector<std::string>> lutTr{"lutTr", std::vector<std::string>{" "}, "LUT for tritons (if emtpy no LUT is taken)"};
122-
Configurable<std::vector<std::string>> lutHe3{"lutHe3", std::vector<std::string>{" "}, "LUT for Helium-3 (if emtpy no LUT is taken)"};
123-
Configurable<std::vector<std::string>> lutAl{"lutAl", std::vector<std::string>{" "}, "LUT for Alphas (if emtpy no LUT is taken)"};
124-
} lookUpTables;
125-
126113
struct : ConfigurableGroup {
127114
ConfigurableAxis axisMomentum{"axisMomentum", {VARIABLE_WIDTH, 0.0f, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f, 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f, 1.7f, 1.8f, 1.9f, 2.0f, 2.2f, 2.4f, 2.6f, 2.8f, 3.0f, 3.2f, 3.4f, 3.6f, 3.8f, 4.0f, 4.4f, 4.8f, 5.2f, 5.6f, 6.0f, 6.5f, 7.0f, 7.5f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 17.0f, 19.0f, 21.0f, 23.0f, 25.0f, 30.0f, 35.0f, 40.0f, 50.0f}, "#it{p} (GeV/#it{c})"};
128115
ConfigurableAxis axisNVertices{"axisNVertices", {20, -0.5, 19.5}, "N_{vertices}"};
@@ -162,7 +149,6 @@ struct OnTheFlyTracker {
162149
std::string prefix = "fastPrimaryTrackerSettings";
163150
Configurable<bool> fastTrackPrimaries{"fastTrackPrimaries", false, "Use fasttracker for primary tracks. Enable with care"};
164151
Configurable<int> minSiliconHits{"minSiliconHits", 4, "minimum number of silicon hits to accept track"};
165-
Configurable<std::string> alice3geo{"alice3geo", "2", "0: ALICE 3 v1, 1: ALICE 3 v4, 2: ALICE 3 Sep 2025, or path to ccdb with a3 geo"};
166152
Configurable<bool> applyZacceptance{"applyZacceptance", false, "apply z limits to detector layers or not"};
167153
Configurable<bool> applyMSCorrection{"applyMSCorrection", true, "apply ms corrections for secondaries or not"};
168154
Configurable<bool> applyElossCorrection{"applyElossCorrection", true, "apply eloss corrections for secondaries or not"};
@@ -309,68 +295,64 @@ struct OnTheFlyTracker {
309295
o2::fastsim::GeometryContainer geoContainer;
310296
geoContainer.init(initContext);
311297

312-
auto loadLUT = [&](int icfg, int pdg, const std::vector<std::string>& tables) {
313-
LOG(info) << "Loading LUT for pdg " << pdg << " for config " << icfg << " from provided tables with size " << tables.size();
314-
if (tables.empty()) {
315-
LOG(debug) << "No LUT file passed for pdg " << pdg << ", skipping.";
316-
return false;
317-
}
318-
const bool foundNewCfg = static_cast<size_t>(icfg) < tables.size();
319-
std::string lutFile = foundNewCfg ? tables[icfg] : tables.front();
320-
LOG(info) << "Loading LUT for pdg " << pdg << " from file " << lutFile << " for config " << icfg;
321-
// strip from leading/trailing spaces
322-
lutFile.erase(0, lutFile.find_first_not_of(" "));
323-
lutFile.erase(lutFile.find_last_not_of(" ") + 1);
324-
if (lutFile.empty()) {
325-
LOG(info) << "Empty LUT file name for pdg " << pdg << ", skipping.";
326-
return false;
327-
}
328-
bool success = mSmearer[icfg]->loadTable(pdg, lutFile.c_str());
329-
if (!success) {
330-
LOG(fatal) << "Having issue with loading the LUT " << pdg << " " << lutFile;
331-
}
332-
333-
return foundNewCfg;
334-
};
335-
int nGeometries = static_cast<int>(fastTrackerSettings.alice3geo->size());
336-
if (enablePrimarySmearing)
337-
nGeometries = static_cast<int>(lookUpTables.lutPi->size());
338-
if (enablePrimarySmearing && enableSecondarySmearing) {
339-
if (static_cast<int>(lookUpTables.lutPi->size()) != static_cast<int>(fastTrackerSettings.alice3geo->size())) {
340-
LOG(fatal) << "When enabling both primary and secondary smearing, the number of LUTs provided must match the number of geometries provided!";
341-
}
342-
}
343-
298+
const int nGeometries = static_cast<int>(fastTrackerSettings.alice3geo->size());
344299
for (int icfg = 0; icfg < nGeometries; ++icfg) {
345-
std::string histPath = "Configuration_" + std::to_string(icfg) + "/";
300+
const std::string histPath = "Configuration_" + std::to_string(icfg) + "/";
346301
mSmearer.emplace_back(std::make_unique<o2::delphes::DelphesO2TrackSmearer>());
347302
mSmearer[icfg]->setCcdbManager(ccdb.operator->());
348303
if (enablePrimarySmearing) {
349-
// check if more configs were provided, fall back to first entry
350-
bool newLUTLoaded = false;
351-
newLUTLoaded |= loadLUT(icfg, kElectron, lookUpTables.lutEl.value);
352-
newLUTLoaded |= loadLUT(icfg, kMuonMinus, lookUpTables.lutMu.value);
353-
newLUTLoaded |= loadLUT(icfg, kPiPlus, lookUpTables.lutPi.value);
354-
newLUTLoaded |= loadLUT(icfg, kKPlus, lookUpTables.lutKa.value);
355-
newLUTLoaded |= loadLUT(icfg, kProton, lookUpTables.lutPr.value);
356-
newLUTLoaded |= loadLUT(icfg, o2::constants::physics::kDeuteron, lookUpTables.lutDe.value);
357-
newLUTLoaded |= loadLUT(icfg, o2::constants::physics::kTriton, lookUpTables.lutTr.value);
358-
newLUTLoaded |= loadLUT(icfg, o2::constants::physics::kHelium3, lookUpTables.lutHe3.value);
359-
newLUTLoaded |= loadLUT(icfg, o2::constants::physics::kAlpha, lookUpTables.lutAl.value);
360-
bool smearerOK = true;
361-
if (!newLUTLoaded) {
362-
mSmearer.pop_back();
363-
// break;
364-
smearerOK = false;
304+
std::map<std::string, std::string> geoEntry = geoContainer.getConfiguration(icfg, "global");
305+
// load LUTs for primaries
306+
for (const auto& entry : geoEntry) {
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+
}
330+
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;
348+
}
365349
}
366350

367351
// interpolate efficiencies if requested to do so
368-
if (smearerOK) {
369-
mSmearer[icfg]->interpolateEfficiency(static_cast<bool>(interpolateLutEfficiencyVsNch));
352+
mSmearer[icfg]->interpolateEfficiency(interpolateLutEfficiencyVsNch.value);
370353

371-
// smear un-reco'ed tracks if asked to do so
372-
mSmearer[icfg]->skipUnreconstructed(static_cast<bool>(!processUnreconstructedTracks));
373-
}
354+
// smear un-reco'ed tracks if asked to do so
355+
mSmearer[icfg]->skipUnreconstructed(!processUnreconstructedTracks.value);
374356

375357
histPointers.insert({histPath + "hPtGenerated", histos.add((histPath + "hPtGenerated").c_str(), "hPtGenerated", {kTH1D, {{axes.axisMomentum}}})});
376358
histPointers.insert({histPath + "hPhiGenerated", histos.add((histPath + "hPhiGenerated").c_str(), "hPhiGenerated", {kTH1D, {{100, 0.0f, 2 * M_PI, "#phi (rad)"}}})});
@@ -397,16 +379,7 @@ struct OnTheFlyTracker {
397379
fastTracker[icfg]->SetApplyZacceptance(fastTrackerSettings.applyZacceptance);
398380
fastTracker[icfg]->SetApplyMSCorrection(fastTrackerSettings.applyMSCorrection);
399381
fastTracker[icfg]->SetApplyElossCorrection(fastTrackerSettings.applyElossCorrection);
400-
if (fastTrackerSettings.alice3geo.value[icfg] == "0") {
401-
fastTracker[icfg]->AddSiliconALICE3v2(fastTrackerSettings.pixelRes);
402-
} else if (fastTrackerSettings.alice3geo.value[icfg] == "1") {
403-
fastTracker[icfg]->AddSiliconALICE3v4(fastTrackerSettings.pixelRes);
404-
fastTracker[icfg]->AddTPC(0.1, 0.1);
405-
} else if (fastTrackerSettings.alice3geo.value[icfg] == "2") {
406-
fastTracker[icfg]->AddSiliconALICE3(fastTrackerSettings.scaleVD, fastTrackerSettings.pixelRes);
407-
} else {
408-
fastTracker[icfg]->AddGenericDetector(geoContainer.getEntry(icfg).getConfigurations(), ccdb.operator->());
409-
}
382+
fastTracker[icfg]->AddGenericDetector(geoContainer.getEntry(icfg), ccdb.operator->());
410383
// print fastTracker settings
411384
fastTracker[icfg]->Print();
412385
if (cascadeDecaySettings.doXiQA)
@@ -516,14 +489,9 @@ struct OnTheFlyTracker {
516489
histos.add("V0Building_Configuration_0/K0/hFinalMass", "hMass", kTH1F, {axes.axisK0Mass});
517490
histos.add("V0Building_Configuration_0/Lambda/hMass", "hMass", kTH2F, {axes.axisLambdaMass, axes.axisMomentum});
518491
histos.add("V0Building_Configuration_0/AntiLambda/hMass", "hMass", kTH2F, {axes.axisLambdaMass, axes.axisMomentum});
519-
if (static_cast<int>(fastTrackerSettings.alice3geo->size()) > 1) {
520-
if (fastTrackerSettings.alice3geo->size() > 4) {
521-
LOG(warn) << "More than 4 FastTracker configurations found. Only first 4 will have V0 QA histograms filled.";
522-
}
523-
for (int icfg = 1; icfg < static_cast<int>(fastTrackerSettings.alice3geo->size()); icfg++) {
524-
std::string histPath = "Configuration_" + std::to_string(icfg) + "/";
525-
histos.addClone("V0Building_Configuration_0/", fmt::format("V0Building_{}", histPath).c_str());
526-
}
492+
for (int icfg = 1; icfg < nGeometries; icfg++) {
493+
std::string histPath = "Configuration_" + std::to_string(icfg) + "/";
494+
histos.addClone("V0Building_Configuration_0/", fmt::format("V0Building_{}", histPath).c_str());
527495
}
528496
}
529497

@@ -578,17 +546,7 @@ struct OnTheFlyTracker {
578546
fastPrimaryTracker.SetApplyZacceptance(fastPrimaryTrackerSettings.applyZacceptance);
579547
fastPrimaryTracker.SetApplyMSCorrection(fastPrimaryTrackerSettings.applyMSCorrection);
580548
fastPrimaryTracker.SetApplyElossCorrection(fastPrimaryTrackerSettings.applyElossCorrection);
581-
582-
if (fastPrimaryTrackerSettings.alice3geo.value == "0") {
583-
fastPrimaryTracker.AddSiliconALICE3v2({0.00025, 0.00025, 0.001, 0.001});
584-
} else if (fastPrimaryTrackerSettings.alice3geo.value == "1") {
585-
fastPrimaryTracker.AddSiliconALICE3v4({0.00025, 0.00025, 0.001, 0.001});
586-
fastPrimaryTracker.AddTPC(0.1, 0.1);
587-
} else if (fastPrimaryTrackerSettings.alice3geo.value == "2") {
588-
fastPrimaryTracker.AddSiliconALICE3(1., {0.00025, 0.00025, 0.001, 0.001});
589-
} else {
590-
fastPrimaryTracker->AddGenericDetector(geoContainer.getEntry(0).getConfigurations(), ccdb.operator->());
591-
}
549+
fastPrimaryTracker.AddGenericDetector(geoContainer.getEntry(0), ccdb.operator->());
592550

593551
// print fastTracker settings
594552
fastPrimaryTracker.Print();

ALICE3/macros/a3geo.ini

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,5 +144,4 @@ B10.resZ: 0.001
144144
B10.eff: 1.
145145
B10.type: 1
146146

147-
148-
147+
global.lutEl: /tmp/lutCovm.el.20kG.rmin20.geometry_v2.dat

0 commit comments

Comments
 (0)