Skip to content

Commit 285def7

Browse files
TPC: Use CTP as fallback if no IDCs are available
1 parent 7ffc897 commit 285def7

File tree

2 files changed

+44
-4
lines changed

2 files changed

+44
-4
lines changed

Detectors/TPC/calibration/include/TPCCalibration/CorrectionMapsLoader.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ class CorrectionMapsLoader : public o2::gpu::CorrectionMapsHelper
7979
float mInstLumiCTPFactor = 1.0; // multiplicative factor for inst. lumi
8080
int mLumiCTPSource = 0; // 0: main, 1: alternative CTP lumi source
8181
std::unique_ptr<o2::gpu::TPCFastTransform> mCorrMapMShape{nullptr};
82+
bool mIDC2CTPFallbackActive = false; // flag indicating that fallback from IDC to CTP scaling is active
8283
#endif
8384
};
8485

Detectors/TPC/calibration/src/CorrectionMapsLoader.cxx

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,47 @@ void CorrectionMapsLoader::extractCCDBInputs(ProcessingContext& pc)
5353
o2::ctp::LumiInfo lumiObj;
5454
static o2::ctp::LumiInfo lumiPrev;
5555

56+
if (getLumiScaleType() == 2 || mIDC2CTPFallbackActive) {
57+
float tpcScaler = pc.inputs().get<float>("tpcscaler");
58+
// check if tpcScaler is valid and CTP fallback is allowed
59+
if (tpcScaler == -1.f) {
60+
const bool canUseCTPScaling = mCorrMap && mCorrMapRef && mCorrMap->isIDCSet() && mCorrMapRef->isIDCSet() && mCorrMap->isLumiSet() && mCorrMapRef->isLumiSet();
61+
if (canUseCTPScaling) {
62+
LOGP(info, "Invalid TPC scaler value {} received for IDC-based scaling! Using CTP fallback", tpcScaler);
63+
mIDC2CTPFallbackActive = true;
64+
if (std::abs(getMeanLumi() - mCorrMap->getLumi()) > 1e-6f) {
65+
// update only mean lumi if changed
66+
setMeanLumi(mCorrMap->getLumi(), false);
67+
setUpdatedMap();
68+
}
69+
if (std::abs(getMeanLumiRef() - mCorrMapRef->getLumi()) > 1e-6f) {
70+
// update only mean lumi ref if changed
71+
setMeanLumiRef(mCorrMapRef->getLumi());
72+
setUpdatedMapRef();
73+
}
74+
setLumiScaleType(1);
75+
} else if (mCorrMap) {
76+
// CTP scaling is not possible, dont do any scaling to avoid applying wrong corrections
77+
const float storedIDC = mCorrMap->getIDC();
78+
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);
79+
setInstLumi(storedIDC);
80+
}
81+
} else {
82+
if (mIDC2CTPFallbackActive) {
83+
// reset back to normal operation
84+
LOGP(info, "Valid TPC scaler value {} received, switching back to IDC-based scaling", tpcScaler);
85+
mIDC2CTPFallbackActive = false;
86+
setMeanLumi(mCorrMap->getIDC(), false);
87+
setUpdatedMap();
88+
setMeanLumiRef(mCorrMapRef->getIDC());
89+
setUpdatedMapRef();
90+
setLumiScaleType(2);
91+
}
92+
// correct IDC received
93+
setInstLumi(tpcScaler);
94+
}
95+
}
96+
5697
if (getLumiCTPAvailable() && mInstCTPLumiOverride <= 0.) {
5798
if (pc.inputs().get<gsl::span<char>>("CTPLumi").size() == sizeof(o2::ctp::LumiInfo)) {
5899
lumiPrev = lumiObj = pc.inputs().get<o2::ctp::LumiInfo>("CTPLumi");
@@ -67,10 +108,7 @@ void CorrectionMapsLoader::extractCCDBInputs(ProcessingContext& pc)
67108
setInstLumi(getInstLumiCTP());
68109
}
69110
}
70-
if (getLumiScaleType() == 2) {
71-
float tpcScaler = pc.inputs().get<float>("tpcscaler");
72-
setInstLumi(tpcScaler);
73-
}
111+
74112
if (getUseMShapeCorrection()) {
75113
LOGP(info, "Setting M-Shape map");
76114
const auto mapMShape = pc.inputs().get<o2::gpu::TPCFastTransform*>("mshape");
@@ -317,6 +355,7 @@ void CorrectionMapsLoader::copySettings(const CorrectionMapsLoader& src)
317355
mLumiCTPSource = src.mLumiCTPSource;
318356
mLumiScaleMode = src.mLumiScaleMode;
319357
mScaleInverse = src.getScaleInverse();
358+
mIDC2CTPFallbackActive = src.mIDC2CTPFallbackActive;
320359
}
321360

322361
void CorrectionMapsLoader::updateInverse()

0 commit comments

Comments
 (0)