Skip to content

Commit 048265a

Browse files
committed
Corrected variable names and set const references for iterators in all range for loops
1 parent 68d76bc commit 048265a

File tree

1 file changed

+34
-33
lines changed

1 file changed

+34
-33
lines changed

PWGLF/TableProducer/Strangeness/sigmaminustask.cxx

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ struct sigmaminustask {
6060

6161
Configurable<std::vector<int>> mothPdgCodes{"mothPdgCodes", std::vector<int>{3112, 3222}, "PDG codes of the selected mother particles"};
6262
Configurable<std::vector<int>> daugPdgCodes{"daugPdgCodes", std::vector<int>{211, 2212}, "PDG codes of the selected charged daughter particles"};
63-
63+
6464
Configurable<bool> fillOutputTree{"fillOutputTree", true, "If true, fill the output tree with Kink candidates"};
6565

6666
// Configurables for findable tracks (kinkBuilder.cxx efficiency)
@@ -242,10 +242,10 @@ struct sigmaminustask {
242242

243243
float kinkAngle(std::array<float, 3> const& p_moth, std::array<float, 3> const& p_daug)
244244
{
245-
float dot_product = std::inner_product(p_moth.begin(), p_moth.end(), p_daug.begin(), 0.0f);
246-
float mag_moth = std::hypot(p_moth[0], p_moth[1], p_moth[2]);
247-
float mag_daug = std::hypot(p_daug[0], p_daug[1], p_daug[2]);
248-
return std::acos(dot_product / (mag_moth * mag_daug)) * 180.0 / M_PI;
245+
float dotProduct = std::inner_product(p_moth.begin(), p_moth.end(), p_daug.begin(), 0.0f);
246+
float magMoth = std::hypot(p_moth[0], p_moth[1], p_moth[2]);
247+
float magDaug = std::hypot(p_daug[0], p_daug[1], p_daug[2]);
248+
return std::acos(dotProduct / (magMoth * magDaug)) * radToDeg;
249249
}
250250

251251
void processData(CollisionsFull::iterator const& collision, aod::KinkCands const& KinkCands, TracksFull const&)
@@ -333,22 +333,22 @@ struct sigmaminustask {
333333
continue;
334334
}
335335

336-
for (auto& mcMother : mcTrackDaug.mothers_as<aod::McParticles>()) {
336+
for (const auto& mcMother : mcTrackDaug.mothers_as<aod::McParticles>()) {
337337
if (mcMother.globalIndex() != mcTrackMoth.globalIndex()) {
338338
continue;
339339
}
340340

341341
// Select only valid mother and daughter
342342
bool isValidMother = false;
343343
bool isValidDaughter = false;
344-
for (int pdgCode : cast_mothPdgCodes) {
344+
for (const int pdgCode : cast_mothPdgCodes) {
345345
if (std::abs(mcTrackMoth.pdgCode()) == pdgCode) {
346346
isValidMother = true;
347347
break;
348348
}
349349
}
350350

351-
for (int pdgCode : cast_daugPdgCodes) {
351+
for (const int pdgCode : cast_daugPdgCodes) {
352352
if (std::abs(mcTrackDaug.pdgCode()) == pdgCode) {
353353
isValidDaughter = true;
354354
break;
@@ -359,9 +359,9 @@ struct sigmaminustask {
359359
continue;
360360
}
361361

362-
float MotherMassMC = std::sqrt(mcMother.e() * mcMother.e() - mcMother.p() * mcMother.p());
363-
float MotherpTMC = mcMother.pt();
364-
float MotherpZMC = mcMother.pz();
362+
float motherMassMC = std::sqrt(mcMother.e() * mcMother.e() - mcMother.p() * mcMother.p());
363+
float motherPtMC = mcMother.pt();
364+
float motherPzMC = mcMother.pz();
365365
float deltaXMother = mcTrackDaug.vx() - mcMother.vx();
366366
float deltaYMother = mcTrackDaug.vy() - mcMother.vy();
367367
float decayRadiusMC = std::sqrt(deltaXMother * deltaXMother + deltaYMother * deltaYMother);
@@ -378,24 +378,25 @@ struct sigmaminustask {
378378

379379
// Check bunch crossing ID coherence
380380
auto mcCollision = mcTrackDaug.template mcCollision_as<aod::McCollisions>();
381-
bool BCId_vs_EvSel = collision.bcId() == collision.foundBCId();
382-
bool EvSel_vs_MCBCId = collision.foundBCId() == mcCollision.bcId();
381+
bool bcIdVsEvSel = (collision.bcId() == collision.foundBCId());
382+
bool evSelVsMcbcId = (collision.foundBCId() == mcCollision.bcId());
383383

384384
rSigmaMinus.fill(HIST("hMcCollIdCoherence"), static_cast<int>(mcCollisionIdCheck));
385-
rSigmaMinus.fill(HIST("h2CollId_BCId"), static_cast<int>(mcCollisionIdCheck), static_cast<int>(EvSel_vs_MCBCId));
386-
rSigmaMinus.fill(HIST("h2BCId_comp"), static_cast<int>(EvSel_vs_MCBCId), static_cast<int>(BCId_vs_EvSel));
385+
rSigmaMinus.fill(HIST("h2CollId_BCId"), static_cast<int>(mcCollisionIdCheck), static_cast<int>(evSelVsMcbcId));
386+
rSigmaMinus.fill(HIST("h2BCId_comp"), static_cast<int>(evSelVsMcbcId), static_cast<int>(bcIdVsEvSel));
387387

388388
rSigmaMinus.fill(HIST("h2MassPtMCRec"), kinkCand.mothSign() * kinkCand.ptMoth(), kinkCand.mSigmaMinus());
389-
rSigmaMinus.fill(HIST("h2MassResolution"), kinkCand.mothSign() * kinkCand.ptMoth(), (kinkCand.mSigmaMinus() - MotherMassMC) / MotherMassMC);
390-
rSigmaMinus.fill(HIST("h2PtResolution"), kinkCand.mothSign() * kinkCand.ptMoth(), (kinkCand.ptMoth() - MotherpTMC) / MotherpTMC);
389+
rSigmaMinus.fill(HIST("h2MassResolution"), kinkCand.mothSign() * kinkCand.ptMoth(), (kinkCand.mSigmaMinus() - motherMassMC) / motherMassMC);
390+
rSigmaMinus.fill(HIST("h2PtResolution"), kinkCand.mothSign() * kinkCand.ptMoth(), (kinkCand.ptMoth() - motherPtMC) / motherPtMC);
391391
rSigmaMinus.fill(HIST("h2RadiusResolution"), kinkCand.mothSign() * kinkCand.ptMoth(), (decayRadiusRec - decayRadiusMC) / decayRadiusMC);
392392
rSigmaMinus.fill(HIST("h2DCAMothPt"), kinkCand.mothSign() * kinkCand.ptMoth(), kinkCand.dcaMothPv());
393393
rSigmaMinus.fill(HIST("h2DCADaugPt"), kinkCand.mothSign() * kinkCand.ptMoth(), kinkCand.dcaDaugPv());
394394
rSigmaMinus.fill(HIST("h2CosPointingAnglePt"), kinkCand.mothSign() * kinkCand.ptMoth(), cosPointingAngleRec);
395395
rSigmaMinus.fill(HIST("h2ArmenterosPostCuts"), alphaAPValue, qtValue);
396-
396+
397397
rSigmaMinus.fill(HIST("h2NSigmaTOFPiPt"), kinkCand.mothSign() * kinkCand.ptMoth(), dauTrack.tofNSigmaPi());
398398
rSigmaMinus.fill(HIST("h2NSigmaTOFPrPt"), kinkCand.mothSign() * kinkCand.ptMoth(), dauTrack.tofNSigmaPr());
399+
399400

400401
// fill the output table with Mc information
401402
if (fillOutputTree) {
@@ -407,7 +408,7 @@ struct sigmaminustask {
407408
dauTrack.tpcNSigmaPi(), dauTrack.tpcNSigmaPr(), dauTrack.tpcNSigmaKa(),
408409
dauTrack.tofNSigmaPi(), dauTrack.tofNSigmaPr(), dauTrack.tofNSigmaKa(),
409410
mcTrackMoth.pdgCode(), mcTrackDaug.pdgCode(),
410-
MotherpTMC, MotherpZMC, MotherMassMC, decayRadiusMC, mcCollisionIdCheck);
411+
motherPtMC, motherPzMC, motherMassMC, decayRadiusMC, mcCollisionIdCheck);
411412
}
412413
}
413414
} // MC association and selection
@@ -421,7 +422,7 @@ struct sigmaminustask {
421422
}
422423

423424
bool isValidMother = false;
424-
for (int pdgCode : cast_mothPdgCodes) {
425+
for (const int pdgCode : cast_mothPdgCodes) {
425426
if (std::abs(mcPart.pdgCode()) == pdgCode) {
426427
isValidMother = true;
427428
break;
@@ -440,16 +441,16 @@ struct sigmaminustask {
440441
}
441442

442443
bool hasValidDaughter = false;
443-
int daug_pdg = 0;
444+
int daugPdg = 0;
444445
std::array<float, 3> secVtx;
445446
std::array<float, 3> momDaug;
446447
for (const auto& daughter : mcPart.daughters_as<aod::McParticles>()) {
447-
for (int pdgCode : cast_daugPdgCodes) {
448+
for (const int pdgCode : cast_daugPdgCodes) {
448449
if (std::abs(daughter.pdgCode()) == pdgCode) {
449450
hasValidDaughter = true;
450451
secVtx = {daughter.vx(), daughter.vy(), daughter.vz()};
451452
momDaug = {daughter.px(), daughter.py(), daughter.pz()};
452-
daug_pdg = daughter.pdgCode();
453+
daugPdg = daughter.pdgCode();
453454
break; // Found a daughter, exit loop
454455
}
455456
}
@@ -477,7 +478,7 @@ struct sigmaminustask {
477478
mothSign,
478479
-999, -999, -999,
479480
-999, -999, -999,
480-
mcPart.pdgCode(), daug_pdg,
481+
mcPart.pdgCode(), daugPdg,
481482
mcPart.pt(), mcPart.pz(), mcMass, mcDecayRadius, false);
482483
}
483484
}
@@ -518,7 +519,7 @@ struct sigmaminustask {
518519
}
519520
auto mcParticle = mcLabel.mcParticle_as<aod::McParticles>();
520521
bool isValidMother = false;
521-
for (int pdgCode : cast_mothPdgCodes) {
522+
for (const int pdgCode : cast_mothPdgCodes) {
522523
if (std::abs(mcParticle.pdgCode()) == pdgCode) {
523524
isValidMother = true;
524525
break;
@@ -536,7 +537,7 @@ struct sigmaminustask {
536537
}
537538
auto mcParticle = mcLabel.mcParticle_as<aod::McParticles>();
538539
bool isValidDaughter = false;
539-
for (int pdgCode : cast_daugPdgCodes) {
540+
for (const int pdgCode : cast_daugPdgCodes) {
540541
if (std::abs(mcParticle.pdgCode()) == pdgCode) {
541542
isValidDaughter = true;
542543
break;
@@ -569,14 +570,14 @@ struct sigmaminustask {
569570
auto mcDaughter = mcLabDaug.mcParticle_as<aod::McParticles>();
570571

571572
bool isValidMother = false;
572-
for (int pdgCode : cast_mothPdgCodes) {
573+
for (const int pdgCode : cast_mothPdgCodes) {
573574
if (std::abs(mcMother.pdgCode()) == pdgCode) {
574575
isValidMother = true;
575576
break;
576577
}
577578
}
578579
bool isValidDaughter = false;
579-
for (int pdgCode : cast_daugPdgCodes) {
580+
for (const int pdgCode : cast_daugPdgCodes) {
580581
if (std::abs(mcDaughter.pdgCode()) == pdgCode) {
581582
isValidDaughter = true;
582583
break;
@@ -623,12 +624,12 @@ struct sigmaminustask {
623624
}
624625

625626
// Check for detector mismatches in ITS mother tracks
626-
auto mask_value = mcLabMoth.mcMask();
627-
int mismatchITS_index = -1;
627+
auto maskValue = mcLabMoth.mcMask();
628+
int mismatchITSIndex = -1;
628629

629630
for (int i = 0; i < 7; ++i) { // ITS has layers 0-6, bit ON means mismatch
630-
if ((mask_value & (1 << i)) != 0) {
631-
mismatchITS_index = i;
631+
if ((maskValue & (1 << i)) != 0) {
632+
mismatchITSIndex = i;
632633
break;
633634
}
634635
}
@@ -642,7 +643,7 @@ struct sigmaminustask {
642643
daughterTrack.hasITS() && daughterTrack.hasTPC()) {
643644
filterIndex += 1;
644645
fillFindableHistograms(filterIndex, mcRadius, recRadius, recPtMother, recPtDaughter, mothPdg, daugPdg);
645-
rFindable.fill(HIST("hfakeITSfindable"), mismatchITS_index);
646+
rFindable.fill(HIST("hfakeITSfindable"), mismatchITSIndex);
646647
} else {
647648
continue;
648649
}

0 commit comments

Comments
 (0)