Skip to content

Commit 8c4ba1d

Browse files
[PWGHF] align the table between reduced and not-reduced workflow for Lb (#11279)
Co-authored-by: ALICE Action Bot <alibuild@cern.ch>
1 parent 495740a commit 8c4ba1d

File tree

8 files changed

+74
-63
lines changed

8 files changed

+74
-63
lines changed

PWGHF/D2H/DataModel/ReducedDataModel.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -506,15 +506,15 @@ using HfRedCandBs = soa::Join<HfCandBsExt, HfRedBsProngs>;
506506

507507
namespace hf_cand_lb_reduced
508508
{
509-
DECLARE_SOA_INDEX_COLUMN_FULL(Prong0Lc, prong0Lc, int, HfRed3Prongs, "_0"); //! Prong0 index
510-
DECLARE_SOA_INDEX_COLUMN_FULL(Prong1Track, prong1Track, int, HfRedTrackBases, "_1"); //! Prong1 index
509+
DECLARE_SOA_INDEX_COLUMN_FULL(Prong0, prong0, int, HfRed3Prongs, "_0"); //! Prong0 index
510+
DECLARE_SOA_INDEX_COLUMN_FULL(Prong1, prong1, int, HfRedTrackBases, "_1"); //! Prong1 index
511511
DECLARE_SOA_COLUMN(Prong0MlScoreBkg, prong0MlScoreBkg, float); //! Bkg ML score of the Lc daughter
512512
DECLARE_SOA_COLUMN(Prong0MlScorePrompt, prong0MlScorePrompt, float); //! Prompt ML score of the Lc daughter
513513
DECLARE_SOA_COLUMN(Prong0MlScoreNonprompt, prong0MlScoreNonprompt, float); //! Nonprompt ML score of the Lc daughter
514514
} // namespace hf_cand_lb_reduced
515515

516516
DECLARE_SOA_TABLE(HfRedLbProngs, "AOD", "HFREDLBPRONG", //! Table with Lb daughter indices
517-
hf_cand_lb_reduced::Prong0LcId, hf_cand_lb_reduced::Prong1TrackId);
517+
hf_cand_lb_reduced::Prong0Id, hf_cand_lb_reduced::Prong1Id);
518518

