From 285def7fc22131e1a9971e9ab1f83b5eb965ab87 Mon Sep 17 00:00:00 2001 From: Matthias Kleiner Date: Fri, 12 Dec 2025 16:18:46 +0100 Subject: [PATCH 1/2] TPC: Use CTP as fallback if no IDCs are available --- .../TPCCalibration/CorrectionMapsLoader.h | 1 + .../calibration/src/CorrectionMapsLoader.cxx | 47 +++++++++++++++++-- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/Detectors/TPC/calibration/include/TPCCalibration/CorrectionMapsLoader.h b/Detectors/TPC/calibration/include/TPCCalibration/CorrectionMapsLoader.h index a907b83fe49bf..5a11ce3ea24e5 100644 --- a/Detectors/TPC/calibration/include/TPCCalibration/CorrectionMapsLoader.h +++ b/Detectors/TPC/calibration/include/TPCCalibration/CorrectionMapsLoader.h @@ -79,6 +79,7 @@ class CorrectionMapsLoader : public o2::gpu::CorrectionMapsHelper float mInstLumiCTPFactor = 1.0; // multiplicative factor for inst. lumi int mLumiCTPSource = 0; // 0: main, 1: alternative CTP lumi source std::unique_ptr mCorrMapMShape{nullptr}; + bool mIDC2CTPFallbackActive = false; // flag indicating that fallback from IDC to CTP scaling is active #endif }; diff --git a/Detectors/TPC/calibration/src/CorrectionMapsLoader.cxx b/Detectors/TPC/calibration/src/CorrectionMapsLoader.cxx index 0e4a5e2a73df4..ceb7d166d28c6 100644 --- a/Detectors/TPC/calibration/src/CorrectionMapsLoader.cxx +++ b/Detectors/TPC/calibration/src/CorrectionMapsLoader.cxx @@ -53,6 +53,47 @@ void CorrectionMapsLoader::extractCCDBInputs(ProcessingContext& pc) o2::ctp::LumiInfo lumiObj; static o2::ctp::LumiInfo lumiPrev; + if (getLumiScaleType() == 2 || mIDC2CTPFallbackActive) { + float tpcScaler = pc.inputs().get("tpcscaler"); + // check if tpcScaler is valid and CTP fallback is allowed + if (tpcScaler == -1.f) { + const bool canUseCTPScaling = mCorrMap && mCorrMapRef && mCorrMap->isIDCSet() && mCorrMapRef->isIDCSet() && mCorrMap->isLumiSet() && mCorrMapRef->isLumiSet(); + if (canUseCTPScaling) { + LOGP(info, "Invalid TPC scaler value {} received for IDC-based scaling! Using CTP fallback", tpcScaler); + mIDC2CTPFallbackActive = true; + if (std::abs(getMeanLumi() - mCorrMap->getLumi()) > 1e-6f) { + // update only mean lumi if changed + setMeanLumi(mCorrMap->getLumi(), false); + setUpdatedMap(); + } + if (std::abs(getMeanLumiRef() - mCorrMapRef->getLumi()) > 1e-6f) { + // update only mean lumi ref if changed + setMeanLumiRef(mCorrMapRef->getLumi()); + setUpdatedMapRef(); + } + setLumiScaleType(1); + } else if (mCorrMap) { + // CTP scaling is not possible, dont do any scaling to avoid applying wrong corrections + const float storedIDC = mCorrMap->getIDC(); + LOGP(warning, "Invalid TPC scaler value {} received for IDC-based scaling! CTP fallback not possible, using stored IDC of {} from the map to avoid applying wrong corrections", tpcScaler, storedIDC); + setInstLumi(storedIDC); + } + } else { + if (mIDC2CTPFallbackActive) { + // reset back to normal operation + LOGP(info, "Valid TPC scaler value {} received, switching back to IDC-based scaling", tpcScaler); + mIDC2CTPFallbackActive = false; + setMeanLumi(mCorrMap->getIDC(), false); + setUpdatedMap(); + setMeanLumiRef(mCorrMapRef->getIDC()); + setUpdatedMapRef(); + setLumiScaleType(2); + } + // correct IDC received + setInstLumi(tpcScaler); + } + } + if (getLumiCTPAvailable() && mInstCTPLumiOverride <= 0.) { if (pc.inputs().get>("CTPLumi").size() == sizeof(o2::ctp::LumiInfo)) { lumiPrev = lumiObj = pc.inputs().get("CTPLumi"); @@ -67,10 +108,7 @@ void CorrectionMapsLoader::extractCCDBInputs(ProcessingContext& pc) setInstLumi(getInstLumiCTP()); } } - if (getLumiScaleType() == 2) { - float tpcScaler = pc.inputs().get("tpcscaler"); - setInstLumi(tpcScaler); - } + if (getUseMShapeCorrection()) { LOGP(info, "Setting M-Shape map"); const auto mapMShape = pc.inputs().get("mshape"); @@ -317,6 +355,7 @@ void CorrectionMapsLoader::copySettings(const CorrectionMapsLoader& src) mLumiCTPSource = src.mLumiCTPSource; mLumiScaleMode = src.mLumiScaleMode; mScaleInverse = src.getScaleInverse(); + mIDC2CTPFallbackActive = src.mIDC2CTPFallbackActive; } void CorrectionMapsLoader::updateInverse() From 52d6a8423d2171b460de9d4f05ef1177a65d1103 Mon Sep 17 00:00:00 2001 From: Matthias Kleiner Date: Fri, 12 Dec 2025 19:09:21 +0100 Subject: [PATCH 2/2] Dont update map as only the lumi is updated --- .../TPC/calibration/src/CorrectionMapsLoader.cxx | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/Detectors/TPC/calibration/src/CorrectionMapsLoader.cxx b/Detectors/TPC/calibration/src/CorrectionMapsLoader.cxx index ceb7d166d28c6..e9d7474699ce2 100644 --- a/Detectors/TPC/calibration/src/CorrectionMapsLoader.cxx +++ b/Detectors/TPC/calibration/src/CorrectionMapsLoader.cxx @@ -61,16 +61,8 @@ void CorrectionMapsLoader::extractCCDBInputs(ProcessingContext& pc) if (canUseCTPScaling) { LOGP(info, "Invalid TPC scaler value {} received for IDC-based scaling! Using CTP fallback", tpcScaler); mIDC2CTPFallbackActive = true; - if (std::abs(getMeanLumi() - mCorrMap->getLumi()) > 1e-6f) { - // update only mean lumi if changed - setMeanLumi(mCorrMap->getLumi(), false); - setUpdatedMap(); - } - if (std::abs(getMeanLumiRef() - mCorrMapRef->getLumi()) > 1e-6f) { - // update only mean lumi ref if changed - setMeanLumiRef(mCorrMapRef->getLumi()); - setUpdatedMapRef(); - } + setMeanLumi(mCorrMap->getLumi(), false); + setMeanLumiRef(mCorrMapRef->getLumi()); setLumiScaleType(1); } else if (mCorrMap) { // CTP scaling is not possible, dont do any scaling to avoid applying wrong corrections @@ -84,9 +76,7 @@ void CorrectionMapsLoader::extractCCDBInputs(ProcessingContext& pc) LOGP(info, "Valid TPC scaler value {} received, switching back to IDC-based scaling", tpcScaler); mIDC2CTPFallbackActive = false; setMeanLumi(mCorrMap->getIDC(), false); - setUpdatedMap(); setMeanLumiRef(mCorrMapRef->getIDC()); - setUpdatedMapRef(); setLumiScaleType(2); } // correct IDC received