diff --git a/PWGLF/TableProducer/Strangeness/strangenessbuilder.cxx b/PWGLF/TableProducer/Strangeness/strangenessbuilder.cxx index f1cb6a0fca7..7de55300bec 100644 --- a/PWGLF/TableProducer/Strangeness/strangenessbuilder.cxx +++ b/PWGLF/TableProducer/Strangeness/strangenessbuilder.cxx @@ -277,7 +277,7 @@ struct StrangenessBuilder { // more algorithms to be added as necessary Configurable deduplicationAlgorithm{"deduplicationAlgorithm", 1, "0: disabled; 1: best pointing angle wins"}; - // V0 buffer for V0s used in cascades: master switch + // V0 buffer for V0s used in cascades: master switch // exchanges CPU (generate V0s again) with memory (save pre-generated V0s) Configurable useV0BufferForCascades{"useV0BufferForCascades", false, "store array of V0s for cascades or not. False (default): save RAM, use more CPU; true: save CPU, use more RAM"}; @@ -458,7 +458,7 @@ struct StrangenessBuilder { auto h2 = histos.add("hInputStatistics", "hInputStatistics", kTH1D, {{nTablesConst, -0.5f, static_cast(nTablesConst)}}); h2->SetTitle("Input table sizes"); - if(v0BuilderOpts.generatePhotonCandidates.value==true){ + if (v0BuilderOpts.generatePhotonCandidates.value == true) { auto hDeduplicationStatistics = histos.add("hDeduplicationStatistics", "hDeduplicationStatistics", kTH1D, {{2, -0.5f, 1.5f}}); hDeduplicationStatistics->GetXaxis()->SetBinLabel(1, "AO2D V0s"); hDeduplicationStatistics->GetXaxis()->SetBinLabel(2, "Deduplicated V0s"); @@ -722,9 +722,9 @@ struct StrangenessBuilder { v0Entry currentV0Entry; cascadeEntry currentCascadeEntry; - std::vector ao2dV0toV0List; // index to relate AO2D V0s -> deduplicated V0s - std::vector bestCollisionArray; // stores McCollision -> Collision map - std::vector bestCollisionNContribsArray; // stores Ncontribs for biggest coll assoc to mccoll + std::vector ao2dV0toV0List; // index to relate AO2D V0s -> deduplicated V0s + std::vector bestCollisionArray; // stores McCollision -> Collision map + std::vector bestCollisionNContribsArray; // stores Ncontribs for biggest coll assoc to mccoll int collisionLessV0s = 0; int collisionLessCascades = 0; @@ -754,16 +754,16 @@ struct StrangenessBuilder { ao2dV0toV0List.clear(); ao2dV0toV0List.resize(v0s.size(), -1); // -1 means keep, -2 means do not keep - if(deduplicationAlgorithm>0 && v0BuilderOpts.generatePhotonCandidates){ + if (deduplicationAlgorithm > 0 && v0BuilderOpts.generatePhotonCandidates) { // handle duplicates explicitly: group V0s according to (p,n) indices - // will provide a list of collisionIds (in V0group), allowing for + // will provide a list of collisionIds (in V0group), allowing for // easy de-duplication when passing to the v0List - std::vector v0tableGrouped = o2::pwglf::groupDuplicates(v0s); + std::vector v0tableGrouped = o2::pwglf::groupDuplicates(v0s); histos.fill(HIST("hDeduplicationStatistics"), 0.0, v0s.size()); histos.fill(HIST("hDeduplicationStatistics"), 1.0, v0tableGrouped.size()); // process grouped duplicates, remove 'bad' ones - for(size_t iV0 = 0; iV0: do not apply selections: do as much as possible to preserve + // : do not apply selections: do as much as possible to preserve // candidate at this level and do not select with topo selections - if(straHelper.buildV0Candidate(v0tableGrouped[iV0].collisionIds[ic], collision.posX(), collision.posY(), collision.posZ(), pTrack, nTrack, posTrackPar, negTrackPar, true, false)){ + if (straHelper.buildV0Candidate(v0tableGrouped[iV0].collisionIds[ic], collision.posX(), collision.posY(), collision.posZ(), pTrack, nTrack, posTrackPar, negTrackPar, true, false)) { // candidate built, check pointing angle - if(straHelper.v0.pointingAngle < bestPointingAngle){ + if (straHelper.v0.pointingAngle < bestPointingAngle) { bestPointingAngle = straHelper.v0.pointingAngle; bestPointingAngleIndex = ic; } @@ -823,17 +823,17 @@ struct StrangenessBuilder { } // end candidate loop // mark de-duplicated candidates - for(size_t ic=0; ic 0)); - + // Cascade part if cores are requested, skip otherwise if (mEnabledTables[kStoredCascCores] || mEnabledTables[kStoredKFCascCores]) { if (mc_findableMode.value < 2) { // simple passthrough: copy existing cascades to build list for (const auto& cascade : cascades) { auto const& v0 = cascade.v0(); - if(v0.v0Type()>1){ + if (v0.v0Type() > 1) { continue; // skip any unexpected stuff (FIXME: follow-up) } currentCascadeEntry.globalId = cascade.globalIndex(); @@ -1716,11 +1716,11 @@ struct StrangenessBuilder { interlinks.cascadeToCascCores.push_back(-1); continue; // didn't work out, skip } - if(useV0BufferForCascades){ - // this processing path uses a buffer of V0s so that no - // additional minimization step is redone. It consumes less - // CPU at the cost of more memory. Since memory is a more - // limited commodity, this isn't the default option. + if (useV0BufferForCascades) { + // this processing path uses a buffer of V0s so that no + // additional minimization step is redone. It consumes less + // CPU at the cost of more memory. Since memory is a more + // limited commodity, this isn't the default option. if (!straHelper.buildCascadeCandidate(cascade.collisionId, pvX, pvY, pvZ, v0sFromCascades[v0Map[cascade.v0Id]], posTrack, @@ -1733,8 +1733,8 @@ struct StrangenessBuilder { interlinks.cascadeToCascCores.push_back(-1); continue; // didn't work out, skip } - }else{ - // this processing path generates the entire cascade + } else { + // this processing path generates the entire cascade // from tracks, without any need to have V0s generated. if (!straHelper.buildCascadeCandidate(cascade.collisionId, pvX, pvY, pvZ, posTrack, diff --git a/PWGLF/Tasks/QC/v0assoqa.cxx b/PWGLF/Tasks/QC/v0assoqa.cxx index 59f88f9f115..603108ca7c2 100644 --- a/PWGLF/Tasks/QC/v0assoqa.cxx +++ b/PWGLF/Tasks/QC/v0assoqa.cxx @@ -116,16 +116,17 @@ struct v0assoqa { Configurable maxDaughterEta{"maxDaughterEta", 5.0, "Maximum daughter eta (in abs value)"}; } cascadeBuilderOpts; -//_______________________________________________________________________ + //_______________________________________________________________________ template - int findMotherFromLabels(int const& p1, int const& p2, const int expected_pdg1, const int expected_pdg2, const int expected_mother_pdg, TMCParticles const& mcparticles){ - // encompasses a simple check for labels existing - if(p1<0||p2<0){ + int findMotherFromLabels(int const& p1, int const& p2, const int expected_pdg1, const int expected_pdg2, const int expected_mother_pdg, TMCParticles const& mcparticles) + { + // encompasses a simple check for labels existing + if (p1 < 0 || p2 < 0) { return -1; } auto mcParticle1 = mcparticles.rawIteratorAt(p1); auto mcParticle2 = mcparticles.rawIteratorAt(p2); - return(findMother(mcParticle1, mcParticle2, expected_pdg1, expected_pdg2, expected_mother_pdg, mcparticles)); + return (findMother(mcParticle1, mcParticle2, expected_pdg1, expected_pdg2, expected_mother_pdg, mcparticles)); } //_______________________________________________________________________ @@ -148,15 +149,15 @@ struct v0assoqa { if (motherid1 != motherid2 || mother1_pdg != mother2_pdg || mother1_pdg != expected_mother_pdg) return -1; - + return motherid1; } void init(InitContext const&) { - histos.add("hDuplicateCount", "hDuplicateCount", kTH1F, {{50,-0.5f, 49.5f}}); - histos.add("hDuplicateCountType7", "hDuplicateCountType7", kTH1F, {{50,-0.5f, 49.5f}}); - histos.add("hDuplicateCountType7allTPConly", "hDuplicateCountType7allTPConly", kTH1F, {{50,-0.5f, 49.5f}}); + histos.add("hDuplicateCount", "hDuplicateCount", kTH1F, {{50, -0.5f, 49.5f}}); + histos.add("hDuplicateCountType7", "hDuplicateCountType7", kTH1F, {{50, -0.5f, 49.5f}}); + histos.add("hDuplicateCountType7allTPConly", "hDuplicateCountType7allTPConly", kTH1F, {{50, -0.5f, 49.5f}}); histos.add("hPhotonPt", "hPhotonPt", kTH1F, {{200, 0.0f, 20.0f}}); histos.add("hPhotonPt_Duplicates", "hPhotonPt_Duplicates", kTH1F, {{200, 0.0f, 20.0f}}); @@ -166,7 +167,7 @@ struct v0assoqa { histos.add("hPA_All", "hPA_All", kTH1F, {{100, 0.0f, 1.0f}}); histos.add("hPA_Correct", "hPA_Correct", kTH1F, {{100, 0.0f, 1.0f}}); - // 2D for vs pT + // 2D for vs pT histos.add("hPAvsPt_All", "hPAvsPt_All", kTH2F, {{200, 0.0f, 20.0f}, {100, 0.0f, 1.0f}}); histos.add("hPAvsPt_Correct", "hPAvsPt_Correct", kTH2F, {{200, 0.0f, 20.0f}, {100, 0.0f, 1.0f}}); histos.add("hDCADaughtersvsPt_All", "hDCADaughtersvsPt_All", kTH2F, {{200, 0.0f, 20.0f}, {100, 0.0f, 5.0f}}); @@ -262,60 +263,60 @@ struct v0assoqa { if (!initCCDB(bcs, collisions)) return; - std::vector v0tableGrouped = o2::pwglf::groupDuplicates(V0s); + std::vector v0tableGrouped = o2::pwglf::groupDuplicates(V0s); - // determine map of McCollisions -> Collisions + // determine map of McCollisions -> Collisions std::vector> mcCollToColl(mcCollisions.size()); - for(auto const& collision: collisions){ - if(collision.mcCollisionId()>-1){ + for (auto const& collision : collisions) { + if (collision.mcCollisionId() > -1) { // useful to determine if collision has been reconstructed afterwards mcCollToColl[collision.mcCollisionId()].push_back(collision.globalIndex()); } } // simple inspection of grouped duplicates - for(size_t iV0 = 0; iV0-1){ + if (v0Label > -1) { // this mc particle exists and is a gamma auto mcV0 = mcParticles.rawIteratorAt(v0Label); correctMcCollision = mcV0.mcCollisionId(); histos.fill(HIST("hPhotonPt"), mcV0.pt()); - if(mcCollToColl[mcV0.mcCollisionId()].size()>0){ + if (mcCollToColl[mcV0.mcCollisionId()].size() > 0) { histos.fill(HIST("hPhotonPt_withRecoedMcCollision"), mcV0.pt()); } bool hasCorrectCollisionCopy = false; - for(size_t ic=0; ic V0Ids; //index list to original aod::V0s - std::vector collisionIds; //coll indices - int posTrackId; - int negTrackId; + std::vector V0Ids; // index list to original aod::V0s + std::vector collisionIds; // coll indices + int posTrackId; + int negTrackId; uint8_t v0Type; }; @@ -56,7 +56,7 @@ std::vector sort_indices_posTrack(const std::vector& v) std::vector idx(v.size()); std::iota(idx.begin(), idx.end(), 0); std::stable_sort(idx.begin(), idx.end(), - [&v](std::size_t i1, std::size_t i2) { return v[i1].posTrackId < v[i2].posTrackId; }); + [&v](std::size_t i1, std::size_t i2) { return v[i1].posTrackId < v[i2].posTrackId; }); return idx; } @@ -67,56 +67,57 @@ std::vector sort_indices_negTrack(const std::vector& v) std::vector idx(v.size()); std::iota(idx.begin(), idx.end(), 0); std::stable_sort(idx.begin(), idx.end(), - [&v](std::size_t i1, std::size_t i2) { return v[i1].negTrackId < v[i2].negTrackId; }); + [&v](std::size_t i1, std::size_t i2) { return v[i1].negTrackId < v[i2].negTrackId; }); return idx; } //_______________________________________________________________________ -// this function deals with the fact that V0s provided in AO2Ds may -// be duplicated in several collisions and groups them into entries -// of type pwglf::V0group, each entry having the same neg/pos tracks -// but an array of compatible collisions. The original V0 indices +// this function deals with the fact that V0s provided in AO2Ds may +// be duplicated in several collisions and groups them into entries +// of type pwglf::V0group, each entry having the same neg/pos tracks +// but an array of compatible collisions. The original V0 indices // are preserved in the resulting structure to allow for easy referencing -// back afterwards. Algorithmically, full N^2 loops and/or multiple -// find calls are avoided via sorting. +// back afterwards. Algorithmically, full N^2 loops and/or multiple +// find calls are avoided via sorting. template -std::vector groupDuplicates(const T& V0s){ +std::vector groupDuplicates(const T& V0s) +{ std::vector v0table; - V0group thisV0; - thisV0.V0Ids.push_back(-1); // create one single element + V0group thisV0; + thisV0.V0Ids.push_back(-1); // create one single element thisV0.collisionIds.push_back(-1); // create one single element - for(auto const& V0 : V0s){ + for (auto const& V0 : V0s) { thisV0.V0Ids[0] = V0.globalIndex(); - thisV0.collisionIds[0] = V0.collisionId(); - thisV0.posTrackId = V0.posTrackId(); + thisV0.collisionIds[0] = V0.collisionId(); + thisV0.posTrackId = V0.posTrackId(); thisV0.negTrackId = V0.negTrackId(); thisV0.v0Type = V0.v0Type(); v0table.push_back(thisV0); - } + } // sort tracks according to positive track index to avoid excessive N^2 searches auto posTrackSort = sort_indices_posTrack(v0table); // create a proper list of V0s including duplicates: collisionIds is now a vector - int atPosTrackId = v0table[posTrackSort[0]].posTrackId; + int atPosTrackId = v0table[posTrackSort[0]].posTrackId; std::vector v0tableFixedPositive; // small list with fixed positive id - std::vector v0tableGrouped; // final list with proper grouping - for(size_t iV0 = 0; iV0 v0tableGrouped; // final list with proper grouping + for (size_t iV0 = 0; iV0 < posTrackSort.size(); iV0++) { + if (atPosTrackId != v0table[posTrackSort[iV0]].posTrackId) { // switched pos track id. Process chunk of V0s auto negTrackSort = sort_indices_negTrack(v0tableFixedPositive); thisV0.collisionIds.clear(); thisV0.V0Ids.clear(); thisV0.negTrackId = v0tableFixedPositive[negTrackSort[0]].negTrackId; - for(size_t iPV0 = 0; iPV0 < v0tableFixedPositive.size(); iPV0++){ - if(thisV0.negTrackId != v0tableFixedPositive[negTrackSort[iPV0]].negTrackId){ + for (size_t iPV0 = 0; iPV0 < v0tableFixedPositive.size(); iPV0++) { + if (thisV0.negTrackId != v0tableFixedPositive[negTrackSort[iPV0]].negTrackId) { v0tableGrouped.push_back(thisV0); thisV0.collisionIds.clear(); // clean collision Ids - thisV0.V0Ids.clear(); // clean aod::V0s Ids + thisV0.V0Ids.clear(); // clean aod::V0s Ids } thisV0.V0Ids.push_back(v0tableFixedPositive[negTrackSort[iPV0]].V0Ids[0]); thisV0.collisionIds.push_back(v0tableFixedPositive[negTrackSort[iPV0]].collisionIds[0]); - thisV0.posTrackId = v0tableFixedPositive[negTrackSort[iPV0]].posTrackId; + thisV0.posTrackId = v0tableFixedPositive[negTrackSort[iPV0]].posTrackId; thisV0.negTrackId = v0tableFixedPositive[negTrackSort[iPV0]].negTrackId; thisV0.v0Type = v0tableFixedPositive[negTrackSort[iPV0]].v0Type; } @@ -273,20 +274,20 @@ class strangenessBuilderHelper if constexpr (useSelections) { // verify track quality if (positiveTrack.tpcNClsCrossedRows() < v0selections.minCrossedRows) { - v0 = {}; + v0 = {}; return false; } if (negativeTrack.tpcNClsCrossedRows() < v0selections.minCrossedRows) { - v0 = {}; + v0 = {}; return false; } // verify eta if (std::fabs(positiveTrack.eta()) > v0selections.maxDaughterEta) { - v0 = {}; + v0 = {}; return false; } if (std::fabs(negativeTrack.eta()) > v0selections.maxDaughterEta) { - v0 = {}; + v0 = {}; return false; } } @@ -303,7 +304,7 @@ class strangenessBuilderHelper if constexpr (useSelections) { if (std::fabs(v0.positiveDCAxy) < v0selections.dcanegtopv) { - v0 = {}; + v0 = {}; return false; } } @@ -313,7 +314,7 @@ class strangenessBuilderHelper if constexpr (useSelections) { if (std::fabs(v0.negativeDCAxy) < v0selections.dcanegtopv) { - v0 = {}; + v0 = {}; return false; } } @@ -324,11 +325,11 @@ class strangenessBuilderHelper try { nCand = fitter.process(positiveTrackParam, negativeTrackParam); } catch (...) { - v0 = {}; + v0 = {}; return false; } if (nCand == 0) { - v0 = {}; + v0 = {}; return false; } fitter.setCollinear(false); // proper cleaning: when exiting this loop, always reset to not collinear @@ -354,7 +355,7 @@ class strangenessBuilderHelper if constexpr (useSelections) { if (std::hypot(v0.position[0], v0.position[1]) < v0selections.v0radius) { - v0 = {}; + v0 = {}; return false; } } @@ -363,7 +364,7 @@ class strangenessBuilderHelper if constexpr (useSelections) { if (v0.daughterDCA > v0selections.dcav0dau) { - v0 = {}; + v0 = {}; return false; } } @@ -374,7 +375,7 @@ class strangenessBuilderHelper std::array{v0.positiveMomentum[0] + v0.negativeMomentum[0], v0.positiveMomentum[1] + v0.negativeMomentum[1], v0.positiveMomentum[2] + v0.negativeMomentum[2]}); if constexpr (useSelections) { if (cosPA < v0selections.v0cospa) { - v0 = {}; + v0 = {}; return false; } } @@ -453,21 +454,21 @@ class strangenessBuilderHelper // verify track quality if (positiveTrack.tpcNClsCrossedRows() < v0selections.minCrossedRows) { - v0 = {}; + v0 = {}; return false; } if (negativeTrack.tpcNClsCrossedRows() < v0selections.minCrossedRows) { - v0 = {}; + v0 = {}; return false; } // verify eta if (std::fabs(positiveTrack.eta()) > v0selections.maxDaughterEta) { - v0 = {}; + v0 = {}; return false; } if (std::fabs(negativeTrack.eta()) > v0selections.maxDaughterEta) { - v0 = {}; + v0 = {}; return false; } @@ -482,7 +483,7 @@ class strangenessBuilderHelper v0.positiveDCAxy = dcaInfo[0]; if (std::fabs(v0.positiveDCAxy) < v0selections.dcanegtopv) { - v0 = {}; + v0 = {}; return false; } @@ -490,7 +491,7 @@ class strangenessBuilderHelper v0.negativeDCAxy = dcaInfo[0]; if (std::fabs(v0.negativeDCAxy) < v0selections.dcanegtopv) { - v0 = {}; + v0 = {}; return false; } @@ -511,7 +512,7 @@ class strangenessBuilderHelper KFV0.Construct(V0Daughters, 2); } catch (std::runtime_error& e) { LOG(debug) << "Failed to construct cascade V0 from daughter tracks: " << e.what(); - v0 = {}; + v0 = {}; return false; } @@ -539,7 +540,7 @@ class strangenessBuilderHelper kfpPos_DecayVtx.GetZ() - kfpNeg_DecayVtx.GetZ()); if (v0.daughterDCA > v0selections.dcav0dau) { - v0 = {}; + v0 = {}; return false; } @@ -548,7 +549,7 @@ class strangenessBuilderHelper v0.position[i] = xyz_decay[i]; } if (std::hypot(v0.position[0], v0.position[1]) < v0selections.v0radius) { - v0 = {}; + v0 = {}; return false; } @@ -558,7 +559,7 @@ class strangenessBuilderHelper // deal with pointing angle float cosPA = cpaFromKF(KFV0, KFPV); if (cosPA < v0selections.v0cospa) { - v0 = {}; + v0 = {}; return false; } v0.pointingAngle = TMath::ACos(cosPA); @@ -603,7 +604,7 @@ class strangenessBuilderHelper //_______________________________________________________________________ // build Cascade from three tracks, including V0 building. - // Populates ::cascade object. + // Populates ::cascade object. // ::cascade will be initialized to defaults if build fails // cascade builder creating a cascade from plain tracks template @@ -633,7 +634,7 @@ class strangenessBuilderHelper // cascade builder using pre-fabricated information, thus not calling // the DCAfitter again for the V0 contained in the cascade // If building from scratch, prefer previous version! - // Populates ::cascade object. + // Populates ::cascade object. // ::cascade will be initialized to defaults if build fails // cascade builder creating a cascade from plain tracks template @@ -737,7 +738,7 @@ class strangenessBuilderHelper cascade = {}; return false; } - if (nCand == 0){ + if (nCand == 0) { cascade = {}; return false; } @@ -860,7 +861,7 @@ class strangenessBuilderHelper //_______________________________________________________________________ // build KF Cascade from three tracks, including V0 building. - // Populates ::cascade object. + // Populates ::cascade object. // ::cascade will be initialized to defaults if build fails // cascade builder creating a cascade from plain tracks template @@ -1016,7 +1017,7 @@ class strangenessBuilderHelper cascade = {}; return false; } - if (nCandCascade == 0){ + if (nCandCascade == 0) { cascade = {}; return false; }