Skip to content

Commit cc8df88

Browse files
committed
[PWGCF] Lambda-Cascade correlation: fix clang-tidy code-check errors
1 parent d24351b commit cc8df88

1 file changed

Lines changed: 36 additions & 39 deletions

File tree

PWGCF/TwoParticleCorrelations/Tasks/Lambdacascadecorrelation.cxx

Lines changed: 36 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,10 @@
2828
#include <CCDB/BasicCCDBManager.h>
2929
#include <CommonConstants/MathConstants.h>
3030
#include <CommonConstants/PhysicsConstants.h>
31-
#include <Framework/ASoAHelpers.h>
3231
#include <Framework/AnalysisDataModel.h>
3332
#include <Framework/AnalysisHelpers.h>
3433
#include <Framework/AnalysisTask.h>
35-
#include <Framework/BinningPolicy.h>
3634
#include <Framework/Configurable.h>
37-
#include <Framework/GroupedCombinations.h>
3835
#include <Framework/HistogramRegistry.h>
3936
#include <Framework/HistogramSpec.h>
4037
#include <Framework/InitContext.h>
@@ -57,7 +54,6 @@
5754
#include <string>
5855
#include <string_view>
5956
#include <unordered_set>
60-
#include <utility>
6157
#include <vector>
6258

