31#ifndef GPUCA_GPUCODE_DEVICE
51 const int maxDumRep = 5;
57 float tpcScaler = pc.
inputs().
get<
float>(
"tpcscaler");
59 if (tpcScaler == -1.f) {
61 if (canUseCTPScaling) {
62 LOGP(info,
"Invalid TPC scaler value {} received for IDC-based scaling! Using CTP fallback", tpcScaler);
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);
76 LOGP(info,
"Valid TPC scaler value {} received, switching back to IDC-based scaling", tpcScaler);
92 LOGP(alarm,
"Previous TF lumi used to substitute dummy input is empty, warning {} of {}", ++dumRep, maxDumRep);
103 LOGP(info,
"Setting M-Shape map");
133 LOG(fatal) <<
"Correction mode unknown! Choose either 0 (default) or 1 (derivative map) for flag corrmap-lumi-mode.";
137 addInput(inputs, {
"CTPLumi",
"CTP",
"LUMI", 0, Lifetime::Timeframe});
177 tpcopt.
lumiMode = opts.
get<
int>(
"corrmap-lumi-mode");
182 LOGP(fatal,
"Scaling with CTP Lumi is requested but this input is disabled");
190 if (std::find(inputs.begin(), inputs.end(), isp) == inputs.end()) {
191 inputs.emplace_back(isp);
198 if (std::find(options.begin(), options.end(), osp) == options.end()) {
199 options.emplace_back(osp);
213 LOGP(info,
"CorrMap mean lumi rate is overridden to {}",
mCorrMap->getLumi());
216 LOGP(info,
"CorrMap mean IDC rate is overridden to {}",
mCorrMap->getIDC());
219 float mapMeanRate = 0;
231 LOGP(
debug,
"MeanLumiOverride={} MeanLumiMap={} -> meanLumi = {}",
getMeanLumiOverride(), mapMeanRate, getMeanLumi());
242 LOGP(info,
"CorrMapRef mean lumi rate is overridden to {}",
mCorrMapRef->getLumi());
245 LOGP(info,
"CorrMapRef mean IDC rate is overridden to {}",
mCorrMapRef->getIDC());
248 float mapRefMeanRate = 0;
286 const std::array<std::string, 3> lumiS{
"OFF",
"CTP",
"TPC scaler"};
287 if (scaleType >= lumiS.size()) {
288 LOGP(fatal,
"Wrong corrmap-lumi-mode provided!");
291 LOGP(info,
"TPC correction map params updated: SP corrections: {} (corr.map scaling type={}, override values: lumiMean={} lumiRefMean={} lumiScaleMode={}), CTP Lumi: source={} lumiInstOverride={} , LumiInst scale={} ",
301 if (getLumiScaleMode() < 0) {
302 LOGP(fatal,
"TPC correction lumi scaling mode is not set");
305 bool foundCTP =
false, foundTPCScl =
false, foundMShape =
false;
306 for (
const auto& route : inputRouts) {
307 if (route.matcher ==
InputSpec{
"CTPLumi",
"CTP",
"LUMI", 0, Lifetime::Timeframe}) {
315 setLumiCTPAvailable(foundCTP);
316 enableMShapeCorrection(foundMShape);
317 if ((getLumiScaleType() == 1 && !foundCTP) || (getLumiScaleType() == 2 && !foundTPCScl)) {
318 LOGP(fatal,
"Lumi scaling source {}({}) is not available for TPC correction", getLumiScaleType(), getLumiScaleType() == 1 ?
"CTP" :
"TPCScaler");
321 if ((getLumiScaleMode() == 1) || (getLumiScaleMode() == 2)) {
322 mScaleInverse = !(ic.options().get<
bool>(
"recalculate-inverse-correction"));
324 mScaleInverse =
true;
326 const int nthreadsInv = (ic.options().get<
int>(
"nthreads-inverse-correction"));
354 LOGP(info,
"Recalculating the inverse correction");
359 scaling.emplace_back(1);
364 LOGP(info,
"Reinitializing inverse correction with lumi scale mode {} not supported for now",
mLumiScaleMode);
371 if (meanLumi < threshold) {
372 LOGP(fatal,
"CTP Lumi scaling source is requested, but the map mean scale {} is below the threshold {}", meanLumi, threshold);
375 if (meanLumi > threshold) {
376 LOGP(fatal,
"IDC scaling source is requested, but the map mean scale {} is above the threshold {}", meanLumi, threshold);
Simple interface to the CDB manager.
Implementation of the parameter class for the CorrectionMapsLoader options.
Helper class to access load maps from CCDB.
class to create TPC fast space charge correction
static const CorrMapParam & Instance()
T get(const char *key) const
ServiceRegistryRef services()
InputRecord & inputs()
The inputs associated with this processing context.
void setInstCTPLumiOverride(float f)
void setCorrMapMShape(o2::gpu::TPCFastTransform *m)
void setLumiScaleType(int32_t v)
void setMeanLumiRefOverride(float f)
void setLumiScaleMode(int32_t v)
void setCorrMapRef(o2::gpu::TPCFastTransform *m)
float mMeanLumiRefOverride
o2::gpu::TPCFastTransform * mCorrMap
float mInstCTPLumiOverride
void setMeanLumiRef(float v, bool report=false)
float getMeanLumiRefOverride() const
int32_t getLumiScaleType() const
void setUpdatedMapMShape()
bool getLumiCTPAvailable() const
void setInstLumi(float v, bool report=false)
bool mCheckCTPIDCConsistency
void setInstLumiCTP(float v)
bool getUseMShapeCorrection() const
void enableMShapeCorrection(bool v)
void setLumiCTPAvailable(bool v)
void setMeanLumiOverride(float f)
void setMeanLumi(float v, bool report=false)
o2::gpu::TPCFastTransform * mCorrMapRef
bool canUseCorrections() const
float getMeanLumiOverride() const
void setCorrMap(std::unique_ptr< o2::gpu::TPCFastTransform > &&m)
void extractCCDBInputs(o2::framework::ProcessingContext &pc)
void updateVDrift(float vdriftCorr, float vdrifRef, float driftTimeOffset=0)
static void addGlobalOptions(std::vector< o2::framework::ConfigParamSpec > &options)
bool accountCCDBInputs(const o2::framework::ConcreteDataMatcher &matcher, void *obj)
static void addOptions(std::vector< o2::framework::ConfigParamSpec > &options)
static void requestCCDBInputs(std::vector< o2::framework::InputSpec > &inputs, std::vector< o2::framework::ConfigParamSpec > &options, const CorrectionMapsLoaderGloOpts &gloOpts)
void init(o2::framework::InitContext &ic)
static void addOption(std::vector< o2::framework::ConfigParamSpec > &options, o2::framework::ConfigParamSpec &&osp)
std::unique_ptr< o2::gpu::TPCFastTransform > mCorrMapMShape
void checkMeanScaleConsistency(float meanLumi, float threshold) const
recalculate inverse correction
bool mIDC2CTPFallbackActive
void copySettings(const CorrectionMapsLoader &src)
static CorrectionMapsLoaderGloOpts parseGlobalOptions(const o2::framework::ConfigParamRegistry &opts)
static void addInput(std::vector< o2::framework::InputSpec > &inputs, o2::framework::InputSpec &&isp)
void initInverse(o2::gpu::TPCFastSpaceChargeCorrection &correction, bool prn)
initialise inverse transformation
void setNthreads(int n)
_______________ Settings ________________________
void setNthreadsToMaximum()
sets number of threads to N cpu cores
static TPCFastSpaceChargeCorrectionHelper * instance()
Singleton.
constexpr o2::header::DataOrigin gDataOriginTPC
Defining PrimaryVertex explicitly as messageable.
std::vector< ConfigParamSpec > ccdbParamSpec(std::string const &path, int runDependent, std::vector< CCDBMetadata > metadata={}, int qrate=0)
Global TPC definitions and constants.
const std::unordered_map< CDBType, const std::string > CDBTypeMap
Storage name in CCDB for each calibration and parameter type.
@ CalCorrMapMC
Cluster correction map (high IR rate distortions) for MC.
@ CalCorrMapRef
Cluster correction reference map (static distortions)
@ CalCorrMap
Cluster correction map (high IR rate distortions)
bool enableMShapeCorrection
int lumiType
what estimator to used for corrections scaling: 0: no scaling, 1: CTP, 2: IDC
bool checkCTPIDCconsistency
int lumiMode
what corrections method to use: 0: classical scaling, 1: Using of the derivative map,...
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"