519519
DECLARE_SOA_TABLE(HfRedLbLcMls, "AOD", "HFREDLBLCML", //! Table with ML scores for the Lc daughter
520520
hf_cand_lb_reduced::Prong0MlScoreBkg,
@@ -796,8 +796,8 @@ DECLARE_SOA_COLUMN(PdgCodeProng3, pdgCodeProng3, int); //! Pdg code
796796

797797
// table with results of reconstruction level MC matching
798798
DECLARE_SOA_TABLE(HfMcRecRedLcPis, "AOD", "HFMCRECREDLCPI", //! Table with reconstructed MC information on LcPi(<-Lb) pairs for reduced workflow
799-
hf_cand_lb_reduced::Prong0LcId,
800-
hf_cand_lb_reduced::Prong1TrackId,
799+
hf_cand_lb_reduced::Prong0Id,
800+
hf_cand_lb_reduced::Prong1Id,
801801
hf_cand_lb::FlagMcMatchRec,
802802
hf_cand_lb::FlagWrongCollision,
803803
hf_cand_lb::DebugMcRec,

PWGHF/D2H/TableProducer/candidateCreatorLbReduced.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ struct HfCandidateCreatorLbReduced {
207207
pVecLc[0], pVecLc[1], pVecLc[2],
208208
pVecPion[0], pVecPion[1], pVecPion[2],
209209
dcaLc.getY(), dcaPion.getY(),
210-
std::sqrt(dcaLc.getSigmaY2()), std::sqrt(dcaPion.getSigmaY2()), candLc.globalIndex(), trackPion.globalIndex(), -999.);
210+
std::sqrt(dcaLc.getSigmaY2()), std::sqrt(dcaPion.getSigmaY2()));
211211

212212
rowCandidateProngs(candLc.globalIndex(), trackPion.globalIndex());
213213

@@ -302,7 +302,7 @@ struct HfCandidateCreatorLbReducedExpressions {
302302
for (const auto& candLb : candsLb) {
303303
bool filledMcInfo{false};
304304
for (const auto& rowLcPiMcRec : rowsLcPiMcRec) {
305-
if ((rowLcPiMcRec.prong0LcId() != candLb.prong0LcId()) || (rowLcPiMcRec.prong1TrackId() != candLb.prong1TrackId())) {
305+
if ((rowLcPiMcRec.prong0Id() != candLb.prong0Id()) || (rowLcPiMcRec.prong1Id() != candLb.prong1Id())) {
306306
continue;
307307
}
308308
rowLbMcRec(rowLcPiMcRec.flagMcMatchRec(), rowLcPiMcRec.flagWrongCollision(), rowLcPiMcRec.debugMcRec(), rowLcPiMcRec.ptMother());

PWGHF/D2H/TableProducer/candidateSelectorLbToLcPiReduced.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ struct HfCandidateSelectorLbToLcPiReduced {
182182
}
183183

184184
// track-level PID selection
185-
auto trackPi = hfCandLb.template prong1Track_as<TracksPion>();
185+
auto trackPi = hfCandLb.template prong1_as<TracksPion>();
186186
if (pionPidMethod == PidMethod::TpcOrTof || pionPidMethod == PidMethod::TpcAndTof) {
187187
int pidTrackPi{TrackSelectorPID::Status::NotApplicable};
188188
if (pionPidMethod == PidMethod::TpcOrTof) {

PWGHF/D2H/Tasks/taskLb.cxx

Lines changed: 52 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
/// \author Martin Voelkl <martin.andreas.volkl@cern.ch>, University of Birmingham
1717

1818
#include <vector>
19+
#include <array>
20+
#include <algorithm>
1921

2022
#include "CommonConstants/PhysicsConstants.h"
2123
#include "Framework/AnalysisTask.h"
@@ -42,7 +44,7 @@ struct HfTaskLb {
4244
Configurable<int> selectionFlagLb{"selectionFlagLb", 0, "Selection Flag for Lb"};
4345
Configurable<float> yCandGenMax{"yCandGenMax", 0.5, "max. gen particle rapidity"};
4446
Configurable<float> yCandRecoMax{"yCandRecoMax", 0.8, "max. cand. rapidity"};
45-
Configurable<float> DCALengthParameter{"DCALengthParameter", 0.02, "decay length for DCA"};
47+
Configurable<float> lengthDCAParameter{"lengthDCAParameter", 0.02, "decay length for DCA"};
4648
Configurable<float> minLikelihoodRatio{"minLikelihoodRatio", 10., "min. likelihood ratio for combined DCAs"};
4749
Configurable<float> minLikelihoodRatioLc{"minLikelihoodRatioLc", 10., "min. likelihood ratio for Lc cross check"};
4850
Configurable<float> mDiffKStar892Max{"mDiffKStar892Max", 0.0473, "Accepted range around KStar mass peak"};
@@ -57,24 +59,24 @@ struct HfTaskLb {
5759
HfHelper hfHelper;
5860
Service<o2::framework::O2DatabasePDG> pdg;
5961

60-
Filter filterSelectCandidates = (aod::hf_sel_candidate_lb::isSelLbToLcPi >= selectionFlagLb);
61-
6262
using TracksWExt = soa::Join<o2::aod::Tracks, o2::aod::TracksExtra, aod::TrackSelection, o2::aod::TrackSelectionExtension, aod::TracksPidPi, aod::PidTpcTofFullPi, aod::TracksPidKa, aod::PidTpcTofFullKa>;
6363
using TracksWExtMc = soa::Join<o2::aod::Tracks, o2::aod::TracksExtra, aod::TrackSelection, o2::aod::TrackSelectionExtension, aod::TracksPidPi, aod::PidTpcTofFullPi, aod::TracksPidKa, aod::PidTpcTofFullKa, McTrackLabels>;
6464

65-
PresliceUnsorted<aod::TracksWMc> McPartID = aod::mctracklabel::mcParticleId;
65+
Filter filterSelectCandidates = (aod::hf_sel_candidate_lb::isSelLbToLcPi >= selectionFlagLb);
66+
67+
PresliceUnsorted<aod::TracksWMc> mcPartID = aod::mctracklabel::mcParticleId;
6668

6769
bool passesImpactParameterResolution(float pT, float d0Resolution)
6870
{
6971
float expectedResolution(0.001 + 0.0052 * std::exp(-0.655 * pT));
7072
return (d0Resolution <= expectedResolution * 1.5);
7173
} // Compares to pT dependent cut on impact parameter resolution
7274

73-
float logLikelihoodRatioSingleTrackDCA(float DCA, float reso, float lengthParameter)
75+
float logLikelihoodRatioSingleTrackDCA(float dca, float reso, float lengthParameter)
7476
{
7577
reso *= resoCorrectionFactor; // In case real resolution is worse
76-
float numerator = 1. / lengthParameter * std::exp(-DCA / lengthParameter);
77-
float denominator = (1. - largeLifetimeBG) * TMath::Gaus(DCA, 0., reso, true) + largeLifetimeBG / 0.2; // flat distribution to 2 mm
78+
float numerator = 1. / lengthParameter * std::exp(-dca / lengthParameter);
79+
float denominator = (1. - largeLifetimeBG) * TMath::Gaus(dca, 0., reso, true) + largeLifetimeBG / 0.2; // flat distribution to 2 mm
7880
return std::log(numerator / denominator);
7981
} // Creates the single track log likelihood assuming an exonential law for the secondaries
8082

@@ -172,6 +174,8 @@ struct HfTaskLb {
172174
{
173175
float massKStar892 = 0.892;
174176
float massDelta1232 = 1.232;
177+
std::array<float, 3> dca = {0.f, 0.f, 0.f};
178+
std::array<float, 3> dcaResolution = {0.f, 0.f, 0.f};
175179

176180
for (const auto& candidateLc : candidatesLc) {
177181
if (!candidateLc.isSelLcToPKPi() && !candidateLc.isSelLcToPiKP())
@@ -194,12 +198,26 @@ struct HfTaskLb {
194198
continue;
195199
if (!passesImpactParameterResolution(track2.pt(), reso2))
196200
continue;
197-
float DCA0 = candidateLc.impactParameter0();
198-
float DCA1 = candidateLc.impactParameter1();
199-
float DCA2 = candidateLc.impactParameter2();
200-
if (DCA0 > maximumImpactParameterForLambdaCCrossChecks || DCA1 > maximumImpactParameterForLambdaCCrossChecks || DCA2 > maximumImpactParameterForLambdaCCrossChecks)
201+
202+
dca = {
203+
candidateLc.impactParameter0(),
204+
candidateLc.impactParameter1(),
205+
candidateLc.impactParameter2()};
206+
207+
bool exceedsMaxDca = std::any_of(dca.begin(), dca.end(), [&](float val) {
208+
return val > maximumImpactParameterForLambdaCCrossChecks;
209+
});
210+
211+
if (exceedsMaxDca) {
201212
continue;
202-
float likelihoodRatio = logLikelihoodRatioSingleTrackDCA(DCA0, reso0, DCALengthParameter) + logLikelihoodRatioSingleTrackDCA(DCA1, reso1, DCALengthParameter) + logLikelihoodRatioSingleTrackDCA(DCA2, reso2, DCALengthParameter);
213+
}
214+
dcaResolution = {reso0, reso1, reso2};
215+
216+
float likelihoodRatio = 0.0f;
217+
for (size_t i = 0; i < dca.size(); ++i) {
218+
likelihoodRatio += logLikelihoodRatioSingleTrackDCA(dca[i], dcaResolution[i], lengthDCAParameter);
219+
}
220+
203221
registry.get<TH2>(HIST("hPtlogLikelihood"))->Fill(candidateLc.pt(), likelihoodRatio);
204222
if (likelihoodRatio < minLikelihoodRatioLc)
205223
continue;
@@ -255,24 +273,31 @@ struct HfTaskLb {
255273
} // Lambda_c candidates loop for cross checks
256274

257275
for (const auto& candidate : candidates) {
258-
if (!(candidate.hfflag() & 1 << hf_cand_lb::DecayType::LbToLcPi)) { // This should never be true as the loop is over Lb candidates
259-
continue;
260-
}
276+
261277
if (yCandRecoMax >= 0. && std::abs(hfHelper.yLb(candidate)) > yCandRecoMax) {
262278
continue;
263279
}
264280
registry.get<TH1>(HIST("hZVertex"))->Fill(collision.posZ());
265281

266282
auto candLc = candidate.prong0_as<soa::Join<aod::HfCand3Prong, aod::HfSelLc>>();
267-
float d0resolution0 = candLc.errorImpactParameter0();
268-
float d0resolution1 = candLc.errorImpactParameter1();
269-
float d0resolution2 = candLc.errorImpactParameter2();
270-
float DCA0 = candLc.impactParameter0();
271-
float DCA1 = candLc.impactParameter1();
272-
float DCA2 = candLc.impactParameter2();
273-
float likelihoodRatio = logLikelihoodRatioSingleTrackDCA(DCA0, d0resolution0, DCALengthParameter) + logLikelihoodRatioSingleTrackDCA(DCA1, d0resolution1, DCALengthParameter) + logLikelihoodRatioSingleTrackDCA(DCA2, d0resolution2, DCALengthParameter);
274-
if (likelihoodRatio < minLikelihoodRatio)
283+
dca = {
284+
candLc.impactParameter0(),
285+
candLc.impactParameter1(),
286+
candLc.impactParameter2()};
287+
288+
dcaResolution = {
289+
candLc.errorImpactParameter0(),
290+
candLc.errorImpactParameter1(),
291+
candLc.errorImpactParameter2()};
292+
293+
float likelihoodRatio = 0.0f;
294+
for (size_t i = 0; i < dca.size(); ++i) {
295+
likelihoodRatio += logLikelihoodRatioSingleTrackDCA(dca[i], dcaResolution[i], lengthDCAParameter);
296+
}
297+
298+
if (likelihoodRatio < minLikelihoodRatio) {
275299
continue; // Larger likelihood means more likely to be signal
300+
}
276301
float lbMass = hfHelper.invMassLbToLcPi(candidate);
277302
registry.get<TH2>(HIST("hPtinvMassLb"))->Fill(candidate.pt(), lbMass);
278303

@@ -304,15 +329,14 @@ struct HfTaskLb {
304329
{
305330
// MC rec
306331
for (const auto& candidate : candidates) {
307-
if (!(candidate.hfflag() & 1 << hf_cand_lb::DecayType::LbToLcPi)) {
308-
continue;
309-
}
332+
310333
if (yCandRecoMax >= 0. && std::abs(hfHelper.yLb(candidate)) > yCandRecoMax) {
311334
continue;
312335
}
313-
auto candLc = candidate.prong0_as<aod::HfCand3Prong>();
336+
auto candLc = candidate.prong0_as<soa::Join<aod::HfCand3Prong, aod::HfCand3ProngMcRec>>();
337+
int flagMcMatchRecLb = std::abs(candidate.flagMcMatchRec());
314338

315-
if (std::abs(candidate.flagMcMatchRec()) == 1 << hf_cand_lb::DecayType::LbToLcPi) {
339+
if (TESTBIT(flagMcMatchRecLb, hf_cand_lb::DecayType::LbToLcPi)) {
316340

317341
auto indexMother = RecoDecay::getMother(mcParticles, candidate.prong1_as<TracksWExtMc>().mcParticle_as<soa::Join<aod::McParticles, aod::HfCandLbMcGen>>(), o2::constants::physics::Pdg::kLambdaB0, true);
318342
auto particleMother = mcParticles.rawIteratorAt(indexMother);

PWGHF/D2H/Tasks/taskLbReduced.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ struct HfTaskLbReduced {
379379
{
380380
auto ptCandLb = candidate.pt();
381381
auto invMassLb = hfHelper.invMassLbToLcPi(candidate);
382-
auto candLc = candidate.template prong0Lc_as<CandsLc>();
382+
auto candLc = candidate.template prong0_as<CandsLc>();
383383
auto ptLc = candidate.ptProng0();
384384
auto invMassLc = candLc.invMassHypo0() > 0 ? candLc.invMassHypo0() : candLc.invMassHypo1();
385385
// TODO: here we are assuming that only one of the two hypotheses is filled, to be checked
@@ -538,7 +538,7 @@ struct HfTaskLbReduced {
538538
if constexpr (withLbMl) {
539539
candidateMlScoreSig = candidate.mlProbLbToLcPi();
540540
}
541-
auto prong1 = candidate.template prong1Track_as<TracksPion>();
541+
auto prong1 = candidate.template prong1_as<TracksPion>();
542542

543543
float ptMother = -1.;
544544
if constexpr (doMc) {

PWGHF/DataModel/CandidateReconstructionTables.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1931,8 +1931,6 @@ DECLARE_SOA_TABLE(HfCandLbBase, "AOD", "HFCANDLBBASE",
19311931
hf_cand::PxProng1, hf_cand::PyProng1, hf_cand::PzProng1,
19321932
hf_cand::ImpactParameter0, hf_cand::ImpactParameter1,
19331933
hf_cand::ErrorImpactParameter0, hf_cand::ErrorImpactParameter1,
1934-
hf_cand_lb::Prong0Id, hf_track_index::Prong1Id,
1935-
hf_track_index::HFflag,
19361934
/* dynamic columns */
19371935
hf_cand_2prong::M<hf_cand::PxProng0, hf_cand::PyProng0, hf_cand::PzProng0, hf_cand::PxProng1, hf_cand::PyProng1, hf_cand::PzProng1>,
19381936
hf_cand_2prong::M2<hf_cand::PxProng0, hf_cand::PyProng0, hf_cand::PzProng0, hf_cand::PxProng1, hf_cand::PyProng1, hf_cand::PzProng1>,
@@ -1958,7 +1956,10 @@ DECLARE_SOA_TABLE(HfCandLbBase, "AOD", "HFCANDLBBASE",
19581956
DECLARE_SOA_EXTENDED_TABLE_USER(HfCandLbExt, HfCandLbBase, "HFCANDLBEXT",
19591957
hf_cand_2prong::Px, hf_cand_2prong::Py, hf_cand_2prong::Pz);
19601958

1961-
using HfCandLb = HfCandLbExt;
1959+
DECLARE_SOA_TABLE(HfCandLbProngs, "AOD", "HFCANDLBPRONGS",
1960+
hf_cand_lb::Prong0Id, hf_track_index::Prong1Id);
1961+
1962+
using HfCandLb = soa::Join<HfCandLbExt, HfCandLbProngs>;
19621963

19631964
// table with results of reconstruction level MC matching
19641965
DECLARE_SOA_TABLE(HfCandLbMcRec, "AOD", "HFCANDLBMCREC", //!

PWGHF/TableProducer/candidateCreatorLb.cxx

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ using namespace o2::hf_trkcandsel;
4343
/// Reconstruction of Λb candidates
4444
struct HfCandidateCreatorLb {
4545
Produces<aod::HfCandLbBase> rowCandidateBase;
46-
46+
Produces<aod::HfCandLbProngs> rowCandidateProngs;
4747
// vertexing
4848
Configurable<float> bz{"bz", 20., "magnetic field"};
4949
Configurable<bool> propagateToPCA{"propagateToPCA", true, "create tracks version propagated to PCA"};
@@ -217,8 +217,6 @@ struct HfCandidateCreatorLb {
217217
auto errorDecayLength = std::sqrt(getRotatedCovMatrixXX(covMatrixPV, phi, theta) + getRotatedCovMatrixXX(covMatrixPCA, phi, theta));
218218
auto errorDecayLengthXY = std::sqrt(getRotatedCovMatrixXX(covMatrixPV, phi, 0.) + getRotatedCovMatrixXX(covMatrixPCA, phi, 0.));
219219

220-
int hfFlag = 1 << hf_cand_lb::DecayType::LbToLcPi;
221-
222220
// fill the candidate table for the Lb here:
223221
rowCandidateBase(collision.globalIndex(),
224222
collision.posX(), collision.posY(), collision.posZ(),
@@ -228,10 +226,8 @@ struct HfCandidateCreatorLb {
228226
pvecLc[0], pvecLc[1], pvecLc[2],
229227
pvecPion[0], pvecPion[1], pvecPion[2],
230228
impactParameter0.getY(), impactParameter1.getY(),
231-
std::sqrt(impactParameter0.getSigmaY2()), std::sqrt(impactParameter1.getSigmaY2()),
232-
lcCand.globalIndex(), trackPion.globalIndex(),
233-
hfFlag);
234-
229+
std::sqrt(impactParameter0.getSigmaY2()), std::sqrt(impactParameter1.getSigmaY2()));
230+
rowCandidateProngs(lcCand.globalIndex(), trackPion.globalIndex());
235231
// calculate invariant mass
236232
auto arrayMomenta = std::array{pvecLc, pvecPion};
237233
massLcPi = RecoDecay::m(std::move(arrayMomenta), std::array{massLc, massPi});
@@ -257,21 +253,19 @@ struct HfCandidateCreatorLbExpressions {
257253
/// @brief dummy process function, to be run on data
258254
void process(aod::Tracks const&) {}
259255

260-
void processMc(aod::HfCand3Prong const& lcCandidates,
261-
aod::TracksWMc const& tracks,
262-
aod::McParticles const& mcParticles)
256+
void processMc(aod::HfCand3Prong const&,
257+
aod::TracksWMc const&,
258+
aod::McParticles const& mcParticles,
259+
aod::HfCandLbProngs const& candsLb)
263260
{
264261
int indexRec = -1;
265262
int8_t sign = 0;
266263
int8_t flag = 0;
267264
int8_t origin = 0;
268265
int8_t debug = 0;
269266

270-
rowCandidateLb->bindExternalIndices(&tracks);
271-
rowCandidateLb->bindExternalIndices(&lcCandidates);
272-
273267
// Match reconstructed candidates.
274-
for (const auto& candidate : *rowCandidateLb) {
268+
for (const auto& candidate : candsLb) {
275269
flag = 0;
276270
origin = 0;
277271
debug = 0;

PWGHF/TableProducer/candidateSelectorLbToLcPi.cxx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,6 @@ struct HfCandidateSelectorLbToLcPi {
164164
for (const auto& hfCandLb : hfCandLbs) { // looping over Lb candidates
165165

166166
int statusLb = 0;
167-
168-
// check if flagged as Λb --> Λc+ π-
169-
if (!(hfCandLb.hfflag() & 1 << hf_cand_lb::DecayType::LbToLcPi)) {
170-
hfSelLbToLcPiCandidate(statusLb);
171-
// LOGF(debug, "Lb candidate selection failed at hfflag check");
172-
continue;
173-
}
174-
175167
// Lc is always index0 and pi is index1 by default
176168
// auto candLc = hfCandLb.prong0();
177169
auto candLc = hfCandLb.prong0_as<soa::Join<aod::HfCand3Prong, aod::HfSelLc>>();

0 commit comments

Comments
 (0)