Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ struct DPLDigitizerParam : public o2::conf::ConfigurableParamHelper<DPLDigitizer
float timeResolution = 0.020f; ///< time resolution sigma in ns (20 ps default)
float tdcBin = 0.010f; ///< TDC time bin (10 ps default)
float efficiency = 0.98f; ///< detection efficiency
std::string efficiencyFilePath{}; ///< optional efficiency map file path.
///< The efficiency map is currently available at /alice/cern.ch/user/g/glucia/ALICE3/IOTOF/pixelEfficiency/PixelEfficiencyMap_TH2.root. FIXME to be removed once switch to CCDBFetcher
std::string efficiencyCcdbPath{}; ///< optional efficiency map CCDB path.
///< The efficiency map is currently available at Users/g/glucia/tmp/ALICE3/IOTOF/pixelEfficiency
int chargeThreshold = 100; ///< charge threshold in Nelectrons
int minChargeToAccount = 7; ///< minimum charge contribution to account
int nSimSteps = 10; ///< number of steps in response simulation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class Digitizer : public TObject
int energyToCharge(float energyLoss) const;

/// Load the efficiency map from a file
void loadEfficiencyMap(const std::string& filePath);
void loadEfficiencyMapFromCCDB(const std::string& ccdbPath);

/// Check if the hit passes efficiency cut
/// \param x Detector local coordinate x in cm with respect to the center of the sensitive volume.
Expand Down
40 changes: 19 additions & 21 deletions Detectors/Upgrades/ALICE3/IOTOF/simulation/src/Digitizer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "IOTOFSimulation/Digitizer.h"
#include "IOTOFSimulation/DPLDigitizerParam.h"
#include "DetectorsRaw/HBFUtils.h"
#include "CCDB/BasicCCDBManager.h"

#include <TCollection.h>
#include <TFile.h>
Expand Down Expand Up @@ -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();
}

Expand Down Expand Up @@ -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<TH2D>(ccdbPath);

auto* rawMap = dynamic_cast<TH2D*>(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<TKey*>(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<TH2D*>(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;
}

//_______________________________________________________________________
Expand Down
Loading