@@ -606,97 +606,94 @@ struct HfTaskD0 {
606606 zdcEnergyZNA = zdc.energyCommonZNA ();
607607 zdcEnergyZNC = zdc.energyCommonZNC ();
608608 registry.fill (HIST (" Data/zdc/energyZNA_vs_energyZNC" ), zdcEnergyZNA, zdcEnergyZNC);
609-
610609 }
611610
612611 registry.fill (HIST (" Data/fitInfo/ampFT0A_vs_ampFT0C" ), fitInfo.ampFT0A , fitInfo.ampFT0C );
613612 registry.fill (HIST (" Data/hUpcGapAfterSelection" ), gap);
614613
615- if (hf_upc::isSingleSidedGap (gap)) {
616- const auto thisCollId = collision.globalIndex ();
617- const auto & groupedD0Candidates = candidates.sliceBy (candD0PerCollision, thisCollId);
614+ const auto thisCollId = collision.globalIndex ();
615+ const auto & groupedD0Candidates = candidates.sliceBy (candD0PerCollision, thisCollId);
618616
619- // Calculate occupancy and interaction rate if needed
620- float occ{-1 .f };
621- float ir{-1 .f };
622- if (storeOccupancyAndIR && occEstimator != OccupancyEstimator::None) {
623- occ = o2::hf_occupancy::getOccupancyColl (collision, occEstimator);
624- ir = mRateFetcher .fetch (ccdb.service , bc.timestamp (), bc.runNumber (), irSource, true ) * 1 .e -3 ; // kHz
617+ // Calculate occupancy and interaction rate if needed
618+ float occ{-1 .f };
619+ float ir{-1 .f };
620+ if (storeOccupancyAndIR && occEstimator != OccupancyEstimator::None) {
621+ occ = o2::hf_occupancy::getOccupancyColl (collision, occEstimator);
622+ ir = mRateFetcher .fetch (ccdb.service , bc.timestamp (), bc.runNumber (), irSource, true ) * 1 .e -3 ; // kHz
623+ }
624+
625+ for (const auto & candidate : groupedD0Candidates) {
626+ if (yCandRecoMax >= 0 . && std::abs (HfHelper::yD0 (candidate)) > yCandRecoMax) {
627+ continue ;
625628 }
626629
627- for (const auto & candidate : groupedD0Candidates) {
628- if (yCandRecoMax >= 0 . && std::abs (HfHelper::yD0 (candidate)) > yCandRecoMax) {
629- continue ;
630- }
630+ const float massD0 = HfHelper::invMassD0ToPiK (candidate);
631+ const float massD0bar = HfHelper::invMassD0barToKPi (candidate);
632+ const auto ptCandidate = candidate.pt ();
631633
632- const float massD0 = HfHelper::invMassD0ToPiK (candidate);
633- const float massD0bar = HfHelper::invMassD0barToKPi (candidate);
634- const auto ptCandidate = candidate.pt ();
634+ if (candidate.isSelD0 () >= selectionFlagD0) {
635+ registry.fill (HIST (" hMass" ), massD0, ptCandidate);
636+ registry.fill (HIST (" hMassFinerBinning" ), massD0, ptCandidate);
637+ registry.fill (HIST (" hMassVsPhi" ), massD0, ptCandidate, candidate.phi ());
638+ }
639+ if (candidate.isSelD0bar () >= selectionFlagD0bar) {
640+ registry.fill (HIST (" hMass" ), massD0bar, ptCandidate);
641+ registry.fill (HIST (" hMassFinerBinning" ), massD0bar, ptCandidate);
642+ registry.fill (HIST (" hMassVsPhi" ), massD0bar, ptCandidate, candidate.phi ());
643+ }
635644
636- if (candidate.isSelD0 () >= selectionFlagD0) {
637- registry.fill (HIST (" hMass" ), massD0, ptCandidate);
638- registry.fill (HIST (" hMassFinerBinning" ), massD0, ptCandidate);
639- registry.fill (HIST (" hMassVsPhi" ), massD0, ptCandidate, candidate.phi ());
645+ // Fill THnSparse with structure matching histogram axes: [mass, pt, (mlScores if FillMl), rapidity, d0Type, (cent if storeCentrality), (occ, ir if storeOccupancyAndIR), gapType, FT0A, FT0C, FV0A, FDDA, FDDC, ZNA, ZNC]
646+ auto fillTHnData = [&](float mass, int d0Type) {
647+ // Pre-calculate vector size to avoid reallocations
648+ constexpr int NAxesBase = 12 ; // mass, pt, rapidity, d0Type, gapType, FT0A, FT0C, FV0A, FDDA, FDDC, ZNA, ZNC
649+ constexpr int NAxesMl = FillMl ? 3 : 0 ; // 3 ML scores if FillMl
650+ int const nAxesCent = storeCentrality ? 1 : 0 ; // centrality if storeCentrality
651+ int const nAxesOccIR = storeOccupancyAndIR ? 2 : 0 ; // occupancy and IR if storeOccupancyAndIR
652+ int const nAxesTotal = NAxesBase + NAxesMl + nAxesCent + nAxesOccIR;
653+
654+ std::vector<double > valuesToFill;
655+ valuesToFill.reserve (nAxesTotal);
656+
657+ // Fill values in order matching histogram axes
658+ valuesToFill.push_back (static_cast <double >(mass));
659+ valuesToFill.push_back (static_cast <double >(ptCandidate));
660+ if constexpr (FillMl) {
661+ valuesToFill.push_back (candidate.mlProbD0 ()[0 ]);
662+ valuesToFill.push_back (candidate.mlProbD0 ()[1 ]);
663+ valuesToFill.push_back (candidate.mlProbD0 ()[2 ]);
640664 }
641- if (candidate. isSelD0bar () >= selectionFlagD0bar) {
642- registry. fill ( HIST ( " hMass " ), massD0bar, ptCandidate );
643- registry. fill ( HIST ( " hMassFinerBinning " ), massD0bar, ptCandidate);
644- registry. fill ( HIST ( " hMassVsPhi " ), massD0bar, ptCandidate, candidate. phi () );
665+ valuesToFill. push_back ( static_cast < double >( HfHelper::yD0 (candidate)));
666+ valuesToFill. push_back ( static_cast < double >(d0Type) );
667+ if (storeCentrality) {
668+ valuesToFill. push_back (centrality );
645669 }
646-
647- // Fill THnSparse with structure matching histogram axes: [mass, pt, (mlScores if FillMl), rapidity, d0Type, (cent if storeCentrality), (occ, ir if storeOccupancyAndIR), gapType, FT0A, FT0C, FV0A, FDDA, FDDC, ZNA, ZNC]
648- auto fillTHnData = [&](float mass, int d0Type) {
649- // Pre-calculate vector size to avoid reallocations
650- constexpr int NAxesBase = 12 ; // mass, pt, rapidity, d0Type, gapType, FT0A, FT0C, FV0A, FDDA, FDDC, ZNA, ZNC
651- constexpr int NAxesMl = FillMl ? 3 : 0 ; // 3 ML scores if FillMl
652- int const nAxesCent = storeCentrality ? 1 : 0 ; // centrality if storeCentrality
653- int const nAxesOccIR = storeOccupancyAndIR ? 2 : 0 ; // occupancy and IR if storeOccupancyAndIR
654- int const nAxesTotal = NAxesBase + NAxesMl + nAxesCent + nAxesOccIR;
655-
656- std::vector<double > valuesToFill;
657- valuesToFill.reserve (nAxesTotal);
658-
659- // Fill values in order matching histogram axes
660- valuesToFill.push_back (static_cast <double >(mass));
661- valuesToFill.push_back (static_cast <double >(ptCandidate));
662- if constexpr (FillMl) {
663- valuesToFill.push_back (candidate.mlProbD0 ()[0 ]);
664- valuesToFill.push_back (candidate.mlProbD0 ()[1 ]);
665- valuesToFill.push_back (candidate.mlProbD0 ()[2 ]);
666- }
667- valuesToFill.push_back (static_cast <double >(HfHelper::yD0 (candidate)));
668- valuesToFill.push_back (static_cast <double >(d0Type));
669- if (storeCentrality) {
670- valuesToFill.push_back (centrality);
671- }
672- if (storeOccupancyAndIR) {
673- valuesToFill.push_back (occ);
674- valuesToFill.push_back (ir);
675- }
676- valuesToFill.push_back (static_cast <double >(gap));
677- valuesToFill.push_back (static_cast <double >(fitInfo.ampFT0A ));
678- valuesToFill.push_back (static_cast <double >(fitInfo.ampFT0C ));
679- valuesToFill.push_back (static_cast <double >(fitInfo.ampFV0A ));
680- valuesToFill.push_back (static_cast <double >(fitInfo.ampFDDA ));
681- valuesToFill.push_back (static_cast <double >(fitInfo.ampFDDC ));
682- valuesToFill.push_back (static_cast <double >(zdcEnergyZNA));
683- valuesToFill.push_back (static_cast <double >(zdcEnergyZNC));
684-
685- if constexpr (FillMl) {
686- registry.get <THnSparse>(HIST (" hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type" ))->Fill (valuesToFill.data ());
687- } else {
688- registry.get <THnSparse>(HIST (" hMassVsPtVsPtBVsYVsOriginVsD0Type" ))->Fill (valuesToFill.data ());
689- }
690- };
691-
692- if (candidate.isSelD0 () >= selectionFlagD0) {
693- fillTHnData (massD0, SigD0);
694- fillTHnData (massD0, candidate.isSelD0bar () ? ReflectedD0 : PureSigD0);
670+ if (storeOccupancyAndIR) {
671+ valuesToFill.push_back (occ);
672+ valuesToFill.push_back (ir);
695673 }
696- if (candidate.isSelD0bar () >= selectionFlagD0bar) {
697- fillTHnData (massD0bar, SigD0bar);
698- fillTHnData (massD0bar, candidate.isSelD0 () ? ReflectedD0bar : PureSigD0bar);
674+ valuesToFill.push_back (static_cast <double >(gap));
675+ valuesToFill.push_back (static_cast <double >(fitInfo.ampFT0A ));
676+ valuesToFill.push_back (static_cast <double >(fitInfo.ampFT0C ));
677+ valuesToFill.push_back (static_cast <double >(fitInfo.ampFV0A ));
678+ valuesToFill.push_back (static_cast <double >(fitInfo.ampFDDA ));
679+ valuesToFill.push_back (static_cast <double >(fitInfo.ampFDDC ));
680+ valuesToFill.push_back (static_cast <double >(zdcEnergyZNA));
681+ valuesToFill.push_back (static_cast <double >(zdcEnergyZNC));
682+
683+ if constexpr (FillMl) {
684+ registry.get <THnSparse>(HIST (" hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type" ))->Fill (valuesToFill.data ());
685+ } else {
686+ registry.get <THnSparse>(HIST (" hMassVsPtVsPtBVsYVsOriginVsD0Type" ))->Fill (valuesToFill.data ());
699687 }
688+ };
689+
690+ if (candidate.isSelD0 () >= selectionFlagD0) {
691+ fillTHnData (massD0, SigD0);
692+ fillTHnData (massD0, candidate.isSelD0bar () ? ReflectedD0 : PureSigD0);
693+ }
694+ if (candidate.isSelD0bar () >= selectionFlagD0bar) {
695+ fillTHnData (massD0bar, SigD0bar);
696+ fillTHnData (massD0bar, candidate.isSelD0 () ? ReflectedD0bar : PureSigD0bar);
700697 }
701698 }
702699 }
0 commit comments