@@ -605,100 +605,95 @@ struct HfTaskD0 {
605605 const auto & zdc = bcForUPC.zdc ();
606606 zdcEnergyZNA = zdc.energyCommonZNA ();
607607 zdcEnergyZNC = zdc.energyCommonZNC ();
608- }
609-
610- // Fill QA histograms using the UPC BC for both FIT and ZDC
611- if (hasZdc) {
612- registry.fill (HIST (" Data/fitInfo/ampFT0A_vs_ampFT0C" ), fitInfo.ampFT0A , fitInfo.ampFT0C );
613608 registry.fill (HIST (" Data/zdc/energyZNA_vs_energyZNC" ), zdcEnergyZNA, zdcEnergyZNC);
614- registry.fill (HIST (" Data/hUpcGapAfterSelection" ), gap);
615609 }
616610
617- if (hf_upc::isSingleSidedGap (gap)) {
618- const auto thisCollId = collision.globalIndex ();
619- const auto & groupedD0Candidates = candidates.sliceBy (candD0PerCollision, thisCollId);
611+ registry.fill (HIST (" Data/fitInfo/ampFT0A_vs_ampFT0C" ), fitInfo.ampFT0A , fitInfo.ampFT0C );
612+ registry.fill (HIST (" Data/hUpcGapAfterSelection" ), gap);
620613
621- // Calculate occupancy and interaction rate if needed
622- float occ{-1 .f };
623- float ir{-1 .f };
624- if (storeOccupancyAndIR && occEstimator != OccupancyEstimator::None) {
625- occ = o2::hf_occupancy::getOccupancyColl (collision, occEstimator);
626- ir = mRateFetcher .fetch (ccdb.service , bc.timestamp (), bc.runNumber (), irSource, true ) * 1 .e -3 ; // kHz
614+ const auto thisCollId = collision.globalIndex ();
615+ const auto & groupedD0Candidates = candidates.sliceBy (candD0PerCollision, thisCollId);
616+
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 ;
627628 }
628629
629- for (const auto & candidate : groupedD0Candidates) {
630- if (yCandRecoMax >= 0 . && std::abs (HfHelper::yD0 (candidate)) > yCandRecoMax) {
631- continue ;
632- }
630+ const float massD0 = HfHelper::invMassD0ToPiK (candidate);
631+ const float massD0bar = HfHelper::invMassD0barToKPi (candidate);
632+ const auto ptCandidate = candidate.pt ();
633633
634- const float massD0 = HfHelper::invMassD0ToPiK (candidate);
635- const float massD0bar = HfHelper::invMassD0barToKPi (candidate);
636- 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+ }
637644
638- if (candidate.isSelD0 () >= selectionFlagD0) {
639- registry.fill (HIST (" hMass" ), massD0, ptCandidate);
640- registry.fill (HIST (" hMassFinerBinning" ), massD0, ptCandidate);
641- 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 ]);
642664 }
643- if (candidate. isSelD0bar () >= selectionFlagD0bar) {
644- registry. fill ( HIST ( " hMass " ), massD0bar, ptCandidate );
645- registry. fill ( HIST ( " hMassFinerBinning " ), massD0bar, ptCandidate);
646- 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 );
647669 }
648-
649- // 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]
650- auto fillTHnData = [&](float mass, int d0Type) {
651- // Pre-calculate vector size to avoid reallocations
652- constexpr int NAxesBase = 12 ; // mass, pt, rapidity, d0Type, gapType, FT0A, FT0C, FV0A, FDDA, FDDC, ZNA, ZNC
653- constexpr int NAxesMl = FillMl ? 3 : 0 ; // 3 ML scores if FillMl
654- int const nAxesCent = storeCentrality ? 1 : 0 ; // centrality if storeCentrality
655- int const nAxesOccIR = storeOccupancyAndIR ? 2 : 0 ; // occupancy and IR if storeOccupancyAndIR
656- int const nAxesTotal = NAxesBase + NAxesMl + nAxesCent + nAxesOccIR;
657-
658- std::vector<double > valuesToFill;
659- valuesToFill.reserve (nAxesTotal);
660-
661- // Fill values in order matching histogram axes
662- valuesToFill.push_back (static_cast <double >(mass));
663- valuesToFill.push_back (static_cast <double >(ptCandidate));
664- if constexpr (FillMl) {
665- valuesToFill.push_back (candidate.mlProbD0 ()[0 ]);
666- valuesToFill.push_back (candidate.mlProbD0 ()[1 ]);
667- valuesToFill.push_back (candidate.mlProbD0 ()[2 ]);
668- }
669- valuesToFill.push_back (static_cast <double >(HfHelper::yD0 (candidate)));
670- valuesToFill.push_back (static_cast <double >(d0Type));
671- if (storeCentrality) {
672- valuesToFill.push_back (centrality);
673- }
674- if (storeOccupancyAndIR) {
675- valuesToFill.push_back (occ);
676- valuesToFill.push_back (ir);
677- }
678- valuesToFill.push_back (static_cast <double >(gap));
679- valuesToFill.push_back (static_cast <double >(fitInfo.ampFT0A ));
680- valuesToFill.push_back (static_cast <double >(fitInfo.ampFT0C ));
681- valuesToFill.push_back (static_cast <double >(fitInfo.ampFV0A ));
682- valuesToFill.push_back (static_cast <double >(fitInfo.ampFDDA ));
683- valuesToFill.push_back (static_cast <double >(fitInfo.ampFDDC ));
684- valuesToFill.push_back (static_cast <double >(zdcEnergyZNA));
685- valuesToFill.push_back (static_cast <double >(zdcEnergyZNC));
686-
687- if constexpr (FillMl) {
688- registry.get <THnSparse>(HIST (" hBdtScoreVsMassVsPtVsPtBVsYVsOriginVsD0Type" ))->Fill (valuesToFill.data ());
689- } else {
690- registry.get <THnSparse>(HIST (" hMassVsPtVsPtBVsYVsOriginVsD0Type" ))->Fill (valuesToFill.data ());
691- }
692- };
693-
694- if (candidate.isSelD0 () >= selectionFlagD0) {
695- fillTHnData (massD0, SigD0);
696- fillTHnData (massD0, candidate.isSelD0bar () ? ReflectedD0 : PureSigD0);
670+ if (storeOccupancyAndIR) {
671+ valuesToFill.push_back (occ);
672+ valuesToFill.push_back (ir);
697673 }
698- if (candidate.isSelD0bar () >= selectionFlagD0bar) {
699- fillTHnData (massD0bar, SigD0bar);
700- 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 ());
701687 }
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);
702697 }
703698 }
704699 }
0 commit comments