Skip to content

Commit 7c8436b

Browse files
matthias-kleinerdavidrohr
authored andcommitted
TPC: centralize correction map building in TPCScalerSpec
`TPCScalerSpec` now owns the full correction map pipeline: loads maps from CCDB, applies luminosity scaling and M-shape corrections, applies VDrift into the final map, and publishes a single merged `TPCFastTransformPOD` (`TPC/TPCCORRMAP`) plus instantaneous CTP lumi (`CTP/LUMICTP`) each TF. Downstream consumers (ITS-TPC matcher, TRD, TOF, secondary vertexing, GPU reco, etc.) are simplified: lumi scale options removed from constructors, `corrMapsLoader.updateVDrift()` / `corrMapsLoader.accountCCDBInputs()` / `corrMapsLoader.init()` calls dropped, and `requestCCDBInputs()` replaced by `requestInputs()` subscribing only to the two new outputs. `TPCScalerSpec` is now always added unconditionally. `CorrectionMapsHelper` is reduced to a thin wrapper around `TPCFastTransformPOD*`; full lumi-scaling state moves to the new `CorrectionMapsHelperFull` / `CorrectionMapsLoaderFull` used only inside `TPCScalerSpec`. `TPCFastTransformPOD` gains a flat buffer offset table and `interpolateAtUZeroCopy()` for correct spline evaluation on zero-copy shared memory paths.
1 parent 59fb554 commit 7c8436b

File tree

76 files changed

+1261
-1126
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+1261
-1126
lines changed

Detectors/Align/Workflow/include/AlignmentWorkflow/BarrelAlignmentSpec.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ namespace align
3131

3232
/// create a processor spec
3333
framework::DataProcessorSpec getBarrelAlignmentSpec(o2::dataformats::GlobalTrackID::mask_t srcMP, o2::dataformats::GlobalTrackID::mask_t src,
34-
o2::detectors::DetID::mask_t dets, o2::detectors::DetID::mask_t skipDetClusters, bool enableCosmic, int postproc, bool useMC, const o2::tpc::CorrectionMapsLoaderGloOpts& sclOpts);
34+
o2::detectors::DetID::mask_t dets, o2::detectors::DetID::mask_t skipDetClusters, bool enableCosmic, int postproc, bool useMC);
3535

3636
} // namespace align
3737
} // namespace o2

