Skip to content

Commit e289430

Browse files
committed
Add/use in TPCFastTransform mean IDC data member on top of Lumi
Nominally both IDC (setIDC(val)) and Lumi (setLumi(val)) info of the map should be filled at the creation time. Depending what is used for the corrections (accoding to --lumi-type value: 1 for CTP lumi or 2 for IDC scaler) the getLumi or getIDC will be used. For the old maps, where the mIDC is absent (i.e. default value -1 returned by getIDC()) but the Lumi was used to stored the IDC mean value, we check if getLumi() is below the threshold TPCCorrMap.CTP2IDCFallBackThreshold (by default set to 30). If this is a case, the getLumi() value will be used as IDC scale, otherwise a Fatal will be thrown. Note that the inverse check is not done: if CTP Lumi scaling is requested for the old map where getLumi returns IDC, a wrong scale will be accepted.
1 parent bc3e04c commit e289430

File tree

6 files changed

+98
-12
lines changed

6 files changed

+98
-12
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ struct CorrMapParam : public o2::conf::ConfigurableParamHelper<CorrMapParam> {
2929
float lumiMean = 0.; // override TPC corr.map mean lumi (if > 0), disable corrections if < 0
3030
float lumiMeanRef = 0.; // override TPC corr.mapRef mean lumi (if > 0)"
3131
float lumiInstFactor = 1.; // scaling to apply to instantaneous lumi from CTP (but not to IDC scaler)
32+
float CTP2IDCFallBackThreshold = 30.; // if needed, interpret map->getLumi() as map->getIDC(), provided map->getLumi() is below this threshold
3233
int ctpLumiSource = 0; // CTP lumi source: 0 = LumiInfo.getLumi(), 1 = LumiInfo.getLumiAlt()
3334

3435
O2ParamDef(CorrMapParam, "TPCCorrMap");

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class CorrectionMapsLoader : public o2::gpu::CorrectionMapsHelper
6363
void init(o2::framework::InitContext& ic);
6464
void copySettings(const CorrectionMapsLoader& src);
6565
void updateInverse(); /// recalculate inverse correction
66+
float getMapMeanRate(const o2::gpu::TPCFastTransform* mp, bool lumiOverridden) const;
6667

6768
static void requestCCDBInputs(std::vector<o2::framework::InputSpec>& inputs, std::vector<o2::framework::ConfigParamSpec>& options, const CorrectionMapsLoaderGloOpts& gloOpts);
6869
static void addGlobalOptions(std::vector<o2::framework::ConfigParamSpec>& options);

Detectors/TPC/calibration/src/CorrectdEdxDistortions.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ void o2::tpc::CorrectdEdxDistortions::setLumi(float lumi)
7070
LOGP(warn, "Nullptr detected in accessing the correction maps");
7171
return;
7272
}
73-
const float lumiAvg = mCorrAvg->getLumi();
74-
const float lumiDer = mCorrDer->getLumi();
73+
const float lumiAvg = mCorrAvg->getIDC();
74+
const float lumiDer = mCorrDer->getIDC();
7575
mScaleDer = (lumi - lumiAvg) / lumiDer;
7676
LOGP(info, "Setting mScaleDer: {} for inst lumi: {} avg lumi: {} deriv. lumi: {}", mScaleDer, lumi, lumiAvg, lumiDer);
7777
}

