Skip to content

Commit d488bdf

Browse files
committed
Please consider the following formatting changes
1 parent f0013a2 commit d488bdf

File tree

2 files changed

+40
-49
lines changed

2 files changed

+40
-49
lines changed

PWGJE/Core/JetTaggingUtilities.h

Lines changed: 36 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -643,53 +643,49 @@ int vertexClustering(AnyCollision const& collision, AnalysisJet const& jet, AnyT
643643

644644
std::vector<int> tempTrkVtxIndex;
645645

646-
int i=0;
646+
int i = 0;
647647
for (const auto& constituent : tracks) {
648648
if (!constituent.has_mcParticle() || !constituent.template mcParticle_as<AnyParticles>().isPhysicalPrimary() || constituent.pt() < trackPtMin)
649649
tempTrkVtxIndex.push_back(-1);
650650
else
651651
tempTrkVtxIndex.push_back(i++);
652652
}
653653
tempTrkVtxIndex.push_back(i); // temporary index for PV
654-
if (n_trks < 1) { // the process should be done for n_trks == 1 as well
654+
if (n_trks < 1) { // the process should be done for n_trks == 1 as well
655655
trkLabels["trkVtxIndex"] = tempTrkVtxIndex;
656656
return n_trks;
657657
}
658658

659659
int n_pos = n_trks + 1;
660660
std::vector<float> dists(n_pos * (n_pos - 1) / 2);
661661
auto trk_pair_idx = [n_pos](int ti, int tj) {
662-
if (ti==tj || ti>=n_pos || tj>=n_pos || ti<0 || tj<0) {
663-
LOGF(info,"Track pair index out of range");
662+
if (ti == tj || ti >= n_pos || tj >= n_pos || ti < 0 || tj < 0) {
663+
LOGF(info, "Track pair index out of range");
664664
return -1;
665-
}
666-
else
665+
} else
667666
return (ti < tj) ? (ti * n_pos - (ti * (ti + 1)) / 2 + tj - ti - 1) : (tj * n_pos - (tj * (tj + 1)) / 2 + ti - tj - 1);
668667
}; // index n_trks is for PV
669668

670-
for (int ti=0; ti<n_pos-1; ti++)
671-
for (int tj=ti+1; tj<n_pos; tj++) {
669+
for (int ti = 0; ti < n_pos - 1; ti++)
670+
for (int tj = ti + 1; tj < n_pos; tj++) {
672671
std::array<float, 3> posi, posj;
673-
672+
674673
if (tj < n_trks) {
675674
if (tracks[tj].has_mcParticle()) {
676675
const auto& pj = tracks[tj].template mcParticle_as<AnyParticles>().template mcParticle_as<AnyOriginalParticles>();
677676
posj = std::array<float, 3>{pj.vx(), pj.vy(), pj.vz()};
678-
}
679-
else {
677+
} else {
680678
dists[trk_pair_idx(ti, tj)] = std::numeric_limits<float>::max();
681679
continue;
682680
}
683-
}
684-
else {
681+
} else {
685682
posj = std::array<float, 3>{collision.posX(), collision.posY(), collision.posZ()};
686683
}
687684

688685
if (tracks[ti].has_mcParticle()) {
689686
const auto& pi = tracks[ti].template mcParticle_as<AnyParticles>().template mcParticle_as<AnyOriginalParticles>();
690687
posi = std::array<float, 3>{pi.vx(), pi.vy(), pi.vz()};
691-
}
692-
else {
688+
} else {
693689
dists[trk_pair_idx(ti, tj)] = std::numeric_limits<float>::max();
694690
continue;
695691
}
@@ -698,13 +694,13 @@ int vertexClustering(AnyCollision const& collision, AnalysisJet const& jet, AnyT
698694
}
699695

700696
int clusteri = -1, clusterj = -1;
701-
float min_min_dist = -1.f; // If there is an not-merge-able min_dist pair, check the 2nd-min_dist pair.
697+
float min_min_dist = -1.f; // If there is an not-merge-able min_dist pair, check the 2nd-min_dist pair.
702698
while (true) {
703699

704700
float min_dist = -1.f; // Get min_dist pair
705-
for (int ti=0; ti<n_pos-1; ti++)
706-
for (int tj=ti+1; tj<n_pos; tj++)
707-
if (tempTrkVtxIndex[ti] != tempTrkVtxIndex[tj] && tempTrkVtxIndex[ti]>=0 && tempTrkVtxIndex[tj]>=0) {
701+
for (int ti = 0; ti < n_pos - 1; ti++)
702+
for (int tj = ti + 1; tj < n_pos; tj++)
703+
if (tempTrkVtxIndex[ti] != tempTrkVtxIndex[tj] && tempTrkVtxIndex[ti] >= 0 && tempTrkVtxIndex[tj] >= 0) {
708704
float dist = dists[trk_pair_idx(ti, tj)];
709705
if ((dist < min_dist || min_dist < 0.f) && dist > min_min_dist) {
710706
min_dist = dist;
@@ -714,22 +710,22 @@ int vertexClustering(AnyCollision const& collision, AnalysisJet const& jet, AnyT
714710
}
715711
if (clusteri < 0 || clusterj < 0)
716712
break;
717-
713+
718714
bool mrg = true; // Merge-ability check
719-
for (int ti=0; ti<n_pos && mrg; ti++)
720-
if (tempTrkVtxIndex[ti] == tempTrkVtxIndex[clusteri] && tempTrkVtxIndex[ti]>=0)
721-
for (int tj=0; tj<n_pos && mrg; tj++)
722-
if (tj != ti && tempTrkVtxIndex[tj] == tempTrkVtxIndex[clusterj] && tempTrkVtxIndex[tj]>=0)
715+
for (int ti = 0; ti < n_pos && mrg; ti++)
716+
if (tempTrkVtxIndex[ti] == tempTrkVtxIndex[clusteri] && tempTrkVtxIndex[ti] >= 0)
717+
for (int tj = 0; tj < n_pos && mrg; tj++)
718+
if (tj != ti && tempTrkVtxIndex[tj] == tempTrkVtxIndex[clusterj] && tempTrkVtxIndex[tj] >= 0)
723719
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.
724720
mrg = false;
725721
min_min_dist = min_dist;
726722
}
727723
if (min_dist > vtxResParam || min_dist < 0.f)
728724
break;
729-
725+
730726
if (mrg) { // Merge two clusters
731727
int old_index = tempTrkVtxIndex[clusterj];
732-
for (int t=0; t<n_pos; t++)
728+
for (int t = 0; t < n_pos; t++)
733729
if (tempTrkVtxIndex[t] == old_index)
734730
tempTrkVtxIndex[t] = tempTrkVtxIndex[clusteri];
735731
}
@@ -739,61 +735,57 @@ int vertexClustering(AnyCollision const& collision, AnalysisJet const& jet, AnyT
739735

740736
// Sort the indices from PV (as 0) to the most distant SV (as 1~).
741737
int idxPV = tempTrkVtxIndex[n_trks];
742-
for (int t=0; t<n_trks; t++)
738+
for (int t = 0; t < n_trks; t++)
743739
if (tempTrkVtxIndex[t] == idxPV) {
744740
tempTrkVtxIndex[t] = -2;
745741
n_vertices = 1; // There is a track originating from PV
746742
}
747-
743+
748744
std::unordered_map<int, float> avgDistances;
749745
std::unordered_map<int, int> count;
750-
for (int t=0; t<n_trks; t++) {
746+
for (int t = 0; t < n_trks; t++) {
751747
if (tempTrkVtxIndex[t] >= 0) {
752748
avgDistances[tempTrkVtxIndex[t]] += dists[trk_pair_idx(t, n_trks)];
753749
count[tempTrkVtxIndex[t]]++;
754750
}
755751
}
756-
752+
757753
trkLabels["trkVtxIndex"] = std::vector<int>(n_trks, -1);
758754
if (count.size() != 0) { // If there is any SV cluster not only PV cluster
759755
for (auto& [idx, avgDistance] : avgDistances)
760756
avgDistance /= count[idx];
761757

762758
n_vertices += avgDistances.size();
763-
759+
764760
std::vector<std::pair<int, float>> sortedIndices(avgDistances.begin(), avgDistances.end());
765761
std::sort(sortedIndices.begin(), sortedIndices.end(), [](const auto& a, const auto& b) { return a.second < b.second; });
766762
int rank = 1;
767763
for (const auto& [idx, avgDistance] : sortedIndices) {
768764
bool found = false;
769-
for (int t=0; t<n_trks; t++)
765+
for (int t = 0; t < n_trks; t++)
770766
if (tempTrkVtxIndex[t] == idx) {
771767
trkLabels["trkVtxIndex"][t] = rank;
772768
found = true;
773769
}
774770
rank += found;
775771
}
776772
}
777-
778-
for (int t=0; t<n_trks; t++)
773+
774+
for (int t = 0; t < n_trks; t++)
779775
if (tempTrkVtxIndex[t] == -2)
780776
trkLabels["trkVtxIndex"][t] = 0;
781777

782778
// trkOrigin
783779

784780
int trkIdx = 0;
785-
for (auto &constituent : jet.template tracks_as<AnyTracks>())
786-
{
787-
if (!constituent.has_mcParticle() || !constituent.template mcParticle_as<AnyParticles>().isPhysicalPrimary() || constituent.pt() < trackPtMin)
788-
{
781+
for (auto& constituent : jet.template tracks_as<AnyTracks>()) {
782+
if (!constituent.has_mcParticle() || !constituent.template mcParticle_as<AnyParticles>().isPhysicalPrimary() || constituent.pt() < trackPtMin) {
789783
trkLabels["trkOrigin"].push_back(0);
790-
}
791-
else
792-
{
793-
const auto &particle = constituent.template mcParticle_as<AnyParticles>();
784+
} else {
785+
const auto& particle = constituent.template mcParticle_as<AnyParticles>();
794786
int orig = RecoDecay::getParticleOrigin(particles, particle, true);
795-
trkLabels["trkOrigin"].push_back((orig > 0) ? orig :
796-
(trkLabels["trkVtxIndex"][trkIdx] == 0) ? 3 : 4);
787+
trkLabels["trkOrigin"].push_back((orig > 0) ? orig : (trkLabels["trkVtxIndex"][trkIdx] == 0) ? 3
788+
: 4);
797789
}
798790

799791
trkIdx++;

PWGJE/Tasks/bjetTreeCreator.cxx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,7 @@ struct BJetTreeCreator {
286286
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.}}});
287287
}
288288

289-
if (doprocessMCJetsForGNN)
290-
{
289+
if (doprocessMCJetsForGNN) {
291290
//+jet
292291
registry.add("h_jet_pt", "jet_pt;#it{p}_{T}^{ch jet} (GeV/#it{c});Entries", {HistType::kTH1F, {{100, 0., 200.}}});
293292
registry.add("h_jet_eta", "jet_eta;#it{#eta}_{ch jet};Entries", {HistType::kTH1F, {{100, -2., 2.}}});
@@ -464,7 +463,7 @@ struct BJetTreeCreator {
464463
}
465464

466465
template <typename AnyCollision, typename AnalysisJet, typename AnyTracks, typename AnyOriginalTracks>
467-
void analyzeJetTrackInfoForGNN(AnyCollision const& /*collision*/, AnalysisJet const& analysisJet, AnyTracks const& /*allTracks*/, AnyOriginalTracks const&, std::vector<int>& trackIndices, int jetFlavor = 0, double eventweight = 1.0, TrackLabelMap *trkLabels = nullptr)
466+
void analyzeJetTrackInfoForGNN(AnyCollision const& /*collision*/, AnalysisJet const& analysisJet, AnyTracks const& /*allTracks*/, AnyOriginalTracks const&, std::vector<int>& trackIndices, int jetFlavor = 0, double eventweight = 1.0, TrackLabelMap* trkLabels = nullptr)
468467
{
469468
int trkIdx = -1;
470469
for (auto& constituent : analysisJet.template tracks_as<AnyTracks>()) {
@@ -523,7 +522,7 @@ struct BJetTreeCreator {
523522
registry.fill(HIST("h_trk_origin"), trkOrigin);
524523

525524
if (produceTree) {
526-
bjetTracksExtraTable(/*bjetParamsTable.lastIndex() + 1, */origConstit.phi(), constituent.sign(), origConstit.itsChi2NCl(), origConstit.tpcChi2NCl(), origConstit.itsNCls(), origConstit.tpcNClsFound(), origConstit.tpcNClsCrossedRows(), trkOrigin, trkVtxIndex); //+
525+
bjetTracksExtraTable(/*bjetParamsTable.lastIndex() + 1, */ origConstit.phi(), constituent.sign(), origConstit.itsChi2NCl(), origConstit.tpcChi2NCl(), origConstit.itsNCls(), origConstit.tpcNClsFound(), origConstit.tpcNClsCrossedRows(), trkOrigin, trkVtxIndex); //+
527526
}
528527
}
529528

@@ -693,7 +692,7 @@ struct BJetTreeCreator {
693692
using MCDJetTableNoSV = soa::Filtered<soa::Join<aod::ChargedMCDetectorLevelJets, aod::ChargedMCDetectorLevelJetConstituents, aod::ChargedMCDetectorLevelJetsMatchedToChargedMCParticleLevelJets, aod::ChargedMCDetectorLevelJetEventWeights>>;
694693
using JetParticleswID = soa::Join<aod::JetParticles, aod::JMcParticlePIs>;
695694

696-
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)
695+
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)
697696
{
698697
if (!jetderiveddatautilities::selectCollision(collision, eventSelection) || (static_cast<double>(std::rand()) / RAND_MAX < eventReductionFactor)) {
699698
return;

0 commit comments

Comments
 (0)