|
11 | 11 |
|
12 | 12 | #include "FlatTrackSmearer.h" |
13 | 13 |
|
| 14 | +#include "ALICE3/Core/GeometryContainer.h" |
| 15 | + |
| 16 | +#include <Framework/RuntimeError.h> |
| 17 | + |
14 | 18 | namespace o2::delphes |
15 | 19 | { |
16 | 20 | int TrackSmearer::getIndexPDG(int pdg) const |
@@ -64,4 +68,63 @@ const char* TrackSmearer::getParticleName(int pdg) const |
64 | 68 | return "pion"; // Default: pion |
65 | 69 | } |
66 | 70 | } |
| 71 | + |
| 72 | +bool TrackSmearer::loadTable(int pdg, const char* filename, bool forceReload) |
| 73 | +{ |
| 74 | + if (!filename || filename[0] == '\0') { |
| 75 | + LOGF(info, "No LUT file provided for PDG %d. Skipping load.", pdg); |
| 76 | + return false; |
| 77 | + } |
| 78 | + |
| 79 | + const auto ipdg = getIndexPDG(pdg); |
| 80 | + LOGF(info, "Loading %s LUT file: '%s'", getParticleName(pdg), filename); |
| 81 | + |
| 82 | + if (mLUTData[ipdg].isLoaded() && !forceReload) { |
| 83 | + LOGF(info, "LUT table for PDG %d already loaded (index %d)", pdg, ipdg); |
| 84 | + return false; |
| 85 | + } |
| 86 | + |
| 87 | + const std::string localFilename = o2::fastsim::GeometryEntry::accessFile(filename, "./.ALICE3/LUTs/", mCcdbManager, 10); |
| 88 | + |
| 89 | + try { |
| 90 | + mLUTData[ipdg] = FlatLutData::loadFromFile(localFilename.c_str()); |
| 91 | + } catch (framework::RuntimeErrorRef ref) { |
| 92 | + LOGF(error, "%s", framework::error_from_ref(ref).what); |
| 93 | + return false; |
| 94 | + } |
| 95 | + |
| 96 | + // Validate header |
| 97 | + const auto& header = mLUTData[ipdg].getHeaderRef(); |
| 98 | + |
| 99 | + bool specialPdgCase = false; |
| 100 | + switch (pdg) { |
| 101 | + case o2::constants::physics::kAlpha: |
| 102 | + // Special case: Allow Alpha particles to use He3 LUT |
| 103 | + specialPdgCase = (header.pdg == o2::constants::physics::kHelium3); |
| 104 | + if (specialPdgCase) { |
| 105 | + LOGF(info, "Alpha particles (PDG %d) will use He3 LUT data (PDG %d)", pdg, header.pdg); |
| 106 | + } |
| 107 | + break; |
| 108 | + default: |
| 109 | + break; |
| 110 | + } |
| 111 | + |
| 112 | + if (header.pdg != pdg && !specialPdgCase) { |
| 113 | + LOGF(error, "LUT header PDG mismatch: expected %d, got %d", pdg, header.pdg); |
| 114 | + mLUTData[ipdg].reset(); |
| 115 | + return false; |
| 116 | + } |
| 117 | + |
| 118 | + LOGF(info, "Successfully read LUT for PDG %d: %s", pdg, localFilename.c_str()); |
| 119 | + header.print(); |
| 120 | + |
| 121 | + return true; |
| 122 | +} |
| 123 | + |
| 124 | +bool TrackSmearer::hasTable(int pdg) const |
| 125 | +{ |
| 126 | + const int ipdg = getIndexPDG(pdg); |
| 127 | + return mLUTData[ipdg].isLoaded(); |
| 128 | +} |
| 129 | + |
67 | 130 | } // namespace o2::delphes |
0 commit comments