Skip to content

Commit cfdd465

Browse files
authored
Update lambdaR2Correlation.cxx
1 parent d61763e commit cfdd465

1 file changed

Lines changed: 27 additions & 39 deletions

File tree

PWGCF/TwoParticleCorrelations/Tasks/lambdaR2Correlation.cxx

Lines changed: 27 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ DECLARE_SOA_COLUMN(Pz, pz, float);
101101
DECLARE_SOA_COLUMN(Mass, mass, float);
102102
DECLARE_SOA_COLUMN(PosTrackId, posTrackId, int64_t);
103103
DECLARE_SOA_COLUMN(NegTrackId, negTrackId, int64_t);
104-
DECLARE_SOA_COLUMN(PosTrackKin, posTrackKin, float[3]);
105-
DECLARE_SOA_COLUMN(NegTrackKin, negTrackKin, float[3]);
104+
DECLARE_SOA_COLUMN(PosTrackKin, posTrackKin, std::vector<float>);
105+
DECLARE_SOA_COLUMN(NegTrackKin, negTrackKin, std::vector<float>);
106106
DECLARE_SOA_COLUMN(PartType, partType, int8_t);
107107
DECLARE_SOA_COLUMN(CorrFact, corrFact, float);
108108
} // namespace lambdatrack
@@ -376,7 +376,7 @@ struct LambdaTableProducer {
376376
Configurable<int64_t> nolaterthan{"nolaterthan", std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count(), "latest acceptable timestamp of creation for the object"};
377377

378378
// Initialize CCDB Service
379-
Service<o2::ccdb::BasicCCDBManager> ccdb;
379+
Service<o2::ccdb::BasicCCDBManager> ccdb{};
380380
o2::parameters::GRPMagField* grpo = nullptr;
381381

382382
// Histogram Registry.
@@ -390,7 +390,7 @@ struct LambdaTableProducer {
390390
float cent = 0., mult = 0.;
391391
TList* ccdbObjRecoEff = nullptr;
392392
TList* ccdbObjMatchEff = nullptr;
393-
static constexpr std::string_view SubDir[] = {"QA/Lambda/", "QA/AntiLambda/", "QA/KaonPlus/", "QA/KaonMinus/"};
393+
static constexpr auto SubDir = std::array{"QA/Lambda/", "QA/AntiLambda/", "QA/KaonPlus/", "QA/KaonMinus/"};
394394

395395
void init(InitContext const&)
396396
{
@@ -790,7 +790,7 @@ struct LambdaTableProducer {
790790

791791
// Get Efficiency Factor
792792
if (cGetEffFact) {
793-
TObject* objEff = reinterpret_cast<TObject*>(ccdbObjRecoEff->FindObject(Form("%s", vCorrFactStrings[cCorrFactHist][part].c_str())));
793+
auto* objEff = ccdbObjRecoEff->FindObject(Form("%s", vCorrFactStrings[cCorrFactHist][part].c_str()));
794794
// check object
795795
if (!objEff) {
796796
LOGF(fatal, "Reco efficiency object not found !");
@@ -813,13 +813,13 @@ struct LambdaTableProducer {
813813

814814
// Get Matching Efficiency Correction
815815
if (cGetMatchEff) {
816-
TObject* objITSTPCMatchEff = reinterpret_cast<TObject*>(ccdbObjMatchEff->FindObject("hITSTPCMatchingEfficiency"));
817-
TObject* objITSTPCTOFMatchEff = reinterpret_cast<TObject*>(ccdbObjMatchEff->FindObject("hITSTPCTOFMatchingEfficiency"));
816+
auto* objITSTPCMatchEff = ccdbObjMatchEff->FindObject("hITSTPCMatchingEfficiency");
817+
auto* objITSTPCTOFMatchEff = ccdbObjMatchEff->FindObject("hITSTPCTOFMatchingEfficiency");
818818
if (!objITSTPCMatchEff || !objITSTPCTOFMatchEff) {
819819
LOGF(fatal, "Matching efficiency object not found !");
820820
} else {
821-
TH1F* histITSTPCMatchEff = reinterpret_cast<TH1F*>(objITSTPCMatchEff->Clone());
822-
TH1F* histITSTPCTOFMatchEff = reinterpret_cast<TH1F*>(objITSTPCTOFMatchEff->Clone());
821+
TH1F* histITSTPCMatchEff = static_cast<TH1F*>(objITSTPCMatchEff->Clone());
822+
TH1F* histITSTPCTOFMatchEff = static_cast<TH1F*>(objITSTPCTOFMatchEff->Clone());
823823
// Lambda / Anti-Lambda
824824
if constexpr (part == kLambda || part == kAntiLambda) {
825825
auto posTrack = v.template posTrack_as<T>();
@@ -1012,12 +1012,12 @@ struct LambdaTableProducer {
10121012
}
10131013

10141014
// Daughter kinematics
1015-
std::array<float, 3> posTrackKin = {postrack.pt(), postrack.eta(), postrack.phi()};
1016-
std::array<float, 3> negTrackKin = {negtrack.pt(), negtrack.eta(), negtrack.phi()};
1015+
std::vector<float> posTrackKin = {postrack.pt(), postrack.eta(), postrack.phi()};
1016+
std::vector<float> negTrackKin = {negtrack.pt(), negtrack.eta(), negtrack.phi()};
10171017

10181018
// Fill Lambda/AntiLambda Table
10191019
lambdaTrackTable(lambdaCollisionTable.lastIndex(), v0.pt(), v0.eta(), v0.phi(), v0.yLambda(), v0.px(), v0.py(), v0.pz(), lambdaMass,
1020-
v0.template posTrack_as<T>().index(), v0.template negTrack_as<T>().index(), posTrackKin.data(), negTrackKin.data(),
1020+
v0.template posTrack_as<T>().index(), v0.template negTrack_as<T>().index(), posTrackKin, negTrackKin,
10211021
(int8_t)partType, lambdaCorrFact);
10221022
}
10231023

@@ -1327,12 +1327,8 @@ struct LambdaTracksExtProducer {
13271327
}
13281328
}
13291329

1330-
// Accept/Reject
1331-
if (cAcceptAllLambda) { // Accept all lambda
1332-
trueLambdaFlag = true;
1333-
} else if (cRejAllLambdaShaDau && !lambdaSharingDauFlag) { // Reject all lambda sharing daughter
1334-
trueLambdaFlag = true;
1335-
}
1330+
// Accept / Reject
1331+
trueLambdaFlag = cAcceptAllLambda || (cRejAllLambdaShaDau && !lambdaSharingDauFlag);
13361332

13371333
// Multiplicity of selected lambda
13381334
if (trueLambdaFlag) {
@@ -1401,11 +1397,7 @@ struct LambdaTracksExtProducer {
14011397
}
14021398

14031399
// Accept / Reject
1404-
if (cAcceptAllKaon) {
1405-
trueKaonFlag = true;
1406-
} else if (cRejAllKaonShaLaDau && !kaonSharingLambdaDauFlag) {
1407-
trueKaonFlag = true;
1408-
}
1400+
trueKaonFlag = cAcceptAllKaon || (cRejAllKaonShaLaDau && !kaonSharingLambdaDauFlag);
14091401

14101402
// Multiplicity of selected kaons
14111403
if (trueKaonFlag) {
@@ -1572,16 +1564,14 @@ struct LambdaR2Correlation {
15721564
// Rap-Phi Bin Index
15731565
int getRapPhiBin(float const& rap, float const& phi)
15741566
{
1575-
int rapbin = static_cast<int>((rap - kminrap) / rapbinwidth);
1576-
int phibin = static_cast<int>(phi / phibinwidth);
1567+
const auto rapbin = static_cast<int>((rap - kminrap) / rapbinwidth);
1568+
const auto phibin = static_cast<int>(phi / phibinwidth);
15771569

1578-
int rapphibin = -99;
15791570
if (rapbin >= 0 && phibin >= 0 && rapbin < nrapbins && phibin < nphibins) {
1580-
rapphibin = rapbin * nphibins + phibin;
1581-
return rapphibin;
1571+
return rapbin * nphibins + phibin;
15821572
}
15831573

1584-
return rapphibin;
1574+
return -99;
15851575
}
15861576

15871577
template <typename A>
@@ -1623,8 +1613,6 @@ struct LambdaR2Correlation {
16231613
retFlag = checkClosePair(trackKin, lambdaPosTrackKin, 1, 1) || checkClosePair(trackKin, lambdaNegTrackKin, 1, -1);
16241614
} else if (track.partType() == kKaonMinus) {
16251615
retFlag = checkClosePair(trackKin, lambdaPosTrackKin, -1, 1) || checkClosePair(trackKin, lambdaNegTrackKin, -1, -1);
1626-
} else {
1627-
return false;
16281616
}
16291617

16301618
// Fill QA
@@ -1654,14 +1642,14 @@ struct LambdaR2Correlation {
16541642
template <ParticlePairType part_pair, RecGenType rec_gen, typename T1, typename T2>
16551643
void fillPairHistos(T1& p1, T2& p2)
16561644
{
1657-
static constexpr std::string_view SubDirRecGen[] = {"Reco/", "McGen/"};
1658-
static constexpr std::string_view SubDirHist[] = {"LaP_LaM", "LaP_LaP", "LaM_LaM", "LaP_KaP", "LaP_KaM", "LaM_KaP", "LaM_KaM", "KaP_KaM", "KaP_KaP", "KaM_KaM"};
1645+
static constexpr auto SubDirRecGen = std::array{"Reco/", "McGen/"};
1646+
static constexpr auto SubDirHist = std::array{"LaP_LaM", "LaP_LaP", "LaM_LaM", "LaP_KaP", "LaP_KaM", "LaM_KaP", "LaM_KaM", "KaP_KaM", "KaP_KaP", "KaM_KaM"};
16591647

1660-
int rapbin1 = static_cast<int>((p1.rap() - kminrap) / rapbinwidth);
1661-
int rapbin2 = static_cast<int>((p2.rap() - kminrap) / rapbinwidth);
1648+
const auto rapbin1 = static_cast<int>((p1.rap() - kminrap) / rapbinwidth);
1649+
const auto rapbin2 = static_cast<int>((p2.rap() - kminrap) / rapbinwidth);
16621650

1663-
int phibin1 = static_cast<int>(p1.phi() / phibinwidth);
1664-
int phibin2 = static_cast<int>(p2.phi() / phibinwidth);
1651+
const auto phibin1 = static_cast<int>(p1.phi() / phibinwidth);
1652+
const auto phibin2 = static_cast<int>(p2.phi() / phibinwidth);
16651653

16661654
float corfac = p1.corrFact() * p2.corrFact();
16671655

@@ -1677,8 +1665,8 @@ struct LambdaR2Correlation {
16771665
template <ParticleType part, RecGenType rec_gen, typename T>
16781666
void analyzeSingles(T const& tracks)
16791667
{
1680-
static constexpr std::string_view SubDirRecGen[] = {"Reco/", "McGen/"};
1681-
static constexpr std::string_view SubDirHist[] = {"LaP", "LaM", "KaP", "KaM"};
1668+
static constexpr auto SubDirRecGen = std::array{"Reco/", "McGen/"};
1669+
static constexpr auto SubDirHist = std::array{"LaP", "LaM", "KaP", "KaM"};
16821670

16831671
for (auto const& track : tracks) {
16841672
// Efficiency Plots

0 commit comments

Comments
 (0)