Skip to content

Commit

Permalink
fixup!
Browse files Browse the repository at this point in the history
  • Loading branch information
f3sch committed Oct 24, 2023
1 parent ae692e5 commit ee1d248
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 68 deletions.
1 change: 1 addition & 0 deletions Detectors/Vertexing/include/DetectorsVertexing/SVertexer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
140 changes: 72 additions & 68 deletions Detectors/Vertexing/src/SVertexer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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<std::vector<V0Index>>(o2f::Output{"GLO", "V0S_IDX", 0, o2f::Lifetime::Timeframe});
auto& cascsIdx = pc.outputs().make<std::vector<CascadeIndex>>(o2f::Output{"GLO", "CASCS_IDX", 0, o2f::Lifetime::Timeframe});
auto& body3Idx = pc.outputs().make<std::vector<Decay3BodyIndex>>(o2f::Output{"GLO", "DECAYS3BODY_IDX", 0, o2f::Lifetime::Timeframe});
Expand Down Expand Up @@ -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();
Expand All @@ -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)
{
Expand Down Expand Up @@ -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<float, 3> pP, pN;
trPProp.getPxPyPzGlo(pP);
trNProp.getPxPyPzGlo(pN);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions dependencies/O2Dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down

0 comments on commit ee1d248

Please sign in to comment.