Skip to content

Commit e1fa179

Browse files
make the map loading funciton generic
1 parent 9736bff commit e1fa179

2 files changed

Lines changed: 12 additions & 10 deletions

File tree

‎Detectors/Upgrades/ALICE3/IOTOF/simulation/include/IOTOFSimulation/Digitizer.h‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ class Digitizer : public TObject
9292
int energyToCharge(float energyLoss) const;
9393

9494
/// Load the efficiency map from a file
95-
void loadEfficiencyMap(const std::string& filePath);
96-
void loadEfficiencyMapFromCCDB(const std::string& ccdbPath);
95+
void loadMap(TH2* map, const std::string& filePath, const char* mapName);
96+
void loadMapFromCCDB(TH2* map, const std::string& ccdbPath, const char* mapName);
9797

9898
/// Check if the hit passes efficiency cut
9999
/// \param x Detector local coordinate x in cm with respect to the center of the sensitive volume.
@@ -119,6 +119,8 @@ class Digitizer : public TObject
119119

120120
const o2::iotof::GeometryTGeo* mGeometry = nullptr; ///< IOTOF geometry
121121
TH2D* mEfficiencyMap = nullptr; ///< Efficiency map for the detector
122+
TH2D* mResolutionMap = nullptr; ///< Resolution map for the detector
123+
TH2D* mTimeOfArrivalMap = nullptr; ///< Time of arrival map for the detector
122124

123125
std::vector<o2::iotof::Chip> mChips; //! Chips in the detector, indexed by chip ID
124126
std::deque<std::unique_ptr<std::vector<o2::iotof::McLabelRef>>> mExtraLabelBuffer; //! buffer for multiple mc labels to the same pixel

‎Detectors/Upgrades/ALICE3/IOTOF/simulation/src/Digitizer.cxx‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ void Digitizer::init()
6565

6666
if (!digitizerParams.efficiencyCcdbPath.empty()) {
6767
LOG(info) << "Loading efficiency map from CCDB: " << digitizerParams.efficiencyCcdbPath;
68-
loadEfficiencyMapFromCCDB(digitizerParams.efficiencyCcdbPath);
68+
loadMapFromCCDB(mEfficiencyMap, digitizerParams.efficiencyCcdbPath, "mEfficiencyMap");
6969
} else if (!digitizerParams.efficiencyFilePath.empty()) {
7070
LOG(info) << "Loading efficiency map from file: " << digitizerParams.efficiencyFilePath;
71-
loadEfficiencyMap(digitizerParams.efficiencyFilePath);
71+
loadMap(mEfficiencyMap, digitizerParams.efficiencyFilePath, "mEfficiencyMap");
7272
} else {
7373
LOG(info) << "No efficiency map provided, using uniform efficiency: " << digitizerParams.efficiency * 100 << " %";
7474
}
@@ -346,7 +346,7 @@ int Digitizer::energyToCharge(float energyLoss) const
346346

347347
//_______________________________________________________________________
348348

349-
void Digitizer::loadEfficiencyMap(const std::string& filePath)
349+
void Digitizer::loadMap(TH1D* map, const std::string& filePath, const char* mapName)
350350
{
351351
// Load the efficiency map from a file
352352
TFile* file = TFile::Open(filePath.c_str());
@@ -367,13 +367,13 @@ void Digitizer::loadEfficiencyMap(const std::string& filePath)
367367
file->Close();
368368
return;
369369
}
370-
mEfficiencyMap = dynamic_cast<TH2D*>(rawMap->Clone("mEfficiencyMap"));
371-
mEfficiencyMap->SetDirectory(nullptr); // Detach from file to avoid deletion when file is closed
370+
map = dynamic_cast<TH2D*>(rawMap->Clone(mapName));
371+
map->SetDirectory(nullptr); // Detach from file to avoid deletion when file is closed
372372

373373
file->Close();
374374
}
375375

376-
void Digitizer::loadEfficiencyMapFromCCDB(const std::string& ccdbPath)
376+
void Digitizer::loadMapFromCCDB(TH1D* map, const std::string& ccdbPath, const char* mapName)
377377
{
378378
// Load the efficiency map from CCDB
379379
auto rawMap = o2::ccdb::BasicCCDBManager::instance().get<TH2D>(ccdbPath);
@@ -386,8 +386,8 @@ void Digitizer::loadEfficiencyMapFromCCDB(const std::string& ccdbPath)
386386
LOG(info) << "Efficiency map dimensions: " << rawMap->GetNbinsX() << " x " << rawMap->GetNbinsY();
387387
}
388388

389-
mEfficiencyMap = dynamic_cast<TH2D*>(rawMap->Clone("mEfficiencyMap"));
390-
mEfficiencyMap->SetDirectory(nullptr); // Detach from file to avoid deletion when file is closed
389+
map = dynamic_cast<TH2D*>(rawMap->Clone(mapName));
390+
map->SetDirectory(nullptr); // Detach from file to avoid deletion when file is closed
391391

392392
LOG(info) << "Successfully loaded efficiency map from CCDB path: " << ccdbPath;
393393
}

0 commit comments

Comments
 (0)