Skip to content

Commit 35852ee

Browse files
authored
[PWGLF] Fix issues in double-strange hypernuclei reconstruction (#9375)
1 parent a378200 commit 35852ee

File tree

2 files changed

+68
-43
lines changed

2 files changed

+68
-43
lines changed

PWGLF/TableProducer/Nuspex/hypKfRecoTask.cxx

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ struct HyperNucCandidate {
231231
HyperNucCandidate* hypNucDaughter;
232232
std::vector<DaughterKf*> daughters;
233233
std::vector<float> recoSV;
234+
std::vector<std::vector<float>> daughterPosMoms;
234235
float mass, px, py, pz;
235236
float devToPvXY, dcaToPvXY, dcaToPvZ, dcaToVtxXY, dcaToVtxZ, chi2;
236237
bool mcTrue, isPhysPrimary, isPrimaryCandidate, isSecondaryCandidate, isUsedSecondary;
@@ -274,13 +275,15 @@ struct HyperNucCandidate {
274275
return kfp.GetQ() / std::abs(kfp.GetQ());
275276
}
276277
int getNdaughters() { return static_cast<int>(daughters.size()); }
277-
float getDcaTracks() { return getNdaughters() == 2 ? getDcaTracks2() : getMaxDcaToSv(); }
278-
float getDcaTracks2() { return daughters.at(0)->daughterKfp.GetDistanceFromParticleXY(daughters.at(1)->daughterKfp); }
279-
float getMaxDcaToSv()
278+
float getDcaTracks()
280279
{
280+
if (!daughterPosMoms.size())
281+
setDaughterPosMoms();
281282
float maxDca = std::numeric_limits<float>::lowest();
282283
for (size_t i = 0; i < daughters.size(); i++) {
283-
float dca = daughters.at(i)->daughterKfp.GetDistanceFromVertexXY(&recoSV[0]);
284+
float dx = daughterPosMoms.at(i).at(0) - recoSV[0];
285+
float dy = daughterPosMoms.at(i).at(1) - recoSV[1];
286+
const float dca = std::sqrt(dx * dx + dy * dy);
284287
if (dca > maxDca)
285288
maxDca = dca;
286289
}
@@ -289,9 +292,7 @@ struct HyperNucCandidate {
289292
float getDcaMotherToVertex(std::vector<float> vtx) { return kfp.GetDistanceFromVertex(&vtx[0]); }
290293
double getCpa(std::vector<float> vtx)
291294
{
292-
kfp.TransportToDecayVertex();
293295
return RecoDecay::cpa(std::array{vtx[0], vtx[1], vtx[2]}, std::array{recoSV[0], recoSV[1], recoSV[2]}, std::array{px, py, pz});
294-
;
295296
}
296297
float getCt(std::vector<float> vtx)
297298
{
@@ -302,11 +303,19 @@ struct HyperNucCandidate {
302303
}
303304
return std::sqrt(dl) * mass / std::sqrt(px * px + py * py + pz * pz);
304305
}
305-
void getDaughterPosMom(int daughter, std::vector<float>& posMom)
306+
void setDaughterPosMoms()
307+
{
308+
for (size_t i = 0; i < daughters.size(); i++) {
309+
daughterPosMoms.push_back(getDaughterPosMom(i));
310+
}
311+
}
312+
std::vector<float> getDaughterPosMom(int daughter)
306313
{
314+
std::vector<float> posMom;
307315
auto kfpDaughter = daughters.at(daughter)->daughterKfp;
308316
kfpDaughter.TransportToPoint(&recoSV[0]);
309317
posMom.assign({kfpDaughter.GetX(), kfpDaughter.GetY(), kfpDaughter.GetZ(), kfpDaughter.GetPx(), kfpDaughter.GetPy(), kfpDaughter.GetPz()});
318+
return posMom;
310319
}
311320
float getDcaMotherToVtxXY(std::vector<float> vtx) { return kfp.GetDistanceFromVertexXY(&vtx[0]); }
312321
float getDcaMotherToVtxZ(std::vector<float> vtx)
@@ -720,11 +729,11 @@ struct HypKfRecoTask {
720729
const float maxDcaTracksCas = cfgPreSelectionsCascades->get(hyperNucIter, "maxDcaTracks");
721730
const float maxDcaMotherToPvXYCas = cfgPreSelectionsCascades->get(hyperNucIter, "maxDcaMotherToPvXY");
722731
const float maxDcaMotherToPvZCas = cfgPreSelectionsCascades->get(hyperNucIter, "maxDcaMotherToPvZ");
723-
const float minCtSec = cfgPreSelectionsSecondaries->get(hyperNucIter, "minCt");
724-
const float maxCtSec = cfgPreSelectionsSecondaries->get(hyperNucIter, "maxCt");
725-
const float minCosPaSvSec = cfgPreSelectionsSecondaries->get(hyperNucIter, "minCosPaSv");
726-
const float maxDcaMotherToSvXYSec = cfgPreSelectionsSecondaries->get(hyperNucIter, "maxDcaMotherToSvXY");
727-
const float maxDcaMotherToSvZSec = cfgPreSelectionsSecondaries->get(hyperNucIter, "maxDcaMotherToSvZ");
732+
const float minCtSec = cfgPreSelectionsSecondaries->get(hyperNuc->daughters.at(0), "minCt");
733+
const float maxCtSec = cfgPreSelectionsSecondaries->get(hyperNuc->daughters.at(0), "maxCt");
734+
const float minCosPaSvSec = cfgPreSelectionsSecondaries->get(hyperNuc->daughters.at(0), "minCosPaSv");
735+
const float maxDcaMotherToSvXYSec = cfgPreSelectionsSecondaries->get(hyperNuc->daughters.at(0), "maxDcaMotherToSvXY");
736+
const float maxDcaMotherToSvZSec = cfgPreSelectionsSecondaries->get(hyperNuc->daughters.at(0), "maxDcaMotherToSvZ");
728737

729738
while (it[0] != hypNucDaughterKfs.at(hyperNucIter).end()) {
730739
// select hypernuclei daughter KFParticle
@@ -803,6 +812,8 @@ struct HypKfRecoTask {
803812
daughterCount++;
804813
}
805814
for (const auto& daughter : hypCand.daughters) {
815+
if (daughter->daughterTrackId < 0)
816+
continue;
806817
const auto& mcLab = trackLabels.rawIteratorAt(daughter->daughterTrackId);
807818
if (!mcLab.has_mcParticle())
808819
continue;
@@ -866,6 +877,8 @@ struct HypKfRecoTask {
866877
int daughterCount = 0;
867878
for (const auto& daughter : hypCand.daughters) {
868879
const auto& daughterTrackId = daughter->daughterTrackId;
880+
if (daughterTrackId < 0)
881+
continue;
869882
int trackTableId;
870883
if (!trackIndices.getIndex(daughterTrackId, trackTableId)) {
871884
auto daught = hyperNuc->daughters.at(daughterCount);
@@ -888,8 +901,7 @@ struct HypKfRecoTask {
888901
daughterCount++;
889902
}
890903
for (int i = 0; i < hypCand.getNdaughters(); i++) {
891-
std::vector<float> posMom;
892-
hypCand.getDaughterPosMom(i, posMom);
904+
std::vector<float>& posMom = hypCand.daughterPosMoms.at(i);
893905
outputDaughterAddonTable(
894906
posMom.at(0), posMom.at(1), posMom.at(2), posMom.at(3), posMom.at(4), posMom.at(5));
895907
vecAddons.push_back(outputDaughterAddonTable.lastIndex());

0 commit comments

Comments
 (0)