From 374d5cf6ce58cc7f68b0f90fc17dfc8484ac5aa9 Mon Sep 17 00:00:00 2001 From: ALICE Action Bot Date: Wed, 20 Nov 2024 01:07:05 +0000 Subject: [PATCH] Please consider the following formatting changes --- PWGJE/Core/JetTaggingUtilities.h | 80 ++++++++++++++------------------ PWGJE/Tasks/bjetTreeCreator.cxx | 9 ++-- 2 files changed, 40 insertions(+), 49 deletions(-) diff --git a/PWGJE/Core/JetTaggingUtilities.h b/PWGJE/Core/JetTaggingUtilities.h index 6e87e5db48b..ba0dce13039 100644 --- a/PWGJE/Core/JetTaggingUtilities.h +++ b/PWGJE/Core/JetTaggingUtilities.h @@ -643,7 +643,7 @@ int vertexClustering(AnyCollision const& collision, AnalysisJet const& jet, AnyT std::vector tempTrkVtxIndex; - int i=0; + int i = 0; for (const auto& constituent : tracks) { if (!constituent.has_mcParticle() || !constituent.template mcParticle_as().isPhysicalPrimary() || constituent.pt() < trackPtMin) tempTrkVtxIndex.push_back(-1); @@ -651,7 +651,7 @@ int vertexClustering(AnyCollision const& collision, AnalysisJet const& jet, AnyT tempTrkVtxIndex.push_back(i++); } tempTrkVtxIndex.push_back(i); // temporary index for PV - if (n_trks < 1) { // the process should be done for n_trks == 1 as well + if (n_trks < 1) { // the process should be done for n_trks == 1 as well trkLabels["trkVtxIndex"] = tempTrkVtxIndex; return n_trks; } @@ -659,37 +659,33 @@ int vertexClustering(AnyCollision const& collision, AnalysisJet const& jet, AnyT int n_pos = n_trks + 1; std::vector dists(n_pos * (n_pos - 1) / 2); auto trk_pair_idx = [n_pos](int ti, int tj) { - if (ti==tj || ti>=n_pos || tj>=n_pos || ti<0 || tj<0) { - LOGF(info,"Track pair index out of range"); + if (ti == tj || ti >= n_pos || tj >= n_pos || ti < 0 || tj < 0) { + LOGF(info, "Track pair index out of range"); return -1; - } - else + } else return (ti < tj) ? (ti * n_pos - (ti * (ti + 1)) / 2 + tj - ti - 1) : (tj * n_pos - (tj * (tj + 1)) / 2 + ti - tj - 1); }; // index n_trks is for PV - for (int ti=0; ti posi, posj; - + if (tj < n_trks) { if (tracks[tj].has_mcParticle()) { const auto& pj = tracks[tj].template mcParticle_as().template mcParticle_as(); posj = std::array{pj.vx(), pj.vy(), pj.vz()}; - } - else { + } else { dists[trk_pair_idx(ti, tj)] = std::numeric_limits::max(); continue; } - } - else { + } else { posj = std::array{collision.posX(), collision.posY(), collision.posZ()}; } if (tracks[ti].has_mcParticle()) { const auto& pi = tracks[ti].template mcParticle_as().template mcParticle_as(); posi = std::array{pi.vx(), pi.vy(), pi.vz()}; - } - else { + } else { dists[trk_pair_idx(ti, tj)] = std::numeric_limits::max(); continue; } @@ -698,13 +694,13 @@ int vertexClustering(AnyCollision const& collision, AnalysisJet const& jet, AnyT } int clusteri = -1, clusterj = -1; - float min_min_dist = -1.f; // If there is an not-merge-able min_dist pair, check the 2nd-min_dist pair. + float min_min_dist = -1.f; // If there is an not-merge-able min_dist pair, check the 2nd-min_dist pair. while (true) { float min_dist = -1.f; // Get min_dist pair - for (int ti=0; ti=0 && tempTrkVtxIndex[tj]>=0) { + for (int ti = 0; ti < n_pos - 1; ti++) + for (int tj = ti + 1; tj < n_pos; tj++) + if (tempTrkVtxIndex[ti] != tempTrkVtxIndex[tj] && tempTrkVtxIndex[ti] >= 0 && tempTrkVtxIndex[tj] >= 0) { float dist = dists[trk_pair_idx(ti, tj)]; if ((dist < min_dist || min_dist < 0.f) && dist > min_min_dist) { min_dist = dist; @@ -714,22 +710,22 @@ int vertexClustering(AnyCollision const& collision, AnalysisJet const& jet, AnyT } if (clusteri < 0 || clusterj < 0) break; - + bool mrg = true; // Merge-ability check - for (int ti=0; ti=0) - for (int tj=0; tj=0) + for (int ti = 0; ti < n_pos && mrg; ti++) + if (tempTrkVtxIndex[ti] == tempTrkVtxIndex[clusteri] && tempTrkVtxIndex[ti] >= 0) + for (int tj = 0; tj < n_pos && mrg; tj++) + if (tj != ti && tempTrkVtxIndex[tj] == tempTrkVtxIndex[clusterj] && tempTrkVtxIndex[tj] >= 0) if (dists[trk_pair_idx(ti, tj)] > vtxResParam) { // If there is more distant pair compared to vtx_res between two clusters, they cannot be merged. mrg = false; min_min_dist = min_dist; } if (min_dist > vtxResParam || min_dist < 0.f) break; - + if (mrg) { // Merge two clusters int old_index = tempTrkVtxIndex[clusterj]; - for (int t=0; t avgDistances; std::unordered_map count; - for (int t=0; t= 0) { avgDistances[tempTrkVtxIndex[t]] += dists[trk_pair_idx(t, n_trks)]; count[tempTrkVtxIndex[t]]++; } } - + trkLabels["trkVtxIndex"] = std::vector(n_trks, -1); if (count.size() != 0) { // If there is any SV cluster not only PV cluster for (auto& [idx, avgDistance] : avgDistances) avgDistance /= count[idx]; n_vertices += avgDistances.size(); - + std::vector> sortedIndices(avgDistances.begin(), avgDistances.end()); std::sort(sortedIndices.begin(), sortedIndices.end(), [](const auto& a, const auto& b) { return a.second < b.second; }); int rank = 1; for (const auto& [idx, avgDistance] : sortedIndices) { bool found = false; - for (int t=0; t()) - { - if (!constituent.has_mcParticle() || !constituent.template mcParticle_as().isPhysicalPrimary() || constituent.pt() < trackPtMin) - { + for (auto& constituent : jet.template tracks_as()) { + if (!constituent.has_mcParticle() || !constituent.template mcParticle_as().isPhysicalPrimary() || constituent.pt() < trackPtMin) { trkLabels["trkOrigin"].push_back(0); - } - else - { - const auto &particle = constituent.template mcParticle_as(); + } else { + const auto& particle = constituent.template mcParticle_as(); int orig = RecoDecay::getParticleOrigin(particles, particle, searchUpToQuark); - trkLabels["trkOrigin"].push_back((orig > 0) ? orig : - (trkLabels["trkVtxIndex"][trkIdx] == 0) ? 3 : 4); + trkLabels["trkOrigin"].push_back((orig > 0) ? orig : (trkLabels["trkVtxIndex"][trkIdx] == 0) ? 3 + : 4); } trkIdx++; diff --git a/PWGJE/Tasks/bjetTreeCreator.cxx b/PWGJE/Tasks/bjetTreeCreator.cxx index b1daabc029e..9391a6d4c79 100644 --- a/PWGJE/Tasks/bjetTreeCreator.cxx +++ b/PWGJE/Tasks/bjetTreeCreator.cxx @@ -286,8 +286,7 @@ struct BJetTreeCreator { registry.add("h2_Response_DetjetpT_PartjetpT_lfjet", "Response matrix lf-jet;#it{p}_{T,jet}^{det} (GeV/#it{c});#it{p}_{T,jet}^{part} (GeV/#it{c})", {HistType::kTH2F, {{200, 0., 200.}, {200, 0., 200.}}}); } - if (doprocessMCJetsForGNN) - { + if (doprocessMCJetsForGNN) { //+jet registry.add("h_jet_pt", "jet_pt;#it{p}_{T}^{ch jet} (GeV/#it{c});Entries", {HistType::kTH1F, {{100, 0., 200.}}}); registry.add("h_jet_eta", "jet_eta;#it{#eta}_{ch jet};Entries", {HistType::kTH1F, {{100, -2., 2.}}}); @@ -464,7 +463,7 @@ struct BJetTreeCreator { } template - void analyzeJetTrackInfoForGNN(AnyCollision const& /*collision*/, AnalysisJet const& analysisJet, AnyTracks const& /*allTracks*/, AnyOriginalTracks const&, std::vector& trackIndices, int jetFlavor = 0, double eventweight = 1.0, TrackLabelMap *trkLabels = nullptr) + void analyzeJetTrackInfoForGNN(AnyCollision const& /*collision*/, AnalysisJet const& analysisJet, AnyTracks const& /*allTracks*/, AnyOriginalTracks const&, std::vector& trackIndices, int jetFlavor = 0, double eventweight = 1.0, TrackLabelMap* trkLabels = nullptr) { int trkIdx = -1; for (auto& constituent : analysisJet.template tracks_as()) { @@ -523,7 +522,7 @@ struct BJetTreeCreator { registry.fill(HIST("h_trk_origin"), trkOrigin); if (produceTree) { - bjetTracksExtraTable(/*bjetParamsTable.lastIndex() + 1, */origConstit.phi(), constituent.sign(), origConstit.itsChi2NCl(), origConstit.tpcChi2NCl(), origConstit.itsNCls(), origConstit.tpcNClsFound(), origConstit.tpcNClsCrossedRows(), trkOrigin, trkVtxIndex); //+ + bjetTracksExtraTable(/*bjetParamsTable.lastIndex() + 1, */ origConstit.phi(), constituent.sign(), origConstit.itsChi2NCl(), origConstit.tpcChi2NCl(), origConstit.itsNCls(), origConstit.tpcNClsFound(), origConstit.tpcNClsCrossedRows(), trkOrigin, trkVtxIndex); //+ } } @@ -693,7 +692,7 @@ struct BJetTreeCreator { using MCDJetTableNoSV = soa::Filtered>; using JetParticleswID = soa::Join; - void processMCJetsForGNN(FilteredCollisionMCD::iterator const &collision, aod::JMcCollisions const &, MCDJetTableNoSV const &MCDjets, MCPJetTable const &MCPjets, JetTracksMCDwID const &allTracks, JetParticleswID const &MCParticles, OriginalTracks const& origTracks, aod::McParticles const& origParticles) + void processMCJetsForGNN(FilteredCollisionMCD::iterator const& collision, aod::JMcCollisions const&, MCDJetTableNoSV const& MCDjets, MCPJetTable const& MCPjets, JetTracksMCDwID const& allTracks, JetParticleswID const& MCParticles, OriginalTracks const& origTracks, aod::McParticles const& origParticles) { if (!jetderiveddatautilities::selectCollision(collision, eventSelection) || (static_cast(std::rand()) / RAND_MAX < eventReductionFactor)) { return;