From ee1d248ba908a6ee444f7ab239bbec50ce533bfb Mon Sep 17 00:00:00 2001 From: Felix Schlepper Date: Tue, 24 Oct 2023 15:30:32 +0200 Subject: [PATCH] fixup! --- .../include/DetectorsVertexing/SVertexer.h | 1 + Detectors/Vertexing/src/SVertexer.cxx | 140 +++++++++--------- dependencies/O2Dependencies.cmake | 8 + 3 files changed, 81 insertions(+), 68 deletions(-) diff --git a/Detectors/Vertexing/include/DetectorsVertexing/SVertexer.h b/Detectors/Vertexing/include/DetectorsVertexing/SVertexer.h index 2e0e2490ebdd8..e325004d93bdd 100644 --- a/Detectors/Vertexing/include/DetectorsVertexing/SVertexer.h +++ b/Detectors/Vertexing/include/DetectorsVertexing/SVertexer.h @@ -106,6 +106,7 @@ class SVertexer void setEnable3BodyDecays(bool v) { mEnable3BodyDecays = v; } void init(); void process(const o2::globaltracking::RecoContainer& recoTracks, o2::framework::ProcessingContext& pc); + void produceOutput(o2::framework::ProcessingContext& pc); int getNV0s() const { return mNV0s; } int getNCascades() const { return mNCascades; } int getN3Bodies() const { return mN3Bodies; } diff --git a/Detectors/Vertexing/src/SVertexer.cxx b/Detectors/Vertexing/src/SVertexer.cxx index 0efb6965f7872..8d535c979c515 100644 --- a/Detectors/Vertexing/src/SVertexer.cxx +++ b/Detectors/Vertexing/src/SVertexer.cxx @@ -47,13 +47,13 @@ void SVertexer::process(const o2::globaltracking::RecoContainer& recoData, o2::f mStrTracker->loadData(recoData); mStrTracker->prepareITStracks(); } -#ifdef WITH_OPENMP - int dynGrp = std::min(4, std::max(1, mNThreads / 2)); -#pragma omp parallel for schedule(dynamic, dynGrp) num_threads(mNThreads) -#endif + + int iThread = 0; +#pragma omp parallel for schedule(dynamic, std::min(4, std::max(1, mNThreads / 2))) \ + num_threads(mNThreads) if (mNThreads > 1) private(iThread) for (int itp = 0; itp < ntrP; itp++) { auto& seedP = mTracksPool[POS][itp]; - int firstN = mVtxFirstTrack[NEG][seedP.vBracket.getMin()]; + const int firstN = mVtxFirstTrack[NEG][seedP.vBracket.getMin()]; if (firstN < 0) { LOG(debug) << "No partner is found for pos.track " << itp << " out of " << ntrP; continue; @@ -68,14 +68,72 @@ void SVertexer::process(const o2::globaltracking::RecoContainer& recoData, o2::f continue; } #ifdef WITH_OPENMP - int iThread = omp_get_thread_num(); -#else - int iThread = 0; + iThread = omp_get_thread_num(); #endif checkV0(seedP, seedN, itp, itn, iThread); } } + produceOutput(pc); +} + +//__________________________________________________________________ +void SVertexer::init() +{ +} + +//__________________________________________________________________ +void SVertexer::updateTimeDependentParams() +{ + // TODO RS: strictly speaking, one should do this only in case of the CCDB objects update + static bool updatedOnce = false; + if (!updatedOnce) { + updatedOnce = true; + mSVParams = &SVertexerParams::Instance(); + // precalculated selection cuts + mMinR2ToMeanVertex = mSVParams->minRToMeanVertex * mSVParams->minRToMeanVertex; + mMaxR2ToMeanVertexCascV0 = mSVParams->maxRToMeanVertexCascV0 * mSVParams->maxRToMeanVertexCascV0; + mMaxDCAXY2ToMeanVertex = mSVParams->maxDCAXYToMeanVertex * mSVParams->maxDCAXYToMeanVertex; + mMaxDCAXY2ToMeanVertexV0Casc = mSVParams->maxDCAXYToMeanVertexV0Casc * mSVParams->maxDCAXYToMeanVertexV0Casc; + mMaxDCAXY2ToMeanVertex3bodyV0 = mSVParams->maxDCAXYToMeanVertex3bodyV0 * mSVParams->maxDCAXYToMeanVertex3bodyV0; + mMinR2DiffV0Casc = mSVParams->minRDiffV0Casc * mSVParams->minRDiffV0Casc; + mMinPt2V0 = mSVParams->minPtV0 * mSVParams->minPtV0; + mMaxTgl2V0 = mSVParams->maxTglV0 * mSVParams->maxTglV0; + mMinPt2Casc = mSVParams->minPtCasc * mSVParams->minPtCasc; + mMaxTgl2Casc = mSVParams->maxTglCasc * mSVParams->maxTglCasc; + mMinPt23Body = mSVParams->minPt3Body * mSVParams->minPt3Body; + mMaxTgl23Body = mSVParams->maxTgl3Body * mSVParams->maxTgl3Body; + setupThreads(); + } + auto bz = o2::base::Propagator::Instance()->getNominalBz(); + mV0Hyps[HypV0::Photon].set(PID::Photon, PID::Electron, PID::Electron, mSVParams->pidCutsPhoton, bz); + mV0Hyps[HypV0::K0].set(PID::K0, PID::Pion, PID::Pion, mSVParams->pidCutsK0, bz); + mV0Hyps[HypV0::Lambda].set(PID::Lambda, PID::Proton, PID::Pion, mSVParams->pidCutsLambda, bz); + mV0Hyps[HypV0::AntiLambda].set(PID::Lambda, PID::Pion, PID::Proton, mSVParams->pidCutsLambda, bz); + mV0Hyps[HypV0::HyperTriton].set(PID::HyperTriton, PID::Helium3, PID::Pion, mSVParams->pidCutsHTriton, bz); + mV0Hyps[HypV0::AntiHyperTriton].set(PID::HyperTriton, PID::Pion, PID::Helium3, mSVParams->pidCutsHTriton, bz); + mV0Hyps[HypV0::Hyperhydrog4].set(PID::Hyperhydrog4, PID::Alpha, PID::Pion, mSVParams->pidCutsHhydrog4, bz); + mV0Hyps[HypV0::AntiHyperhydrog4].set(PID::Hyperhydrog4, PID::Pion, PID::Alpha, mSVParams->pidCutsHhydrog4, bz); + mCascHyps[HypCascade::XiMinus].set(PID::XiMinus, PID::Lambda, PID::Pion, mSVParams->pidCutsXiMinus, bz); + mCascHyps[HypCascade::OmegaMinus].set(PID::OmegaMinus, PID::Lambda, PID::Kaon, mSVParams->pidCutsOmegaMinus, bz); + + m3bodyHyps[Hyp3body::H3L3body].set(PID::HyperTriton, PID::Proton, PID::Pion, PID::Deuteron, mSVParams->pidCutsH3L3body, bz); + m3bodyHyps[Hyp3body::AntiH3L3body].set(PID::HyperTriton, PID::Pion, PID::Proton, PID::Deuteron, mSVParams->pidCutsH3L3body, bz); + + for (auto& ft : mFitterV0) { + ft.setBz(bz); + } + for (auto& ft : mFitterCasc) { + ft.setBz(bz); + } + for (auto& ft : mFitter3body) { + ft.setBz(bz); + } +} + +//__________________________________________________________________ +void SVertexer::produceOutput(o2::framework::ProcessingContext& pc) +{ // sort V0s and Cascades in vertex id struct vid { int thrID; @@ -105,8 +163,8 @@ void SVertexer::process(const o2::globaltracking::RecoContainer& recoData, o2::f std::sort(v0SortID.begin(), v0SortID.end(), [](const vid& a, const vid& b) { return a.vtxID < b.vtxID; }); std::sort(cascSortID.begin(), cascSortID.end(), [](const vid& a, const vid& b) { return a.vtxID < b.vtxID; }); std::sort(nbodySortID.begin(), nbodySortID.end(), [](const vid& a, const vid& b) { return a.vtxID < b.vtxID; }); - // sorted V0s + // dpl outpu auto& v0sIdx = pc.outputs().make>(o2f::Output{"GLO", "V0S_IDX", 0, o2f::Lifetime::Timeframe}); auto& cascsIdx = pc.outputs().make>(o2f::Output{"GLO", "CASCS_IDX", 0, o2f::Lifetime::Timeframe}); auto& body3Idx = pc.outputs().make>(o2f::Output{"GLO", "DECAYS3BODY_IDX", 0, o2f::Lifetime::Timeframe}); @@ -233,7 +291,7 @@ void SVertexer::process(const o2::globaltracking::RecoContainer& recoData, o2::f strTrMCLableOut.swap(mcLabsOut); } } - // + for (int ith = 0; ith < mNThreads; ith++) { // clean unneeded s.vertices mV0sTmp[ith].clear(); mCascadesTmp[ith].clear(); @@ -246,60 +304,6 @@ void SVertexer::process(const o2::globaltracking::RecoContainer& recoData, o2::f extractPVReferences(v0sIdx, v0Refs, cascsIdx, cascRefs, body3Idx, vtx3bodyRefs); } -//__________________________________________________________________ -void SVertexer::init() -{ -} - -//__________________________________________________________________ -void SVertexer::updateTimeDependentParams() -{ - // TODO RS: strictly speaking, one should do this only in case of the CCDB objects update - static bool updatedOnce = false; - if (!updatedOnce) { - updatedOnce = true; - mSVParams = &SVertexerParams::Instance(); - // precalculated selection cuts - mMinR2ToMeanVertex = mSVParams->minRToMeanVertex * mSVParams->minRToMeanVertex; - mMaxR2ToMeanVertexCascV0 = mSVParams->maxRToMeanVertexCascV0 * mSVParams->maxRToMeanVertexCascV0; - mMaxDCAXY2ToMeanVertex = mSVParams->maxDCAXYToMeanVertex * mSVParams->maxDCAXYToMeanVertex; - mMaxDCAXY2ToMeanVertexV0Casc = mSVParams->maxDCAXYToMeanVertexV0Casc * mSVParams->maxDCAXYToMeanVertexV0Casc; - mMaxDCAXY2ToMeanVertex3bodyV0 = mSVParams->maxDCAXYToMeanVertex3bodyV0 * mSVParams->maxDCAXYToMeanVertex3bodyV0; - mMinR2DiffV0Casc = mSVParams->minRDiffV0Casc * mSVParams->minRDiffV0Casc; - mMinPt2V0 = mSVParams->minPtV0 * mSVParams->minPtV0; - mMaxTgl2V0 = mSVParams->maxTglV0 * mSVParams->maxTglV0; - mMinPt2Casc = mSVParams->minPtCasc * mSVParams->minPtCasc; - mMaxTgl2Casc = mSVParams->maxTglCasc * mSVParams->maxTglCasc; - mMinPt23Body = mSVParams->minPt3Body * mSVParams->minPt3Body; - mMaxTgl23Body = mSVParams->maxTgl3Body * mSVParams->maxTgl3Body; - setupThreads(); - } - auto bz = o2::base::Propagator::Instance()->getNominalBz(); - mV0Hyps[HypV0::Photon].set(PID::Photon, PID::Electron, PID::Electron, mSVParams->pidCutsPhoton, bz); - mV0Hyps[HypV0::K0].set(PID::K0, PID::Pion, PID::Pion, mSVParams->pidCutsK0, bz); - mV0Hyps[HypV0::Lambda].set(PID::Lambda, PID::Proton, PID::Pion, mSVParams->pidCutsLambda, bz); - mV0Hyps[HypV0::AntiLambda].set(PID::Lambda, PID::Pion, PID::Proton, mSVParams->pidCutsLambda, bz); - mV0Hyps[HypV0::HyperTriton].set(PID::HyperTriton, PID::Helium3, PID::Pion, mSVParams->pidCutsHTriton, bz); - mV0Hyps[HypV0::AntiHyperTriton].set(PID::HyperTriton, PID::Pion, PID::Helium3, mSVParams->pidCutsHTriton, bz); - mV0Hyps[HypV0::Hyperhydrog4].set(PID::Hyperhydrog4, PID::Alpha, PID::Pion, mSVParams->pidCutsHhydrog4, bz); - mV0Hyps[HypV0::AntiHyperhydrog4].set(PID::Hyperhydrog4, PID::Pion, PID::Alpha, mSVParams->pidCutsHhydrog4, bz); - mCascHyps[HypCascade::XiMinus].set(PID::XiMinus, PID::Lambda, PID::Pion, mSVParams->pidCutsXiMinus, bz); - mCascHyps[HypCascade::OmegaMinus].set(PID::OmegaMinus, PID::Lambda, PID::Kaon, mSVParams->pidCutsOmegaMinus, bz); - - m3bodyHyps[Hyp3body::H3L3body].set(PID::HyperTriton, PID::Proton, PID::Pion, PID::Deuteron, mSVParams->pidCutsH3L3body, bz); - m3bodyHyps[Hyp3body::AntiH3L3body].set(PID::HyperTriton, PID::Pion, PID::Proton, PID::Deuteron, mSVParams->pidCutsH3L3body, bz); - - for (auto& ft : mFitterV0) { - ft.setBz(bz); - } - for (auto& ft : mFitterCasc) { - ft.setBz(bz); - } - for (auto& ft : mFitter3body) { - ft.setBz(bz); - } -} - //______________________________________________ void SVertexer::setTPCVDrift(const o2::tpc::VDriftCorrFact& v) { @@ -537,8 +541,8 @@ bool SVertexer::checkV0(const TrackCand& seedP, const TrackCand& seedN, int iP, if (!fitterV0.isPropagateTracksToVertexDone(cand) && !fitterV0.propagateTracksToVertex(cand)) { return false; } - auto& trPProp = fitterV0.getTrack(0, cand); - auto& trNProp = fitterV0.getTrack(1, cand); + const auto& trPProp = fitterV0.getTrack(0, cand); + const auto& trNProp = fitterV0.getTrack(1, cand); std::array pP, pN; trPProp.getPxPyPzGlo(pP); trNProp.getPxPyPzGlo(pN); @@ -581,7 +585,7 @@ bool SVertexer::checkV0(const TrackCand& seedP, const TrackCand& seedN, int iP, // we want to reconstruct the 3 body decay of hypernuclei starting from the V0 of a proton and a pion (e.g. H3L->d + (p + pi-), or He4L->He3 + (p + pi-))) bool checkFor3BodyDecays = mEnable3BodyDecays && (!mSVParams->checkV0Hypothesis || good3bodyV0Hyp) && (pt2V0 > 0.5); bool rejectAfter3BodyCheck = false; // To reject v0s which can be 3-body decay candidates but not cascade or v0 - bool checkForCascade = mEnableCascades && r2v0 < mMaxR2ToMeanVertexCascV0 && (!mSVParams->checkV0Hypothesis || (hypCheckStatus[HypV0::Lambda] || hypCheckStatus[HypV0::AntiLambda])); + bool checkForCascade = mEnableCascades && r2v0 < mMaxR2ToMeanVertexCascV0 && (!mSVParams->checkV0Hypothesis || ((hypCheckStatus[HypV0::Lambda] || hypCheckStatus[HypV0::AntiLambda]) && !hypCheckStatus[HypV0::Photon])); bool rejectIfNotCascade = false; if (!goodHyp && mSVParams->checkV0Hypothesis) { @@ -1121,7 +1125,7 @@ bool SVertexer::processTPCTrack(const o2::tpc::TrackTPC& trTPC, GIndex gid, int auto err = correctTPCTrack(trLoc, trTPC, twe.getTimeStamp(), twe.getTimeStampError()); if (err < 0) { mTracksPool[posneg].pop_back(); // discard - return true; // skip minR calculation to 'invalid' memory (trLoc will probably be still there and not be invalidated but we discarded it) + return true; // skip minR calculation to 'invalid' memory (trLoc will probably be still there and not be invalidated but we discarded it) } trLoc.minR = std::sqrt(trLoc.getX() * trLoc.getX() + trLoc.getY() * trLoc.getY()); return true; diff --git a/dependencies/O2Dependencies.cmake b/dependencies/O2Dependencies.cmake index 4d90d59c9f2be..2ffa6c46a17da 100644 --- a/dependencies/O2Dependencies.cmake +++ b/dependencies/O2Dependencies.cmake @@ -11,6 +11,14 @@ include_guard() +find_program(CCACHE_PROGRAM ccache) +if(CCACHE_PROGRAM) + message(STATUS "Found ccache in ${CCACHE_PROGRAM}") + set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}") +else() + message(STATUS "Not using ccache") +endif() + include("${CMAKE_CURRENT_LIST_DIR}/O2TestsAdapter.cmake") set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR} ${CMAKE_MODULE_PATH})