Skip to content

Commit dc2fde9

Browse files
[PWGHF] Tasks D0, D+: Minor fix for UPC processes (#13941)
Co-authored-by: minjungkim12 <minjungkim12@users.noreply.github.com> Co-authored-by: ALICE Action Bot <alibuild@cern.ch>
1 parent bb22c27 commit dc2fde9

File tree

3 files changed

+142
-153
lines changed

3 files changed

+142
-153
lines changed

PWGHF/D2H/Tasks/taskD0.cxx

Lines changed: 77 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

PWGHF/D2H/Tasks/taskDplus.cxx

Lines changed: 62 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ struct HfTaskDplus {
213213
registry.add("hPtVsYGenPrompt", "MC particles (matched, prompt);#it{p}_{T}^{gen.}; #it{y}", {HistType::kTH2F, {{vbins, "#it{p}_{T} (GeV/#it{c})"}, {100, -5., 5.}}});
214214
registry.add("hPtVsYGenNonPrompt", "MC particles (matched, non-prompt);#it{p}_{T}^{gen.}; #it{y}", {HistType::kTH2F, {{vbins, "#it{p}_{T} (GeV/#it{c})"}, {100, -5., 5.}}});
215215

216-
if (doprocessDataWithMl || doprocessData || doprocessDataWithMlWithUpc) {
216+
if (doprocessDataWithMl || doprocessData || doprocessDataWithMlWithUpc || doprocessDataWithUpc) {
217217
std::vector<AxisSpec> axes = {thnAxisMass, thnAxisPt};
218218

219219
if (doprocessDataWithMl || doprocessDataWithMlWithUpc) {
@@ -742,81 +742,75 @@ struct HfTaskDplus {
742742
const auto& zdc = bcForUPC.zdc();
743743
zdcEnergyZNA = zdc.energyCommonZNA();
744744
zdcEnergyZNC = zdc.energyCommonZNC();
745-
}
746-
747-
// Fill QA histograms using the UPC BC for both FIT and ZDC
748-
if (hasZdc) {
749-
registry.fill(HIST("Data/fitInfo/ampFT0A_vs_ampFT0C"), fitInfo.ampFT0A, fitInfo.ampFT0C);
750745
registry.fill(HIST("Data/zdc/energyZNA_vs_energyZNC"), zdcEnergyZNA, zdcEnergyZNC);
751-
registry.fill(HIST("Data/hUpcGapAfterSelection"), gap);
752746
}
747+
registry.fill(HIST("Data/fitInfo/ampFT0A_vs_ampFT0C"), fitInfo.ampFT0A, fitInfo.ampFT0C);
748+
registry.fill(HIST("Data/hUpcGapAfterSelection"), gap);
753749

754-
if (hf_upc::isSingleSidedGap(gap)) {
755-
const auto thisCollId = collision.globalIndex();
756-
const auto& groupedDplusCandidates = candidates.sliceBy(candDplusPerCollision, thisCollId);
750+
const auto thisCollId = collision.globalIndex();
751+
const auto& groupedDplusCandidates = candidates.sliceBy(candDplusPerCollision, thisCollId);
757752

758-
float cent{-1.f};
759-
float occ{-1.f};
760-
float ir{-1.f};
761-
if (storeOccupancy && occEstimator != OccupancyEstimator::None) {
762-
occ = o2::hf_occupancy::getOccupancyColl(collision, occEstimator);
753+
float cent{-1.f};
754+
float occ{-1.f};
755+
float ir{-1.f};
756+
if (storeOccupancy && occEstimator != OccupancyEstimator::None) {
757+
occ = o2::hf_occupancy::getOccupancyColl(collision, occEstimator);
758+
}
759+
if (storeIR) {
760+
ir = mRateFetcher.fetch(ccdb.service, bc.timestamp(), bc.runNumber(), irSource, true) * 1.e-3; // kHz
761+
}
762+
static constexpr auto HSparseMass = HIST("hSparseMass");
763+
// Lambda function to fill THn - handles both ML and non-ML cases
764+
auto fillTHnData = [&](const auto& candidate) {
765+
// Pre-calculate vector size to avoid reallocations
766+
constexpr int NAxesBase = 10; // mass, pt, gapType, FT0A, FT0C, FV0A, FDDA, FDDC, ZNA, ZNC
767+
constexpr int NAxesMl = FillMl ? 3 : 0; // 3 ML scores if FillMl
768+
int const nAxesCent = storeCentrality ? 1 : 0; // centrality if storeCentrality
769+
int const nAxesOcc = storeOccupancy ? 1 : 0; // occupancy if storeOccupancy
770+
int const nAxesIR = storeIR ? 1 : 0; // IR if storeIR
771+
int const nAxesTotal = NAxesBase + NAxesMl + nAxesCent + nAxesOcc + nAxesIR;
772+
773+
std::vector<double> valuesToFill;
774+
valuesToFill.reserve(nAxesTotal);
775+
776+
// Fill values in order matching histogram axes
777+
valuesToFill.push_back(HfHelper::invMassDplusToPiKPi(candidate));
778+
valuesToFill.push_back(static_cast<double>(candidate.pt()));
779+
if constexpr (FillMl) {
780+
std::vector<float> outputMl = {-999., -999., -999.};
781+
for (unsigned int iclass = 0; iclass < classMl->size(); iclass++) {
782+
outputMl[iclass] = candidate.mlProbDplusToPiKPi()[classMl->at(iclass)];
783+
}
784+
valuesToFill.push_back(outputMl[0]);
785+
valuesToFill.push_back(outputMl[1]);
786+
valuesToFill.push_back(outputMl[2]);
787+
}
788+
if (storeCentrality) {
789+
valuesToFill.push_back(cent);
790+
}
791+
if (storeOccupancy) {
792+
valuesToFill.push_back(occ);
763793
}
764794
if (storeIR) {
765-
ir = mRateFetcher.fetch(ccdb.service, bc.timestamp(), bc.runNumber(), irSource, true) * 1.e-3; // kHz
795+
valuesToFill.push_back(ir);
766796
}
767-
static constexpr auto HSparseMass = HIST("hSparseMass");
768-
// Lambda function to fill THn - handles both ML and non-ML cases
769-
auto fillTHnData = [&](const auto& candidate) {
770-
// Pre-calculate vector size to avoid reallocations
771-
constexpr int NAxesBase = 10; // mass, pt, gapType, FT0A, FT0C, FV0A, FDDA, FDDC, ZNA, ZNC
772-
constexpr int NAxesMl = FillMl ? 3 : 0; // 3 ML scores if FillMl
773-
int const nAxesCent = storeCentrality ? 1 : 0; // centrality if storeCentrality
774-
int const nAxesOcc = storeOccupancy ? 1 : 0; // occupancy if storeOccupancy
775-
int const nAxesIR = storeIR ? 1 : 0; // IR if storeIR
776-
int const nAxesTotal = NAxesBase + NAxesMl + nAxesCent + nAxesOcc + nAxesIR;
777-
778-
std::vector<double> valuesToFill;
779-
valuesToFill.reserve(nAxesTotal);
780-
781-
// Fill values in order matching histogram axes
782-
valuesToFill.push_back(HfHelper::invMassDplusToPiKPi(candidate));
783-
valuesToFill.push_back(static_cast<double>(candidate.pt()));
784-
if constexpr (FillMl) {
785-
std::vector<float> outputMl = {-999., -999., -999.};
786-
for (unsigned int iclass = 0; iclass < classMl->size(); iclass++) {
787-
outputMl[iclass] = candidate.mlProbDplusToPiKPi()[classMl->at(iclass)];
788-
}
789-
valuesToFill.push_back(outputMl[0]);
790-
valuesToFill.push_back(outputMl[1]);
791-
valuesToFill.push_back(outputMl[2]);
792-
}
793-
if (storeCentrality) {
794-
valuesToFill.push_back(cent);
795-
}
796-
if (storeOccupancy) {
797-
valuesToFill.push_back(occ);
798-
}
799-
if (storeIR) {
800-
valuesToFill.push_back(ir);
801-
}
802-
valuesToFill.push_back(static_cast<double>(gap));
803-
valuesToFill.push_back(static_cast<double>(fitInfo.ampFT0A));
804-
valuesToFill.push_back(static_cast<double>(fitInfo.ampFT0C));
805-
valuesToFill.push_back(static_cast<double>(fitInfo.ampFV0A));
806-
valuesToFill.push_back(static_cast<double>(fitInfo.ampFDDA));
807-
valuesToFill.push_back(static_cast<double>(fitInfo.ampFDDC));
808-
valuesToFill.push_back(static_cast<double>(zdcEnergyZNA));
809-
valuesToFill.push_back(static_cast<double>(zdcEnergyZNC));
810-
registry.get<THnSparse>(HSparseMass)->Fill(valuesToFill.data());
811-
};
812-
813-
for (const auto& candidate : groupedDplusCandidates) {
814-
if ((yCandRecoMax >= 0. && std::abs(HfHelper::yDplus(candidate)) > yCandRecoMax)) {
815-
continue;
816-
}
817-
fillHisto(candidate);
818-
fillTHnData(candidate);
797+
valuesToFill.push_back(static_cast<double>(gap));
798+
valuesToFill.push_back(static_cast<double>(fitInfo.ampFT0A));
799+
valuesToFill.push_back(static_cast<double>(fitInfo.ampFT0C));
800+
valuesToFill.push_back(static_cast<double>(fitInfo.ampFV0A));
801+
valuesToFill.push_back(static_cast<double>(fitInfo.ampFDDA));
802+
valuesToFill.push_back(static_cast<double>(fitInfo.ampFDDC));
803+
valuesToFill.push_back(static_cast<double>(zdcEnergyZNA));
804+
valuesToFill.push_back(static_cast<double>(zdcEnergyZNC));
805+
registry.get<THnSparse>(HSparseMass)->Fill(valuesToFill.data());
806+
};
807+
808+
for (const auto& candidate : groupedDplusCandidates) {
809+
if ((yCandRecoMax >= 0. && std::abs(HfHelper::yDplus(candidate)) > yCandRecoMax)) {
810+
continue;
819811
}
812+
fillHisto(candidate);
813+
fillTHnData(candidate);
820814
}
821815
}
822816
}

PWGHF/Utils/utilsUpcHf.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,15 @@ inline auto determineGapType(TCollision const& collision,
111111
thresholds.ft0aThreshold.value,
112112
thresholds.ft0cThreshold.value);
113113
}
114-
114+
/*
115115
/// \brief Check if the gap type is a single-sided gap (SingleGapA or SingleGapC)
116116
/// \param gap TrueGap enum value
117117
/// \return true if single-sided gap, false otherwise
118118
constexpr bool isSingleSidedGap(int gap) noexcept
119119
{
120-
return (gap == TrueGap::SingleGapA || gap == TrueGap::SingleGapC);
120+
return (gap == TrueGap::SingleGapA || gap == TrueGap::SingleGapC || gap == TrueGap::DoubleGap || gap == TrueGap::BadDoubleGap || gap == TrueGap::TrkOutOfRange || gap == TrueGap::NoUpc);
121121
}
122-
122+
*/
123123
/// \brief Get gap type name as string
124124
/// \param gap TrueGap enum value
125125
/// \return String representation of gap type

0 commit comments

Comments
 (0)