Skip to content

Commit 34e494d

Browse files
committed
fix O2Physics-code-check
1 parent 51ee8df commit 34e494d

3 files changed

Lines changed: 86 additions & 61 deletions

File tree

PWGCF/Femto/FemtoNuclei/TableProducer/HadNucleiFemto.cxx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -448,14 +448,14 @@ struct HadNucleiFemto {
448448
float phiPi{0.f};
449449
bool isMatter{false};
450450

451-
float pt() const { return std::hypot(momentum[0], momentum[1]); }
452-
float eta() const
451+
[[nodiscard]] float pt() const { return std::hypot(momentum[0], momentum[1]); }
452+
[[nodiscard]] float eta() const
453453
{
454454
const float transverseMomentum = pt();
455455
return transverseMomentum > 0.f ? std::asinh(momentum[2] / transverseMomentum) : 999.f;
456456
}
457-
float phi() const { return std::atan2(momentum[1], momentum[0]); }
458-
int8_t sign() const { return isMatter ? 1 : -1; }
457+
[[nodiscard]] float phi() const { return std::atan2(momentum[1], momentum[0]); }
458+
[[nodiscard]] int8_t sign() const { return isMatter ? 1 : -1; }
459459
};
460460

461461
struct HadHyperHadron {
@@ -470,10 +470,10 @@ struct HadNucleiFemto {
470470
float phiValue{0.f};
471471
int8_t signValue{0};
472472

473-
float pt() const { return std::hypot(momentum[0], momentum[1]); }
474-
float eta() const { return etaValue; }
475-
float phi() const { return phiValue; }
476-
int8_t sign() const { return signValue; }
473+
[[nodiscard]] float pt() const { return std::hypot(momentum[0], momentum[1]); }
474+
[[nodiscard]] float eta() const { return etaValue; }
475+
[[nodiscard]] float phi() const { return phiValue; }
476+
[[nodiscard]] int8_t sign() const { return signValue; }
477477
};
478478

479479
struct HadHyperEvent {

PWGLF/TableProducer/Nuspex/hyperRecoTask.cxx

Lines changed: 56 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@
5858
#include <cmath>
5959
#include <cstddef>
6060
#include <cstdint>
61-
#include <memory>
6261
#include <string>
6362
#include <vector>
6463

@@ -89,16 +88,16 @@ static const std::vector<std::string> particleName{"He3"};
8988
} // namespace
9089

9190
struct hyperCandidate {
92-
float recoPtHe3() const { return std::hypot(momHe3[0], momHe3[1]); }
93-
float recoPhiHe3() const { return std::atan2(momHe3[1], momHe3[0]); }
94-
float recoEtaHe3() const { return std::asinh(momHe3[2] / recoPtHe3()); }
95-
float recoPtPi() const { return std::hypot(momPi[0], momPi[1]); }
96-
float recoPhiPi() const { return std::atan2(momPi[1], momPi[0]); }
97-
float recoEtaPi() const { return std::asinh(momPi[2] / recoPtPi()); }
98-
float genPt() const { return std::hypot(gMom[0], gMom[1]); }
99-
float genPtHe3() const { return std::hypot(gMomHe3[0], gMomHe3[1]); }
100-
float genPhi() const { return std::atan2(gMom[1], gMom[0]); }
101-
float genEta() const { return std::asinh(gMom[2] / genPt()); }
91+
[[nodiscard]] float recoPtHe3() const { return std::hypot(momHe3[0], momHe3[1]); }
92+
[[nodiscard]] float recoPhiHe3() const { return std::atan2(momHe3[1], momHe3[0]); }
93+
[[nodiscard]] float recoEtaHe3() const { return std::asinh(momHe3[2] / recoPtHe3()); }
94+
[[nodiscard]] float recoPtPi() const { return std::hypot(momPi[0], momPi[1]); }
95+
[[nodiscard]] float recoPhiPi() const { return std::atan2(momPi[1], momPi[0]); }
96+
[[nodiscard]] float recoEtaPi() const { return std::asinh(momPi[2] / recoPtPi()); }
97+
[[nodiscard]] float genPt() const { return std::hypot(gMom[0], gMom[1]); }
98+
[[nodiscard]] float genPtHe3() const { return std::hypot(gMomHe3[0], gMomHe3[1]); }
99+
[[nodiscard]] float genPhi() const { return std::atan2(gMom[1], gMom[0]); }
100+
[[nodiscard]] float genEta() const { return std::asinh(gMom[2] / genPt()); }
102101

103102
int v0ID = -1;
104103
int heTrackID = -1;
@@ -482,8 +481,9 @@ struct HyperRecoTask {
482481
if (collision.has_mcCollision()) {
483482
recoCollisionIds[collision.mcCollisionId()] = collision.globalIndex();
484483
}
485-
if (!collision.selection_bit(aod::evsel::kIsTriggerTVX) || !collision.selection_bit(aod::evsel::kNoTimeFrameBorder))
484+
if (!collision.selection_bit(aod::evsel::kIsTriggerTVX) || !collision.selection_bit(aod::evsel::kNoTimeFrameBorder)) {
486485
continue;
486+
}
487487

488488
qaRegistry.fill(HIST("hEvents"), 1.);
489489

@@ -536,8 +536,9 @@ struct HyperRecoTask {
536536
hypCand.clusterSizeITSPi = piTrack.itsClusterSizes();
537537
bool heliumPID = heTrack.pidForTracking() == o2::track::PID::Helium3 || heTrack.pidForTracking() == o2::track::PID::Alpha;
538538
hypCand.momHe3TPC = (heliumPID && cfgCompensatePIDinTracking) ? heTrack.tpcInnerParam() / 2 : heTrack.tpcInnerParam();
539-
if (hypCand.momHe3TPC < tpcRigidityMinHe)
539+
if (hypCand.momHe3TPC < tpcRigidityMinHe) {
540540
return;
541+
}
541542
hypCand.momPiTPC = piTrack.tpcInnerParam();
542543
qaRegistry.fill(HIST("hDeDxTot"), hypCand.momHe3TPC * heTrack.sign(), heTrack.tpcSignal());
543544
qaRegistry.fill(HIST("hDeDxTot"), hypCand.momPiTPC * piTrack.sign(), piTrack.tpcSignal());
@@ -579,17 +580,21 @@ struct HyperRecoTask {
579580
hypMom[i] = hypCand.momHe3[i] + hypCand.momPi[i];
580581
}
581582
float hypPt = std::hypot(hypMom[0], hypMom[1]);
582-
if (hypPt < ptMin)
583+
if (hypPt < ptMin) {
583584
return;
585+
}
584586
float massH3L = std::sqrt(h3lE * h3lE - hypMom[0] * hypMom[0] - hypMom[1] * hypMom[1] - hypMom[2] * hypMom[2]);
585587
float massH4L = std::sqrt(h4lE * h4lE - hypMom[0] * hypMom[0] - hypMom[1] * hypMom[1] - hypMom[2] * hypMom[2]);
586588
bool isHypMass = false;
587-
if (massH3L > o2::constants::physics::MassHyperTriton - massWidth && massH3L < o2::constants::physics::MassHyperTriton + massWidth)
589+
if (massH3L > o2::constants::physics::MassHyperTriton - massWidth && massH3L < o2::constants::physics::MassHyperTriton + massWidth) {
588590
isHypMass = true;
589-
if (massH4L > o2::constants::physics::MassHyperhydrog4 - massWidth && massH4L < o2::constants::physics::MassHyperhydrog4 + massWidth)
591+
}
592+
if (massH4L > o2::constants::physics::MassHyperhydrog4 - massWidth && massH4L < o2::constants::physics::MassHyperhydrog4 + massWidth) {
590593
isHypMass = true;
591-
if (!isHypMass)
594+
}
595+
if (!isHypMass) {
592596
return;
597+
}
593598

594599
qaRegistry.fill(HIST("hH3LMassBefSel"), massH3L);
595600
qaRegistry.fill(HIST("hH4LMassBefSel"), massH4L);
@@ -671,8 +676,9 @@ struct HyperRecoTask {
671676
auto posTrack = tracks.rawIteratorAt(v0.posTrackId());
672677
auto negTrack = tracks.rawIteratorAt(v0.negTrackId());
673678

674-
if (std::abs(posTrack.eta()) > etaMax || std::abs(negTrack.eta()) > etaMax)
679+
if (std::abs(posTrack.eta()) > etaMax || std::abs(negTrack.eta()) > etaMax) {
675680
continue;
681+
}
676682

677683
// temporary fix: tpcInnhRecoCentralityColvsFT0CmultiplicityerParam() returns the momentum in all the software tags before: https://github.com/AliceO2Group/AliceO2/pull/12521
678684
auto nSigmaTPCpos = computeNSigmaHe3(posTrack);
@@ -711,24 +717,30 @@ struct HyperRecoTask {
711717

712718
for (const auto& track : tracks) {
713719

714-
if (std::abs(track.eta()) > etaMax)
720+
if (std::abs(track.eta()) > etaMax) {
715721
continue;
722+
}
716723

717-
if (!track.hasITS())
724+
if (!track.hasITS()) {
718725
continue;
726+
}
719727

720728
auto nSigmaHe = computeNSigmaHe3(track);
721729
bool isHe = nSigmaHe > -1 * nSigmaMaxHe;
722730
int pdgHypo = isHe ? heDauPdg : PDG_t::kPiPlus;
723731
// LOG(info) << "ncls found: " << track.tpcNClsFound();
724-
if (isHe && track.tpcNClsFound() < nTPCClusMinHe)
732+
if (isHe && track.tpcNClsFound() < nTPCClusMinHe) {
725733
continue;
726-
if (!isHe && track.tpcNClsFound() < nTPCClusMinPi)
734+
}
735+
if (!isHe && track.tpcNClsFound() < nTPCClusMinPi) {
727736
continue;
728-
if (isHe && track.tpcNClsCrossedRows() < nTPCCrossedRowsMinHe)
737+
}
738+
if (isHe && track.tpcNClsCrossedRows() < nTPCCrossedRowsMinHe) {
729739
continue;
730-
if (!isHe && track.tpcNClsCrossedRows() < nTPCCrossedRowsMinPi)
740+
}
741+
if (!isHe && track.tpcNClsCrossedRows() < nTPCCrossedRowsMinPi) {
731742
continue;
743+
}
732744

733745
svCreator.appendTrackCand(track, collisions, pdgHypo, ambiguousTracks, bcs);
734746
}
@@ -756,12 +768,15 @@ struct HyperRecoTask {
756768
if (mcTrackHe.has_mothers() && mcTrackPi.has_mothers()) {
757769
for (const auto& heMother : mcTrackHe.mothers_as<aod::McParticles>()) {
758770
for (const auto& piMother : mcTrackPi.mothers_as<aod::McParticles>()) {
759-
if (heMother.globalIndex() != piMother.globalIndex())
771+
if (heMother.globalIndex() != piMother.globalIndex()) {
760772
continue;
761-
if (std::abs(mcTrackHe.pdgCode()) != heDauPdg || std::abs(mcTrackPi.pdgCode()) != PDG_t::kPiPlus)
773+
}
774+
if (std::abs(mcTrackHe.pdgCode()) != heDauPdg || std::abs(mcTrackPi.pdgCode()) != PDG_t::kPiPlus) {
762775
continue;
763-
if (std::abs(heMother.pdgCode()) != hyperPdg)
776+
}
777+
if (std::abs(heMother.pdgCode()) != hyperPdg) {
764778
continue;
779+
}
765780

766781
auto primVtx = std::array<float, 3>{heMother.vx(), heMother.vy(), heMother.vz()};
767782
auto secVtx = std::array<float, 3>{mcTrackHe.vx(), mcTrackHe.vy(), mcTrackHe.vz()};
@@ -1055,17 +1070,21 @@ struct HyperRecoTask {
10551070
template <typename CollType>
10561071
bool passEvtSel(const CollType& collision)
10571072
{
1058-
if (!collision.sel8())
1073+
if (!collision.sel8()) {
10591074
return false;
1075+
}
10601076

1061-
if ((std::abs(collision.posZ())) > MaxAbsVertexZ)
1077+
if ((std::abs(collision.posZ())) > MaxAbsVertexZ) {
10621078
return false;
1079+
}
10631080

1064-
if (cfgEvSelkNoSameBunchPileup && !collision.selection_bit(aod::evsel::kNoSameBunchPileup))
1081+
if (cfgEvSelkNoSameBunchPileup && !collision.selection_bit(aod::evsel::kNoSameBunchPileup)) {
10651082
return false;
1083+
}
10661084

1067-
if (cfgEvSelkIsGoodZvtxFT0vsPV && !collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV))
1085+
if (cfgEvSelkIsGoodZvtxFT0vsPV && !collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) {
10681086
return false;
1087+
}
10691088

10701089
return true;
10711090
}
@@ -1127,10 +1146,12 @@ struct HyperRecoTask {
11271146
ROOT::Math::PxPyPzMVector daugh1, daugh2, mother;
11281147

11291148
for (const auto& genParticle : GenParticles) {
1130-
if (std::abs(genParticle.y()) > 1)
1149+
if (std::abs(genParticle.y()) > 1) {
11311150
continue;
1132-
if (std::abs(genParticle.pdgCode()) != hyperPdg)
1151+
}
1152+
if (std::abs(genParticle.pdgCode()) != hyperPdg) {
11331153
continue;
1154+
}
11341155

11351156
auto daughters = genParticle.daughters_as<aod::McParticles>();
11361157

@@ -1153,8 +1174,9 @@ struct HyperRecoTask {
11531174
}
11541175
}
11551176
// Check pairs to avoid wrong charge associations
1156-
if (!((dauHe3 && dauPiMinus) || !(dauAntiHe3 && dauPiPos)))
1177+
if (!((dauHe3 && dauPiMinus) || !(dauAntiHe3 && dauPiPos))) {
11571178
continue;
1179+
}
11581180

11591181
mother = daugh1 + daugh2;
11601182

PWGLF/TableProducer/Nuspex/piHypertritonFemto.cxx

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include <CommonConstants/PhysicsConstants.h>
3535
#include <DataFormatsParameters/GRPMagField.h>
3636
#include <Framework/AnalysisDataModel.h>
37+
#include <Framework/AnalysisHelpers.h>
3738
#include <Framework/AnalysisTask.h>
3839
#include <Framework/BinningPolicy.h>
3940
#include <Framework/CallbackService.h>
@@ -44,6 +45,7 @@
4445
#include <Framework/InitContext.h>
4546
#include <Framework/OutputObjHeader.h>
4647
#include <Framework/runDataProcessing.h>
48+
#include <ReconstructionDataFormats/TrackParametrization.h>
4749

4850
#include <Math/GenVector/Boost.h>
4951
#include <Math/GenVector/LorentzVector.h>
@@ -55,6 +57,7 @@
5557
#include <algorithm>
5658
#include <array>
5759
#include <cmath>
60+
#include <cstddef>
5861
#include <cstdint>
5962
#include <deque>
6063
#include <functional>
@@ -274,14 +277,14 @@ struct PiHypertritonFemto {
274277
std::array<ClosePairTrack, 2> daughterClosePairTracks{}; // He3, decay pion.
275278
uint64_t mixedPairCount{0}; // Accumulated over the complete residence in the mixing pool.
276279

277-
float pt() const { return std::hypot(momentum[0], momentum[1]); }
278-
float eta() const
280+
[[nodiscard]] float pt() const { return std::hypot(momentum[0], momentum[1]); }
281+
[[nodiscard]] float eta() const
279282
{
280283
const float transverseMomentum = pt();
281284
return transverseMomentum > 0.f ? std::asinh(momentum[2] / transverseMomentum) : 999.f;
282285
}
283-
float phi() const { return std::atan2(momentum[1], momentum[0]); }
284-
int8_t sign() const { return isMatter ? 1 : -1; }
286+
[[nodiscard]] float phi() const { return std::atan2(momentum[1], momentum[0]); }
287+
[[nodiscard]] int8_t sign() const { return isMatter ? 1 : -1; }
285288
};
286289

287290
struct HadHyperHadron {
@@ -293,9 +296,9 @@ struct PiHypertritonFemto {
293296
int8_t signValue{0};
294297
ClosePairTrack closePairTrack{};
295298

296-
float eta() const { return std::get<1>(info); }
297-
float phi() const { return std::get<2>(info); }
298-
int8_t sign() const { return signValue; }
299+
[[nodiscard]] float eta() const { return std::get<1>(info); }
300+
[[nodiscard]] float phi() const { return std::get<2>(info); }
301+
[[nodiscard]] int8_t sign() const { return signValue; }
299302
};
300303

301304
struct HadHyperEvent {
@@ -402,7 +405,7 @@ struct PiHypertritonFemto {
402405
// AO2D signed1Pt is signed inverse rigidity: He3's |Z|=2 is already included.
403406
// Do not multiply it by two again. Cache each source event's field-dependent values.
404407
constexpr float CurvatureFactor = 0.3f * 0.01f / 2.f; // B in T, radius in cm.
405-
for (size_t i = 0; i < CPRTPCRadii.size(); ++i) {
408+
for (std::size_t i = 0; i < CPRTPCRadii.size(); ++i) {
406409
const float argument = CurvatureFactor * mMagneticFieldTesla * CPRTPCRadii[i] * track.signed1Pt();
407410
if (std::isfinite(argument) && std::abs(argument) < 1.f) {
408411
result.phiStar[i] = track.phi() - std::asin(argument);
@@ -415,7 +418,7 @@ struct PiHypertritonFemto {
415418
constexpr float TeslaToKilogauss = 10.f;
416419
constexpr float TPCHalfLength = 250.f; // cm
417420
const float fieldKilogauss = TeslaToKilogauss * mMagneticFieldTesla;
418-
for (size_t i = 0; i < CPRTPCRadii.size(); ++i) {
421+
for (std::size_t i = 0; i < CPRTPCRadii.size(); ++i) {
419422
float localX = 0.f;
420423
if (!trackPar.getXatLabR(CPRTPCRadii[i], localX, fieldKilogauss, o2::track::DirOutward)) {
421424
continue;
@@ -436,7 +439,7 @@ struct PiHypertritonFemto {
436439
{
437440
ClosePairResult result;
438441
result.deltaEta = pion.eta - daughter.eta;
439-
for (size_t i = 0; i < CPRTPCRadii.size(); ++i) {
442+
for (std::size_t i = 0; i < CPRTPCRadii.size(); ++i) {
440443
if (pion.valid[i] && daughter.valid[i]) {
441444
result.deltaPhiStar += wrapDeltaPhi(pion.phiStar[i] - daughter.phiStar[i]);
442445
++result.validRadii;
@@ -487,7 +490,7 @@ struct PiHypertritonFemto {
487490
rejectionFlags |= aod::pihypertritonfemto::ClosePairDistanceUnavailable;
488491
}
489492
}
490-
for (size_t i = 0; i < results.size(); ++i) {
493+
for (std::size_t i = 0; i < results.size(); ++i) {
491494
const auto& result = results[i];
492495
const auto& qa = mClosePairQA[mixed ? 1 : 0][i];
493496
qa.validRadii->Fill(result.validRadii);
@@ -581,7 +584,7 @@ struct PiHypertritonFemto {
581584
const std::array<float, 3> decayPionMomentum{candidate.ptPi() * std::cos(candidate.phiPi()), candidate.ptPi() * std::sin(candidate.phiPi()), candidate.ptPi() * std::sinh(candidate.etaPi())};
582585

583586
HadHyperCandidate result;
584-
for (size_t i = 0; i < result.momentum.size(); ++i) {
587+
for (std::size_t i = 0; i < result.momentum.size(); ++i) {
585588
result.momentum[i] = heMomentum[i] + decayPionMomentum[i];
586589
}
587590
result.mass = computeHyperCandidateMass(candidate);
@@ -857,23 +860,23 @@ struct PiHypertritonFemto {
857860
{
858861
const int depth = static_cast<int>(pool.size());
859862
hadHyperRegistry.fill(HIST("hMixingDepth"), depth);
860-
for (size_t partnerIndex = 0; partnerIndex < pool.size(); ++partnerIndex) {
863+
for (std::size_t partnerIndex = 0; partnerIndex < pool.size(); ++partnerIndex) {
861864
auto& partner = pool[partnerIndex];
862865
const float currentPosZ = std::get<0>(currentEvent.info);
863866
const float partnerPosZ = std::get<0>(partner.info);
864867
hadHyperRegistry.fill(HIST("hMixEventDeltaPosZVsCent"), currentEvent.centrality, currentPosZ - partnerPosZ);
865868
hadHyperRegistry.fill(HIST("hMixEventDeltaCentFT0CVsCent"), currentEvent.centrality, currentEvent.centrality - partner.centrality);
866869
hadHyperRegistry.fill(HIST("hMixEventDeltaPosZVsCent"), partner.centrality, partnerPosZ - currentPosZ);
867870
hadHyperRegistry.fill(HIST("hMixEventDeltaCentFT0CVsCent"), partner.centrality, partner.centrality - currentEvent.centrality);
868-
for (size_t candidateIndex = 0; candidateIndex < currentEvent.candidates.size(); ++candidateIndex) {
871+
for (std::size_t candidateIndex = 0; candidateIndex < currentEvent.candidates.size(); ++candidateIndex) {
869872
auto& candidate = currentEvent.candidates[candidateIndex];
870873
for (const auto& pion : partner.hadrons) {
871874
if (fillPair<isMC>(candidate, pion, currentEvent, partner, true, depth)) {
872875
++candidate.mixedPairCount;
873876
}
874877
}
875878
}
876-
for (size_t candidateIndex = 0; candidateIndex < partner.candidates.size(); ++candidateIndex) {
879+
for (std::size_t candidateIndex = 0; candidateIndex < partner.candidates.size(); ++candidateIndex) {
877880
auto& candidate = partner.candidates[candidateIndex];
878881
for (const auto& pion : currentEvent.hadrons) {
879882
if (fillPair<isMC>(candidate, pion, partner, currentEvent, true, depth)) {
@@ -908,7 +911,7 @@ struct PiHypertritonFemto {
908911
if (requestedMixingDepth <= 0) {
909912
return;
910913
}
911-
const auto mixingDepth = static_cast<size_t>(requestedMixingDepth);
914+
const auto mixingDepth = static_cast<std::size_t>(requestedMixingDepth);
912915
if (pool.size() >= mixingDepth) {
913916
flushMixedEventMultiplicity(pool.front());
914917
pool.pop_front();
@@ -949,8 +952,8 @@ void PiHypertritonFemto::init(o2::framework::InitContext&)
949952

950953
const std::array<std::string, 2> eventNames{"SE", "ME"};
951954
const std::array<std::string, 2> daughterNames{"He3", "DecayPi"};
952-
for (size_t eventIndex = 0; eventIndex < eventNames.size(); ++eventIndex) {
953-
for (size_t daughterIndex = 0; daughterIndex < daughterNames.size(); ++daughterIndex) {
955+
for (std::size_t eventIndex = 0; eventIndex < eventNames.size(); ++eventIndex) {
956+
for (std::size_t daughterIndex = 0; daughterIndex < daughterNames.size(); ++daughterIndex) {
954957
const std::string prefix = "CPR/" + eventNames[eventIndex] + "/" + daughterNames[daughterIndex];
955958
auto& qa = mClosePairQA[eventIndex][daughterIndex];
956959
qa.before = hadHyperRegistry.add<TH2>((prefix + "/hBefore").c_str(), "All pairs;#Delta#eta;#LT#Delta#varphi*#GT",
@@ -1006,7 +1009,7 @@ void PiHypertritonFemto::init(o2::framework::InitContext&)
10061009
"Zorro (data, optional)",
10071010
"MC collision label (MC, optional)",
10081011
"Mixing bin (if enabled)"};
1009-
for (size_t i = 0; i < eventsLabels.size(); i++) {
1012+
for (std::size_t i = 0; i < eventsLabels.size(); i++) {
10101013
mQaRegistry.get<TH1>(HIST("hEvents"))->GetXaxis()->SetBinLabel(i + 1, eventsLabels[i].c_str());
10111014
}
10121015
}

0 commit comments

Comments
 (0)