Detectors/TPC/calibration/src/CorrectionMapsLoader.cxx

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -176,20 +176,52 @@ bool CorrectionMapsLoader::accountCCDBInputs(const ConcreteDataMatcher& matcher,
176176
if (matcher == ConcreteDataMatcher("TPC", "CorrMap", 0)) {
177177
setCorrMap((o2::gpu::TPCFastTransform*)obj);
178178
mCorrMap->rectifyAfterReadingFromFile();
179-
if (getMeanLumiOverride() == 0 && mCorrMap->getLumi() > 0.) {
180-
setMeanLumi(mCorrMap->getLumi(), false);
179+
mCorrMap->setCTP2IDCFallBackThreshold(o2::tpc::CorrMapParam::Instance().CTP2IDCFallBackThreshold);
180+
if (getMeanLumiOverride() != 0) {
181+
if (getLumiScaleType() == 1) {
182+
mCorrMap->setLumi(getMeanLumiOverride());
183+
LOGP(info, "CorrMap mean lumi rate is overridden to {}", mCorrMap->getLumi());
184+
} else if (getLumiScaleType() == 2) {
185+
mCorrMap->setIDC(getMeanLumiOverride());
186+
LOGP(info, "CorrMap mean IDC rate is overridden to {}", mCorrMap->getIDC());
187+
}
188+
}
189+
float mapMeanRate = 0;
190+
if (getLumiScaleType() == 1) {
191+
mapMeanRate = mCorrMap->getLumi();
192+
} else if (getLumiScaleType() == 2) {
193+
mapMeanRate = mCorrMap->getIDC();
194+
}
195+
if (getMeanLumiOverride() == 0 && mapMeanRate > 0.) {
196+
setMeanLumi(mapMeanRate, false);
181197
}
182-
LOGP(debug, "MeanLumiOverride={} MeanLumiMap={} -> meanLumi = {}", getMeanLumiOverride(), mCorrMap->getLumi(), getMeanLumi());
198+
LOGP(debug, "MeanLumiOverride={} MeanLumiMap={} -> meanLumi = {}", getMeanLumiOverride(), mapMeanRate, getMeanLumi());
183199
setUpdatedMap();
184200
return true;
185201
}
186202
if (matcher == ConcreteDataMatcher("TPC", "CorrMapRef", 0)) {
187203
setCorrMapRef((o2::gpu::TPCFastTransform*)obj);
188204
mCorrMapRef->rectifyAfterReadingFromFile();
205+
mCorrMapRef->setCTP2IDCFallBackThreshold(o2::tpc::CorrMapParam::Instance().CTP2IDCFallBackThreshold);
206+
if (getMeanLumiRefOverride() != 0) {
207+
if (getLumiScaleType() == 1) {
208+
mCorrMapRef->setLumi(getMeanLumiRefOverride());
209+
LOGP(info, "CorrMapRef mean lumi rate is overridden to {}", mCorrMapRef->getLumi());
210+
} else if (getLumiScaleType() == 2) {
211+
mCorrMapRef->setIDC(getMeanLumiRefOverride());
212+
LOGP(info, "CorrMapRef mean IDC rate is overridden to {}", mCorrMapRef->getIDC());
213+
}
214+
}
215+
float mapRefMeanRate = 0;
216+
if (getLumiScaleType() == 1) {
217+
mapRefMeanRate = mCorrMapRef->getLumi();
218+
} else if (getLumiScaleType() == 2) {
219+
mapRefMeanRate = mCorrMapRef->getIDC();
220+
}
189221
if (getMeanLumiRefOverride() == 0) {
190-
setMeanLumiRef(mCorrMapRef->getLumi());
222+
setMeanLumiRef(mapRefMeanRate);
191223
}
192-
LOGP(debug, "MeanLumiRefOverride={} MeanLumiMap={} -> meanLumi = {}", getMeanLumiRefOverride(), mCorrMapRef->getLumi(), getMeanLumiRef());
224+
LOGP(debug, "MeanLumiRefOverride={} MeanLumiMap={} -> meanLumi = {}", getMeanLumiRefOverride(), mapRefMeanRate, getMeanLumiRef());
193225
setUpdatedMapRef();
194226
return true;
195227
}
@@ -217,7 +249,7 @@ bool CorrectionMapsLoader::accountCCDBInputs(const ConcreteDataMatcher& matcher,
217249
int scaleType = getLumiScaleType();
218250
const std::array<std::string, 3> lumiS{"OFF", "CTP", "TPC scaler"};
219251
if (scaleType >= lumiS.size()) {
220-
LOGP(fatal, "Wrong lumi-scale-type provided!");
252+
LOGP(fatal, "Wrong corrmap-lumi-mode provided!");
221253
}
222254

223255
LOGP(info, "TPC correction map params updated: SP corrections: {} (corr.map scaling type={}, override values: lumiMean={} lumiRefMean={} lumiScaleMode={}), CTP Lumi: source={} lumiInstOverride={} , LumiInst scale={} ",

GPU/TPCFastTransformation/TPCFastTransform.cxx

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
using namespace o2::gpu;
3838

3939
TPCFastTransform::TPCFastTransform()
40-
: FlatObject(), mTimeStamp(0), mCorrection(), mApplyCorrection(1), mT0(0.f), mVdrift(0.f), mVdriftCorrY(0.f), mLdriftCorr(0.f), mTOFcorr(0.f), mPrimVtxZ(0.f), mLumi(0.f), mLumiError(0.f), mLumiScaleFactor(1.0f)
40+
: FlatObject(), mTimeStamp(0), mCorrection(), mApplyCorrection(1), mT0(0.f), mVdrift(0.f), mVdriftCorrY(0.f), mLdriftCorr(0.f), mTOFcorr(0.f), mPrimVtxZ(0.f), mLumi(TPCFastTransform::DEFLUMI), mLumiError(0.f), mLumiScaleFactor(1.0f), mIDC(TPCFastTransform::DEFIDC), mIDCError(0.f), mCTP2IDCFallBackThreshold(30.f)
4141
{
4242
// Default Constructor: creates an empty uninitialized object
4343
}
@@ -60,6 +60,9 @@ void TPCFastTransform::cloneFromObject(const TPCFastTransform& obj, char* newFla
6060
mPrimVtxZ = obj.mPrimVtxZ;
6161
mLumi = obj.mLumi;
6262
mLumiError = obj.mLumiError;
63+
mIDC = obj.mIDC;
64+
mIDCError = obj.mIDCError;
65+
mCTP2IDCFallBackThreshold = obj.mCTP2IDCFallBackThreshold;
6366
mLumiScaleFactor = obj.mLumiScaleFactor;
6467
// variable-size data
6568

@@ -108,8 +111,11 @@ void TPCFastTransform::startConstruction(const TPCFastSpaceChargeCorrection& cor
108111
mLdriftCorr = 0.f;
109112
mTOFcorr = 0.f;
110113
mPrimVtxZ = 0.f;
111-
mLumi = 0.f;
114+
mLumi = DEFLUMI;
112115
mLumiError = 0.f;
116+
mIDC = DEFIDC;
117+
mIDCError = 0.f;
118+
mCTP2IDCFallBackThreshold = 30.f;
113119
mLumiScaleFactor = 1.f;
114120

115121
// variable-size data
@@ -160,6 +166,9 @@ void TPCFastTransform::print() const
160166
LOG(info) << "mPrimVtxZ = " << mPrimVtxZ;
161167
LOG(info) << "mLumi = " << mLumi;
162168
LOG(info) << "mLumiError = " << mLumiError;
169+
LOG(info) << "mIDC = " << mIDC;
170+
LOG(info) << "mIDCError = " << mIDCError;
171+
LOG(info) << "mCTP2IDCFallBackThreshold = " << mCTP2IDCFallBackThreshold;
163172
LOG(info) << "mLumiScaleFactor = " << mLumiScaleFactor;
164173
mCorrection.print();
165174
#endif
@@ -251,3 +260,25 @@ void TPCFastTransform::setSlowTPCSCCorrection(TFile& inpf)
251260
mCorrectionSlow->mCorr->setGlobalCorrectionsFromFile<float>(inpf, o2::tpc::Side::C);
252261
}
253262
#endif
263+
264+
float TPCFastTransform::getIDC() const
265+
{
266+
auto val = mIDC;
267+
if (!isIDCSet()) {
268+
if (mLumi < mCTP2IDCFallBackThreshold) {
269+
#if !defined(GPUCA_GPUCODE)
270+
bool static report = true;
271+
if (report) {
272+
report = false;
273+
LOG(warn) << "IDC scaling is requested but map IDC record is empty. Since map Lumi " << mLumi << " is less than fall-back threshold " << mCTP2IDCFallBackThreshold << ", interpret Lumi record as IDC";
274+
}
275+
#endif
276+
val = mLumi;
277+
} else {
278+
#if !defined(GPUCA_GPUCODE) && !defined(GPUCA_STANDALONE)
279+
LOG(fatal) << "IDC scaling is requested but map IDC record is empty. The map Lumi " << mLumi << " exceeds Lumi->IDC fall-back threshold " << mCTP2IDCFallBackThreshold;
280+
#endif
281+
}
282+
}
283+
return val;
284+
}

GPU/TPCFastTransformation/TPCFastTransform.h

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ struct TPCSlowSpaceChargeCorrection {
9696
class TPCFastTransform : public FlatObject
9797
{
9898
public:
99+
static constexpr float DEFLUMI = -1e6f; // default value to check if member was set
100+
static constexpr float DEFIDC = -1e6f; // default value to check if member was set
101+
99102
/// _____________ Constructors / destructors __________________________
100103

101104
/// Default constructor: creates an empty uninitialized object
@@ -162,7 +165,9 @@ class TPCFastTransform : public FlatObject
162165
void setLumi(float l) { mLumi = l; }
163166
void setLumiError(float e) { mLumiError = e; }
164167
void setLumiScaleFactor(float s) { mLumiScaleFactor = s; }
165-
168+
void setIDC(float l) { mIDC = l; }
169+
void setIDCError(float e) { mIDCError = e; }
170+
void setCTP2IDCFallBackThreshold(float v) { mCTP2IDCFallBackThreshold = v; }
166171
/// Sets the time stamp of the current calibaration
167172
void setTimeStamp(int64_t v) { mTimeStamp = v; }
168173

@@ -251,9 +256,21 @@ class TPCFastTransform : public FlatObject
251256
/// Return map lumi
252257
GPUd() float getLumi() const { return mLumi; }
253258

259+
GPUd() float isLumiSet() const { return mLumi != DEFLUMI; }
260+
254261
/// Return map lumi error
255262
GPUd() float getLumiError() const { return mLumiError; }
256263

264+
/// Return map lumi
265+
GPUd() float getIDC() const;
266+
267+
GPUd() bool isIDCSet() const { return mIDC != DEFIDC; }
268+
269+
/// Return map lumi error
270+
GPUd() float getIDCError() const { return mIDCError; }
271+
272+
GPUd() float getCTP2IDCFallBackThreshold() const { return mCTP2IDCFallBackThreshold; }
273+
257274
/// Return map user defined lumi scale factor
258275
GPUd() float getLumiScaleFactor() const { return mLumiScaleFactor; }
259276

@@ -334,12 +351,16 @@ class TPCFastTransform : public FlatObject
334351
float mLumiError; ///< error on luminosity
335352
float mLumiScaleFactor; ///< user correction factor for lumi (e.g. normalization, efficiency correction etc.)
336353

354+
float mIDC; ///< IDC estimator
355+
float mIDCError; ///< error on IDC
356+
float mCTP2IDCFallBackThreshold; ///< if IDC is not set but requested, use Lumi if it does not exceed this threshold
357+
337358
/// Correction of (x,u,v) with tricubic interpolator on a regular grid
338359
TPCSlowSpaceChargeCorrection* mCorrectionSlow{nullptr}; ///< reference space charge corrections
339360

340361
GPUd() void TransformInternal(int32_t slice, int32_t row, float& u, float& v, float& x, const TPCFastTransform* ref, const TPCFastTransform* ref2, float scale, float scale2, int32_t scaleMode) const;
341362

342-
ClassDefNV(TPCFastTransform, 3);
363+
ClassDefNV(TPCFastTransform, 4);
343364
};
344365

345366
// =======================================================================

0 commit comments

Comments
 (0)