Skip to content

Commit 6546f66

Browse files
committed
modification of o2_rint
1 parent f3d7327 commit 6546f66

File tree

3 files changed

+439
-439
lines changed

3 files changed

+439
-439
lines changed

PWGJE/Core/JetTaggingUtilities.h

Lines changed: 59 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ int jetOrigin(T const& jet, U const& particles, float dRMax = 0.25)
323323
bool firstPartonFound = false;
324324
typename U::iterator parton1;
325325
typename U::iterator parton2;
326-
for (auto& particle : particles) {
326+
for (auto const& particle : particles) {
327327
if (std::abs(particle.getGenStatusCode() == 23)) {
328328
if (!firstPartonFound) {
329329
parton1 = particle;
@@ -359,15 +359,15 @@ template <typename AnyJet, typename AllMCParticles>
359359
int16_t getJetFlavor(AnyJet const& jet, AllMCParticles const& mcparticles)
360360
{
361361
bool charmQuark = false;
362-
for (auto& mcpart : mcparticles) {
362+
for (auto const& mcpart : mcparticles) {
363363
int pdgcode = mcpart.pdgCode();
364-
if (TMath::Abs(pdgcode) == 21 || (TMath::Abs(pdgcode) >= 1 && TMath::Abs(pdgcode) <= 5)) {
364+
if (std::abs(pdgcode) == 21 || (std::abs(pdgcode) >= 1 && std::abs(pdgcode) <= 5)) {
365365
double dR = jetutilities::deltaR(jet, mcpart);
366366

367367
if (dR < jet.r() / 100.f) {
368-
if (TMath::Abs(pdgcode) == 5) {
368+
if (std::abs(pdgcode) == 5) {
369369
return JetTaggingSpecies::beauty; // Beauty jet
370-
} else if (TMath::Abs(pdgcode) == 4) {
370+
} else if (std::abs(pdgcode) == 4) {
371371
charmQuark = true;
372372
}
373373
}
@@ -392,7 +392,7 @@ int16_t getJetFlavorHadron(AnyJet const& jet, AllMCParticles const& mcparticles)
392392
{
393393
bool charmHadron = false;
394394

395-
for (auto& mcpart : mcparticles) {
395+
for (auto const& mcpart : mcparticles) {
396396
int pdgcode = mcpart.pdgCode();
397397
if (isBHadron(pdgcode) || isCHadron(pdgcode)) {
398398
double dR = jetutilities::deltaR(jet, mcpart);
@@ -491,7 +491,7 @@ int getGeoSign(T const& jet, U const& jtrack)
491491
template <typename T, typename U, typename Vec = std::vector<float>>
492492
void orderForIPJetTracks(T const& jet, U const& /*jtracks*/, float const& trackDcaXYMax, float const& trackDcaZMax, Vec& vecSignImpSig, bool useIPxyz)
493493
{
494-
for (auto& jtrack : jet.template tracks_as<U>()) {
494+
for (auto const& jtrack : jet.template tracks_as<U>()) {
495495
if (!trackAcceptanceWithDca(jtrack, trackDcaXYMax, trackDcaZMax))
496496
continue;
497497
auto geoSign = getGeoSign(jet, jtrack);
@@ -565,7 +565,7 @@ template <typename T, typename U>
565565
float getTrackProbability(T const& fResoFuncjet, U const& track, const float& minSignImpXYSig = -40)
566566
{
567567
float probTrack = 0;
568-
auto varSignImpXYSig = TMath::Abs(track.dcaXY()) / track.sigmadcaXY();
568+
auto varSignImpXYSig = std::abs(track.dcaXY()) / track.sigmadcaXY();
569569
if (-varSignImpXYSig < minSignImpXYSig)
570570
varSignImpXYSig = -minSignImpXYSig - 0.01; // To avoid overflow for integral
571571
probTrack = fResoFuncjet->Integral(minSignImpXYSig, -varSignImpXYSig) / fResoFuncjet->Integral(minSignImpXYSig, 0);
@@ -600,7 +600,7 @@ float getJetProbability(T const& fResoFuncjet, U const& jet, V const& jtracks, f
600600
std::vector<float> jetTracksPt;
601601
float trackjetProb = 1.;
602602

603-
for (auto& jtrack : jet.template tracks_as<V>()) {
603+
for (auto const& jtrack : jet.template tracks_as<V>()) {
604604
if (!trackAcceptanceWithDca(jtrack, trackDcaXYMax, trackDcaZMax))
605605
continue;
606606

@@ -613,17 +613,17 @@ float getJetProbability(T const& fResoFuncjet, U const& jet, V const& jtracks, f
613613
}
614614
}
615615

616-
float JP = -1.;
616+
float jp = -1.;
617617
if (jetTracksPt.size() < 2)
618618
return -1;
619619

620620
float sumjetProb = 0.;
621621
for (std::vector<float>::size_type i = 0; i < jetTracksPt.size(); i++) {
622-
sumjetProb += (TMath::Power(-1 * TMath::Log(trackjetProb), static_cast<int>(i)) / TMath::Factorial(i));
622+
sumjetProb += (std::pow(-1 * std::log(trackjetProb), static_cast<int>(i)) / TMath::Factorial(i));
623623
}
624624

625-
JP = trackjetProb * sumjetProb;
626-
return JP;
625+
jp = trackjetProb * sumjetProb;
626+
return jp;
627627
}
628628

629629
// For secaondy vertex method utilites
@@ -638,13 +638,13 @@ typename ProngType::iterator jetFromProngMaxDecayLength(const JetType& jet, floa
638638
if (!prongAcceptance(prong, prongChi2PCAMin, prongChi2PCAMax, prongsigmaLxyMax, prongIPxyMin, prongIPxyMax, doXYZ))
639639
continue;
640640
*checkSv = true;
641-
float Sxy = -1.0f;
641+
float sxy = -1.0f;
642642
if (!doXYZ) {
643-
Sxy = prong.decayLengthXY() / prong.errorDecayLengthXY();
643+
sxy = prong.decayLengthXY() / prong.errorDecayLengthXY();
644644
} else {
645-
Sxy = prong.decayLength() / prong.errorDecayLength();
645+
sxy = prong.decayLength() / prong.errorDecayLength();
646646
}
647-
if (maxSxy < Sxy) {
647+
if (maxSxy < sxy) {
648648
bjetCand = prong;
649649
}
650650
}
@@ -681,7 +681,7 @@ template <typename AnyCollision, typename AnalysisJet, typename AnyTracks, typen
681681
int vertexClustering(AnyCollision const& collision, AnalysisJet const& jet, AnyTracks const&, AnyParticles const& particles, AnyOriginalParticles const&, std::unordered_map<std::string, std::vector<int>>& trkLabels, bool searchUpToQuark, float vtxResParam = 0.01 /* 0.01cm = 100um */, float trackPtMin = 0.5)
682682
{
683683
const auto& tracks = jet.template tracks_as<AnyTracks>();
684-
const int n_trks = tracks.size();
684+
const int nTrks = tracks.size();
685685

686686
// trkVtxIndex
687687

@@ -695,32 +695,32 @@ int vertexClustering(AnyCollision const& collision, AnalysisJet const& jet, AnyT
695695
tempTrkVtxIndex.push_back(i++);
696696
}
697697
tempTrkVtxIndex.push_back(i); // temporary index for PV
698-
if (n_trks < 1) { // the process should be done for n_trks == 1 as well
698+
if (nTrks < 1) { // the process should be done for nTrks == 1 as well
699699
trkLabels["trkVtxIndex"] = tempTrkVtxIndex;
700-
return n_trks;
700+
return nTrks;
701701
}
702702

703-
int n_pos = n_trks + 1;
704-
std::vector<float> dists(n_pos * (n_pos - 1) / 2);
705-
auto trk_pair_idx = [n_pos](int ti, int tj) {
706-
if (ti == tj || ti >= n_pos || tj >= n_pos || ti < 0 || tj < 0) {
703+
int nPos = nTrks + 1;
704+
std::vector<float> dists(nPos * (nPos - 1) / 2);
705+
auto trkPairIdx = [nPos](int ti, int tj) {
706+
if (ti == tj || ti >= nPos || tj >= nPos || ti < 0 || tj < 0) {
707707
LOGF(info, "Track pair index out of range");
708708
return -1;
709709
} else {
710-
return (ti < tj) ? (ti * n_pos - (ti * (ti + 1)) / 2 + tj - ti - 1) : (tj * n_pos - (tj * (tj + 1)) / 2 + ti - tj - 1);
710+
return (ti < tj) ? (ti * nPos - (ti * (ti + 1)) / 2 + tj - ti - 1) : (tj * nPos - (tj * (tj + 1)) / 2 + ti - tj - 1);
711711
}
712-
}; // index n_trks is for PV
712+
}; // index nTrks is for PV
713713

714-
for (int ti = 0; ti < n_pos - 1; ti++)
715-
for (int tj = ti + 1; tj < n_pos; tj++) {
714+
for (int ti = 0; ti < nPos - 1; ti++)
715+
for (int tj = ti + 1; tj < nPos; tj++) {
716716
std::array<float, 3> posi, posj;
717717

718-
if (tj < n_trks) {
718+
if (tj < nTrks) {
719719
if (tracks[tj].has_mcParticle()) {
720720
const auto& pj = tracks[tj].template mcParticle_as<AnyParticles>().template mcParticle_as<AnyOriginalParticles>();
721721
posj = std::array<float, 3>{pj.vx(), pj.vy(), pj.vz()};
722722
} else {
723-
dists[trk_pair_idx(ti, tj)] = std::numeric_limits<float>::max();
723+
dists[trkPairIdx(ti, tj)] = std::numeric_limits<float>::max();
724724
continue;
725725
}
726726
} else {
@@ -731,24 +731,24 @@ int vertexClustering(AnyCollision const& collision, AnalysisJet const& jet, AnyT
731731
const auto& pi = tracks[ti].template mcParticle_as<AnyParticles>().template mcParticle_as<AnyOriginalParticles>();
732732
posi = std::array<float, 3>{pi.vx(), pi.vy(), pi.vz()};
733733
} else {
734-
dists[trk_pair_idx(ti, tj)] = std::numeric_limits<float>::max();
734+
dists[trkPairIdx(ti, tj)] = std::numeric_limits<float>::max();
735735
continue;
736736
}
737737

738-
dists[trk_pair_idx(ti, tj)] = RecoDecay::distance(posi, posj);
738+
dists[trkPairIdx(ti, tj)] = RecoDecay::distance(posi, posj);
739739
}
740740

741741
int clusteri = -1, clusterj = -1;
742-
float min_min_dist = -1.f; // If there is an not-merge-able min_dist pair, check the 2nd-min_dist pair.
742+
float minMinDist = -1.f; // If there is an not-merge-able minDist pair, check the 2nd-minDist pair.
743743
while (true) {
744744

745-
float min_dist = -1.f; // Get min_dist pair
746-
for (int ti = 0; ti < n_pos - 1; ti++)
747-
for (int tj = ti + 1; tj < n_pos; tj++)
745+
float minDist = -1.f; // Get minDist pair
746+
for (int ti = 0; ti < nPos - 1; ti++)
747+
for (int tj = ti + 1; tj < nPos; tj++)
748748
if (tempTrkVtxIndex[ti] != tempTrkVtxIndex[tj] && tempTrkVtxIndex[ti] >= 0 && tempTrkVtxIndex[tj] >= 0) {
749-
float dist = dists[trk_pair_idx(ti, tj)];
750-
if ((dist < min_dist || min_dist < 0.f) && dist > min_min_dist) {
751-
min_dist = dist;
749+
float dist = dists[trkPairIdx(ti, tj)];
750+
if ((dist < minDist || minDist < 0.f) && dist > minMinDist) {
751+
minDist = dist;
752752
clusteri = ti;
753753
clusterj = tj;
754754
}
@@ -757,59 +757,59 @@ int vertexClustering(AnyCollision const& collision, AnalysisJet const& jet, AnyT
757757
break;
758758

759759
bool mrg = true; // Merge-ability check
760-
for (int ti = 0; ti < n_pos && mrg; ti++)
760+
for (int ti = 0; ti < nPos && mrg; ti++)
761761
if (tempTrkVtxIndex[ti] == tempTrkVtxIndex[clusteri] && tempTrkVtxIndex[ti] >= 0) {
762-
for (int tj = 0; tj < n_pos && mrg; tj++)
762+
for (int tj = 0; tj < nPos && mrg; tj++)
763763
if (tj != ti && tempTrkVtxIndex[tj] == tempTrkVtxIndex[clusterj] && tempTrkVtxIndex[tj] >= 0) {
764-
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.
764+
if (dists[trkPairIdx(ti, tj)] > vtxResParam) { // If there is more distant pair compared to vtx_res between two clusters, they cannot be merged.
765765
mrg = false;
766-
min_min_dist = min_dist;
766+
minMinDist = minDist;
767767
}
768768
}
769769
}
770-
if (min_dist > vtxResParam || min_dist < 0.f)
770+
if (minDist > vtxResParam || minDist < 0.f)
771771
break;
772772

773773
if (mrg) { // Merge two clusters
774-
int old_index = tempTrkVtxIndex[clusterj];
775-
for (int t = 0; t < n_pos; t++)
776-
if (tempTrkVtxIndex[t] == old_index)
774+
int oldIndex = tempTrkVtxIndex[clusterj];
775+
for (int t = 0; t < nPos; t++)
776+
if (tempTrkVtxIndex[t] == oldIndex)
777777
tempTrkVtxIndex[t] = tempTrkVtxIndex[clusteri];
778778
}
779779
}
780780

781-
int n_vertices = 0;
781+
int nVertices = 0;
782782

783783
// Sort the indices from PV (as 0) to the most distant SV (as 1~).
784-
int idxPV = tempTrkVtxIndex[n_trks];
785-
for (int t = 0; t < n_trks; t++)
784+
int idxPV = tempTrkVtxIndex[nTrks];
785+
for (int t = 0; t < nTrks; t++)
786786
if (tempTrkVtxIndex[t] == idxPV) {
787787
tempTrkVtxIndex[t] = -2;
788-
n_vertices = 1; // There is a track originating from PV
788+
nVertices = 1; // There is a track originating from PV
789789
}
790790

791791
std::unordered_map<int, float> avgDistances;
792792
std::unordered_map<int, int> count;
793-
for (int t = 0; t < n_trks; t++) {
793+
for (int t = 0; t < nTrks; t++) {
794794
if (tempTrkVtxIndex[t] >= 0) {
795-
avgDistances[tempTrkVtxIndex[t]] += dists[trk_pair_idx(t, n_trks)];
795+
avgDistances[tempTrkVtxIndex[t]] += dists[trkPairIdx(t, nTrks)];
796796
count[tempTrkVtxIndex[t]]++;
797797
}
798798
}
799799

800-
trkLabels["trkVtxIndex"] = std::vector<int>(n_trks, -1);
800+
trkLabels["trkVtxIndex"] = std::vector<int>(nTrks, -1);
801801
if (count.size() != 0) { // If there is any SV cluster not only PV cluster
802802
for (auto& [idx, avgDistance] : avgDistances)
803803
avgDistance /= count[idx];
804804

805-
n_vertices += avgDistances.size();
805+
nVertices += avgDistances.size();
806806

807807
std::vector<std::pair<int, float>> sortedIndices(avgDistances.begin(), avgDistances.end());
808808
std::sort(sortedIndices.begin(), sortedIndices.end(), [](const auto& a, const auto& b) { return a.second < b.second; });
809809
int rank = 1;
810810
for (const auto& [idx, avgDistance] : sortedIndices) {
811811
bool found = false;
812-
for (int t = 0; t < n_trks; t++)
812+
for (int t = 0; t < nTrks; t++)
813813
if (tempTrkVtxIndex[t] == idx) {
814814
trkLabels["trkVtxIndex"][t] = rank;
815815
found = true;
@@ -818,14 +818,14 @@ int vertexClustering(AnyCollision const& collision, AnalysisJet const& jet, AnyT
818818
}
819819
}
820820

821-
for (int t = 0; t < n_trks; t++)
821+
for (int t = 0; t < nTrks; t++)
822822
if (tempTrkVtxIndex[t] == -2)
823823
trkLabels["trkVtxIndex"][t] = 0;
824824

825825
// trkOrigin
826826

827827
int trkIdx = 0;
828-
for (auto& constituent : jet.template tracks_as<AnyTracks>()) {
828+
for (auto const& constituent : jet.template tracks_as<AnyTracks>()) {
829829
if (!constituent.has_mcParticle() || !constituent.template mcParticle_as<AnyParticles>().isPhysicalPrimary() || constituent.pt() < trackPtMin) {
830830
trkLabels["trkOrigin"].push_back(0);
831831
} else {
@@ -838,7 +838,7 @@ int vertexClustering(AnyCollision const& collision, AnalysisJet const& jet, AnyT
838838
trkIdx++;
839839
}
840840

841-
return n_vertices;
841+
return nVertices;
842842
}
843843

844844
}; // namespace jettaggingutilities

0 commit comments

Comments
 (0)