Detectors/Align/Workflow/src/BarrelAlignmentSpec.cxx

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,9 @@ class BarrelAlignmentSpec : public Task
8686
CheckConstaints = 0x1 << 1,
8787
GenPedeFiles = 0x1 << 2,
8888
LabelPedeResults = 0x1 << 3 };
89-
BarrelAlignmentSpec(GTrackID::mask_t srcMP, std::shared_ptr<DataRequest> dr, std::shared_ptr<o2::base::GRPGeomRequest> ggrec, const o2::tpc::CorrectionMapsLoaderGloOpts& tpcOpt,
89+
BarrelAlignmentSpec(GTrackID::mask_t srcMP, std::shared_ptr<DataRequest> dr, std::shared_ptr<o2::base::GRPGeomRequest> ggrec,
9090
DetID::mask_t detmask, bool cosmic, int postprocess, bool useMC, bool loadTPCCalib)
91-
: mDataRequest(dr), mGRPGeomRequest(ggrec), mMPsrc{srcMP}, mDetMask{detmask}, mCosmic(cosmic), mPostProcessing(postprocess), mUseMC(useMC), mLoadTPCCalib(loadTPCCalib)
92-
{
93-
mTPCCorrMapsLoader.setLumiScaleType(tpcOpt.lumiType);
94-
mTPCCorrMapsLoader.setLumiScaleMode(tpcOpt.lumiMode);
95-
mTPCCorrMapsLoader.setCheckCTPIDCConsistency(tpcOpt.checkCTPIDCconsistency);
96-
}
91+
: mDataRequest(dr), mGRPGeomRequest(ggrec), mMPsrc{srcMP}, mDetMask{detmask}, mCosmic(cosmic), mPostProcessing(postprocess), mUseMC(useMC), mLoadTPCCalib(loadTPCCalib) {}
9792
~BarrelAlignmentSpec() override = default;
9893
void init(InitContext& ic) final;
9994
void run(ProcessingContext& pc) final;
@@ -184,9 +179,6 @@ void BarrelAlignmentSpec::init(InitContext& ic)
184179
}
185180
mIgnoreCCDBAlignment = ic.options().get<bool>("ignore-ccdb-alignment");
186181
if (!mPostProcessing) {
187-
if (mLoadTPCCalib) {
188-
mTPCCorrMapsLoader.init(ic);
189-
}
190182
if (GTrackID::includesDet(DetID::TRD, mMPsrc)) {
191183
mTRDTransformer.reset(new o2::trd::TrackletTransformer);
192184
if (ic.options().get<bool>("apply-xor")) {
@@ -278,7 +270,7 @@ void BarrelAlignmentSpec::updateTimeDependentParams(ProcessingContext& pc)
278270
mTPCCorrMapsLoader.acknowledgeUpdate();
279271
updateMaps = true;
280272
}
281-
mController->setTPCCorrMaps(&mTPCCorrMapsLoader);
273+
// mController->setTPCCorrMaps(&mTPCCorrMapsLoader);
282274
if (mTPCVDriftHelper.isUpdated()) {
283275
LOGP(info, "Updating TPC fast transform map with new VDrift factor of {} wrt reference {} and DriftTimeOffset correction {} wrt {} from source {}",
284276
mTPCVDriftHelper.getVDriftObject().corrFact, mTPCVDriftHelper.getVDriftObject().refVDrift,
@@ -288,9 +280,6 @@ void BarrelAlignmentSpec::updateTimeDependentParams(ProcessingContext& pc)
288280
mTPCVDriftHelper.acknowledgeUpdate();
289281
updateMaps = true;
290282
}
291-
if (updateMaps) {
292-
mTPCCorrMapsLoader.updateVDrift(mTPCVDriftHelper.getVDriftObject().corrFact, mTPCVDriftHelper.getVDriftObject().refVDrift, mTPCVDriftHelper.getVDriftObject().getTimeOffset());
293-
}
294283
}
295284
}
296285

@@ -314,9 +303,6 @@ void BarrelAlignmentSpec::finaliseCCDB(o2::framework::ConcreteDataMatcher& match
314303

315304
return;
316305
}
317-
if (mTPCCorrMapsLoader.accountCCDBInputs(matcher, obj)) {
318-
return;
319-
}
320306
}
321307

322308
void BarrelAlignmentSpec::run(ProcessingContext& pc)
@@ -374,7 +360,7 @@ void BarrelAlignmentSpec::endOfStream(EndOfStreamContext& ec)
374360
mDBGOut.reset();
375361
}
376362

377-
DataProcessorSpec getBarrelAlignmentSpec(GTrackID::mask_t srcMP, GTrackID::mask_t src, DetID::mask_t dets, DetID::mask_t skipDetClusters, bool enableCosmic, int postprocess, bool useMC, const o2::tpc::CorrectionMapsLoaderGloOpts& sclOpts)
363+
DataProcessorSpec getBarrelAlignmentSpec(GTrackID::mask_t srcMP, GTrackID::mask_t src, DetID::mask_t dets, DetID::mask_t skipDetClusters, bool enableCosmic, int postprocess, bool useMC)
378364
{
379365
std::vector<OutputSpec> outputs;
380366
auto dataRequest = std::make_shared<DataRequest>();
@@ -399,7 +385,7 @@ DataProcessorSpec getBarrelAlignmentSpec(GTrackID::mask_t srcMP, GTrackID::mask_
399385
}
400386
if (src[DetID::TPC] && !skipDetClusters[DetID::TPC]) {
401387
o2::tpc::VDriftHelper::requestCCDBInputs(dataRequest->inputs);
402-
o2::tpc::CorrectionMapsLoader::requestCCDBInputs(dataRequest->inputs, opts, sclOpts);
388+
o2::tpc::CorrectionMapsLoader::requestInputs(dataRequest->inputs, opts);
403389
loadTPCCalib = true;
404390
}
405391
}
@@ -417,7 +403,7 @@ DataProcessorSpec getBarrelAlignmentSpec(GTrackID::mask_t srcMP, GTrackID::mask_
417403
"barrel-alignment",
418404
dataRequest->inputs,
419405
outputs,
420-
AlgorithmSpec{adaptFromTask<BarrelAlignmentSpec>(srcMP, dataRequest, ccdbRequest, sclOpts, dets, enableCosmic, postprocess, useMC, loadTPCCalib)},
406+
AlgorithmSpec{adaptFromTask<BarrelAlignmentSpec>(srcMP, dataRequest, ccdbRequest, dets, enableCosmic, postprocess, useMC, loadTPCCalib)},
421407
opts};
422408
}
423409

