diff --git a/Detectors/Upgrades/ALICE3/IOTOF/simulation/include/IOTOFSimulation/DPLDigitizerParam.h b/Detectors/Upgrades/ALICE3/IOTOF/simulation/include/IOTOFSimulation/DPLDigitizerParam.h index 7f96b8e509d0c..8e23a4e3e153d 100644 --- a/Detectors/Upgrades/ALICE3/IOTOF/simulation/include/IOTOFSimulation/DPLDigitizerParam.h +++ b/Detectors/Upgrades/ALICE3/IOTOF/simulation/include/IOTOFSimulation/DPLDigitizerParam.h @@ -30,8 +30,8 @@ struct DPLDigitizerParam : public o2::conf::ConfigurableParamHelper #include @@ -56,15 +57,19 @@ void Digitizer::init() } const auto& digitizerParams = o2::iotof::DPLDigitizerParam::Instance(); - if (!digitizerParams.efficiencyFilePath.empty()) { - loadEfficiencyMap(digitizerParams.efficiencyFilePath); - } LOG(info) << "Initializing IOTOF digitizer"; LOG(info) << " Time resolution: " << digitizerParams.timeResolution * 1e3 << " ps"; LOG(info) << " Charge threshold: " << digitizerParams.chargeThreshold << " electrons"; - LOG(info) << " Detection efficiency: " << digitizerParams.efficiency * 100 << " %"; LOG(info) << " Continuous mode: " << (mContinuous ? "ON" : "OFF"); + + if (!digitizerParams.efficiencyCcdbPath.empty()) { + LOG(info) << "Loading efficiency map from CCDB: " << digitizerParams.efficiencyCcdbPath; + loadEfficiencyMapFromCCDB(digitizerParams.efficiencyCcdbPath); + } else { + LOG(info) << "No efficiency map provided, using uniform efficiency: " << digitizerParams.efficiency * 100 << " %"; + } + sSegmentation = o2::iotof::Segmentation::Instance(); } @@ -337,31 +342,24 @@ int Digitizer::energyToCharge(float energyLoss) const } //_______________________________________________________________________ -void Digitizer::loadEfficiencyMap(const std::string& filePath) + +void Digitizer::loadEfficiencyMapFromCCDB(const std::string& ccdbPath) { - // Load the efficiency map from a file - TFile* file = TFile::Open(filePath.c_str()); - if (!file || !file->IsOpen()) { - LOG(error) << "Failed to open efficiency map file: " << filePath; - return; - } + // Load the efficiency map from CCDB + auto rawMap = o2::ccdb::BasicCCDBManager::instance().get(ccdbPath); - auto* rawMap = dynamic_cast(file->Get("hEfficiencyMap")); if (!rawMap) { - LOG(error) << "Failed to retrieve efficiency map from file: " << filePath; - LOG(error) << "Available keys in the file:"; - TIter next(file->GetListOfKeys()); - TKey* key; - while ((key = dynamic_cast(next()))) { - LOG(error) << " " << key->GetName() << " (" << key->GetClassName() << ")"; - } - file->Close(); + LOG(error) << "Failed to retrieve efficiency map from CCDB path: " << ccdbPath; return; + } else { + LOG(info) << "Successfully retrieved efficiency map from CCDB path: " << ccdbPath; + LOG(info) << "Efficiency map dimensions: " << rawMap->GetNbinsX() << " x " << rawMap->GetNbinsY(); } + mEfficiencyMap = dynamic_cast(rawMap->Clone("mEfficiencyMap")); mEfficiencyMap->SetDirectory(nullptr); // Detach from file to avoid deletion when file is closed - file->Close(); + LOG(info) << "Successfully loaded efficiency map from CCDB path: " << ccdbPath; } //_______________________________________________________________________