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; - } - } - - 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)"; - - if (file) { - file->Close(); - delete file; - } -} - void Digitizer::prepareScaledResolutionMap() { if (!mResolutionMap) { diff --git a/Steer/DigitizerWorkflow/src/IOTOFDigitizerSpec.cxx b/Steer/DigitizerWorkflow/src/IOTOFDigitizerSpec.cxx index 1fa43b72684a3..6c0bfc2b0760d 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 @@ -69,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); @@ -163,10 +174,59 @@ class IOTOFDPLDigitizerTask : o2::base::BaseDPLDigitizer mFinished = true; } + void finaliseCCDB(ConcreteDataMatcher& matcher, void* obj) + { + if (matcher == ConcreteDataMatcher(mOrigin, "MADPIXEFF", 0)) { + if (mLocalEfficiencyFile.empty()) { + LOG(info) << "Using CCDB/MADPIX efficiency file"; + 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((TH2D*)file->Get("efficiency_pixel")); + } + 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("sigma_pixel")); + } + 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")); + } + } + } + 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 +257,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 +268,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