From 33890e0e7d1022c49c4e55f5fb68e37aae580be0 Mon Sep 17 00:00:00 2001 From: shahoian Date: Mon, 13 Nov 2023 00:03:15 +0100 Subject: [PATCH] Assign lowest TPC cluster position as TPC track minR ... even if the track was already propagated to the reference X=83cm. --- .../src/SecondaryVertexingSpec.cxx | 65 +++++++++++-------- .../src/secondary-vertexing-workflow.cxx | 11 ++-- .../include/DetectorsVertexing/SVertexer.h | 12 +++- Detectors/Vertexing/src/SVertexer.cxx | 45 ++++++++++--- 4 files changed, 91 insertions(+), 42 deletions(-) diff --git a/Detectors/GlobalTrackingWorkflow/src/SecondaryVertexingSpec.cxx b/Detectors/GlobalTrackingWorkflow/src/SecondaryVertexingSpec.cxx index c4def304b796d..082ca6286c25f 100644 --- a/Detectors/GlobalTrackingWorkflow/src/SecondaryVertexingSpec.cxx +++ b/Detectors/GlobalTrackingWorkflow/src/SecondaryVertexingSpec.cxx @@ -56,7 +56,7 @@ namespace o2d = o2::dataformats; class SecondaryVertexingSpec : public Task { public: - SecondaryVertexingSpec(std::shared_ptr dr, std::shared_ptr gr, bool enabCasc, bool enable3body, bool enableStrangenessTracking, bool useMC) : mDataRequest(dr), mGGCCDBRequest(gr), mEnableCascades(enabCasc), mEnable3BodyVertices(enable3body), mEnableStrangenessTracking(enableStrangenessTracking), mUseMC(useMC) {} + SecondaryVertexingSpec(std::shared_ptr dr, std::shared_ptr gr, GTrackID::mask_t src, bool enabCasc, bool enable3body, bool enableStrangenessTracking, bool useMC) : mDataRequest(dr), mGGCCDBRequest(gr), mSrc(src), mEnableCascades(enabCasc), mEnable3BodyVertices(enable3body), mEnableStrangenessTracking(enableStrangenessTracking), mUseMC(useMC) {} ~SecondaryVertexingSpec() override = default; void init(InitContext& ic) final; void run(ProcessingContext& pc) final; @@ -69,6 +69,7 @@ class SecondaryVertexingSpec : public Task std::shared_ptr mGGCCDBRequest; o2::tpc::VDriftHelper mTPCVDriftHelper{}; o2::tpc::CorrectionMapsLoader mTPCCorrMapsLoader{}; + GTrackID::mask_t mSrc{}; bool mEnableCascades = false; bool mEnable3BodyVertices = false; bool mEnableStrangenessTracking = false; @@ -96,7 +97,9 @@ void SecondaryVertexingSpec::init(InitContext& ic) mStrTracker.setMCTruthOn(mUseMC); mVertexer.setStrangenessTracker(&mStrTracker); } - mTPCCorrMapsLoader.init(ic); + if (mSrc[GTrackID::TPC]) { + mTPCCorrMapsLoader.init(ic); + } } void SecondaryVertexingSpec::run(ProcessingContext& pc) @@ -151,8 +154,10 @@ void SecondaryVertexingSpec::finaliseCCDB(ConcreteDataMatcher& matcher, void* ob void SecondaryVertexingSpec::updateTimeDependentParams(ProcessingContext& pc) { o2::base::GRPGeomHelper::instance().checkUpdates(pc); - mTPCVDriftHelper.extractCCDBInputs(pc); - mTPCCorrMapsLoader.extractCCDBInputs(pc); + if (mSrc[GTrackID::TPC]) { + mTPCVDriftHelper.extractCCDBInputs(pc); + mTPCCorrMapsLoader.extractCCDBInputs(pc); + } static bool initOnceDone = false; if (!initOnceDone) { // this params need to be queried only once initOnceDone = true; @@ -166,23 +171,25 @@ void SecondaryVertexingSpec::updateTimeDependentParams(ProcessingContext& pc) } } // we may have other params which need to be queried regularly - bool updateMaps = false; - if (mTPCCorrMapsLoader.isUpdated()) { - mVertexer.setTPCCorrMaps(&mTPCCorrMapsLoader); - mTPCCorrMapsLoader.acknowledgeUpdate(); - updateMaps = true; - } - if (mTPCVDriftHelper.isUpdated()) { - LOGP(info, "Updating TPC fast transform map with new VDrift factor of {} wrt reference {} and DriftTimeOffset correction {} wrt {} from source {}", - mTPCVDriftHelper.getVDriftObject().corrFact, mTPCVDriftHelper.getVDriftObject().refVDrift, - mTPCVDriftHelper.getVDriftObject().timeOffsetCorr, mTPCVDriftHelper.getVDriftObject().refTimeOffset, - mTPCVDriftHelper.getSourceName()); - mVertexer.setTPCVDrift(mTPCVDriftHelper.getVDriftObject()); - mTPCVDriftHelper.acknowledgeUpdate(); - updateMaps = true; - } - if (updateMaps) { - mTPCCorrMapsLoader.updateVDrift(mTPCVDriftHelper.getVDriftObject().corrFact, mTPCVDriftHelper.getVDriftObject().refVDrift, mTPCVDriftHelper.getVDriftObject().getTimeOffset()); + if (mSrc[GTrackID::TPC]) { + bool updateMaps = false; + if (mTPCCorrMapsLoader.isUpdated()) { + mVertexer.setTPCCorrMaps(&mTPCCorrMapsLoader); + mTPCCorrMapsLoader.acknowledgeUpdate(); + updateMaps = true; + } + if (mTPCVDriftHelper.isUpdated()) { + LOGP(info, "Updating TPC fast transform map with new VDrift factor of {} wrt reference {} and DriftTimeOffset correction {} wrt {} from source {}", + mTPCVDriftHelper.getVDriftObject().corrFact, mTPCVDriftHelper.getVDriftObject().refVDrift, + mTPCVDriftHelper.getVDriftObject().timeOffsetCorr, mTPCVDriftHelper.getVDriftObject().refTimeOffset, + mTPCVDriftHelper.getSourceName()); + mVertexer.setTPCVDrift(mTPCVDriftHelper.getVDriftObject()); + mTPCVDriftHelper.acknowledgeUpdate(); + updateMaps = true; + } + if (updateMaps) { + mTPCCorrMapsLoader.updateVDrift(mTPCVDriftHelper.getVDriftObject().corrFact, mTPCVDriftHelper.getVDriftObject().refVDrift, mTPCVDriftHelper.getVDriftObject().getTimeOffset()); + } } if (mEnableStrangenessTracking) { if (o2::base::Propagator::Instance()->getNominalBz() != mStrTracker.getBz()) { @@ -203,7 +210,12 @@ DataProcessorSpec getSecondaryVertexingSpec(GTrackID::mask_t src, bool enableCas auto dataRequest = std::make_shared(); GTrackID::mask_t srcClus{}; if (enableStrangenesTracking) { - src |= (srcClus = GTrackID::getSourceMask(GTrackID::Source::ITS)); + src |= (srcClus = GTrackID::getSourceMask(GTrackID::ITS)); + } + if (src[GTrackID::TPC]) { + srcClus |= GTrackID::getSourceMask(GTrackID::TPC); + } + if (srcClus.any()) { dataRequest->requestClusters(srcClus, useMC); } dataRequest->requestTracks(src, useMC); @@ -217,9 +229,10 @@ DataProcessorSpec getSecondaryVertexingSpec(GTrackID::mask_t src, bool enableCas enableStrangenesTracking ? o2::base::GRPGeomRequest::Aligned : o2::base::GRPGeomRequest::None, // geometry dataRequest->inputs, true); - o2::tpc::VDriftHelper::requestCCDBInputs(dataRequest->inputs); - o2::tpc::CorrectionMapsLoader::requestCCDBInputs(dataRequest->inputs, opts, lumiType); - + if (src[GTrackID::TPC]) { + o2::tpc::VDriftHelper::requestCCDBInputs(dataRequest->inputs); + o2::tpc::CorrectionMapsLoader::requestCCDBInputs(dataRequest->inputs, opts, lumiType); + } outputs.emplace_back("GLO", "V0S_IDX", 0, Lifetime::Timeframe); // found V0s indices outputs.emplace_back("GLO", "V0S", 0, Lifetime::Timeframe); // found V0s outputs.emplace_back("GLO", "PVTX_V0REFS", 0, Lifetime::Timeframe); // prim.vertex -> V0s refs @@ -245,7 +258,7 @@ DataProcessorSpec getSecondaryVertexingSpec(GTrackID::mask_t src, bool enableCas "secondary-vertexing", dataRequest->inputs, outputs, - AlgorithmSpec{adaptFromTask(dataRequest, ggRequest, enableCasc, enable3body, enableStrangenesTracking, useMC)}, + AlgorithmSpec{adaptFromTask(dataRequest, ggRequest, src, enableCasc, enable3body, enableStrangenesTracking, useMC)}, opts}; } diff --git a/Detectors/GlobalTrackingWorkflow/src/secondary-vertexing-workflow.cxx b/Detectors/GlobalTrackingWorkflow/src/secondary-vertexing-workflow.cxx index f88776fd5cfa5..ffb71129a6ecd 100644 --- a/Detectors/GlobalTrackingWorkflow/src/secondary-vertexing-workflow.cxx +++ b/Detectors/GlobalTrackingWorkflow/src/secondary-vertexing-workflow.cxx @@ -80,20 +80,23 @@ WorkflowSpec defineDataProcessing(ConfigContext const& configcontext) auto disableRootOut = configcontext.options().get("disable-root-output"); auto enableCasc = !configcontext.options().get("disable-cascade-finder"); auto enable3body = !configcontext.options().get("disable-3body-finder"); - auto enagleStrTr = !configcontext.options().get("disable-strangeness-tracker"); + auto enableStrTr = !configcontext.options().get("disable-strangeness-tracker"); auto lumiType = configcontext.options().get("lumi-type"); GID::mask_t src = allowedSources & GID::getSourcesMask(configcontext.options().get("vertexing-sources")); GID::mask_t dummy, srcClus = GID::includesDet(DetID::TOF, src) ? GID::getSourceMask(GID::TOF) : dummy; // eventually, TPC clusters will be needed for refit - if (enagleStrTr) { + if (enableStrTr) { srcClus |= GID::getSourceMask(GID::ITS); } + if (src[GID::TPC]) { + srcClus |= GID::getSourceMask(GID::TPC); + } if (lumiType == 1) { src = src | GID::getSourcesMask("CTP"); } WorkflowSpec specs; - specs.emplace_back(o2::vertexing::getSecondaryVertexingSpec(src, enableCasc, enable3body, enagleStrTr, useMC, lumiType)); + specs.emplace_back(o2::vertexing::getSecondaryVertexingSpec(src, enableCasc, enable3body, enableStrTr, useMC, lumiType)); // only TOF clusters are needed if TOF is involved, no clusters MC needed WorkflowSpec inputspecs; @@ -118,7 +121,7 @@ WorkflowSpec defineDataProcessing(ConfigContext const& configcontext) if (!disableRootOut) { specs.emplace_back(o2::vertexing::getSecondaryVertexWriterSpec()); - if (enagleStrTr) { + if (enableStrTr) { specs.emplace_back(o2::strangeness_tracking::getStrangenessTrackingWriterSpec(useMC)); } } diff --git a/Detectors/Vertexing/include/DetectorsVertexing/SVertexer.h b/Detectors/Vertexing/include/DetectorsVertexing/SVertexer.h index ba86fe4474f3d..6439831ad991a 100644 --- a/Detectors/Vertexing/include/DetectorsVertexing/SVertexer.h +++ b/Detectors/Vertexing/include/DetectorsVertexing/SVertexer.h @@ -26,6 +26,7 @@ #include "ReconstructionDataFormats/VtxTrackIndex.h" #include "ReconstructionDataFormats/VtxTrackRef.h" #include "CommonDataFormat/RangeReference.h" +#include "DataFormatsTPC/ClusterNativeHelper.h" #include "DCAFitter/DCAFitterN.h" #include "DetectorsVertexing/SVertexerParams.h" #include "DetectorsVertexing/SVertexHypothesis.h" @@ -131,11 +132,11 @@ class SVertexer } void setTPCVDrift(const o2::tpc::VDriftCorrFact& v); void setTPCCorrMaps(o2::gpu::CorrectionMapsHelper* maph); - void initTPCTransform(); void setStrangenessTracker(o2::strangeness_tracking::StrangenessTracker* tracker) { mStrTracker = tracker; } o2::strangeness_tracking::StrangenessTracker* getStrangenessTracker() { return mStrTracker; } std::array getNFitterCalls() const; + void setSources(GIndex::mask_t src) { mSrc = src; } private: template @@ -148,14 +149,19 @@ class SVertexer void updateTimeDependentParams(); bool acceptTrack(GIndex gid, const o2::track::TrackParCov& trc) const; bool processTPCTrack(const o2::tpc::TrackTPC& trTPC, GIndex gid, int vtxid); - float correctTPCTrack(o2::track::TrackParCov& trc, const o2::tpc::TrackTPC tTPC, float tmus, float tmusErr) const; + float correctTPCTrack(TrackCand& trc, const o2::tpc::TrackTPC& tTPC, float tmus, float tmusErr) const; uint64_t getPairIdx(GIndex id1, GIndex id2) const { return (uint64_t(id1) << 32) | id2; } + const o2::globaltracking::RecoContainer* mRecoCont = nullptr; + GIndex::mask_t mSrc{}; - // at the moment not used + const o2::tpc::ClusterNativeAccess* mTPCClusterIdxStruct = nullptr; ///< struct holding the TPC cluster indices + gsl::span mTPCTracksArray; ///< input TPC tracks span + gsl::span mTPCTrackClusIdx; ///< input TPC track cluster indices span + gsl::span mTPCRefitterShMap; ///< externally set TPC clusters sharing map o2::gpu::CorrectionMapsHelper* mTPCCorrMapsHelper = nullptr; std::unique_ptr mTPCRefitter; ///< TPC refitter used for TPC tracks refit during the reconstruction o2::strangeness_tracking::StrangenessTracker* mStrTracker = nullptr; diff --git a/Detectors/Vertexing/src/SVertexer.cxx b/Detectors/Vertexing/src/SVertexer.cxx index df14b282773f8..14b4b93224e72 100644 --- a/Detectors/Vertexing/src/SVertexer.cxx +++ b/Detectors/Vertexing/src/SVertexer.cxx @@ -16,11 +16,13 @@ #include "DetectorsVertexing/SVertexer.h" #include "DetectorsBase/Propagator.h" #include "TPCReconstruction/TPCFastTransformHelperO2.h" +#include "DataFormatsTPC/WorkflowHelper.h" #include "DataFormatsTPC/VDriftCorrFact.h" #include "CorrectionMapsHelper.h" #include "Framework/ProcessingContext.h" #include "Framework/DataProcessorSpec.h" #include "ReconstructionDataFormats/StrangeTrack.h" +#include "CommonConstants/GeomConstants.h" #ifdef WITH_OPENMP #include @@ -38,6 +40,7 @@ using TrackTPC = o2::tpc::TrackTPC; //__________________________________________________________________ void SVertexer::process(const o2::globaltracking::RecoContainer& recoData, o2::framework::ProcessingContext& pc) { + mRecoCont = &recoData; mNV0s = mNCascades = mN3Bodies = 0; updateTimeDependentParams(); // TODO RS: strictly speaking, one should do this only in case of the CCDB objects update mPVertices = recoData.getPrimaryVertices(); @@ -313,8 +316,6 @@ void SVertexer::setTPCVDrift(const o2::tpc::VDriftCorrFact& v) void SVertexer::setTPCCorrMaps(o2::gpu::CorrectionMapsHelper* maph) { mTPCCorrMapsHelper = maph; - // to be used with refitter as - // mTPCRefitter = std::make_unique(mTPCClusterIdxStruct, mTPCCorrMapsHelper, mBz, mTPCTrackClusIdx.data(), mTPCRefitterShMap.data(), nullptr, o2::base::Propagator::Instance()); } //__________________________________________________________________ @@ -428,6 +429,13 @@ void SVertexer::buildT2V(const o2::globaltracking::RecoContainer& recoData) // a auto trackIndex = recoData.getPrimaryVertexMatchedTracks(); // Global ID's for associated tracks auto vtxRefs = recoData.getPrimaryVertexMatchedTrackRefs(); // references from vertex to these track IDs bool isTPCloaded = recoData.isTrackSourceLoaded(GIndex::TPC); + if (isTPCloaded && !mSVParams->mExcludeTPCtracks) { + mTPCTracksArray = recoData.getTPCTracks(); + mTPCTrackClusIdx = recoData.getTPCTracksClusterRefs(); + mTPCClusterIdxStruct = &recoData.inputsTPCclusters->clusterIndex; + mTPCRefitterShMap = recoData.clusterShMapTPC; + mTPCRefitter = std::make_unique(mTPCClusterIdxStruct, mTPCCorrMapsHelper, o2::base::Propagator::Instance()->getNominalBz(), mTPCTrackClusIdx.data(), mTPCRefitterShMap.data(), nullptr, o2::base::Propagator::Instance()); + } std::unordered_map> tmap; std::unordered_map rejmap; @@ -451,7 +459,7 @@ void SVertexer::buildT2V(const o2::globaltracking::RecoContainer& recoData) // a } // unconstrained TPC tracks require special treatment: there is no point in checking DCA to mean vertex since it is not precise, // but we need to create a clone of TPC track constrained to this particular vertex time. - if (processTPCTrack(recoData.getTPCTrack(tvid), tvid, iv)) { + if (processTPCTrack(mTPCTracksArray[tvid], tvid, iv)) { continue; } } @@ -489,6 +497,9 @@ void SVertexer::buildT2V(const o2::globaltracking::RecoContainer& recoData) // a int posneg = trc.getSign() < 0 ? 1 : 0; float r = std::sqrt(trc.getX() * trc.getX() + trc.getY() * trc.getY()); mTracksPool[posneg].emplace_back(TrackCand{trc, tvid, {iv, iv}, r}); + if (tvid.getSource() == GIndex::TPC) { // constrained TPC track? + correctTPCTrack(mTracksPool[posneg].back(), mTPCTracksArray[tvid], -1, -1); + } if (tvid.isAmbiguous()) { // track attached to >1 vertex, remember that it was already processed tmap[tvid] = {mTracksPool[posneg].size() - 1, posneg}; } @@ -1130,24 +1141,40 @@ bool SVertexer::processTPCTrack(const o2::tpc::TrackTPC& trTPC, GIndex gid, int if (err < 0) { mTracksPool[posneg].pop_back(); // discard } - trLoc.minR = std::sqrt(trLoc.getX() * trLoc.getX() + trLoc.getY() * trLoc.getY()); return true; } //______________________________________________ -float SVertexer::correctTPCTrack(o2::track::TrackParCov& trc, const o2::tpc::TrackTPC tTPC, float tmus, float tmusErr) const +float SVertexer::correctTPCTrack(SVertexer::TrackCand& trc, const o2::tpc::TrackTPC& tTPC, float tmus, float tmusErr) const { // Correct the track copy trc of the TPC track for the assumed interaction time // return extra uncertainty in Z due to the interaction time uncertainty // TODO: at the moment, apply simple shift, but with Z-dependent calibration we may // need to do corrections on TPC cluster level and refit - // This is a clone of MatchTPCITS::correctTPCTrack - float dDrift = (tmus * mMUS2TPCBin - tTPC.getTime0()) * mTPCBin2Z; - float driftErr = tmusErr * mMUS2TPCBin * mTPCBin2Z; + // This is almosto clone of the MatchTPCITS::correctTPCTrack + + float tTB, tTBErr; + if (tmusErr < 0) { // use track data + tTB = tTPC.getTime0(); + tTBErr = 0.5 * (tTPC.getDeltaTBwd() + tTPC.getDeltaTFwd()); + } else { + tTB = tmus * mMUS2TPCBin; + tTBErr = tmusErr * mMUS2TPCBin; + } + float dDrift = (tTB - tTPC.getTime0()) * mTPCBin2Z; + float driftErr = tTBErr * mTPCBin2Z; // eventually should be refitted, at the moment we simply shift... trc.setZ(tTPC.getZ() + (tTPC.hasASideClustersOnly() ? dDrift : -dDrift)); trc.setCov(trc.getSigmaZ2() + driftErr * driftErr, o2::track::kSigZ2); - + uint8_t sector, row; + auto cl = &tTPC.getCluster(mTPCTrackClusIdx, tTPC.getNClusters() - 1, *mTPCClusterIdxStruct, sector, row); + float x = 0, y = 0, z = 0; + mTPCCorrMapsHelper->Transform(sector, row, cl->getPad(), cl->getTime(), x, y, z, tTB); + if (x < o2::constants::geom::XTPCInnerRef) { + x = o2::constants::geom::XTPCInnerRef; + } + trc.minR = std::sqrt(x * x + y * y); + LOGP(debug, "set MinR = {} for row {}, x:{}, y:{}, z:{}", trc.minR, row, x, y, z); return driftErr; }