Skip to content

Commit 314d5ef

Browse files
matthias-kleineralcaliva
authored andcommitted
TPC: Use CTP as fallback if no IDCs are available (#14919)
* TPC: Use CTP as fallback if no IDCs are available * Dont update map as only the lumi is updated
1 parent 1cd002b commit 314d5ef

File tree

2 files changed

+34
-4
lines changed

2 files changed

+34
-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: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,37 @@ 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+
setMeanLumi(mCorrMap->getLumi(), false);
65+
setMeanLumiRef(mCorrMapRef->getLumi());
66+
setLumiScaleType(1);
67+
} else if (mCorrMap) {
68+
// CTP scaling is not possible, dont do any scaling to avoid applying wrong corrections
69+
const float storedIDC = mCorrMap->getIDC();
70+
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);
71+
setInstLumi(storedIDC);
72+
}
73+
} else {
74+
if (mIDC2CTPFallbackActive) {
75+
// reset back to normal operation
76+
LOGP(info, "Valid TPC scaler value {} received, switching back to IDC-based scaling", tpcScaler);
77+
mIDC2CTPFallbackActive = false;
78+
setMeanLumi(mCorrMap->getIDC(), false);
79+
setMeanLumiRef(mCorrMapRef->getIDC());
80+
setLumiScaleType(2);
81+
}
82+
// correct IDC received
83+
setInstLumi(tpcScaler);
84+
}
85+
}
86+
5687
if (getLumiCTPAvailable() && mInstCTPLumiOverride <= 0.) {
5788
if (pc.inputs().get<gsl::span<char>>("CTPLumi").size() == sizeof(o2::ctp::LumiInfo)) {
5889
lumiPrev = lumiObj = pc.inputs().get<o2::ctp::LumiInfo>("CTPLumi");
@@ -67,10 +98,7 @@ void CorrectionMapsLoader::extractCCDBInputs(ProcessingContext& pc)
6798
setInstLumi(getInstLumiCTP());
6899
}
69100
}
70-
if (getLumiScaleType() == 2) {
71-
float tpcScaler = pc.inputs().get<float>("tpcscaler");
72-
setInstLumi(tpcScaler);
73-
}
101+
74102
if (getUseMShapeCorrection()) {
75103
LOGP(info, "Setting M-Shape map");
76104
const auto mapMShape = pc.inputs().get<o2::gpu::TPCFastTransform*>("mshape");
@@ -317,6 +345,7 @@ void CorrectionMapsLoader::copySettings(const CorrectionMapsLoader& src)
317345
mLumiCTPSource = src.mLumiCTPSource;
318346
mLumiScaleMode = src.mLumiScaleMode;
319347
mScaleInverse = src.getScaleInverse();
348+
mIDC2CTPFallbackActive = src.mIDC2CTPFallbackActive;
320349
}
321350

322351
void CorrectionMapsLoader::updateInverse()

0 commit comments

Comments
 (0)