@@ -89,6 +89,7 @@ struct HfDerivedDataCreatorD0ToKPi {
8989
9090 SliceCache cache;
9191 static constexpr double Mass{o2::constants::physics::MassD0};
92+ static constexpr int NHypothesesCand{2 }; // Number of possible selection hypotheses per candidate.
9293
9394 using CollisionsWCentMult = soa::Join<aod::Collisions, aod::CentFV0As, aod::CentFT0Ms, aod::CentFT0As, aod::CentFT0Cs, aod::PVMultZeqs>;
9495 using CollisionsWMcCentMult = soa::Join<aod::Collisions, aod::McCollisionLabels, aod::CentFV0As, aod::CentFT0Ms, aod::CentFT0As, aod::CentFT0Cs, aod::PVMultZeqs>;
@@ -150,6 +151,7 @@ struct HfDerivedDataCreatorD0ToKPi {
150151 void fillTablesCandidate (const T& candidate, int candFlag, double invMass, double cosThetaStar, double topoChi2,
151152 double ct, double y, int8_t flagMc, int8_t origin, const std::vector<float >& mlScores)
152153 {
154+ LOGF (debug, " Filling candidate at derived index %d" , rowsCommon.rowCandidateBase .lastIndex () + 1 );
153155 rowsCommon.fillTablesCandidate (candidate, invMass, y);
154156 if (fillCandidatePar) {
155157 std::array<std::array<std::array<float , 3 >, 2 >, 2 > sigmas{}; // PID nSigma [Expected][Hypothesis][TPC/TOF/TPC+TOF]
@@ -248,12 +250,22 @@ struct HfDerivedDataCreatorD0ToKPi {
248250 rowsCommon.matchedCollisions .clear ();
249251 }
250252 }
251- auto sizeTableColl = collisions.size ();
252- rowsCommon.reserveTablesColl (sizeTableColl);
253+ // const auto sizeTableColl = collisions.size();
254+ // rowsCommon.reserveTablesColl(sizeTableColl);
255+ const auto sizeTableCand = candidates.size () * NHypothesesCand;
256+ rowsCommon.reserveTablesCandidates (sizeTableCand);
257+ reserveTable (rowCandidatePar, fillCandidatePar, sizeTableCand);
258+ reserveTable (rowCandidateParE, fillCandidateParE, sizeTableCand);
259+ reserveTable (rowCandidateSel, fillCandidateSel, sizeTableCand);
260+ reserveTable (rowCandidateMl, fillCandidateMl, sizeTableCand);
261+ reserveTable (rowCandidateId, fillCandidateId, sizeTableCand);
262+ if constexpr (IsMc) {
263+ reserveTable (rowCandidateMc, fillCandidateMc, sizeTableCand);
264+ }
253265 for (const auto & collision : collisions) {
254- auto thisCollId = collision.globalIndex ();
255- auto candidatesThisColl = candidates->sliceByCached (aod::hf_cand::collisionId, thisCollId, cache); // FIXME
256- auto sizeTableCand = candidatesThisColl.size ();
266+ const auto thisCollId = collision.globalIndex ();
267+ const auto candidatesThisColl = candidates->sliceByCached (aod::hf_cand::collisionId, thisCollId, cache); // FIXME
268+ const auto sizeTableCand = candidatesThisColl.size ();
257269 LOGF (debug, " Rec. collision %d has %d candidates" , thisCollId, sizeTableCand);
258270 // Skip collisions without HF candidates (and without HF particles in matched MC collisions if saving indices of reconstructed collisions matched to MC collisions)
259271 bool mcCollisionHasMcParticles{false };
@@ -269,15 +281,6 @@ struct HfDerivedDataCreatorD0ToKPi {
269281 rowsCommon.fillTablesCollision <IsMc>(collision);
270282
271283 // Fill candidate properties
272- rowsCommon.reserveTablesCandidates (sizeTableCand);
273- reserveTable (rowCandidatePar, fillCandidatePar, sizeTableCand);
274- reserveTable (rowCandidateParE, fillCandidateParE, sizeTableCand);
275- reserveTable (rowCandidateSel, fillCandidateSel, sizeTableCand);
276- reserveTable (rowCandidateMl, fillCandidateMl, sizeTableCand);
277- reserveTable (rowCandidateId, fillCandidateId, sizeTableCand);
278- if constexpr (IsMc) {
279- reserveTable (rowCandidateMc, fillCandidateMc, sizeTableCand);
280- }
281284 int8_t flagMcRec = 0 , origin = 0 ;
282285 for (const auto & candidate : candidatesThisColl) {
283286 if constexpr (IsMc) {
0 commit comments