Detectors/Align/Workflow/src/barrel-alignment-workflow.cxx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include "TPCReaderWorkflow/ClusterReaderSpec.h"
2121
#include "TPCWorkflow/ClusterSharingMapSpec.h"
2222
#include "TPCWorkflow/TPCScalerSpec.h"
23-
#include "TPCCalibration/CorrectionMapsLoader.h"
2423
#include "TOFWorkflowIO/ClusterReaderSpec.h"
2524
#include "TOFWorkflowIO/TOFMatchedReaderSpec.h"
2625
#include "TOFWorkflowIO/ClusterReaderSpec.h"
@@ -148,11 +147,11 @@ WorkflowSpec defineDataProcessing(ConfigContext const& configcontext)
148147
o2::conf::ConfigurableParam::writeINI("o2_barrel_alignment_configuration.ini");
149148
}
150149

151-
if (sclOpt.needTPCScalersWorkflow() && !configcontext.options().get<bool>("disable-root-input")) {
152-
specs.emplace_back(o2::tpc::getTPCScalerSpec(sclOpt.lumiType == 2, sclOpt.enableMShapeCorrection));
150+
if (!configcontext.options().get<bool>("disable-root-input")) {
151+
specs.emplace_back(o2::tpc::getTPCScalerSpec(sclOpt.lumiType == o2::tpc::LumiScaleType::TPCScaler, sclOpt.enableMShapeCorrection, sclOpt));
153152
}
154153

155-
specs.emplace_back(o2::align::getBarrelAlignmentSpec(srcMP, src, dets, skipDetClusters, enableCosmic, postprocess, useMC, sclOpt));
154+
specs.emplace_back(o2::align::getBarrelAlignmentSpec(srcMP, src, dets, skipDetClusters, enableCosmic, postprocess, useMC));
156155
// RS FIXME: check which clusters are really needed
157156
if (!postprocess) {
158157
GID::mask_t dummy;

Detectors/GlobalTracking/src/MatchTOF.cxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2087,6 +2087,7 @@ void MatchTOF::updateTimeDependentParams()
20872087
const auto& trackTune = TrackTuneParams::Instance();
20882088
float scale = mTPCCorrMapsHelper->getInstLumiCTP();
20892089
if (scale < 0.f) {
2090+
LOGP(warning, "Negative scale factor for TPC covariance correction, setting it to zero");
20902091
scale = 0.f;
20912092
}
20922093
mCovDiagInner = trackTune.getCovInnerTotal(scale);

Detectors/GlobalTracking/src/MatchTPCITS.cxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ void MatchTPCITS::updateTimeDependentParams()
288288
const auto& trackTune = TrackTuneParams::Instance();
289289
float scale = mTPCCorrMapsHelper->getInstLumiCTP();
290290
if (scale < 0.f) {
291+
LOGP(warning, "Negative scale factor for TPC covariance correction, setting it to zero");
291292
scale = 0.f;
292293
}
293294
mCovDiagInner = trackTune.getCovInnerTotal(scale);

Detectors/GlobalTrackingWorkflow/include/GlobalTrackingWorkflow/CosmicsMatchingSpec.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ namespace globaltracking
2929
{
3030

3131
/// create a processor spec
32-
framework::DataProcessorSpec getCosmicsMatchingSpec(o2::dataformats::GlobalTrackID::mask_t src, bool useMC, const o2::tpc::CorrectionMapsLoaderGloOpts& sclOpts);
32+
framework::DataProcessorSpec getCosmicsMatchingSpec(o2::dataformats::GlobalTrackID::mask_t src, bool useMC);
3333

3434
} // namespace globaltracking
3535
} // namespace o2

Detectors/GlobalTrackingWorkflow/include/GlobalTrackingWorkflow/SecondaryVertexingSpec.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ namespace vertexing
2929
{
3030

3131
/// create a processor spec
32-
o2::framework::DataProcessorSpec getSecondaryVertexingSpec(o2::dataformats::GlobalTrackID::mask_t src, bool enableCasc, bool enable3body, bool enableStrangenesTracking, bool enableCCDBParams, bool useMC, bool useGeom, const o2::tpc::CorrectionMapsLoaderGloOpts& sclOpts);
32+
o2::framework::DataProcessorSpec getSecondaryVertexingSpec(o2::dataformats::GlobalTrackID::mask_t src, bool enableCasc, bool enable3body, bool enableStrangenesTracking, bool enableCCDBParams, bool useMC, bool useGeom);
3333

3434
} // namespace vertexing
3535
} // namespace o2

