From b399aae97860bbf9d7574a304cdd03471105be72 Mon Sep 17 00:00:00 2001 From: maciacco Date: Wed, 21 Oct 2026 00:07:44 +0200 Subject: [PATCH 1/3] move initialization of maps to digitizer workflow (TODO: load also reso + toa map + scale resolutio nmap to center) --- .../IOTOFSimulation/DPLDigitizerParam.h | 9 --- .../include/IOTOFSimulation/Digitizer.h | 14 ++-- .../ALICE3/IOTOF/simulation/src/Digitizer.cxx | 78 ++++--------------- .../src/IOTOFDigitizerSpec.cxx | 37 ++++++++- 4 files changed, 56 insertions(+), 82 deletions(-) diff --git a/Detectors/Upgrades/ALICE3/IOTOF/simulation/include/IOTOFSimulation/DPLDigitizerParam.h b/Detectors/Upgrades/ALICE3/IOTOF/simulation/include/IOTOFSimulation/DPLDigitizerParam.h index 48c873d86dc2f..6e6ecb3ec53e2 100644 --- a/Detectors/Upgrades/ALICE3/IOTOF/simulation/include/IOTOFSimulation/DPLDigitizerParam.h +++ b/Detectors/Upgrades/ALICE3/IOTOF/simulation/include/IOTOFSimulation/DPLDigitizerParam.h @@ -31,15 +31,6 @@ struct DPLDigitizerParam : public o2::conf::ConfigurableParamHelper(ccdbPath); // owned by the CCDB manager - if (!rawMap) { - LOG(error) << "Failed to retrieve " << mapName << " from CCDB path: " << ccdbPath; - return; - } - } else { - LOG(info) << "Loading " << mapName << " from file: " << path; - file = TFile::Open(path.c_str()); - if (!file || !file->IsOpen()) { - LOG(error) << "Failed to open file: " << path; - delete file; - return; - } - rawMap = dynamic_cast(file->Get(mapName)); - if (!rawMap) { - LOG(error) << "Failed to retrieve " << mapName << " from file: " << path; - 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(); - delete file; - return; - } - } + mEfficiencyMap = dynamic_cast(map->Clone()); + mEfficiencyMap->SetDirectory(nullptr); +} - map = dynamic_cast(rawMap->Clone()); - map->SetDirectory(nullptr); // Detach from file to avoid deletion when file is closed - LOG(info) << "Loaded " << mapName << " (" << map->GetNbinsX() << " x " << map->GetNbinsY() << " bins)"; +void Digitizer::loadResolutionMap(const TH2D* map) +{ + mResolutionMap = dynamic_cast(map->Clone()); + mResolutionMap->SetDirectory(nullptr); +} - if (file) { - file->Close(); - delete file; - } +void Digitizer::loadTimeOfArrivalMap(const TH2D* map) +{ + mTimeOfArrivalMap = dynamic_cast(map->Clone()); + mTimeOfArrivalMap->SetDirectory(nullptr); } void Digitizer::prepareScaledResolutionMap() diff --git a/Steer/DigitizerWorkflow/src/IOTOFDigitizerSpec.cxx b/Steer/DigitizerWorkflow/src/IOTOFDigitizerSpec.cxx index 1fa43b72684a3..2f6d790a52b9b 100644 --- a/Steer/DigitizerWorkflow/src/IOTOFDigitizerSpec.cxx +++ b/Steer/DigitizerWorkflow/src/IOTOFDigitizerSpec.cxx @@ -54,6 +54,10 @@ class IOTOFDPLDigitizerTask : o2::base::BaseDPLDigitizer void initDigitizerTask(framework::InitContext& ic) override { mDisableQED = ic.options().get("disable-qed"); + mEnableResponseFiles = ic.options().get("enable-response-files"); + mLocalEfficiencyFile = ic.options().get("local-efficiency-file"); + mLocalTimeResoFile = ic.options().get("local-timereso-file"); + mLocalToAFile = ic.options().get("local-toa-file"); auto geom = GeometryTGeo::Instance(); geom->fillMatrixCache(o2::math_utils::bit2Mask(o2::math_utils::TransformType::L2G)); // make sure L2G matrices are loaded @@ -163,10 +167,34 @@ class IOTOFDPLDigitizerTask : o2::base::BaseDPLDigitizer mFinished = true; } + void finaliseCCDB(ConcreteDataMatcher& matcher, void* obj) + { + if (!mEnableResponseFiles) { + return; + } + if (matcher == ConcreteDataMatcher(mOrigin, "MADPIXEFF", 0)) { + if (mLocalEfficiencyFile.empty()) { + LOG(info) << "Using CCDB/MADPIX efficiency file"; + mDigitizer.loadEfficiencyMap((const TH2D*)obj); + } else { + LOG(info) << "Response function will be loaded from local file: " << mLocalEfficiencyFile; + std::unique_ptr file(TFile::Open(mLocalEfficiencyFile.data(), "READ")); + if (!file) { + LOG(fatal) << "Cannot open response file " << mLocalEfficiencyFile.data(); + } + mDigitizer.loadEfficiencyMap((const TH2D*)file->Get("hEfficiencyMap")); + } + } + } + private: bool mDisableQED = false; + bool mEnableResponseFiles = false; bool mWithMCTruth{true}; bool mFinished{false}; + std::string mLocalEfficiencyFile{""}; + std::string mLocalTimeResoFile{""}; + std::string mLocalToAFile{""}; unsigned long mFirstOrbitTF = 0x0; const o2::detectors::DetID mID{o2::detectors::DetID::TF3}; const o2::header::DataOrigin mOrigin{o2::header::gDataOriginTF3}; @@ -197,7 +225,9 @@ o2::framework::DataProcessorSpec getIOTOFDigitizerSpec(int channel, bool mctruth { std::vector inputs; inputs.emplace_back("collisioncontext", "SIM", "COLLISIONCONTEXT", static_cast(channel), o2::framework::Lifetime::Timeframe); - inputs.emplace_back("IOTOF_aptsresp", "TF3", "APTSRESP", 0, o2::framework::Lifetime::Condition, o2::framework::ccdbParamSpec("IT3/Calib/APTSResponse")); + inputs.emplace_back("madpixeff", "TF3", "MADPIXEFF", 0, o2::framework::Lifetime::Condition, o2::framework::ccdbParamSpec("Users/g/glucia/tmp/ALICE3/IOTOF/pixelEfficiency")); + inputs.emplace_back("madpixreso", "TF3", "MADPIXRESO", 0, o2::framework::Lifetime::Condition, o2::framework::ccdbParamSpec("Users/g/glucia/tmp/ALICE3/IOTOF/pixelResolution")); + inputs.emplace_back("madpixtoa", "TF3", "MADPIXTOA", 0, o2::framework::Lifetime::Condition, o2::framework::ccdbParamSpec("Users/g/glucia/tmp/ALICE3/IOTOF/pixelTimeOfArrival")); const std::string detStr = o2::detectors::DetID::getName(o2::detectors::DetID::TF3); return o2::framework::DataProcessorSpec{detStr + "Digitizer", @@ -206,7 +236,10 @@ o2::framework::DataProcessorSpec getIOTOFDigitizerSpec(int channel, bool mctruth o2::framework::AlgorithmSpec{o2::framework::adaptFromTask(mctruth)}, o2::framework::Options{ {"disable-qed", o2::framework::VariantType::Bool, false, {"disable QED handling"}}, - {"local-response-file", o2::framework::VariantType::String, "", {"use response file saved locally at this path/filename"}}}}; + {"enable-response-files", o2::framework::VariantType::Bool, false, {"enable in-pixel response maps from data"}}, + {"local-efficiency-file", o2::framework::VariantType::String, "", {"use efficiency map saved locally at this path/filename"}}, + {"local-timereso-file", o2::framework::VariantType::String, "", {"use time resolution map saved locally at this path/filename"}}, + {"local-toa-file", o2::framework::VariantType::String, "", {"use ToA map saved locally at this path/filename"}}}}; } } // namespace o2::iotof From ac7b071f584da3594dfb33aecab3a6eacaebed7c Mon Sep 17 00:00:00 2001 From: maciacco Date: Fri, 23 Oct 2026 19:11:35 +0200 Subject: [PATCH 2/3] conditional loading of maps + fetch time reso and toa maps --- .../include/IOTOFSimulation/Digitizer.h | 8 ++-- .../ALICE3/IOTOF/simulation/src/Digitizer.cxx | 19 --------- .../src/IOTOFDigitizerSpec.cxx | 42 ++++++++++++++++--- 3 files changed, 40 insertions(+), 29 deletions(-) diff --git a/Detectors/Upgrades/ALICE3/IOTOF/simulation/include/IOTOFSimulation/Digitizer.h b/Detectors/Upgrades/ALICE3/IOTOF/simulation/include/IOTOFSimulation/Digitizer.h index d9b1a2d5ceffe..4ed2f87ba5aeb 100644 --- a/Detectors/Upgrades/ALICE3/IOTOF/simulation/include/IOTOFSimulation/Digitizer.h +++ b/Detectors/Upgrades/ALICE3/IOTOF/simulation/include/IOTOFSimulation/Digitizer.h @@ -75,11 +75,9 @@ class Digitizer : public TObject // Provide the common iotof::GeometryTGeo to access matrices and segmentation void setGeometry(const o2::iotof::GeometryTGeo* gm) { mGeometry = gm; } - void loadEfficiencyMap(const TH2D* map); - - void loadResolutionMap(const TH2D* map); - - void loadTimeOfArrivalMap(const TH2D* map); + void loadEfficiencyMap(TH2D* map) { mEfficiencyMap = map; } + void loadResolutionMap(TH2D* map) { mResolutionMap = map; } + void loadTimeOfArrivalMap(TH2D* map) { mTimeOfArrivalMap = map; } void prepareScaledResolutionMap(); diff --git a/Detectors/Upgrades/ALICE3/IOTOF/simulation/src/Digitizer.cxx b/Detectors/Upgrades/ALICE3/IOTOF/simulation/src/Digitizer.cxx index 9e0b5cd628af2..2e8bd96b6b8e3 100644 --- a/Detectors/Upgrades/ALICE3/IOTOF/simulation/src/Digitizer.cxx +++ b/Detectors/Upgrades/ALICE3/IOTOF/simulation/src/Digitizer.cxx @@ -358,25 +358,6 @@ int Digitizer::energyToCharge(float energyLoss) const } //_______________________________________________________________________ - -void Digitizer::loadEfficiencyMap(const TH2D* map) -{ - mEfficiencyMap = dynamic_cast(map->Clone()); - mEfficiencyMap->SetDirectory(nullptr); -} - -void Digitizer::loadResolutionMap(const TH2D* map) -{ - mResolutionMap = dynamic_cast(map->Clone()); - mResolutionMap->SetDirectory(nullptr); -} - -void Digitizer::loadTimeOfArrivalMap(const TH2D* map) -{ - mTimeOfArrivalMap = dynamic_cast(map->Clone()); - mTimeOfArrivalMap->SetDirectory(nullptr); -} - void Digitizer::prepareScaledResolutionMap() { if (!mResolutionMap) { diff --git a/Steer/DigitizerWorkflow/src/IOTOFDigitizerSpec.cxx b/Steer/DigitizerWorkflow/src/IOTOFDigitizerSpec.cxx index 2f6d790a52b9b..6005c584d0b40 100644 --- a/Steer/DigitizerWorkflow/src/IOTOFDigitizerSpec.cxx +++ b/Steer/DigitizerWorkflow/src/IOTOFDigitizerSpec.cxx @@ -73,6 +73,13 @@ class IOTOFDPLDigitizerTask : o2::base::BaseDPLDigitizer if (mFinished) { return; } + + if (mEnableResponseFiles) { + pc.inputs().get("madpixeff"); + pc.inputs().get("madpixreso"); + pc.inputs().get("madpixtoa"); + } + mFirstOrbitTF = pc.services().get().firstTForbit; const o2::InteractionRecord firstIR(0, mFirstOrbitTF); @@ -169,20 +176,45 @@ class IOTOFDPLDigitizerTask : o2::base::BaseDPLDigitizer void finaliseCCDB(ConcreteDataMatcher& matcher, void* obj) { - if (!mEnableResponseFiles) { - return; - } if (matcher == ConcreteDataMatcher(mOrigin, "MADPIXEFF", 0)) { if (mLocalEfficiencyFile.empty()) { LOG(info) << "Using CCDB/MADPIX efficiency file"; - mDigitizer.loadEfficiencyMap((const TH2D*)obj); + mDigitizer.loadEfficiencyMap((TH2D*)obj); } else { LOG(info) << "Response function will be loaded from local file: " << mLocalEfficiencyFile; std::unique_ptr file(TFile::Open(mLocalEfficiencyFile.data(), "READ")); if (!file) { LOG(fatal) << "Cannot open response file " << mLocalEfficiencyFile.data(); } - mDigitizer.loadEfficiencyMap((const TH2D*)file->Get("hEfficiencyMap")); + mDigitizer.loadEfficiencyMap((TH2D*)file->Get("hEfficiencyMap")); + } + return; + } + if (matcher == ConcreteDataMatcher(mOrigin, "MADPIXRESO", 0)) { + if (mLocalTimeResoFile.empty()) { + LOG(info) << "Using CCDB/MADPIX time resolution file"; + mDigitizer.loadResolutionMap((TH2D*)obj); + } else { + LOG(info) << "Response function will be loaded from local file: " << mLocalTimeResoFile; + std::unique_ptr file(TFile::Open(mLocalTimeResoFile.data(), "READ")); + if (!file) { + LOG(fatal) << "Cannot open response file " << mLocalTimeResoFile.data(); + } + mDigitizer.loadResolutionMap((TH2D*)file->Get("hSigmaPixel")); + } + return; + } + if (matcher == ConcreteDataMatcher(mOrigin, "MADPIXTOA", 0)) { + if (mLocalToAFile.empty()) { + LOG(info) << "Using CCDB/MADPIX time-of-arrival file"; + mDigitizer.loadTimeOfArrivalMap((TH2D*)obj); + } else { + LOG(info) << "Response function will be loaded from local file: " << mLocalToAFile; + std::unique_ptr file(TFile::Open(mLocalToAFile.data(), "READ")); + if (!file) { + LOG(fatal) << "Cannot open response file " << mLocalToAFile.data(); + } + mDigitizer.loadTimeOfArrivalMap((TH2D*)file->Get("toa_pixel")); } } } From d6df685b78011443030ebc664838f8d1347594be Mon Sep 17 00:00:00 2001 From: Mario Ciacco Date: Sat, 24 Oct 2026 08:58:00 +0200 Subject: [PATCH 3/3] rename local maps --- Steer/DigitizerWorkflow/src/IOTOFDigitizerSpec.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Steer/DigitizerWorkflow/src/IOTOFDigitizerSpec.cxx b/Steer/DigitizerWorkflow/src/IOTOFDigitizerSpec.cxx index 6005c584d0b40..6c0bfc2b0760d 100644 --- a/Steer/DigitizerWorkflow/src/IOTOFDigitizerSpec.cxx +++ b/Steer/DigitizerWorkflow/src/IOTOFDigitizerSpec.cxx @@ -186,7 +186,7 @@ class IOTOFDPLDigitizerTask : o2::base::BaseDPLDigitizer if (!file) { LOG(fatal) << "Cannot open response file " << mLocalEfficiencyFile.data(); } - mDigitizer.loadEfficiencyMap((TH2D*)file->Get("hEfficiencyMap")); + mDigitizer.loadEfficiencyMap((TH2D*)file->Get("efficiency_pixel")); } return; } @@ -200,7 +200,7 @@ class IOTOFDPLDigitizerTask : o2::base::BaseDPLDigitizer if (!file) { LOG(fatal) << "Cannot open response file " << mLocalTimeResoFile.data(); } - mDigitizer.loadResolutionMap((TH2D*)file->Get("hSigmaPixel")); + mDigitizer.loadResolutionMap((TH2D*)file->Get("sigma_pixel")); } return; }