Skip to content
Draft
72 changes: 36 additions & 36 deletions PWGHF/TableProducer/candidateCreator3Prong.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@ struct HfCandidateCreator3Prong {
Configurable<bool> propagateToPCA{"propagateToPCA", true, "create tracks version propagated to PCA"};
Configurable<bool> useAbsDCA{"useAbsDCA", false, "Minimise abs. distance rather than chi2"};
Configurable<bool> useWeightedFinalPCA{"useWeightedFinalPCA", false, "Recalculate vertex position using track covariances, effective only if useAbsDCA is true"};
Configurable<double> maxR{"maxR", 200., "reject PCA's above this radius"};
Configurable<double> maxDZIni{"maxDZIni", 4., "reject (if>0) PCA candidate if tracks DZ exceeds threshold"};
Configurable<double> minParamChange{"minParamChange", 1.e-3, "stop iterations if largest change of any X is smaller than this"};
Configurable<double> minRelChi2Change{"minRelChi2Change", 0.9, "stop iterations is chi2/chi2old > this"};
Configurable<float> maxR{"maxR", 200., "reject PCA's above this radius"};
Configurable<float> maxDZIni{"maxDZIni", 4., "reject (if>0) PCA candidate if tracks DZ exceeds threshold"};
Configurable<float> minParamChange{"minParamChange", 1.e-3, "stop iterations if largest change of any X is smaller than this"};
Configurable<float> minRelChi2Change{"minRelChi2Change", 0.9, "stop iterations is chi2/chi2old > this"};
Comment on lines -114 to +117
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will invalidate existing wagon configuration. Not sure we want that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So will it be a better solution to revert Configurables' types to double and static_cast to float functions' arguments?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, we define Configurables with double precision which we never use, since immediately cast it to float. Is it worth fixing once with taking care of wagons adjusting (also once, and the place of concern is well known)?
I will take the responsibility to wide-post in the HF chat the announcement and ask service wagons owners to do adjustment.

Configurable<bool> fillHistograms{"fillHistograms", true, "do validation plots"};
// magnetic field setting from CCDB
Configurable<bool> isRun2{"isRun2", false, "enable Run 2 or Run 3 GRP objects for magnetic field"};
Expand All @@ -138,7 +138,7 @@ struct HfCandidateCreator3Prong {
int runNumber{0};
double bz{0.};

const float toMicrometers = 10000.; // from cm to µm
constexpr static float CentiToMicro{10000.f}; // from cm to µm
constexpr static float UndefValueFloat{-999.f};

using FilteredHf3Prongs = soa::Filtered<aod::Hf3Prongs>;
Expand Down Expand Up @@ -307,7 +307,7 @@ struct HfCandidateCreator3Prong {
// df.setBz(bz); /// put it outside the 'if'! Otherwise we have a difference wrt bz Configurable (< 1 permille) in Run2 conv. data
// df.print();
}
df.setBz(bz);
df.setBz(static_cast<float>(bz));

// reconstruct the 3-prong secondary vertex
hCandidates->Fill(SVFitting::BeforeFit);
Expand Down Expand Up @@ -371,15 +371,15 @@ struct HfCandidateCreator3Prong {
trackParVar0.propagateToDCA(primaryVertex, bz, &impactParameter0);
trackParVar1.propagateToDCA(primaryVertex, bz, &impactParameter1);
trackParVar2.propagateToDCA(primaryVertex, bz, &impactParameter2);
registry.fill(HIST("hDcaXYProngs"), track0.pt(), impactParameter0.getY() * toMicrometers);
registry.fill(HIST("hDcaXYProngs"), track1.pt(), impactParameter1.getY() * toMicrometers);
registry.fill(HIST("hDcaXYProngs"), track2.pt(), impactParameter2.getY() * toMicrometers);
registry.fill(HIST("hDcaZProngs"), track0.pt(), impactParameter0.getZ() * toMicrometers);
registry.fill(HIST("hDcaZProngs"), track1.pt(), impactParameter1.getZ() * toMicrometers);
registry.fill(HIST("hDcaZProngs"), track2.pt(), impactParameter2.getZ() * toMicrometers);
registry.fill(HIST("hDcaXYProngs"), track0.pt(), impactParameter0.getY() * CentiToMicro);
registry.fill(HIST("hDcaXYProngs"), track1.pt(), impactParameter1.getY() * CentiToMicro);
registry.fill(HIST("hDcaXYProngs"), track2.pt(), impactParameter2.getY() * CentiToMicro);
registry.fill(HIST("hDcaZProngs"), track0.pt(), impactParameter0.getZ() * CentiToMicro);
registry.fill(HIST("hDcaZProngs"), track1.pt(), impactParameter1.getZ() * CentiToMicro);
registry.fill(HIST("hDcaZProngs"), track2.pt(), impactParameter2.getZ() * CentiToMicro);

// get uncertainty of the decay length
double phi, theta;
double phi{}, theta{};
getPointDirection(std::array{primaryVertex.getX(), primaryVertex.getY(), primaryVertex.getZ()}, secondaryVertex, phi, theta);
auto errorDecayLength = std::sqrt(getRotatedCovMatrixXX(covMatrixPV, phi, theta) + getRotatedCovMatrixXX(covMatrixPCA, phi, theta));
auto errorDecayLengthXY = std::sqrt(getRotatedCovMatrixXX(covMatrixPV, phi, 0.) + getRotatedCovMatrixXX(covMatrixPCA, phi, 0.));
Expand Down Expand Up @@ -481,7 +481,7 @@ struct HfCandidateCreator3Prong {
}
float covMatrixPV[6];

KFParticle::SetField(bz);
KFParticle::SetField(static_cast<float>(bz));
KFPVertex kfpVertex = createKFPVertexFromCollision(collision);

if constexpr (DoPvRefit) {
Expand Down Expand Up @@ -513,22 +513,22 @@ struct HfCandidateCreator3Prong {

float impactParameter0XY = 0., errImpactParameter0XY = 0., impactParameter1XY = 0., errImpactParameter1XY = 0., impactParameter2XY = 0., errImpactParameter2XY = 0.;
if (!kfFirstProton.GetDistanceFromVertexXY(kfpV, impactParameter0XY, errImpactParameter0XY)) {
registry.fill(HIST("hDcaXYProngs"), track0.pt(), impactParameter0XY * toMicrometers);
registry.fill(HIST("hDcaZProngs"), track0.pt(), std::sqrt(kfFirstProton.GetDistanceFromVertex(kfpV) * kfFirstProton.GetDistanceFromVertex(kfpV) - impactParameter0XY * impactParameter0XY) * toMicrometers);
registry.fill(HIST("hDcaXYProngs"), track0.pt(), impactParameter0XY * CentiToMicro);
registry.fill(HIST("hDcaZProngs"), track0.pt(), std::sqrt(kfFirstProton.GetDistanceFromVertex(kfpV) * kfFirstProton.GetDistanceFromVertex(kfpV) - impactParameter0XY * impactParameter0XY) * CentiToMicro);
} else {
registry.fill(HIST("hDcaXYProngs"), track0.pt(), UndefValueFloat);
registry.fill(HIST("hDcaZProngs"), track0.pt(), UndefValueFloat);
}
if (!kfSecondKaon.GetDistanceFromVertexXY(kfpV, impactParameter1XY, errImpactParameter1XY)) {
registry.fill(HIST("hDcaXYProngs"), track1.pt(), impactParameter1XY * toMicrometers);
registry.fill(HIST("hDcaZProngs"), track1.pt(), std::sqrt(kfSecondKaon.GetDistanceFromVertex(kfpV) * kfSecondKaon.GetDistanceFromVertex(kfpV) - impactParameter1XY * impactParameter1XY) * toMicrometers);
registry.fill(HIST("hDcaXYProngs"), track1.pt(), impactParameter1XY * CentiToMicro);
registry.fill(HIST("hDcaZProngs"), track1.pt(), std::sqrt(kfSecondKaon.GetDistanceFromVertex(kfpV) * kfSecondKaon.GetDistanceFromVertex(kfpV) - impactParameter1XY * impactParameter1XY) * CentiToMicro);
} else {
registry.fill(HIST("hDcaXYProngs"), track1.pt(), UndefValueFloat);
registry.fill(HIST("hDcaZProngs"), track1.pt(), UndefValueFloat);
}
if (!kfThirdProton.GetDistanceFromVertexXY(kfpV, impactParameter2XY, errImpactParameter2XY)) {
registry.fill(HIST("hDcaXYProngs"), track2.pt(), impactParameter2XY * toMicrometers);
registry.fill(HIST("hDcaZProngs"), track2.pt(), std::sqrt(kfThirdProton.GetDistanceFromVertex(kfpV) * kfThirdProton.GetDistanceFromVertex(kfpV) - impactParameter2XY * impactParameter2XY) * toMicrometers);
registry.fill(HIST("hDcaXYProngs"), track2.pt(), impactParameter2XY * CentiToMicro);
registry.fill(HIST("hDcaZProngs"), track2.pt(), std::sqrt(kfThirdProton.GetDistanceFromVertex(kfpV) * kfThirdProton.GetDistanceFromVertex(kfpV) - impactParameter2XY * impactParameter2XY) * CentiToMicro);
} else {
registry.fill(HIST("hDcaXYProngs"), track2.pt(), UndefValueFloat);
registry.fill(HIST("hDcaZProngs"), track2.pt(), UndefValueFloat);
Expand Down Expand Up @@ -604,14 +604,14 @@ struct HfCandidateCreator3Prong {
const float massPiK = kfPairPiK.GetMass();

if (applyInvMassConstraint) { // constraints applied after minv getters - to preserve unbiased values of minv
kfCandPKPi.SetNonlinearMassConstraint(createLc ? MassLambdaCPlus : MassXiCPlus);
kfCandPiKP.SetNonlinearMassConstraint(createLc ? MassLambdaCPlus : MassXiCPlus);
kfCandPKPi.SetNonlinearMassConstraint(createLc ? static_cast<float>(MassLambdaCPlus) : static_cast<float>(MassXiCPlus));
kfCandPiKP.SetNonlinearMassConstraint(createLc ? static_cast<float>(MassLambdaCPlus) : static_cast<float>(MassXiCPlus));
Comment on lines +607 to +608
Copy link
Collaborator

@vkucera vkucera Jan 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SetNonlinearMassConstraint() has a float parameter, while particle mass O2 constants are double.
BTW clang-tidy generates warning only when the conditional operator is used, otherwise (few lines below highlighted) there is no warning.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what I was wondering, since below you still pass double values.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the key difference is that below I pass constant expressions, and compiler does not consider it as narrowing conversion since this particular double value fits into float range.
And the expression with conditional operator is not constant (although 2-nd and 3-d operands are constexpr).

kfCandPiKPi.SetNonlinearMassConstraint(MassDPlus);
kfCandKKPi.SetNonlinearMassConstraint(MassDS);
kfCandPiKK.SetNonlinearMassConstraint(MassDS);
}

const float chi2geo = kfCandPKPi.Chi2() / kfCandPKPi.NDF();
const float chi2geo = kfCandPKPi.Chi2() / static_cast<float>(kfCandPKPi.NDF());
const std::pair<float, float> ldl = kfCalculateLdL(kfCandPKPi, kfpV);

std::array<float, 3> pProng0 = kfCalculateProngMomentumInSecondaryVertex(kfFirstProton, kfCandPiKP);
Expand All @@ -624,7 +624,7 @@ struct HfCandidateCreator3Prong {
registry.fill(HIST("hCovSVZZ"), kfCandPKPi.Covariance(2, 2));

auto* covMatrixSV = kfCandPKPi.CovarianceMatrix();
double phi, theta;
double phi{}, theta{};
getPointDirection(std::array{kfpV.GetX(), kfpV.GetY(), kfpV.GetZ()}, std::array{kfCandPKPi.GetX(), kfCandPKPi.GetY(), kfCandPKPi.GetZ()}, phi, theta);
auto errorDecayLength = std::sqrt(getRotatedCovMatrixXX(covMatrixPV, phi, theta) + getRotatedCovMatrixXX(covMatrixSV, phi, theta));
auto errorDecayLengthXY = std::sqrt(getRotatedCovMatrixXX(covMatrixPV, phi, 0.) + getRotatedCovMatrixXX(covMatrixSV, phi, 0.));
Expand All @@ -647,7 +647,7 @@ struct HfCandidateCreator3Prong {
kfpV.GetX(), kfpV.GetY(), kfpV.GetZ(),
kfCandPKPi.GetX(), kfCandPKPi.GetY(), kfCandPKPi.GetZ(),
errorDecayLength, errorDecayLengthXY,
kfCandPKPi.GetChi2() / kfCandPKPi.GetNDF(),
kfCandPKPi.GetChi2() / static_cast<float>(kfCandPKPi.GetNDF()),
pProng0.at(0), pProng0.at(1), pProng0.at(2),
pProng1.at(0), pProng1.at(1), pProng1.at(2),
pProng2.at(0), pProng2.at(1), pProng2.at(2),
Expand Down Expand Up @@ -904,7 +904,7 @@ struct HfCandidateCreator3Prong {
const auto bc = collision.template foundBC_as<aod::BCsWithTimestamps>();
const auto ir = hfEvSel.getInteractionRate(bc, ccdb); // Hz
/// monitor the satisfied event selections
hfEvSel.fillHistograms(collision, rejectionMask, centrality, occupancy, ir);
hfEvSel.fillHistograms(collision, rejectionMask, centrality, occupancy, static_cast<float>(ir));

} /// end loop over collisions
}
Expand All @@ -923,7 +923,7 @@ struct HfCandidateCreator3Prong {
const auto bc = collision.template foundBC_as<aod::BCsWithTimestamps>();
const auto ir = hfEvSel.getInteractionRate(bc, ccdb); // Hz
/// monitor the satisfied event selections
hfEvSel.fillHistograms(collision, rejectionMask, centrality, occupancy, ir);
hfEvSel.fillHistograms(collision, rejectionMask, centrality, occupancy, static_cast<float>(ir));

} /// end loop over collisions
}
Expand All @@ -942,7 +942,7 @@ struct HfCandidateCreator3Prong {
const auto bc = collision.template foundBC_as<aod::BCsWithTimestamps>();
const auto ir = hfEvSel.getInteractionRate(bc, ccdb); // Hz
/// monitor the satisfied event selections
hfEvSel.fillHistograms(collision, rejectionMask, centrality, occupancy, ir);
hfEvSel.fillHistograms(collision, rejectionMask, centrality, occupancy, static_cast<float>(ir));

} /// end loop over collisions
}
Expand All @@ -966,7 +966,7 @@ struct HfCandidateCreator3Prong {
const auto bc = collision.template foundBC_as<aod::BcFullInfos>();
const auto ir = hfEvSel.getInteractionRate(bc, ccdb); // Hz
/// monitor the satisfied event selections
hfEvSel.fillHistograms(collision, rejectionMask, centrality, occupancy, ir);
hfEvSel.fillHistograms(collision, rejectionMask, centrality, occupancy, static_cast<float>(ir));

} /// end loop over collisions
}
Expand Down Expand Up @@ -1132,7 +1132,7 @@ struct HfCandidateCreator3ProngExpressions {
return;
}
if (indexRec > -1) {
flagChannelMain = sign * channelMain;
flagChannelMain = static_cast<int8_t>(sign * channelMain);

/// swapping for D+, Ds->Kpipi; Lc, Xic->pKpi
if (std::abs(flagChannelMain) == DecayChannelMain::DplusToPiKK || std::abs(flagChannelMain) == DecayChannelMain::DsToPiKK || std::abs(flagChannelMain) == DecayChannelMain::LcToPKPi || std::abs(flagChannelMain) == DecayChannelMain::XicToPKPi) {
Expand Down Expand Up @@ -1185,7 +1185,7 @@ struct HfCandidateCreator3ProngExpressions {
indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kDPlus, arrPdgDaughtersDplusToPiKPi, true, &sign, 2);
}
if (indexRec > -1) {
flagChannelMain = sign * DecayChannelMain::DplusToPiKPi;
flagChannelMain = static_cast<int8_t>(sign * DecayChannelMain::DplusToPiKPi);
}
}

Expand Down Expand Up @@ -1215,7 +1215,7 @@ struct HfCandidateCreator3ProngExpressions {
}
}
if (indexRec > -1) {
flagChannelMain = sign * (isDplus ? DecayChannelMain::DplusToPiKK : DecayChannelMain::DsToPiKK);
flagChannelMain = sign * (isDplus ? static_cast<int8_t>(DecayChannelMain::DplusToPiKK) : static_cast<int8_t>(DecayChannelMain::DsToPiKK));
if (arrayDaughters[0].has_mcParticle()) {
swapping = static_cast<int8_t>(std::abs(arrayDaughters[0].mcParticle().pdgCode()) == kPiPlus);
}
Expand Down Expand Up @@ -1243,7 +1243,7 @@ struct HfCandidateCreator3ProngExpressions {
indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kDStar, arrPdgDaughtersDstarToPiKPi, true, &sign, 2);
}
if (indexRec > -1) {
flagChannelMain = sign * DecayChannelMain::DstarToPiKPi;
flagChannelMain = static_cast<int8_t>(sign * DecayChannelMain::DstarToPiKPi);
flagChannelResonant = 0;
}
}
Expand All @@ -1261,7 +1261,7 @@ struct HfCandidateCreator3ProngExpressions {
indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kLambdaCPlus, arrPdgDaughtersLcToPKPi, true, &sign, 2);
}
if (indexRec > -1) {
flagChannelMain = sign * DecayChannelMain::LcToPKPi;
flagChannelMain = static_cast<int8_t>(sign * DecayChannelMain::LcToPKPi);

// Flagging the different Λc± → p± K∓ π± decay channels
if (arrayDaughters[0].has_mcParticle()) {
Expand Down Expand Up @@ -1297,7 +1297,7 @@ struct HfCandidateCreator3ProngExpressions {
indexRec = RecoDecay::getMatchedMCRec(mcParticles, arrayDaughters, Pdg::kXiCPlus, arrPdgDaughtersXicToPKPi, true, &sign, 2);
}
if (indexRec > -1) {
flagChannelMain = sign * DecayChannelMain::XicToPKPi;
flagChannelMain = static_cast<int8_t>(sign * DecayChannelMain::XicToPKPi);
flagChannelResonant = 0; // TODO
if (arrayDaughters[0].has_mcParticle()) {
swapping = static_cast<int8_t>(std::abs(arrayDaughters[0].mcParticle().pdgCode()) == kPiPlus);
Expand All @@ -1309,7 +1309,7 @@ struct HfCandidateCreator3ProngExpressions {
// Check whether the particle is non-prompt (from a b quark).
if (flagChannelMain != 0) {
auto particle = mcParticles.rawIteratorAt(indexRec);
origin = RecoDecay::getCharmHadronOrigin(mcParticles, particle, false, &idxBhadMothers);
origin = static_cast<int8_t>(RecoDecay::getCharmHadronOrigin(mcParticles, particle, false, &idxBhadMothers));
}
if (origin == RecoDecay::OriginType::NonPrompt) {
auto bHadMother = mcParticles.rawIteratorAt(idxBhadMothers[0]);
Expand Down
10 changes: 6 additions & 4 deletions PWGHF/TableProducer/candidateCreatorXic0Omegac0.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
#include <Framework/HistogramSpec.h>
#include <Framework/InitContext.h>
#include <Framework/Logger.h>
#include <Framework/O2DatabasePDGPlugin.h>
#include <Framework/RunningWorkflowInfo.h>
#include <Framework/runDataProcessing.h>
#include <ReconstructionDataFormats/DCA.h>
Expand Down Expand Up @@ -144,6 +145,7 @@ struct HfCandidateCreatorXic0Omegac0 {
HfEventSelection hfEvSel; // event selection and monitoring
o2::vertexing::DCAFitterN<2> df; // 2-prong vertex fitter to build the omegac/xic vertex
Service<o2::ccdb::BasicCCDBManager> ccdb;
Service<o2::framework::O2DatabasePDG> pdgdb;
o2::base::MatLayerCylSet* lut{};
o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrLUT;
int runNumber{-1};
Expand Down Expand Up @@ -1124,7 +1126,7 @@ struct HfCandidateCreatorXic0Omegac0 {
kfOmegac0Candidate.rapOmegac = kfOmegaC0.GetRapidity();

// KF cosThetaStar
kfOmegac0Candidate.cosThetaStarPiFromOmegac = cosThetaStarFromKF(0, 4332, 211, 3312, kfBachPionToOmegaC, kfOmegaToOmegaC);
kfOmegac0Candidate.cosThetaStarPiFromOmegac = cosThetaStarFromKF(0, 4332, 211, 3312, kfBachPionToOmegaC, kfOmegaToOmegaC, pdgdb);

// KF ct
kfOmegac0Candidate.ctV0 = kfV0.GetLifeTime();
Expand Down Expand Up @@ -1588,7 +1590,7 @@ struct HfCandidateCreatorXic0Omegac0 {
kfXic0Candidate.rapXic = kfXiC0.GetRapidity();

// KF cosThetaStar
kfXic0Candidate.cosThetaStarPiFromXic = cosThetaStarFromKF(0, 4132, 211, 3312, kfCharmBachPionToXiC, kfXiToXiC);
kfXic0Candidate.cosThetaStarPiFromXic = cosThetaStarFromKF(0, 4132, 211, 3312, kfCharmBachPionToXiC, kfXiToXiC, pdgdb);

// KF ct
kfXic0Candidate.ctV0 = kfV0ToCasc.GetLifeTime();
Expand Down Expand Up @@ -1950,8 +1952,8 @@ struct HfCandidateCreatorXic0Omegac0 {
float const ptOmega = kfOmega.GetPt();

// KF cosThetaStar
float const cosThetaStarKaFromOmegac = cosThetaStarFromKF(0, 4332, 321, 3334, kfKaFromCharmToOmegaKa, kfOmegaToOmegaKa);
float const cosThetaStarKaFromXic = cosThetaStarFromKF(0, 4132, 321, 3334, kfKaFromCharmToOmegaKa, kfOmegaToOmegaKa);
float const cosThetaStarKaFromOmegac = cosThetaStarFromKF(0, 4332, 321, 3334, kfKaFromCharmToOmegaKa, kfOmegaToOmegaKa, pdgdb);
float const cosThetaStarKaFromXic = cosThetaStarFromKF(0, 4132, 321, 3334, kfKaFromCharmToOmegaKa, kfOmegaToOmegaKa, pdgdb);

// KF ct
float const ctV0 = kfV0ToOmega.GetLifeTime();
Expand Down
Loading
Loading