Detectors/GlobalTrackingWorkflow/include/GlobalTrackingWorkflow/TOFMatcherSpec.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ namespace globaltracking
2929
{
3030

3131
/// create a processor spec
32-
framework::DataProcessorSpec getTOFMatcherSpec(o2::dataformats::GlobalTrackID::mask_t src, bool useMC, bool useFIT, bool tpcRefit, bool strict, float extratolerancetrd, bool pushMatchable, const o2::tpc::CorrectionMapsLoaderGloOpts& sclOpts, int nlanes = 1);
32+
framework::DataProcessorSpec getTOFMatcherSpec(o2::dataformats::GlobalTrackID::mask_t src, bool useMC, bool useFIT, bool tpcRefit, bool strict, float extratolerancetrd, bool pushMatchable, int nlanes = 1);
3333

3434
} // namespace globaltracking
3535
} // namespace o2

Detectors/GlobalTrackingWorkflow/include/GlobalTrackingWorkflow/TPCITSMatchingSpec.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ struct CorrectionMapsLoaderGloOpts;
2727
namespace globaltracking
2828
{
2929
/// create a processor spec
30-
framework::DataProcessorSpec getTPCITSMatchingSpec(o2::dataformats::GlobalTrackID::mask_t src, bool useFT0, bool calib, bool skipTPCOnly, bool useGeom, bool useMC, const o2::tpc::CorrectionMapsLoaderGloOpts& sclOpts);
30+
framework::DataProcessorSpec getTPCITSMatchingSpec(o2::dataformats::GlobalTrackID::mask_t src, bool useFT0, bool calib, bool skipTPCOnly, bool useGeom, bool useMC);
3131

3232
} // namespace globaltracking
3333
} // namespace o2

Detectors/GlobalTrackingWorkflow/src/CosmicsMatchingSpec.cxx

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,7 @@ namespace globaltracking
6262
class CosmicsMatchingSpec : public Task
6363
{
6464
public:
65-
CosmicsMatchingSpec(std::shared_ptr<DataRequest> dr, std::shared_ptr<o2::base::GRPGeomRequest> gr, const o2::tpc::CorrectionMapsLoaderGloOpts& sclOpts, bool useMC) : mDataRequest(dr), mGGCCDBRequest(gr), mUseMC(useMC)
66-
{
67-
mTPCCorrMapsLoader.setLumiScaleType(sclOpts.lumiType);
68-
mTPCCorrMapsLoader.setLumiScaleMode(sclOpts.lumiMode);
69-
mTPCCorrMapsLoader.setCheckCTPIDCConsistency(sclOpts.checkCTPIDCconsistency);
70-
}
65+
CosmicsMatchingSpec(std::shared_ptr<DataRequest> dr, std::shared_ptr<o2::base::GRPGeomRequest> gr, bool useMC) : mDataRequest(dr), mGGCCDBRequest(gr), mUseMC(useMC) {}
7166
~CosmicsMatchingSpec() override = default;
7267
void init(InitContext& ic) final;
7368
void run(ProcessingContext& pc) final;
@@ -92,7 +87,6 @@ void CosmicsMatchingSpec::init(InitContext& ic)
9287
o2::base::GRPGeomHelper::instance().setRequest(mGGCCDBRequest);
9388
mMatching.setDebugFlag(ic.options().get<int>("debug-tree-flags"));
9489
mMatching.setUseMC(mUseMC);
95-
mTPCCorrMapsLoader.init(ic);
9690
//
9791
}
9892