6359
using namespace o2;
@@ -738,11 +734,11 @@ struct LambdaCascadeProducer {
738734

739735
// Initialize CCDB Service (shared with cascade-side path; LTP's cUrlCCDB
740736
// is the live URL — see init() comment).
741-
Service<o2::ccdb::BasicCCDBManager> ccdb;
737+
Service<o2::ccdb::BasicCCDBManager> ccdb = {};
742738

743739
// PDG service for cascade competing-mass cut, brought in from
744740
// the former CascadeSelector struct.
745-
Service<o2::framework::O2DatabasePDG> pdgDB;
741+
Service<o2::framework::O2DatabasePDG> pdgDB = {};
746742

747743
// ===========================================================================
748744
// Cascade-side Configurables bundled into one ConfigurableGroup:
@@ -1273,11 +1269,7 @@ struct LambdaCascadeProducer {
12731269
// Kinematic Selection
12741270
bool kinCutSelection(float const& ptVal, float const& rapVal, float const& ptMin, float const& ptMax, float const& rapMax)
12751271
{
1276-
if (ptVal <= ptMin || ptVal >= ptMax || rapVal >= rapMax) {
1277-
return false;
1278-
}
1279-
1280-
return true;
1272+
return (ptVal > ptMin && ptVal < ptMax && rapVal < rapMax);
12811273
}
12821274

12831275
// Track Selection
@@ -1424,7 +1416,8 @@ struct LambdaCascadeProducer {
14241416
if (!lambdaFlag && !antiLambdaFlag) { // neither Lambda nor Anti-Lambda
14251417
histos.fill(HIST("Tracks/h1f_tracks_info"), kNotLambdaNotAntiLambda);
14261418
return false;
1427-
} else if (lambdaFlag && antiLambdaFlag) { // check if the track is identified as lambda and anti-lambda both (DISCARD THIS TRACK)
1419+
}
1420+
if (lambdaFlag && antiLambdaFlag) { // identified as both lambda and anti-lambda (DISCARD THIS TRACK)
14281421
histos.fill(HIST("Tracks/h1f_tracks_info"), kV0IsBothLambdaAntiLambda);
14291422
return false;
14301423
}
@@ -1654,12 +1647,12 @@ struct LambdaCascadeProducer {
16541647
// histogram may be missing from the CCDB TList. Previously the
16551648
// subsequent ->Clone() dereferenced nullptr and crashed.
16561649
const auto effName = Form("%s", vCorrFactStrings[cCorrFactHist][part].c_str());
1657-
TObject* objEff = reinterpret_cast<TObject*>(ccdbObj->FindObject(effName));
1650+
auto* objEff = ccdbObj->FindObject(effName);
16581651
if (!objEff) {
16591652
LOGF(warning, "[CCDB] Efficiency histogram '%s' not found; using effCorrFact=1.0", effName);
16601653
effCorrFact = 1.f;
16611654
} else {
1662-
TH1F* histEff = reinterpret_cast<TH1F*>(objEff->Clone());
1655+
auto* histEff = static_cast<TH1F*>(objEff->Clone());
16631656
if (histEff->GetDimension() == TwoDimCorr) {
16641657
histos.fill(HIST("Tracks/h1f_tracks_info"), kEffCorrPtCent);
16651658
effCorrFact = histEff->GetBinContent(histEff->FindBin(cent, v0.pt()));
@@ -1680,12 +1673,12 @@ struct LambdaCascadeProducer {
16801673
if (cGetPrimFrac) {
16811674
// Same null-guard as the efficiency lookup above.
16821675
const auto pfName = Form("%s", vPrimFracStrings[cPrimFracHist][part].c_str());
1683-
TObject* objPrm = reinterpret_cast<TObject*>(ccdbObj->FindObject(pfName));
1676+
auto* objPrm = ccdbObj->FindObject(pfName);
16841677
if (!objPrm) {
16851678
LOGF(warning, "[CCDB] Primary-fraction histogram '%s' not found; using primFrac=1.0", pfName);
16861679
primFrac = 1.f;
16871680
} else {
1688-
TH1F* histPrm = reinterpret_cast<TH1F*>(objPrm->Clone());
1681+
auto* histPrm = static_cast<TH1F*>(objPrm->Clone());
16891682
if (histPrm->GetDimension() == TwoDimCorr) {
16901683
histos.fill(HIST("Tracks/h1f_tracks_info"), kPFCorrPtCent);
16911684
primFrac = histPrm->GetBinContent(histPrm->FindBin(cent, v0.pt()));
@@ -1736,7 +1729,7 @@ struct LambdaCascadeProducer {
17361729
template <ParticleType part, typename C, typename V, typename T>
17371730
void fillLambdaQAHistos(C const& col, V const& v0, T const&)
17381731
{
1739-
static constexpr std::string_view SubDir[] = {"QA/Lambda/", "QA/AntiLambda/"};
1732+
static constexpr std::array<std::string_view, 2> SubDir = {"QA/Lambda/", "QA/AntiLambda/"};
17401733

17411734
// daugthers
17421735
auto postrack = v0.template posTrack_as<T>();
@@ -1786,8 +1779,8 @@ struct LambdaCascadeProducer {
17861779
template <RecGenType rg, ParticleType part>
17871780
void fillKinematicHists(float const& ptVal, float const& etaVal, float const& y, float const& phiVal)
17881781
{
1789-
static constexpr std::string_view SubDirRG[] = {"McRec/", "McGen/"};
1790-
static constexpr std::string_view SubDirPart[] = {"Lambda/", "AntiLambda/"};
1782+
static constexpr std::array<std::string_view, 2> SubDirRG = {"McRec/", "McGen/"};
1783+
static constexpr std::array<std::string_view, 2> SubDirPart = {"Lambda/", "AntiLambda/"};
17911784

17921785
histos.fill(HIST(SubDirRG[rg]) + HIST(SubDirPart[part]) + HIST("hPt"), ptVal);
17931786
histos.fill(HIST(SubDirRG[rg]) + HIST(SubDirPart[part]) + HIST("hEta"), etaVal);
@@ -1930,11 +1923,11 @@ struct LambdaCascadeProducer {
19301923
auto negTrk = v0.template negTrack_as<T>();
19311924
float dcaV0ToPV_v = v0.dcav0topv(); // V0 line vs PV
19321925
float v0Radius_v = v0.v0radius(); // transverse decay radius
1933-
int8_t posItsNCls_v = static_cast<int8_t>(posTrk.itsNCls());
1934-
int8_t negItsNCls_v = static_cast<int8_t>(negTrk.itsNCls());
1926+
auto posItsNCls_v = static_cast<int8_t>(posTrk.itsNCls());
1927+
auto negItsNCls_v = static_cast<int8_t>(negTrk.itsNCls());
19351928
// ITS hit-map per daughter (uint8_t bitmask, bit i = layer i).
1936-
uint8_t posItsClusterMap_v = static_cast<uint8_t>(posTrk.itsClusterMap());
1937-
uint8_t negItsClusterMap_v = static_cast<uint8_t>(negTrk.itsClusterMap());
1929+
auto posItsClusterMap_v = static_cast<uint8_t>(posTrk.itsClusterMap());
1930+
auto negItsClusterMap_v = static_cast<uint8_t>(negTrk.itsClusterMap());
19381931
// Per-daughter signed DCA-XY-to-PV (V0Datas already exposes
19391932
// these as helices propagated to the PV).
19401933
float posDcaXY_v = v0.dcapostopv();
@@ -2175,7 +2168,7 @@ struct LambdaCascadeProducer {
21752168
// TracksMC for MC reco). Avoids hardcoding FullTracksExtIUWithPID, which
21762169
// is TracksIU-based and incompatible with our merged Tracks-based binding.
21772170
template <typename TTracks, typename TCollision>
2178-
void fillMatchedHistos(LabeledCascades::iterator rec, int flag, TCollision collision)
2171+
void fillMatchedHistos(LabeledCascades::iterator const& rec, int flag, TCollision const& collision)
21792172
{
21802173
if (flag == 0)
21812174
return;
@@ -2227,6 +2220,8 @@ struct LambdaCascadeProducer {
22272220
case -lcorr_const::kOmegaMinusPdg:
22282221
cascRegistry.fill(HIST("truerec/hOmegaPlus"), rec.pt(), rec.yOmega());
22292222
break;
2223+
default:
2224+
break;
22302225
}
22312226
}
22322227
}
@@ -2373,6 +2368,8 @@ struct LambdaCascadeProducer {
23732368
cascRegistry.fill(HIST("hMassOmegaPlus"), casc.mOmega(), casc.pt(), casc.yOmega());
23742369
}
23752370
break;
2371+
default:
2372+
break;
23762373
}
23772374

23782375
return flag;
@@ -2718,6 +2715,8 @@ struct LambdaCascadeProducer {
27182715
case -lcorr_const::kOmegaMinusPdg:
27192716
cascRegistry.fill(HIST("gen/hOmegaPlus"), mcPart.pt(), mcPart.y());
27202717
break;
2718+
default:
2719+
break;
27212720
}
27222721
}
27232722

@@ -2757,6 +2756,8 @@ struct LambdaCascadeProducer {
27572756
case -lcorr_const::kOmegaMinusPdg:
27582757
cascRegistry.fill(HIST("genwithrec/hOmegaPlus"), mcPart.pt(), mcPart.y());
27592758
break;
2759+
default:
2760+
break;
27602761
}
27612762
}
27622763
}
@@ -2839,7 +2840,7 @@ struct LambdaTracksExtProducer {
28392840
template <ShareDauLambda sd, typename T>
28402841
void fillHistos(T const& track)
28412842
{
2842-
static constexpr std::string_view SubDir[] = {"Reco/", "SharingDau/"};
2843+
static constexpr std::array<std::string_view, 2> SubDir = {"Reco/", "SharingDau/"};
28432844

28442845
if (track.v0Type() == kLambda) {
28452846
histos.fill(HIST(SubDir[sd]) + HIST("h1f_lambda_invmass"), track.mass());
@@ -2919,15 +2920,11 @@ struct LambdaTracksExtProducer {
29192920
fillHistos<kUniqueLambda>(lambda);
29202921
}
29212922

2922-
if (cAcceptAllLambda) { // Accept all lambda
2923-
trueLambdaFlag = true;
2924-
} else if (cRejAllLambdaShaDau && !lambdaSharingDauFlag) { // Reject all lambda sharing daughter
2925-
trueLambdaFlag = true;
2926-
} else if (cSelLambdaMassPdg && lambdaMinDeltaMassFlag) { // Select lambda closest to pdg mass
2927-
trueLambdaFlag = true;
2928-
} else if (cSelLambdaTScore && lambdaMinTScoreFlag) { // Select lambda based on t-score
2929-
trueLambdaFlag = true;
2930-
}
2923+
// Selection policy: accept all / reject sharers / best mass / best t-score.
2924+
trueLambdaFlag = cAcceptAllLambda ||
2925+
(cRejAllLambdaShaDau && !lambdaSharingDauFlag) ||
2926+
(cSelLambdaMassPdg && lambdaMinDeltaMassFlag) ||
2927+
(cSelLambdaTScore && lambdaMinTScoreFlag);
29312928

29322929
// Multiplicity of selected lambda
29332930
if (trueLambdaFlag) {
@@ -3214,7 +3211,7 @@ struct Lambdacascadecorrelation {
32143211
ConfigurableAxis cRapAxis{"cRapAxis", {100, -1.0f, 1.0f}, "rapidity"};
32153212
// φ axis on single-particle (y, φ) histograms — needed
32163213
// to build ρ₁(y, φ) and convolve into ρ₁⊗ρ₁ in (Δy, Δφ).
3217-
ConfigurableAxis cPhiAxis{"cPhiAxis", {72, 0.f, 2.0f * static_cast<float>(M_PI)}, "φ (rad)"};
3214+
ConfigurableAxis cPhiAxis{"cPhiAxis", {72, 0.f, TwoPI}, "φ (rad)"};
32183215
} histAxes;
32193216

32203217
// --- Outputs ---
@@ -3464,7 +3461,7 @@ struct Lambdacascadecorrelation {
34643461
if (!hPairs || !hSinglesTrig || !hSinglesAssoc || nEvents <= 0)
34653462
return nullptr;
34663463

3467-
TH2* hR2 = reinterpret_cast<TH2*>(hPairs->Clone(Form("%s_R2", hPairs->GetName())));
3464+
auto* hR2 = static_cast<TH2*>(hPairs->Clone(Form("%s_R2", hPairs->GetName())));
34683465
hR2->Reset();
34693466

34703467
double nS1 = hSinglesTrig->Integral();
@@ -3822,7 +3819,7 @@ struct Lambdacascadecorrelation {
38223819

38233820
// --- 3. Efficiency map production histograms ---
38243821
// Axis definitions for efficiency maps (coarser binning to avoid empty bins)
3825-
const AxisSpec effCent{cent};
3822+
const AxisSpec& effCent = cent;
38263823
const AxisSpec effPt{50, 0, 10, "p_{T} (GeV/c)"};
38273824
const AxisSpec effRap{20, -1.0, 1.0, "y"};
38283825

@@ -4928,7 +4925,7 @@ struct Lambdacascadecorrelation {
49284925
continue;
49294926
if (std::abs(lam.rap()) > maxY)
49304927
continue;
4931-
LamLite l{static_cast<float>(lam.pt()), static_cast<float>(lam.rap()), static_cast<float>(lam.phi())};
4928+
LamLite l{.pt = static_cast<float>(lam.pt()), .rap = static_cast<float>(lam.rap()), .phi = static_cast<float>(lam.phi())};
49324929
// Wrap φ to [0, 2π) to match the reco-side convention.
49334930
float phiWrapped = RecoDecay::constrainAngle(lam.phi(), 0.f);
49344931
if (lam.v0Type() == static_cast<int8_t>(kLambda)) {
@@ -5060,7 +5057,7 @@ struct Lambdacascadecorrelation {
50605057
continue;
50615058
if (std::abs(lam.rap()) > maxY)
50625059
continue;
5063-
LamLite l{static_cast<float>(lam.pt()), static_cast<float>(lam.rap()), static_cast<float>(lam.phi())};
5060+
LamLite l{.pt = static_cast<float>(lam.pt()), .rap = static_cast<float>(lam.rap()), .phi = static_cast<float>(lam.phi())};
50645061
if (lam.v0Type() == static_cast<int8_t>(kLambda)) {
50655062
goodLam.push_back(l);
50665063
} else if (lam.v0Type() == static_cast<int8_t>(kAntiLambda)) {

0 commit comments

Comments
 (0)