From f0fa9e41a82da920dd8fd474d67fd2cae54705a8 Mon Sep 17 00:00:00 2001 From: Felix Schlepper Date: Thu, 9 Nov 2023 20:36:32 +0100 Subject: [PATCH] ccccc --- .../include/DetectorsVertexing/SVertexer.h | 26 +++- .../Vertexing/src/DetectorsVertexingLinkDef.h | 3 + Detectors/Vertexing/src/SVertexer.cxx | 52 ++++++- cmake/rootcling_wrapper.sh.in | 143 +++++++++--------- 4 files changed, 143 insertions(+), 81 deletions(-) diff --git a/Detectors/Vertexing/include/DetectorsVertexing/SVertexer.h b/Detectors/Vertexing/include/DetectorsVertexing/SVertexer.h index be427a8f606a2..c642b27b77105 100644 --- a/Detectors/Vertexing/include/DetectorsVertexing/SVertexer.h +++ b/Detectors/Vertexing/include/DetectorsVertexing/SVertexer.h @@ -235,15 +235,20 @@ class SVertexer using key_t = std::tuple; + static size_t make_hash(int src, int eve, int id) + { + size_t seed = 0; + boost::hash_combine(seed, src ^ (0xdeadbeef ^ id)); + boost::hash_combine(seed, eve << id); + boost::hash_combine(seed, id); + return seed; + } + struct key_hash { size_t operator()(const key_t& k) const { - const auto& [eve, src, trkid] = k; - size_t seed = 0; - boost::hash_combine(seed, eve); - boost::hash_combine(seed, src); - boost::hash_combine(seed, trkid); - return seed; + const auto& [src, eve, trkid] = k; + return make_hash(src, eve, trkid); } }; using map_timing_t = std::unordered_map, key_hash>; @@ -251,7 +256,9 @@ class SVertexer using map_after_t = std::unordered_map, key_hash>; using map_mc_t = std::unordered_map, key_hash>; using map_mc_particle_t = std::unordered_map; + using map_discard_t = std::unordered_map; + map_discard_t mDiscardMap; map_mc_t mD0V0Map; map_mc_t mD1V0Map; map_mc_t mMotherV0Map; @@ -832,13 +839,14 @@ class SVertexer return i; } - void inc(Enum e, GIndex const& gid, o2::MCCompLabel const& lbl, map_mc_t const& d0, map_mc_t const& d1, map_mc_particle_t const& mcparticles) + bool inc(Enum e, GIndex const& gid, o2::MCCompLabel const& lbl, map_mc_t const& d0, map_mc_t const& d1, map_mc_particle_t const& mcparticles) { auto c = static_cast(e); auto gidITS = gid.includesDet(o2::detectors::DetID::ITS); auto gidTPC = gid.includesDet(o2::detectors::DetID::TPC); auto gidTRD = gid.includesDet(o2::detectors::DetID::TRD); auto gidTOF = gid.includesDet(o2::detectors::DetID::TOF); + bool isV0 = false; int i = getType(gidITS, gidTPC, gidTRD, gidTOF); ++mCounters[i][c]; ++mTotCounters[c]; @@ -849,7 +857,7 @@ class SVertexer mDupMap[i][c][gid] = true; } if (lbl.isFake() || !lbl.isValid()) { - return; + return false; } auto idx = std::make_tuple(lbl.getSourceID(), lbl.getEventID(), lbl.getTrackID()); auto it0 = d0.find(idx); @@ -857,6 +865,7 @@ class SVertexer auto it0T = it0 != d0.end(); auto it1T = it1 != d1.end(); if (it0T || it1T) { + isV0 = true; ++mCountersV0[i][c]; if (dup) { ++mCountersV0Dup[i][c]; @@ -866,6 +875,7 @@ class SVertexer if (mcgen) { ++mCountersMC[i][c]; } + return isV0; } void incAcceptTrack(Enum e, GIndex const& gid, o2::MCCompLabel const& lbl, map_mc_t const& d0, map_mc_t const& d1, map_mc_particle_t const& mcparticles, utils::TreeStreamRedirector& mDebugStream, o2::track::TrackPar const& trc, bool write = false) diff --git a/Detectors/Vertexing/src/DetectorsVertexingLinkDef.h b/Detectors/Vertexing/src/DetectorsVertexingLinkDef.h index 4530ab6249527..f78225f5bbdb9 100644 --- a/Detectors/Vertexing/src/DetectorsVertexingLinkDef.h +++ b/Detectors/Vertexing/src/DetectorsVertexingLinkDef.h @@ -31,4 +31,7 @@ #pragma link C++ class o2::vertexing::PVtxCompDump + ; #pragma link C++ class std::vector < o2::vertexing::PVtxCompDump> + ; +#pragma link C++ class std::unorderd_map < size_t, int> + ; +#pragma link C++ class std::unorderd_map < int, int> + ; + #endif diff --git a/Detectors/Vertexing/src/SVertexer.cxx b/Detectors/Vertexing/src/SVertexer.cxx index ff06664ac8104..b66effa7c04d2 100644 --- a/Detectors/Vertexing/src/SVertexer.cxx +++ b/Detectors/Vertexing/src/SVertexer.cxx @@ -263,6 +263,9 @@ void SVertexer::process(const o2::globaltracking::RecoContainer& recoData, o2::f mCascadesIdxTmp[ith].clear(); m3bodyIdxTmp[ith].clear(); } + mDebugStream << "discardMap" + << "map=" << mDiscardMap + << "\n"; extractPVReferences(v0sIdx, v0Refs, cascsIdx, cascRefs, body3Idx, vtx3bodyRefs); if (mUseDebug) { @@ -491,15 +494,20 @@ void SVertexer::buildT2V(const o2::globaltracking::RecoContainer& recoData) // a for (; it < itLim; it++) { auto tvid = trackIndex[it]; auto lbl = getLabel(tvid, recoData); - mCounterBuildT2V.inc(BUILDT2V::CALLED, tvid, lbl, mD0V0Map, mD1V0Map, mMCParticle); + bool check = mCounterBuildT2V.inc(BUILDT2V::CALLED, tvid, lbl, mD0V0Map, mD1V0Map, mMCParticle); if (!recoData.isTrackSourceLoaded(tvid.getSource())) { mCounterBuildT2V.inc(BUILDT2V::NOTLOADED, tvid, lbl, mD0V0Map, mD1V0Map, mMCParticle); + if (check) { + mDiscardMap[make_hash(lbl.getSourceID(), lbl.getEventID(), lbl.getTrackID())] = 1 * int(BUILDT2V::NOTLOADED); + } continue; } if (tvid.getSource() == GIndex::TPC) { mCounterBuildT2V.inc(BUILDT2V::TPCTRACK, tvid, lbl, mD0V0Map, mD1V0Map, mMCParticle); if (mSVParams->mExcludeTPCtracks) { mCounterBuildT2V.inc(BUILDT2V::TPCEXCLUDE, tvid, lbl, mD0V0Map, mD1V0Map, mMCParticle); + if (check) + mDiscardMap[make_hash(lbl.getSourceID(), lbl.getEventID(), lbl.getTrackID())] = 1 * int(BUILDT2V::TPCEXCLUDE); continue; } // unconstrained TPC tracks require special treatment: there is no point in checking DCA to mean vertex since it is not precise, @@ -509,6 +517,9 @@ void SVertexer::buildT2V(const o2::globaltracking::RecoContainer& recoData) // a if (status) { mCounterBuildT2V.inc(BUILDT2V::TPCSPROCESS, tvid, lbl, mD0V0Map, mD1V0Map, mMCParticle); ++cTPC; + } else { + if (check) + mDiscardMap[make_hash(lbl.getSourceID(), lbl.getEventID(), lbl.getTrackID())] = 1 * int(BUILDT2V::TPCSPROCESS); } continue; } @@ -615,8 +626,11 @@ bool SVertexer::checkV0(const TrackCand& seedP, const TrackCand& seedN, int iP, // seedN.gid.print(); fitterV0.process(seedP, seedN); fitterV0.unsetDebug(); + mDiscardMap[make_hash(lbl0.getSourceID(), lbl0.getEventID(), lbl0.getTrackID())] = int(CHECKV0::FPROCESS) + 1000; + mDiscardMap[make_hash(lbl1.getSourceID(), lbl1.getEventID(), lbl1.getTrackID())] = int(CHECKV0::FPROCESS) + 1000; } mCounterV0.inc(CHECKV0::FPROCESS, {}, pVtx, pVtxLbl, {}, seedP, seedN, lbl0, lbl1, ok, mD0V0Map, mD1V0Map, mcReader, mDebugStream, check, true, fitterV0.isPropagationFailure(), fitterV0.getNIterations()); + if (mSVParams->ret) { return false; } @@ -627,6 +641,10 @@ bool SVertexer::checkV0(const TrackCand& seedP, const TrackCand& seedN, int iP, const float dxv0 = v0XYZ[0] - mMeanVertex.getX(), dyv0 = v0XYZ[1] - mMeanVertex.getY(), r2v0 = dxv0 * dxv0 + dyv0 * dyv0; if (r2v0 < mMinR2ToMeanVertex) { mCounterV0.inc(CHECKV0::MINR2TOMEANVERTEX, {}, pVtx, pVtxLbl, v0XYZ, seedP, seedN, lbl0, lbl1, ok, mD0V0Map, mD1V0Map, mcReader, mDebugStream, true, check, fitterV0.isPropagationFailure()); + if (check) { + mDiscardMap[make_hash(lbl0.getSourceID(), lbl0.getEventID(), lbl0.getTrackID())] = int(CHECKV0::MINR2TOMEANVERTEX) + 1000; + mDiscardMap[make_hash(lbl1.getSourceID(), lbl1.getEventID(), lbl1.getTrackID())] = int(CHECKV0::MINR2TOMEANVERTEX) + 1000; + } if (mSVParams->ret) { return false; } @@ -635,6 +653,10 @@ bool SVertexer::checkV0(const TrackCand& seedP, const TrackCand& seedN, int iP, if (drv0P > mSVParams->causalityRTolerance || drv0P < -mSVParams->maxV0ToProngsRDiff || drv0N > mSVParams->causalityRTolerance || drv0N < -mSVParams->maxV0ToProngsRDiff) { mCounterV0.inc(CHECKV0::REJCAUSALITY, {}, pVtx, pVtxLbl, v0XYZ, seedP, seedN, lbl0, lbl1, ok, mD0V0Map, mD1V0Map, mcReader, mDebugStream, true, check, fitterV0.isPropagationFailure()); + if (check) { + mDiscardMap[make_hash(lbl0.getSourceID(), lbl0.getEventID(), lbl0.getTrackID())] = int(CHECKV0::REJCAUSALITY) + 1000; + mDiscardMap[make_hash(lbl1.getSourceID(), lbl1.getEventID(), lbl1.getTrackID())] = int(CHECKV0::REJCAUSALITY) + 1000; + } if (mSVParams->ret) { return false; } @@ -642,6 +664,10 @@ bool SVertexer::checkV0(const TrackCand& seedP, const TrackCand& seedN, int iP, const int cand = 0; if (!fitterV0.isPropagateTracksToVertexDone(cand) && !fitterV0.propagateTracksToVertex(cand)) { mCounterV0.inc(CHECKV0::PROPVTX, {}, pVtx, pVtxLbl, v0XYZ, seedP, seedN, lbl0, lbl1, ok, mD0V0Map, mD1V0Map, mcReader, mDebugStream, true, check, fitterV0.isPropagationFailure()); + if (check) { + mDiscardMap[make_hash(lbl0.getSourceID(), lbl0.getEventID(), lbl0.getTrackID())] = int(CHECKV0::PROPVTX) + 1000; + mDiscardMap[make_hash(lbl1.getSourceID(), lbl1.getEventID(), lbl1.getTrackID())] = int(CHECKV0::PROPVTX) + 1000; + } if (mSVParams->ret) { return false; } @@ -656,6 +682,10 @@ bool SVertexer::checkV0(const TrackCand& seedP, const TrackCand& seedN, int iP, if (pt2V0 < mMinPt2V0) { // pt cut LOG(debug) << "RejPt2 " << pt2V0; mCounterV0.inc(CHECKV0::REJPT2, {}, pVtx, pVtxLbl, v0XYZ, seedP, seedN, lbl0, lbl1, ok, mD0V0Map, mD1V0Map, mcReader, mDebugStream, true, check, fitterV0.isPropagationFailure()); + if (check) { + mDiscardMap[make_hash(lbl0.getSourceID(), lbl0.getEventID(), lbl0.getTrackID())] = int(CHECKV0::REJPT2) + 1000; + mDiscardMap[make_hash(lbl1.getSourceID(), lbl1.getEventID(), lbl1.getTrackID())] = int(CHECKV0::REJPT2) + 1000; + } if (mSVParams->ret) { return false; } @@ -663,6 +693,10 @@ bool SVertexer::checkV0(const TrackCand& seedP, const TrackCand& seedN, int iP, if (pV0[2] * pV0[2] / pt2V0 > mMaxTgl2V0) { // tgLambda cut LOG(debug) << "RejTgL " << pV0[2] * pV0[2] / pt2V0; mCounterV0.inc(CHECKV0::REJTGL, {}, pVtx, pVtxLbl, v0XYZ, seedP, seedN, lbl0, lbl1, ok, mD0V0Map, mD1V0Map, mcReader, mDebugStream, true, check, fitterV0.isPropagationFailure()); + if (check) { + mDiscardMap[make_hash(lbl0.getSourceID(), lbl0.getEventID(), lbl0.getTrackID())] = int(CHECKV0::REJTGL) + 1000; + mDiscardMap[make_hash(lbl1.getSourceID(), lbl1.getEventID(), lbl1.getTrackID())] = int(CHECKV0::REJTGL) + 1000; + } if (mSVParams->ret) { return false; } @@ -702,6 +736,11 @@ bool SVertexer::checkV0(const TrackCand& seedP, const TrackCand& seedN, int iP, LOG(debug) << "RejHypo"; if (!checkFor3BodyDecays && !checkForCascade) { mCounterV0.inc(CHECKV0::V0HYP, {}, pVtx, pVtxLbl, fitterV0.getPCACandidate(cand), seedP, seedN, lbl0, lbl1, ok, mD0V0Map, mD1V0Map, mcReader, mDebugStream, true, check, fitterV0.isPropagationFailure()); + if (check) { + mDiscardMap[make_hash(lbl0.getSourceID(), lbl0.getEventID(), lbl0.getTrackID())] = int(CHECKV0::V0HYP) + 1000; + mDiscardMap[make_hash(lbl1.getSourceID(), lbl1.getEventID(), lbl1.getTrackID())] = int(CHECKV0::V0HYP) + 1000; + } + if (mSVParams->ret) { return false; } @@ -752,9 +791,17 @@ bool SVertexer::checkV0(const TrackCand& seedP, const TrackCand& seedN, int iP, } else { if (cosPAXY < mSVParams->minCosPAXYMeanVertex) { mCounterV0.inc(CHECKV0::COSPAXY, {}, pVtx, pVtxLbl, fitterV0.getPCACandidate(cand), seedP, seedN, lbl0, lbl1, ok, mD0V0Map, mD1V0Map, mcReader, mDebugStream, true, check, fitterV0.isPropagationFailure(), -1, cosPAXY, dca2); + if (check) { + mDiscardMap[make_hash(lbl0.getSourceID(), lbl0.getEventID(), lbl0.getTrackID())] = int(CHECKV0::COSPAXY) + 1000; + mDiscardMap[make_hash(lbl1.getSourceID(), lbl1.getEventID(), lbl1.getTrackID())] = int(CHECKV0::COSPAXY) + 1000; + } } if (dca2 > mMaxDCAXY2ToMeanVertex) { mCounterV0.inc(CHECKV0::DCA2, {}, pVtx, pVtxLbl, fitterV0.getPCACandidate(cand), seedP, seedN, lbl0, lbl1, ok, mD0V0Map, mD1V0Map, mcReader, mDebugStream, true, check, fitterV0.isPropagationFailure(), -1, cosPAXY, dca2); + if (check) { + mDiscardMap[make_hash(lbl0.getSourceID(), lbl0.getEventID(), lbl0.getTrackID())] = int(CHECKV0::DCA2) + 1000; + mDiscardMap[make_hash(lbl1.getSourceID(), lbl1.getEventID(), lbl1.getTrackID())] = int(CHECKV0::DCA2) + 1000; + } } if (mSVParams->ret) { return false; @@ -1540,7 +1587,9 @@ void SVertexer::writeMCInfo() if (!mcReader.initFromDigitContext("collisioncontext.root")) { LOGP(fatal, "Initialization of MCKinematicsReader failed!"); } + int events{0}; for (int iSource{0}; iSource < mcReader.getNSources(); ++iSource) { + events += mcReader.getNEvents(iSource); for (int iEvent{0}; iEvent < mcReader.getNEvents(iSource); ++iEvent) { const auto& header = mcReader.getMCEventHeader(iSource, iEvent); if (abs(header.GetZ()) > 30) { @@ -1630,6 +1679,7 @@ void SVertexer::writeMCInfo() } } } + LOGP(info, "+++ Sources: {} Events: {}", mcReader.getNSources(), events); LOGP(info, "~~~~~~~~~~~~~~~~~~~MC GEN Stats~~~~~~~~~~~~~~~~"); mCounterMC.printMC(); LOGP(info, "~~~~~~~~~~~~~~~~~~~V0 pairs generated~~~~~~~~~~"); diff --git a/cmake/rootcling_wrapper.sh.in b/cmake/rootcling_wrapper.sh.in index 72e101cd1cbf8..a061cbb7cdad7 100755 --- a/cmake/rootcling_wrapper.sh.in +++ b/cmake/rootcling_wrapper.sh.in @@ -8,106 +8,105 @@ # while [[ $# -gt 0 ]]; do - case "$1" in - --rootmap_library_name) - ROOTMAP_LIBRARY_NAME="$2" - shift 2 - ;; - --include_dirs) - INCLUDE_DIRS="$2" - shift 2 - ;; - --compile_defs) - COMPILE_DEFINITIONS="$2" - shift 2 - ;; - --headers) - HEADERS="$2" - shift 2 - ;; - --ld_library_path) - LD_LIBRARY_PATH="$2" - shift 2 - ;; - --dictionary_file) - DICTIONARY_FILE="$2" - shift 2 - ;; - --rootmap_file) - ROOTMAP_FILE="$2" - shift 2 - ;; - --pcmdeps) - PCMDEPS="$2" - shift 2 - ;; - *) - if [[ -z "$1" ]]; then - shift - else - echo "Parameter unknown: $1" >&2 - exit 1 - fi - ;; - esac + case "$1" in + --rootmap_library_name) + ROOTMAP_LIBRARY_NAME="$2" + shift 2 + ;; + --include_dirs) + INCLUDE_DIRS="$2" + shift 2 + ;; + --compile_defs) + COMPILE_DEFINITIONS="$2" + shift 2 + ;; + --headers) + HEADERS="$2" + shift 2 + ;; + --ld_library_path) + LD_LIBRARY_PATH="$2" + shift 2 + ;; + --dictionary_file) + DICTIONARY_FILE="$2" + shift 2 + ;; + --rootmap_file) + ROOTMAP_FILE="$2" + shift 2 + ;; + --pcmdeps) + PCMDEPS="$2" + shift 2 + ;; + *) + if [[ -z "$1" ]]; then + shift + else + echo "Parameter unknown: $1" >&2 + exit 1 + fi + ;; + esac done if [[ ! $ROOTMAP_LIBRARY_NAME ]]; then - echo "--rootmap_library_name option is mandatory but was not given" >&2 - exit 1 + echo "--rootmap_library_name option is mandatory but was not given" >&2 + exit 1 fi if [[ ! $INCLUDE_DIRS ]]; then - echo "--include_dirs option is mandatory but was not given" >&2 - exit 1 + echo "--include_dirs option is mandatory but was not given" >&2 + exit 1 fi if [[ ! $DICTIONARY_FILE ]]; then - echo "--dictionary_file option is mandatory but was not given" >&2 - exit 1 + echo "--dictionary_file option is mandatory but was not given" >&2 + exit 1 fi if [[ ! $ROOTMAP_FILE ]]; then - echo "--rootmap_file option is mandatory but was not given" >&2 - exit 1 + echo "--rootmap_file option is mandatory but was not given" >&2 + exit 1 fi case $OSTYPE in - darwin*) +darwin*) unset PCMDEPS ;; - *) - ;; +*) ;; esac LOGFILE=${DICTIONARY_FILE}.log @CMAKE_COMMAND@ -E env LD_LIBRARY_PATH=${LD_LIBRARY_PATH} @ROOT_rootcling_CMD@ \ - -f $DICTIONARY_FILE \ - -inlineInputHeader \ - -noGlobalUsingStd \ - -rmf ${ROOTMAP_FILE} \ - -rml ${ROOTMAP_LIBRARY_NAME} \ - ${INCLUDE_DIRS//;/ } \ - ${COMPILE_DEFINITIONS//;/ } \ - ${PCMDEPS:+-m }${PCMDEPS//;/ -m } \ - ${HEADERS//;/ } \ - > ${LOGFILE} 2>&1 || cat ${LOGFILE} >&2 + -f $DICTIONARY_FILE \ + -inlineInputHeader \ + -noGlobalUsingStd \ + -rmf ${ROOTMAP_FILE} \ + -rml ${ROOTMAP_LIBRARY_NAME} \ + ${INCLUDE_DIRS//;/ } \ + ${COMPILE_DEFINITIONS//;/ } \ + ${PCMDEPS:+-m }${PCMDEPS//;/ -m } \ + ${HEADERS//;/ } \ + >${LOGFILE} 2>&1 || cat ${LOGFILE} >&2 if [[ $? != "0" ]]; then - rm $DICTIONARY_FILE - exit 1 + rm $DICTIONARY_FILE + exit 1 fi MSG="Warning: Unused class rule" if [[ -s ${LOGFILE} ]]; then - WARNINGS=$(grep -c "${MSG}" ${LOGFILE} || :) - if [[ ! $WARNINGS == 0 ]]; then - echo "ERROR: please fix the warnings below about unused class rule" >&2 - grep "$MSG" ${LOGFILE} >&2 - rm $DICTIONARY_FILE - exit 1 - fi + WARNINGS=$(grep -c "${MSG}" ${LOGFILE} || :) + if [[ ! $WARNINGS == 0 ]]; then + echo "ERROR: please fix the warnings below about unused class rule in $DICTIONARY_FILE" >&2 + grep "$MSG" ${LOGFILE} >&2 + #rm $DICTIONARY_FILE + #exit 1 + fi fi exit 0