From f95efbe2e162af25d0ebb40a763fd0a906634518 Mon Sep 17 00:00:00 2001 From: Fabrizio Grosa Date: Sun, 31 Oct 2021 19:26:42 +0100 Subject: [PATCH 1/6] Fix conflicts --- .../HFTrackIndexSkimsCreator.cxx | 256 ++++++++++-------- 1 file changed, 137 insertions(+), 119 deletions(-) diff --git a/PWGHF/TableProducer/HFTrackIndexSkimsCreator.cxx b/PWGHF/TableProducer/HFTrackIndexSkimsCreator.cxx index f39e0f99b26..8a622d21a0c 100644 --- a/PWGHF/TableProducer/HFTrackIndexSkimsCreator.cxx +++ b/PWGHF/TableProducer/HFTrackIndexSkimsCreator.cxx @@ -129,40 +129,43 @@ struct HfTagSelCollisions { template void selectVertex(const Col& collision, int& statusCollision) { - registry.fill(HIST("hNContributors"), collision.numContrib()); + if (fillHistograms) { + registry.fill(HIST("hNContributors"), collision.numContrib()); + } + // x position if (collision.posX() < xVertexMin || collision.posX() > xVertexMax) { SETBIT(statusCollision, EventRejection::PositionX); if (fillHistograms) { - registry.get(HIST("hEvents"))->Fill(3 + EventRejection::PositionX); + registry.fill(HIST("hEvents"), 3 + EventRejection::PositionX); } } // y position if (collision.posY() < yVertexMin || collision.posY() > yVertexMax) { SETBIT(statusCollision, EventRejection::PositionY); if (fillHistograms) { - registry.get(HIST("hEvents"))->Fill(3 + EventRejection::PositionY); + registry.fill(HIST("hEvents"), 3 + EventRejection::PositionY); } } // z position if (collision.posZ() < zVertexMin || collision.posZ() > zVertexMax) { SETBIT(statusCollision, EventRejection::PositionZ); if (fillHistograms) { - registry.get(HIST("hEvents"))->Fill(3 + EventRejection::PositionZ); + registry.fill(HIST("hEvents"), 3 + EventRejection::PositionZ); } } // number of contributors if (collision.numContrib() < nContribMin) { SETBIT(statusCollision, EventRejection::NContrib); if (fillHistograms) { - registry.get(HIST("hEvents"))->Fill(3 + EventRejection::NContrib); + registry.fill(HIST("hEvents"), 3 + EventRejection::NContrib); } } // chi^2 if (chi2Max > 0. && collision.chi2() > chi2Max) { SETBIT(statusCollision, EventRejection::Chi2); if (fillHistograms) { - registry.get(HIST("hEvents"))->Fill(3 + EventRejection::Chi2); + registry.fill(HIST("hEvents"), 3 + EventRejection::Chi2); } } } @@ -174,14 +177,14 @@ struct HfTagSelCollisions { // processed events if (fillHistograms) { - registry.get(HIST("hEvents"))->Fill(1); + registry.fill(HIST("hEvents"), 1); } // trigger selection if (!collision.alias()[triggerClass]) { SETBIT(statusCollision, EventRejection::Trigger); if (fillHistograms) { - registry.get(HIST("hEvents"))->Fill(3 + EventRejection::Trigger); + registry.fill(HIST("hEvents"), 3 + EventRejection::Trigger); } } @@ -192,7 +195,7 @@ struct HfTagSelCollisions { // selected events if (fillHistograms && statusCollision == 0) { - registry.get(HIST("hEvents"))->Fill(2); + registry.fill(HIST("hEvents"), 2); } // fill table row @@ -208,7 +211,7 @@ struct HfTagSelCollisions { // processed events if (fillHistograms) { - registry.get(HIST("hEvents"))->Fill(1); + registry.fill(HIST("hEvents"), 1); } // vertex selection @@ -216,7 +219,7 @@ struct HfTagSelCollisions { // selected events if (fillHistograms && statusCollision == 0) { - registry.get(HIST("hEvents"))->Fill(2); + registry.fill(HIST("hEvents"), 2); } // fill table row @@ -313,7 +316,7 @@ struct HfTagSelTracks { return true; } - void process(aod::Collisions const& collisions, + void process(aod::Collision const& collision, MY_TYPE1 const& tracks #ifdef MY_DEBUG , @@ -321,19 +324,8 @@ struct HfTagSelTracks { #endif ) { - auto prevColId = -1; - math_utils::Point3D vtxXYZ; + math_utils::Point3D vtxXYZ(collision.posX(), collision.posY(), collision.posZ()); for (auto& track : tracks) { - if (track.has_collision()) { - if (track.collisionId() != prevColId) { - auto collision = track.collision(); - vtxXYZ = {collision.posX(), collision.posY(), collision.posZ()}; - prevColId = track.collisionId(); - } - } else { - // reset vertex for unassigned track - vtxXYZ = {0, 0, 0}; - } #ifdef MY_DEBUG auto indexBach = track.mcParticleId(); @@ -358,7 +350,7 @@ struct HfTagSelTracks { auto trackEta = track.eta(); if (fillHistograms) { - registry.get(HIST("hPtNoCuts"))->Fill(trackPt); + registry.fill(HIST("hPtNoCuts"), trackPt); } int iDebugCut = 2; @@ -368,7 +360,7 @@ struct HfTagSelTracks { if (debug) { cutStatus[CandidateType::Cand2Prong][0] = false; if (fillHistograms) { - registry.get(HIST("hRejTracks"))->Fill((nCuts + 1) * CandidateType::Cand2Prong + iDebugCut); + registry.fill(HIST("hRejTracks"), (nCuts + 1) * CandidateType::Cand2Prong + iDebugCut); } } } @@ -377,7 +369,7 @@ struct HfTagSelTracks { if (debug) { cutStatus[CandidateType::Cand3Prong][0] = false; if (fillHistograms) { - registry.get(HIST("hRejTracks"))->Fill((nCuts + 1) * CandidateType::Cand3Prong + iDebugCut); + registry.fill(HIST("hRejTracks"), (nCuts + 1) * CandidateType::Cand3Prong + iDebugCut); } } } @@ -388,7 +380,7 @@ struct HfTagSelTracks { if (debug) { cutStatus[CandidateType::CandV0bachelor][0] = false; if (fillHistograms) { - registry.get(HIST("hRejTracks"))->Fill((nCuts + 1) * CandidateType::CandV0bachelor + iDebugCut); + registry.fill(HIST("hRejTracks"), (nCuts + 1) * CandidateType::CandV0bachelor + iDebugCut); } } } @@ -400,7 +392,7 @@ struct HfTagSelTracks { if (debug) { cutStatus[CandidateType::Cand2Prong][1] = false; if (fillHistograms) { - registry.get(HIST("hRejTracks"))->Fill((nCuts + 1) * CandidateType::Cand2Prong + iDebugCut); + registry.fill(HIST("hRejTracks"), (nCuts + 1) * CandidateType::Cand2Prong + iDebugCut); } } } @@ -409,7 +401,7 @@ struct HfTagSelTracks { if (debug) { cutStatus[CandidateType::Cand3Prong][1] = false; if (fillHistograms) { - registry.get(HIST("hRejTracks"))->Fill((nCuts + 1) * CandidateType::Cand3Prong + iDebugCut); + registry.fill(HIST("hRejTracks"), (nCuts + 1) * CandidateType::Cand3Prong + iDebugCut); } } } @@ -420,7 +412,7 @@ struct HfTagSelTracks { if (debug) { cutStatus[CandidateType::CandV0bachelor][1] = false; if (fillHistograms) { - registry.get(HIST("hRejTracks"))->Fill((nCuts + 1) * CandidateType::CandV0bachelor + iDebugCut); + registry.fill(HIST("hRejTracks"), (nCuts + 1) * CandidateType::CandV0bachelor + iDebugCut); } } } @@ -440,7 +432,7 @@ struct HfTagSelTracks { for (int iCandType = 0; iCandType < CandidateType::NCandidateTypes; iCandType++) { cutStatus[iCandType][2] = false; if (fillHistograms) { - registry.get(HIST("hRejTracks"))->Fill((nCuts + 1) * iCandType + iDebugCut); + registry.fill(HIST("hRejTracks"), (nCuts + 1) * iCandType + iDebugCut); } } } @@ -449,41 +441,36 @@ struct HfTagSelTracks { iDebugCut = 5; // DCA cut - // FIXME: set some unambiguosly incorrect value for unassigned tracks? This will put them into overflow bins - array dca{10, 10}; + array dca; if ((debug || statusProng > 0)) { - // can only check DCA if the vertex is known - // FIXME: try alternative associations - if (track.has_collision()) { - auto trackparvar0 = getTrackParCov(track); - if (!trackparvar0.propagateParamToDCA(vtxXYZ, bz, &dca, 100.)) { // get impact parameters - statusProng = 0; - } - if ((debug || TESTBIT(statusProng, CandidateType::Cand2Prong)) && !isSelectedTrack(track, dca, CandidateType::Cand2Prong)) { - CLRBIT(statusProng, CandidateType::Cand2Prong); - if (debug) { - cutStatus[CandidateType::Cand2Prong][3] = false; - if (fillHistograms) { - registry.get(HIST("hRejTracks"))->Fill((nCuts + 1) * CandidateType::Cand2Prong + iDebugCut); - } + auto trackparvar0 = getTrackParCov(track); + if (!trackparvar0.propagateParamToDCA(vtxXYZ, bz, &dca, 100.)) { // get impact parameters + statusProng = 0; + } + if ((debug || TESTBIT(statusProng, CandidateType::Cand2Prong)) && !isSelectedTrack(track, dca, CandidateType::Cand2Prong)) { + CLRBIT(statusProng, CandidateType::Cand2Prong); + if (debug) { + cutStatus[CandidateType::Cand2Prong][3] = false; + if (fillHistograms) { + registry.fill(HIST("hRejTracks"), (nCuts + 1) * CandidateType::Cand2Prong + iDebugCut); } } - if ((debug || TESTBIT(statusProng, CandidateType::Cand3Prong)) && !isSelectedTrack(track, dca, CandidateType::Cand3Prong)) { - CLRBIT(statusProng, CandidateType::Cand3Prong); - if (debug) { - cutStatus[CandidateType::Cand3Prong][3] = false; - if (fillHistograms) { - registry.get(HIST("hRejTracks"))->Fill((nCuts + 1) * CandidateType::Cand3Prong + iDebugCut); - } + } + if ((debug || TESTBIT(statusProng, CandidateType::Cand3Prong)) && !isSelectedTrack(track, dca, CandidateType::Cand3Prong)) { + CLRBIT(statusProng, CandidateType::Cand3Prong); + if (debug) { + cutStatus[CandidateType::Cand3Prong][3] = false; + if (fillHistograms) { + registry.fill(HIST("hRejTracks"), (nCuts + 1) * CandidateType::Cand3Prong + iDebugCut); } } - if ((debug || TESTBIT(statusProng, CandidateType::CandV0bachelor)) && !isSelectedTrack(track, dca, CandidateType::CandV0bachelor)) { - CLRBIT(statusProng, CandidateType::CandV0bachelor); - if (debug) { - cutStatus[CandidateType::CandV0bachelor][3] = false; - if (fillHistograms) { - registry.get(HIST("hRejTracks"))->Fill((nCuts + 1) * CandidateType::CandV0bachelor + iDebugCut); - } + } + if ((debug || TESTBIT(statusProng, CandidateType::CandV0bachelor)) && !isSelectedTrack(track, dca, CandidateType::CandV0bachelor)) { + CLRBIT(statusProng, CandidateType::CandV0bachelor); + if (debug) { + cutStatus[CandidateType::CandV0bachelor][3] = false; + if (fillHistograms) { + registry.fill(HIST("hRejTracks"), (nCuts + 1) * CandidateType::CandV0bachelor + iDebugCut); } } } @@ -494,28 +481,28 @@ struct HfTagSelTracks { if (fillHistograms) { iDebugCut = 1; if (TESTBIT(statusProng, CandidateType::Cand2Prong)) { - registry.get(HIST("hPtCuts2Prong"))->Fill(trackPt); - registry.get(HIST("hEtaCuts2Prong"))->Fill(trackEta); - registry.get(HIST("hDCAToPrimXYVsPtCuts2Prong"))->Fill(trackPt, dca[0]); + registry.fill(HIST("hPtCuts2Prong"), trackPt); + registry.fill(HIST("hEtaCuts2Prong"), trackEta); + registry.fill(HIST("hDCAToPrimXYVsPtCuts2Prong"), trackPt, dca[0]); if (debug) { - registry.get(HIST("hRejTracks"))->Fill((nCuts + 1) * CandidateType::Cand2Prong + iDebugCut); + registry.fill(HIST("hRejTracks"), (nCuts + 1) * CandidateType::Cand2Prong + iDebugCut); } } if (TESTBIT(statusProng, CandidateType::Cand3Prong)) { - registry.get(HIST("hPtCuts3Prong"))->Fill(trackPt); - registry.get(HIST("hEtaCuts3Prong"))->Fill(trackEta); - registry.get(HIST("hDCAToPrimXYVsPtCuts3Prong"))->Fill(trackPt, dca[0]); + registry.fill(HIST("hPtCuts3Prong"), trackPt); + registry.fill(HIST("hEtaCuts3Prong"), trackEta); + registry.fill(HIST("hDCAToPrimXYVsPtCuts3Prong"), trackPt, dca[0]); if (debug) { - registry.get(HIST("hRejTracks"))->Fill((nCuts + 1) * CandidateType::Cand3Prong + iDebugCut); + registry.fill(HIST("hRejTracks"), (nCuts + 1) * CandidateType::Cand3Prong + iDebugCut); } } if (TESTBIT(statusProng, CandidateType::CandV0bachelor)) { MY_DEBUG_MSG(isProtonFromLc, LOG(info) << "Will be kept: Proton from Lc " << indexBach); - registry.get(HIST("hPtCutsV0bachelor"))->Fill(trackPt); - registry.get(HIST("hEtaCutsV0bachelor"))->Fill(trackEta); - registry.get(HIST("hDCAToPrimXYVsPtCutsV0bachelor"))->Fill(trackPt, dca[0]); + registry.fill(HIST("hPtCutsV0bachelor"), trackPt); + registry.fill(HIST("hEtaCutsV0bachelor"), trackEta); + registry.fill(HIST("hDCAToPrimXYVsPtCutsV0bachelor"), trackPt, dca[0]); if (debug) { - registry.get(HIST("hRejTracks"))->Fill((nCuts + 1) * CandidateType::CandV0bachelor + iDebugCut); + registry.fill(HIST("hRejTracks"), (nCuts + 1) * CandidateType::CandV0bachelor + iDebugCut); } } } @@ -670,16 +657,19 @@ struct HfTrackIndexSkimsCreator { /// FIXME: this would be better fixed by having a convention on the position of min and max in the 2D Array static std::vector massMinIndex; static std::vector massMaxIndex; - static auto cacheIndices = [](std::array, n2ProngDecays>& cut2Prong, std::vector& mins, std::vector& maxs) { + static std::vector d0d0Index; + static auto cacheIndices = [](std::array, n2ProngDecays>& cut2Prong, std::vector& mins, std::vector& maxs, std::vector& d0d0) { mins.resize(cut2Prong.size()); maxs.resize(cut2Prong.size()); + d0d0.resize(cut2Prong.size()); for (size_t i = 0; i < cut2Prong.size(); ++i) { mins[i] = cut2Prong[i].colmap.find("massMin")->second; maxs[i] = cut2Prong[i].colmap.find("massMax")->second; + d0d0[i] = cut2Prong[i].colmap.find("d0d0")->second; } return true; }; - static bool initIndex = cacheIndices(cut2Prong, massMinIndex, massMaxIndex); + static bool initIndex = cacheIndices(cut2Prong, massMinIndex, massMaxIndex, d0d0Index); // invariant mass double massHypos[2]; @@ -707,7 +697,7 @@ struct HfTrackIndexSkimsCreator { // imp. par. product cut if (debug || TESTBIT(isSelected, iDecay2P)) { auto impParProduct = hfTrack0.dcaPrim0() * hfTrack1.dcaPrim0(); - if (impParProduct > cut2Prong[iDecay2P].get(pTBin, "d0d0")) { + if (impParProduct > cut2Prong[iDecay2P].get(pTBin, d0d0Index[iDecay2P])) { CLRBIT(isSelected, iDecay2P); if (debug) { cutStatus[iDecay2P][2] = false; @@ -733,15 +723,16 @@ struct HfTrackIndexSkimsCreator { array{hfTrack2.px(), hfTrack2.py(), hfTrack2.pz()}}; auto pT = RecoDecay::Pt(arrMom[0], arrMom[1], arrMom[2]) + pTTolerance; // add tolerance because of no reco decay vertex + /// FIXME: this would be better fixed by having a convention on the position of min and max in the 2D Array static std::vector massMinIndex; static std::vector massMaxIndex; static auto cacheIndices = [](std::array, n3ProngDecays>& cut3Prong, std::vector& mins, std::vector& maxs) { mins.resize(cut3Prong.size()); maxs.resize(cut3Prong.size()); - for (size_t i = 0; i < cut3Prong.size(); ++i) { - mins[i] = cut3Prong[i].colmap.find("massMin")->second; - maxs[i] = cut3Prong[i].colmap.find("massMax")->second; + for (size_t iDecay3P = 0; iDecay3P < cut3Prong.size(); ++iDecay3P) { + mins[iDecay3P] = cut3Prong[iDecay3P].colmap.find("massMin")->second; + maxs[iDecay3P] = cut3Prong[iDecay3P].colmap.find("massMax")->second; } return true; }; @@ -795,6 +786,18 @@ struct HfTrackIndexSkimsCreator { void is2ProngSelected(const T1& pVecCand, const T2& secVtx, const T3& primVtx, T4& cutStatus, int& isSelected) { if (debug || isSelected > 0) { + + /// FIXME: this would be better fixed by having a convention on the position of min and max in the 2D Array + static std::vector cospIndex; + static auto cacheIndices = [](std::array, n2ProngDecays>& cut2Prong, std::vector& cosp) { + cosp.resize(cut2Prong.size()); + for (size_t iDecay2P = 0; iDecay2P < cut2Prong.size(); ++iDecay2P) { + cosp[iDecay2P] = cut2Prong[iDecay2P].colmap.find("cosp")->second; + } + return true; + }; + static bool initIndex = cacheIndices(cut2Prong, cospIndex); + for (int iDecay2P = 0; iDecay2P < n2ProngDecays; iDecay2P++) { // pT @@ -810,7 +813,7 @@ struct HfTrackIndexSkimsCreator { // cosp if (debug || TESTBIT(isSelected, iDecay2P)) { auto cpa = RecoDecay::CPA(primVtx, secVtx, pVecCand); - if (cpa < cut2Prong[iDecay2P].get("cosp")) { + if (cpa < cut2Prong[iDecay2P].get(pTBin, cospIndex[iDecay2P])) { CLRBIT(isSelected, iDecay2P); if (debug) { cutStatus[iDecay2P][3] = false; @@ -831,6 +834,21 @@ struct HfTrackIndexSkimsCreator { void is3ProngSelected(const T1& pVecCand, const T2& secVtx, const T3& primVtx, T4& cutStatus, int& isSelected) { if (debug || isSelected > 0) { + + /// FIXME: this would be better fixed by having a convention on the position of min and max in the 2D Array + static std::vector cospIndex; + static std::vector decLenIndex; + static auto cacheIndices = [](std::array, n3ProngDecays>& cut3Prong, std::vector& cosp, std::vector& decL) { + cosp.resize(cut3Prong.size()); + decL.resize(cut3Prong.size()); + for (size_t iDecay3P = 0; iDecay3P < cut3Prong.size(); ++iDecay3P) { + cosp[iDecay3P] = cut3Prong[iDecay3P].colmap.find("cosp")->second; + decL[iDecay3P] = cut3Prong[iDecay3P].colmap.find("decL")->second; + } + return true; + }; + static bool initIndex = cacheIndices(cut3Prong, cospIndex, decLenIndex); + for (int iDecay3P = 0; iDecay3P < n3ProngDecays; iDecay3P++) { // pT @@ -846,7 +864,7 @@ struct HfTrackIndexSkimsCreator { // cosp if ((debug || TESTBIT(isSelected, iDecay3P))) { auto cpa = RecoDecay::CPA(primVtx, secVtx, pVecCand); - if (cpa < cut3Prong[iDecay3P].get("cosp")) { + if (cpa < cut3Prong[iDecay3P].get(pTBin, cospIndex[iDecay3P])) { CLRBIT(isSelected, iDecay3P); if (debug) { cutStatus[iDecay3P][2] = false; @@ -857,7 +875,7 @@ struct HfTrackIndexSkimsCreator { // decay length if ((debug || TESTBIT(isSelected, iDecay3P))) { auto decayLength = RecoDecay::distance(primVtx, secVtx); - if (decayLength < cut3Prong[iDecay3P].get("decL")) { + if (decayLength < cut3Prong[iDecay3P].get(pTBin, decLenIndex[iDecay3P])) { CLRBIT(isSelected, iDecay3P); if (debug) { cutStatus[iDecay3P][3] = false; @@ -1016,9 +1034,9 @@ struct HfTrackIndexSkimsCreator { // fill histograms if (fillHistograms) { - registry.get(HIST("hVtx2ProngX"))->Fill(secondaryVertex2[0]); - registry.get(HIST("hVtx2ProngY"))->Fill(secondaryVertex2[1]); - registry.get(HIST("hVtx2ProngZ"))->Fill(secondaryVertex2[2]); + registry.fill(HIST("hVtx2ProngX"), secondaryVertex2[0]); + registry.fill(HIST("hVtx2ProngY"), secondaryVertex2[1]); + registry.fill(HIST("hVtx2ProngZ"), secondaryVertex2[2]); array, 2> arrMom = {pvec0, pvec1}; for (int iDecay2P = 0; iDecay2P < n2ProngDecays; iDecay2P++) { if (TESTBIT(isSelected2ProngCand, iDecay2P)) { @@ -1026,20 +1044,20 @@ struct HfTrackIndexSkimsCreator { auto mass2Prong = RecoDecay::M(arrMom, arrMass2Prong[iDecay2P][0]); switch (iDecay2P) { case hf_cand_prong2::DecayType::D0ToPiK: - registry.get(HIST("hmassD0ToPiK"))->Fill(mass2Prong); + registry.fill(HIST("hmassD0ToPiK"), mass2Prong); break; case hf_cand_prong2::DecayType::JpsiToEE: - registry.get(HIST("hmassJpsiToEE"))->Fill(mass2Prong); + registry.fill(HIST("hmassJpsiToEE"), mass2Prong); break; case hf_cand_prong2::DecayType::JpsiToMuMu: - registry.get(HIST("hmassJpsiToMuMu"))->Fill(mass2Prong); + registry.fill(HIST("hmassJpsiToMuMu"), mass2Prong); break; } } if (whichHypo2Prong[iDecay2P] >= 2) { auto mass2Prong = RecoDecay::M(arrMom, arrMass2Prong[iDecay2P][1]); if (iDecay2P == hf_cand_prong2::DecayType::D0ToPiK) { - registry.get(HIST("hmassD0ToPiK"))->Fill(mass2Prong); + registry.fill(HIST("hmassD0ToPiK"), mass2Prong); } } } @@ -1126,9 +1144,9 @@ struct HfTrackIndexSkimsCreator { // fill histograms if (fillHistograms) { - registry.get(HIST("hVtx3ProngX"))->Fill(secondaryVertex3[0]); - registry.get(HIST("hVtx3ProngY"))->Fill(secondaryVertex3[1]); - registry.get(HIST("hVtx3ProngZ"))->Fill(secondaryVertex3[2]); + registry.fill(HIST("hVtx3ProngX"), secondaryVertex3[0]); + registry.fill(HIST("hVtx3ProngY"), secondaryVertex3[1]); + registry.fill(HIST("hVtx3ProngZ"), secondaryVertex3[2]); array, 3> arr3Mom = {pvec0, pvec1, pvec2}; for (int iDecay3P = 0; iDecay3P < n3ProngDecays; iDecay3P++) { if (TESTBIT(isSelected3ProngCand, iDecay3P)) { @@ -1136,16 +1154,16 @@ struct HfTrackIndexSkimsCreator { auto mass3Prong = RecoDecay::M(arr3Mom, arrMass3Prong[iDecay3P][0]); switch (iDecay3P) { case hf_cand_prong3::DecayType::DPlusToPiKPi: - registry.get(HIST("hmassDPlusToPiKPi"))->Fill(mass3Prong); + registry.fill(HIST("hmassDPlusToPiKPi"), mass3Prong); break; case hf_cand_prong3::DecayType::DsToPiKK: - registry.get(HIST("hmassDsToPiKK"))->Fill(mass3Prong); + registry.fill(HIST("hmassDsToPiKK"), mass3Prong); break; case hf_cand_prong3::DecayType::LcToPKPi: - registry.get(HIST("hmassLcToPKPi"))->Fill(mass3Prong); + registry.fill(HIST("hmassLcToPKPi"), mass3Prong); break; case hf_cand_prong3::DecayType::XicToPKPi: - registry.get(HIST("hmassXicToPKPi"))->Fill(mass3Prong); + registry.fill(HIST("hmassXicToPKPi"), mass3Prong); break; } } @@ -1153,13 +1171,13 @@ struct HfTrackIndexSkimsCreator { auto mass3Prong = RecoDecay::M(arr3Mom, arrMass3Prong[iDecay3P][1]); switch (iDecay3P) { case hf_cand_prong3::DecayType::DsToPiKK: - registry.get(HIST("hmassDsToPiKK"))->Fill(mass3Prong); + registry.fill(HIST("hmassDsToPiKK"), mass3Prong); break; case hf_cand_prong3::DecayType::LcToPKPi: - registry.get(HIST("hmassLcToPKPi"))->Fill(mass3Prong); + registry.fill(HIST("hmassLcToPKPi"), mass3Prong); break; case hf_cand_prong3::DecayType::XicToPKPi: - registry.get(HIST("hmassXicToPKPi"))->Fill(mass3Prong); + registry.fill(HIST("hmassXicToPKPi"), mass3Prong); break; } } @@ -1238,9 +1256,9 @@ struct HfTrackIndexSkimsCreator { // fill histograms if (fillHistograms) { - registry.get(HIST("hVtx3ProngX"))->Fill(secondaryVertex3[0]); - registry.get(HIST("hVtx3ProngY"))->Fill(secondaryVertex3[1]); - registry.get(HIST("hVtx3ProngZ"))->Fill(secondaryVertex3[2]); + registry.fill(HIST("hVtx3ProngX"), secondaryVertex3[0]); + registry.fill(HIST("hVtx3ProngY"), secondaryVertex3[1]); + registry.fill(HIST("hVtx3ProngZ"), secondaryVertex3[2]); array, 3> arr3Mom = {pvec0, pvec1, pvec2}; for (int iDecay3P = 0; iDecay3P < n3ProngDecays; iDecay3P++) { if (TESTBIT(isSelected3ProngCand, iDecay3P)) { @@ -1248,16 +1266,16 @@ struct HfTrackIndexSkimsCreator { auto mass3Prong = RecoDecay::M(arr3Mom, arrMass3Prong[iDecay3P][0]); switch (iDecay3P) { case hf_cand_prong3::DecayType::DPlusToPiKPi: - registry.get(HIST("hmassDPlusToPiKPi"))->Fill(mass3Prong); + registry.fill(HIST("hmassDPlusToPiKPi"), mass3Prong); break; case hf_cand_prong3::DecayType::DsToPiKK: - registry.get(HIST("hmassDsToPiKK"))->Fill(mass3Prong); + registry.fill(HIST("hmassDsToPiKK"), mass3Prong); break; case hf_cand_prong3::DecayType::LcToPKPi: - registry.get(HIST("hmassLcToPKPi"))->Fill(mass3Prong); + registry.fill(HIST("hmassLcToPKPi"), mass3Prong); break; case hf_cand_prong3::DecayType::XicToPKPi: - registry.get(HIST("hmassXicToPKPi"))->Fill(mass3Prong); + registry.fill(HIST("hmassXicToPKPi"), mass3Prong); break; } } @@ -1265,13 +1283,13 @@ struct HfTrackIndexSkimsCreator { auto mass3Prong = RecoDecay::M(arr3Mom, arrMass3Prong[iDecay3P][1]); switch (iDecay3P) { case hf_cand_prong3::DecayType::DsToPiKK: - registry.get(HIST("hmassDsToPiKK"))->Fill(mass3Prong); + registry.fill(HIST("hmassDsToPiKK"), mass3Prong); break; case hf_cand_prong3::DecayType::LcToPKPi: - registry.get(HIST("hmassLcToPKPi"))->Fill(mass3Prong); + registry.fill(HIST("hmassLcToPKPi"), mass3Prong); break; case hf_cand_prong3::DecayType::XicToPKPi: - registry.get(HIST("hmassXicToPKPi"))->Fill(mass3Prong); + registry.fill(HIST("hmassXicToPKPi"), mass3Prong); break; } } @@ -1287,11 +1305,11 @@ struct HfTrackIndexSkimsCreator { nCand2 = rowTrackIndexProng2.lastIndex() - nCand2; // number of 2-prong candidates in this collision nCand3 = rowTrackIndexProng3.lastIndex() - nCand3; // number of 3-prong candidates in this collision - registry.get(HIST("hNTracks"))->Fill(nTracks); - registry.get(HIST("hNCand2Prong"))->Fill(nCand2); - registry.get(HIST("hNCand3Prong"))->Fill(nCand3); - registry.get(HIST("hNCand2ProngVsNTracks"))->Fill(nTracks, nCand2); - registry.get(HIST("hNCand3ProngVsNTracks"))->Fill(nTracks, nCand3); + registry.fill(HIST("hNTracks"), nTracks); + registry.fill(HIST("hNCand2Prong"), nCand2); + registry.fill(HIST("hNCand3Prong"), nCand3); + registry.fill(HIST("hNCand2ProngVsNTracks"), nTracks, nCand2); + registry.fill(HIST("hNCand3ProngVsNTracks"), nTracks, nCand3); } }; @@ -1558,10 +1576,10 @@ struct HfTrackIndexSkimsCreatorCascades { // fill histograms if (doValPlots) { MY_DEBUG_MSG(isK0SfromLc && isProtonFromLc && isLc, LOG(info) << "KEPT! True Lc from proton " << indexBach << " and K0S pos " << indexV0DaughPos << " and neg " << indexV0DaughNeg); - registry.get(HIST("hVtx2ProngX"))->Fill(posCasc[0]); - registry.get(HIST("hVtx2ProngY"))->Fill(posCasc[1]); - registry.get(HIST("hVtx2ProngZ"))->Fill(posCasc[2]); - registry.get(HIST("hmass2"))->Fill(mass2K0sP); + registry.fill(HIST("hVtx2ProngX"), posCasc[0]); + registry.fill(HIST("hVtx2ProngY"), posCasc[1]); + registry.fill(HIST("hVtx2ProngZ"), posCasc[2]); + registry.fill(HIST("hmass2"), mass2K0sP); } } // loop over V0s From 432a9a687cff6a607c1cea0e748a3b9e6e162fd3 Mon Sep 17 00:00:00 2001 From: Fabrizio Grosa Date: Sun, 31 Oct 2021 19:28:16 +0100 Subject: [PATCH 2/6] Fix conflicts --- PWGHF/TableProducer/HFTrackIndexSkimsCreator.cxx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/PWGHF/TableProducer/HFTrackIndexSkimsCreator.cxx b/PWGHF/TableProducer/HFTrackIndexSkimsCreator.cxx index 8a622d21a0c..9c12572c1df 100644 --- a/PWGHF/TableProducer/HFTrackIndexSkimsCreator.cxx +++ b/PWGHF/TableProducer/HFTrackIndexSkimsCreator.cxx @@ -316,7 +316,8 @@ struct HfTagSelTracks { return true; } - void process(aod::Collision const& collision, + + void process(aod::Collisions const& collisions, MY_TYPE1 const& tracks #ifdef MY_DEBUG , @@ -324,8 +325,19 @@ struct HfTagSelTracks { #endif ) { - math_utils::Point3D vtxXYZ(collision.posX(), collision.posY(), collision.posZ()); + auto prevColId = -1; + math_utils::Point3D vtxXYZ; for (auto& track : tracks) { + if (track.has_collision()) { + if (track.collisionId() != prevColId) { + auto collision = track.collision(); + vtxXYZ = {collision.posX(), collision.posY(), collision.posZ()}; + prevColId = track.collisionId(); + } + } else { + // reset vertex for unassigned track + vtxXYZ = {0, 0, 0}; + } for (auto& track : tracks) { #ifdef MY_DEBUG auto indexBach = track.mcParticleId(); From d60ca9d2e11b96fe06f54907237636fe579808d1 Mon Sep 17 00:00:00 2001 From: Fabrizio Grosa Date: Sun, 31 Oct 2021 19:29:02 +0100 Subject: [PATCH 3/6] Fix conflicts --- PWGHF/TableProducer/HFTrackIndexSkimsCreator.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PWGHF/TableProducer/HFTrackIndexSkimsCreator.cxx b/PWGHF/TableProducer/HFTrackIndexSkimsCreator.cxx index 9c12572c1df..117fd39f1d2 100644 --- a/PWGHF/TableProducer/HFTrackIndexSkimsCreator.cxx +++ b/PWGHF/TableProducer/HFTrackIndexSkimsCreator.cxx @@ -337,7 +337,7 @@ struct HfTagSelTracks { } else { // reset vertex for unassigned track vtxXYZ = {0, 0, 0}; - } for (auto& track : tracks) { + } #ifdef MY_DEBUG auto indexBach = track.mcParticleId(); From facd3564daecbb71d7eaef04f201c94b78bfd312 Mon Sep 17 00:00:00 2001 From: Fabrizio Grosa Date: Sun, 31 Oct 2021 19:35:03 +0100 Subject: [PATCH 4/6] Fix conflicts --- .../HFTrackIndexSkimsCreator.cxx | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/PWGHF/TableProducer/HFTrackIndexSkimsCreator.cxx b/PWGHF/TableProducer/HFTrackIndexSkimsCreator.cxx index 117fd39f1d2..861ccb1cd87 100644 --- a/PWGHF/TableProducer/HFTrackIndexSkimsCreator.cxx +++ b/PWGHF/TableProducer/HFTrackIndexSkimsCreator.cxx @@ -453,18 +453,24 @@ struct HfTagSelTracks { iDebugCut = 5; // DCA cut - array dca; + + // FIXME: set some unambiguosly incorrect value for unassigned tracks? This will put them into overflow bins + array dca{10, 10}; if ((debug || statusProng > 0)) { - auto trackparvar0 = getTrackParCov(track); - if (!trackparvar0.propagateParamToDCA(vtxXYZ, bz, &dca, 100.)) { // get impact parameters - statusProng = 0; - } - if ((debug || TESTBIT(statusProng, CandidateType::Cand2Prong)) && !isSelectedTrack(track, dca, CandidateType::Cand2Prong)) { - CLRBIT(statusProng, CandidateType::Cand2Prong); - if (debug) { - cutStatus[CandidateType::Cand2Prong][3] = false; - if (fillHistograms) { - registry.fill(HIST("hRejTracks"), (nCuts + 1) * CandidateType::Cand2Prong + iDebugCut); + // can only check DCA if the vertex is known + // FIXME: try alternative associations + if (track.has_collision()) { + auto trackparvar0 = getTrackParCov(track); + if (!trackparvar0.propagateParamToDCA(vtxXYZ, bz, &dca, 100.)) { // get impact parameters + statusProng = 0; + } + if ((debug || TESTBIT(statusProng, CandidateType::Cand2Prong)) && !isSelectedTrack(track, dca, CandidateType::Cand2Prong)) { + CLRBIT(statusProng, CandidateType::Cand2Prong); + if (debug) { + cutStatus[CandidateType::Cand2Prong][3] = false; + if (fillHistograms) { + registry.fill(HIST("hRejTracks"), (nCuts + 1) * CandidateType::Cand2Prong + iDebugCut); + } } } } From bf19f9b94505cc7c2f8ca38ffb9a9cc85c85662e Mon Sep 17 00:00:00 2001 From: Fabrizio Grosa Date: Sun, 31 Oct 2021 19:36:54 +0100 Subject: [PATCH 5/6] Fix format --- PWGHF/TableProducer/HFTrackIndexSkimsCreator.cxx | 1 - 1 file changed, 1 deletion(-) diff --git a/PWGHF/TableProducer/HFTrackIndexSkimsCreator.cxx b/PWGHF/TableProducer/HFTrackIndexSkimsCreator.cxx index 861ccb1cd87..9baf14ec04c 100644 --- a/PWGHF/TableProducer/HFTrackIndexSkimsCreator.cxx +++ b/PWGHF/TableProducer/HFTrackIndexSkimsCreator.cxx @@ -316,7 +316,6 @@ struct HfTagSelTracks { return true; } - void process(aod::Collisions const& collisions, MY_TYPE1 const& tracks #ifdef MY_DEBUG From c653381a49fb691412483c0979965b818e4e6a86 Mon Sep 17 00:00:00 2001 From: Fabrizio Grosa Date: Thu, 4 Nov 2021 14:08:12 +0100 Subject: [PATCH 6/6] Add px, py, pz columns to avoid overhead from multiple computations --- PWGHF/DataModel/HFSecondaryVertex.h | 8 ++- .../HFTrackIndexSkimsCreator.cxx | 58 +++++++++---------- 2 files changed, 36 insertions(+), 30 deletions(-) diff --git a/PWGHF/DataModel/HFSecondaryVertex.h b/PWGHF/DataModel/HFSecondaryVertex.h index 0a99dc94911..b29d10682bc 100644 --- a/PWGHF/DataModel/HFSecondaryVertex.h +++ b/PWGHF/DataModel/HFSecondaryVertex.h @@ -42,12 +42,18 @@ namespace hf_seltrack DECLARE_SOA_COLUMN(IsSelProng, isSelProng, int); //! DECLARE_SOA_COLUMN(DCAPrim0, dcaPrim0, float); //! DECLARE_SOA_COLUMN(DCAPrim1, dcaPrim1, float); //! +DECLARE_SOA_COLUMN(PxProng, pxProng, float); //! +DECLARE_SOA_COLUMN(PyProng, pyProng, float); //! +DECLARE_SOA_COLUMN(PzProng, pzProng, float); //! } // namespace hf_seltrack DECLARE_SOA_TABLE(HFSelTrack, "AOD", "HFSELTRACK", //! hf_seltrack::IsSelProng, hf_seltrack::DCAPrim0, - hf_seltrack::DCAPrim1); + hf_seltrack::DCAPrim1, + hf_seltrack::PxProng, + hf_seltrack::PyProng, + hf_seltrack::PzProng); using BigTracks = soa::Join; using BigTracksMC = soa::Join; diff --git a/PWGHF/TableProducer/HFTrackIndexSkimsCreator.cxx b/PWGHF/TableProducer/HFTrackIndexSkimsCreator.cxx index 9baf14ec04c..b2642521e28 100644 --- a/PWGHF/TableProducer/HFTrackIndexSkimsCreator.cxx +++ b/PWGHF/TableProducer/HFTrackIndexSkimsCreator.cxx @@ -525,7 +525,7 @@ struct HfTagSelTracks { } // fill table row - rowSelectedTrack(statusProng, dca[0], dca[1]); + rowSelectedTrack(statusProng, dca[0], dca[1], track.px(), track.py(), track.pz()); } } }; @@ -603,8 +603,8 @@ struct HfTrackIndexSkimsCreator { static const int nCuts2Prong = 4; // how many different selections are made on 2-prongs static const int nCuts3Prong = 4; // how many different selections are made on 3-prongs - array, 2>, n2ProngDecays> arrMass2Prong; - array, 2>, n3ProngDecays> arrMass3Prong; + std::array, 2>, n2ProngDecays> arrMass2Prong; + std::array, 2>, n3ProngDecays> arrMass3Prong; // arrays of 2-prong and 3-prong cuts std::array, n2ProngDecays> cut2Prong; @@ -652,9 +652,26 @@ struct HfTrackIndexSkimsCreator { template void is2ProngPreselected(T1 const& hfTrack0, T1 const& hfTrack1, T2& cutStatus, T3& whichHypo, int& isSelected) { + /// FIXME: this would be better fixed by having a convention on the position of min and max in the 2D Array + static std::vector massMinIndex; + static std::vector massMaxIndex; + static std::vector d0d0Index; + static auto cacheIndices = [](std::array, n2ProngDecays>& cut2Prong, std::vector& mins, std::vector& maxs, std::vector& d0d0) { + mins.resize(cut2Prong.size()); + maxs.resize(cut2Prong.size()); + d0d0.resize(cut2Prong.size()); + for (size_t i = 0; i < cut2Prong.size(); ++i) { + mins[i] = cut2Prong[i].colmap.find("massMin")->second; + maxs[i] = cut2Prong[i].colmap.find("massMax")->second; + d0d0[i] = cut2Prong[i].colmap.find("d0d0")->second; + } + return true; + }; + static bool initIndex = cacheIndices(cut2Prong, massMinIndex, massMaxIndex, d0d0Index); + auto arrMom = array{ - array{hfTrack0.px(), hfTrack0.py(), hfTrack0.pz()}, - array{hfTrack1.px(), hfTrack1.py(), hfTrack1.pz()}}; + array{hfTrack0.pxProng(), hfTrack0.pyProng(), hfTrack0.pzProng()}, + array{hfTrack1.pxProng(), hfTrack1.pyProng(), hfTrack1.pzProng()}}; auto pT = RecoDecay::Pt(arrMom[0], arrMom[1]) + pTTolerance; // add tolerance because of no reco decay vertex @@ -671,23 +688,6 @@ struct HfTrackIndexSkimsCreator { continue; } - /// FIXME: this would be better fixed by having a convention on the position of min and max in the 2D Array - static std::vector massMinIndex; - static std::vector massMaxIndex; - static std::vector d0d0Index; - static auto cacheIndices = [](std::array, n2ProngDecays>& cut2Prong, std::vector& mins, std::vector& maxs, std::vector& d0d0) { - mins.resize(cut2Prong.size()); - maxs.resize(cut2Prong.size()); - d0d0.resize(cut2Prong.size()); - for (size_t i = 0; i < cut2Prong.size(); ++i) { - mins[i] = cut2Prong[i].colmap.find("massMin")->second; - maxs[i] = cut2Prong[i].colmap.find("massMax")->second; - d0d0[i] = cut2Prong[i].colmap.find("d0d0")->second; - } - return true; - }; - static bool initIndex = cacheIndices(cut2Prong, massMinIndex, massMaxIndex, d0d0Index); - // invariant mass double massHypos[2]; whichHypo[iDecay2P] = 3; @@ -734,13 +734,6 @@ struct HfTrackIndexSkimsCreator { template void is3ProngPreselected(T1 const& hfTrack0, T1 const& hfTrack1, T1 const& hfTrack2, T2& cutStatus, T3& whichHypo, int& isSelected) { - auto arrMom = array{ - array{hfTrack0.px(), hfTrack0.py(), hfTrack0.pz()}, - array{hfTrack1.px(), hfTrack1.py(), hfTrack1.pz()}, - array{hfTrack2.px(), hfTrack2.py(), hfTrack2.pz()}}; - - auto pT = RecoDecay::Pt(arrMom[0], arrMom[1], arrMom[2]) + pTTolerance; // add tolerance because of no reco decay vertex - /// FIXME: this would be better fixed by having a convention on the position of min and max in the 2D Array static std::vector massMinIndex; static std::vector massMaxIndex; @@ -755,6 +748,13 @@ struct HfTrackIndexSkimsCreator { }; static bool initIndex = cacheIndices(cut3Prong, massMinIndex, massMaxIndex); + auto arrMom = array{ + array{hfTrack0.pxProng(), hfTrack0.pyProng(), hfTrack0.pzProng()}, + array{hfTrack1.pxProng(), hfTrack1.pyProng(), hfTrack1.pzProng()}, + array{hfTrack2.pxProng(), hfTrack2.pyProng(), hfTrack2.pzProng()}}; + + auto pT = RecoDecay::Pt(arrMom[0], arrMom[1], arrMom[2]) + pTTolerance; // add tolerance because of no reco decay vertex + for (int iDecay3P = 0; iDecay3P < n3ProngDecays; iDecay3P++) { // pT