diff --git a/Detectors/Vertexing/include/DetectorsVertexing/PVertexer.h b/Detectors/Vertexing/include/DetectorsVertexing/PVertexer.h index ad5ec5684bf2e..cff2a748206bc 100644 --- a/Detectors/Vertexing/include/DetectorsVertexing/PVertexer.h +++ b/Detectors/Vertexing/include/DetectorsVertexing/PVertexer.h @@ -56,6 +56,11 @@ class PVertexer int process(gsl::span tracksITSTPC, gsl::span ft0Data, std::vector& vertices, std::vector& vertexTrackIDs, std::vector& v2tRefs); + /// Process function specific for ALICE3 + int process(gsl::span tracks, + std::vector& vertices, + std::vector& vertexTrackIDs, + std::vector& v2tRefs); static void createMCLabels(gsl::span lblITS, gsl::span lblTPC, const std::vector vertices, const std::vector vertexTrackIDs, const std::vector v2tRefs, @@ -107,6 +112,8 @@ class PVertexer void applyConstraint(VertexSeed& vtxSeed) const; bool upscaleSigma(VertexSeed& vtxSeed) const; void createTracksPool(gsl::span tracksITSTPC); + /// Function specific for ALICE3 + void createTracksPool(gsl::span tracks); int findVertices(const VertexingInput& input, std::vector& vertices, std::vector& vertexTrackIDs, std::vector& v2tRefs); std::pair getBestFT0Trigger(const PVertex& vtx, gsl::span ft0Data, int& currEntry) const; @@ -121,13 +128,13 @@ class PVertexer // o2::math_utils::StatAccumulator mStatZErr; o2::math_utils::StatAccumulator mStatTErr; - std::vector mTracksPool; ///< tracks in internal representation used for vertexing - std::vector mSortedTrackID; ///< indices of tracks sorted in time + std::vector mTracksPool; ///< tracks in internal representation used for vertexing + std::vector mSortedTrackID; ///< indices of tracks sorted in time std::vector mTimeZClusters; ///< set of time clusters std::vector mClusterTrackIDs; ///< IDs of tracks making the clusters - float mBz = 0.; ///< mag.field at beam line - bool mValidateWithFT0 = false; ///< require vertex validation with FT0 (if available) + float mBz = 0.; ///< mag.field at beam line + bool mValidateWithFT0 = false; ///< require vertex validation with FT0 (if available) o2::InteractionRecord mStartIR{0, 0}; ///< IR corresponding to the start of the TF diff --git a/Detectors/Vertexing/src/PVertexer.cxx b/Detectors/Vertexing/src/PVertexer.cxx index ee2bc321e868e..1a47d1b27ac30 100644 --- a/Detectors/Vertexing/src/PVertexer.cxx +++ b/Detectors/Vertexing/src/PVertexer.cxx @@ -27,6 +27,64 @@ constexpr float PVertexer::kAlmost0F; constexpr double PVertexer::kAlmost0D; constexpr float PVertexer::kHugeF; +//___________________________________________________________________ +int PVertexer::process(gsl::span tracks, + std::vector& vertices, + std::vector& vertexTrackIDs, + std::vector& v2tRefs) +{ + Printf("Processing the vertexing on ALICE3"); + createTracksPool(tracks); + dbscan_clusterize(); + + std::vector verticesLoc; + std::vector vertexTrackIDsLoc; + std::vector v2tRefsLoc; + std::vector validationTimes; + + for (auto tc : mTimeZClusters) { + VertexingInput inp; + // inp.idRange = gsl::span((int*)&mSortedTrackID[tc.first], tc.count); + inp.idRange = gsl::span((int*)&mClusterTrackIDs[tc.first], tc.count); + inp.scaleSigma2 = 3. * estimateScale2(); + inp.timeEst = tc.timeEst; + findVertices(inp, verticesLoc, vertexTrackIDsLoc, v2tRefsLoc); + } + + // sort in time + std::vector vtTimeSortID(verticesLoc.size()); + std::iota(vtTimeSortID.begin(), vtTimeSortID.end(), 0); + std::sort(vtTimeSortID.begin(), vtTimeSortID.end(), [&verticesLoc](int i, int j) { + return verticesLoc[i].getTimeStamp().getTimeStamp() < verticesLoc[j].getTimeStamp().getTimeStamp(); + }); + + vertices.clear(); + v2tRefs.clear(); + vertexTrackIDs.clear(); + vertices.reserve(verticesLoc.size()); + v2tRefs.reserve(v2tRefsLoc.size()); + vertexTrackIDs.reserve(vertexTrackIDsLoc.size()); + + int trCopied = 0, count = 0, vtimeID = 0; + for (auto i : vtTimeSortID) { + auto& vtx = verticesLoc[i]; + + bool irSet = setCompatibleIR(vtx); + if (!irSet) { + continue; + } + vertices.push_back(vtx); + int it = v2tRefsLoc[i].getFirstEntry(), itEnd = it + v2tRefsLoc[i].getEntries(), dest0 = vertexTrackIDs.size(); + for (; it < itEnd; it++) { + auto& gid = vertexTrackIDs.emplace_back(vertexTrackIDsLoc[it]); + gid.setPVContributor(); + } + v2tRefs.emplace_back(dest0, v2tRefsLoc[i].getEntries()); + LOG(DEBUG) << "#" << count++ << " " << vertices.back() << " | " << v2tRefs.back().getEntries() << " indices from " << v2tRefs.back().getFirstEntry(); // RS REM + } + + return vertices.size(); +} //___________________________________________________________________ int PVertexer::process(gsl::span tracksITSTPC, gsl::span ft0Data, std::vector& vertices, std::vector& vertexTrackIDs, std::vector& v2tRefs) @@ -468,7 +526,7 @@ void PVertexer::createTracksPool(gsl::span tracksITSTPC) mTracksPool.reserve(ntGlo); // check all containers float vtxErr2 = 0.5 * (mMeanVertex.getSigmaX2() + mMeanVertex.getSigmaY2()); - float pullIniCut = 9.; // RS FIXME pullIniCut should be a parameter + float pullIniCut = 9.; // RS FIXME pullIniCut should be a parameter o2d::DCA dca; for (uint32_t i = 0; i < ntGlo; i++) { @@ -501,6 +559,52 @@ void PVertexer::createTracksPool(gsl::span tracksITSTPC) auto tMax = mTracksPool[mSortedTrackID.back()].timeEst.getTimeStamp(); } +//___________________________________________________________________ +void PVertexer::createTracksPool(gsl::span tracks) +{ + Printf("Creating a pool of tracks for ALICE3!"); + // create pull of all candidate tracks in a global array ordered in time + mTracksPool.clear(); + mSortedTrackID.clear(); + + auto ntGlo = tracks.size(); + mTracksPool.reserve(ntGlo); + // check all containers + float vtxErr2 = 0.5 * (mMeanVertex.getSigmaX2() + mMeanVertex.getSigmaY2()); + float pullIniCut = 9.; // RS FIXME pullIniCut should be a parameter + o2d::DCA dca; + + for (uint32_t i = 0; i < ntGlo; i++) { + o2::track::TrackParCov trc = tracks[i]; + if (!trc.propagateToDCA(mMeanVertex, mBz, &dca, mPVParams->dcaTolerance) || + dca.getY() * dca.getY() / (dca.getSigmaY2() + vtxErr2) > mPVParams->pullIniCut) { + continue; + } + auto& tvf = mTracksPool.emplace_back(trc, TimeEst{0.f, 1.f}, GTrackID{i, o2::dataformats::GlobalTrackID::ITS}); + mStatZErr.add(std::sqrt(trc.getSigmaZ2())); + mStatTErr.add(tvf.timeEst.getTimeStampError()); + } + // TODO: try to narrow timestamps using tof times + auto [zerrMean, zerrRMS] = mStatZErr.getMeanRMS2(); + + auto [terrMean, terrRMS] = mStatTErr.getMeanRMS2(); + + if (mTracksPool.empty()) { + Printf("Empty pool!"); + return; + } + // + mSortedTrackID.resize(mTracksPool.size()); + std::iota(mSortedTrackID.begin(), mSortedTrackID.end(), 0); + + std::sort(mSortedTrackID.begin(), mSortedTrackID.end(), [this](int i, int j) { + return this->mTracksPool[i].timeEst.getTimeStamp() < this->mTracksPool[j].timeEst.getTimeStamp(); + }); + + auto tMin = mTracksPool[mSortedTrackID.front()].timeEst.getTimeStamp(); + auto tMax = mTracksPool[mSortedTrackID.back()].timeEst.getTimeStamp(); +} + //___________________________________________________________________ void PVertexer::createMCLabels(gsl::span lblITS, gsl::span lblTPC, const std::vector vertices, const std::vector vertexTrackIDs, const std::vector v2tRefs,