Skip to content

Commit 9736bff

Browse files
keep inclusion of efficiency file direct loading
1 parent 86df8d0 commit 9736bff

3 files changed

Lines changed: 33 additions & 0 deletions

File tree

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ struct DPLDigitizerParam : public o2::conf::ConfigurableParamHelper<DPLDigitizer
3030
float timeResolution = 0.020f; ///< time resolution sigma in ns (20 ps default)
3131
float tdcBin = 0.010f; ///< TDC time bin (10 ps default)
3232
float efficiency = 0.98f; ///< detection efficiency
33+
std::string efficiencyFilePath{}; ///< optional efficiency map file path.
34+
///< 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
3335
std::string efficiencyCcdbPath{}; ///< optional efficiency map CCDB path.
3436
///< The efficiency map is currently available at Users/g/glucia/tmp/ALICE3/IOTOF/pixelEfficiency
3537
int chargeThreshold = 100; ///< charge threshold in Nelectrons

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ 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);
9596
void loadEfficiencyMapFromCCDB(const std::string& ccdbPath);
9697

9798
/// Check if the hit passes efficiency cut

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ void Digitizer::init()
6666
if (!digitizerParams.efficiencyCcdbPath.empty()) {
6767
LOG(info) << "Loading efficiency map from CCDB: " << digitizerParams.efficiencyCcdbPath;
6868
loadEfficiencyMapFromCCDB(digitizerParams.efficiencyCcdbPath);
69+
} else if (!digitizerParams.efficiencyFilePath.empty()) {
70+
LOG(info) << "Loading efficiency map from file: " << digitizerParams.efficiencyFilePath;
71+
loadEfficiencyMap(digitizerParams.efficiencyFilePath);
6972
} else {
7073
LOG(info) << "No efficiency map provided, using uniform efficiency: " << digitizerParams.efficiency * 100 << " %";
7174
}
@@ -343,6 +346,33 @@ int Digitizer::energyToCharge(float energyLoss) const
343346

344347
//_______________________________________________________________________
345348

349+
void Digitizer::loadEfficiencyMap(const std::string& filePath)
350+
{
351+
// Load the efficiency map from a file
352+
TFile* file = TFile::Open(filePath.c_str());
353+
if (!file || !file->IsOpen()) {
354+
LOG(error) << "Failed to open efficiency map file: " << filePath;
355+
return;
356+
}
357+
358+
auto* rawMap = dynamic_cast<TH2D*>(file->Get("hEfficiencyMap"));
359+
if (!rawMap) {
360+
LOG(error) << "Failed to retrieve efficiency map from file: " << filePath;
361+
LOG(error) << "Available keys in the file:";
362+
TIter next(file->GetListOfKeys());
363+
TKey* key;
364+
while ((key = dynamic_cast<TKey*>(next()))) {
365+
LOG(error) << " " << key->GetName() << " (" << key->GetClassName() << ")";
366+
}
367+
file->Close();
368+
return;
369+
}
370+
mEfficiencyMap = dynamic_cast<TH2D*>(rawMap->Clone("mEfficiencyMap"));
371+
mEfficiencyMap->SetDirectory(nullptr); // Detach from file to avoid deletion when file is closed
372+
373+
file->Close();
374+
}
375+
346376
void Digitizer::loadEfficiencyMapFromCCDB(const std::string& ccdbPath)
347377
{
348378
// Load the efficiency map from CCDB

0 commit comments

Comments
 (0)