@@ -132,10 +126,8 @@ void CosmicsMatchingSpec::updateTimeDependentParams(ProcessingContext& pc)
132126
}
133127
mMatching.init();
134128
}
135-
bool updateMaps = false;
136129
if (mTPCCorrMapsLoader.isUpdated()) {
137130
mTPCCorrMapsLoader.acknowledgeUpdate();
138-
updateMaps = true;
139131
}
140132
mMatching.setTPCCorrMaps(&mTPCCorrMapsLoader);
141133
if (mTPCVDriftHelper.isUpdated()) {
@@ -145,10 +137,6 @@ void CosmicsMatchingSpec::updateTimeDependentParams(ProcessingContext& pc)
145137
mTPCVDriftHelper.getSourceName());
146138
mMatching.setTPCVDrift(mTPCVDriftHelper.getVDriftObject());
147139
mTPCVDriftHelper.acknowledgeUpdate();
148-
updateMaps = true;
149-
}
150-
if (updateMaps) {
151-
mTPCCorrMapsLoader.updateVDrift(mTPCVDriftHelper.getVDriftObject().corrFact, mTPCVDriftHelper.getVDriftObject().refVDrift, mTPCVDriftHelper.getVDriftObject().getTimeOffset());
152140
}
153141
}
154142

@@ -160,9 +148,6 @@ void CosmicsMatchingSpec::finaliseCCDB(ConcreteDataMatcher& matcher, void* obj)
160148
if (mTPCVDriftHelper.accountCCDBInputs(matcher, obj)) {
161149
return;
162150
}
163-
if (mTPCCorrMapsLoader.accountCCDBInputs(matcher, obj)) {
164-
return;
165-
}
166151
if (matcher == ConcreteDataMatcher("ITS", "CLUSDICT", 0)) {
167152
LOG(info) << "cluster dictionary updated";
168153
mMatching.setITSDict((const o2::itsmft::TopologyDictionary*)obj);
@@ -177,7 +162,7 @@ void CosmicsMatchingSpec::endOfStream(EndOfStreamContext& ec)
177162
mTimer.CpuTime(), mTimer.RealTime(), mTimer.Counter() - 1);
178163
}
179164

180-
DataProcessorSpec getCosmicsMatchingSpec(GTrackID::mask_t src, bool useMC, const o2::tpc::CorrectionMapsLoaderGloOpts& sclOpts)
165+
DataProcessorSpec getCosmicsMatchingSpec(GTrackID::mask_t src, bool useMC)
181166
{
182167
std::vector<OutputSpec> outputs;
183168
Options opts{
@@ -203,13 +188,13 @@ DataProcessorSpec getCosmicsMatchingSpec(GTrackID::mask_t src, bool useMC, const
203188
dataRequest->inputs,
204189
true);
205190
o2::tpc::VDriftHelper::requestCCDBInputs(dataRequest->inputs);
206-
o2::tpc::CorrectionMapsLoader::requestCCDBInputs(dataRequest->inputs, opts, sclOpts);
191+
o2::tpc::CorrectionMapsLoader::requestInputs(dataRequest->inputs, opts);
207192

208193
return DataProcessorSpec{
209194
"cosmics-matcher",
210195
dataRequest->inputs,
211196
outputs,
212-
AlgorithmSpec{adaptFromTask<CosmicsMatchingSpec>(dataRequest, ggRequest, sclOpts, useMC)},
197+
AlgorithmSpec{adaptFromTask<CosmicsMatchingSpec>(dataRequest, ggRequest, useMC)},
213198
opts};
214199
}
215200

0 commit comments

Comments
 (0)