From 0acf1d8b4345ba98272b3958fbeb00dba8aee8b1 Mon Sep 17 00:00:00 2001 From: Maria Paula Martins Palhares Date: Mon, 27 Apr 2026 15:18:55 +0200 Subject: [PATCH 1/2] Added } missing in processMC + fix clang issues --- PWGLF/TableProducer/Nuspex/lnnRecoTask.cxx | 244 +++++++++++---------- 1 file changed, 129 insertions(+), 115 deletions(-) diff --git a/PWGLF/TableProducer/Nuspex/lnnRecoTask.cxx b/PWGLF/TableProducer/Nuspex/lnnRecoTask.cxx index c5edd7f2043..2d4720caddd 100644 --- a/PWGLF/TableProducer/Nuspex/lnnRecoTask.cxx +++ b/PWGLF/TableProducer/Nuspex/lnnRecoTask.cxx @@ -216,9 +216,11 @@ struct lnnRecoTask { Configurable ptMinTOF{"ptMinTOF", 0.8, "minimum pt for TOF cut"}; Configurable trTOFMass2Cut{"trTOFMass2Cut", 5.5, "minimum Triton mass square to TOF"}; Configurable betaTrTOF{"betaTrTOF", 0.4, "minimum beta TOF cut"}; + Configurable vtxZCut{"vtxZCut", 10., "vxt Z cut for event selection"}; Configurable mcSignalOnly{"mcSignalOnly", true, "If true, save only signal in MC"}; Configurable doTrackQA{"doTrackQA", true, "if true, compute the QA studies beased on detectors (ITS-TPC-TOF) signals"}; Configurable useNoSameBunchPileup{"useNoSameBunchPileup", false, "reject collisions in case of pileup with another collision in the same foundBC"}; + // Define o2 fitter, 2-prong, active memory (no need to redefine per event) o2::vertexing::DCAFitterN<2> fitter; @@ -232,7 +234,7 @@ struct lnnRecoTask { Configurable cfgMaterialCorrection{"cfgMaterialCorrection", static_cast(o2::base::Propagator::MatCorrType::USEMatCorrNONE), "Type of material correction"}; // CCDB options - Configurable d_bz_input{"d_bz_input", -999., "bz field, -999 is automatic"}; + Configurable dBzInput{"dBzInput", -999., "bz field, -999 is automatic"}; Configurable ccdburl{"ccdburl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; Configurable grpPath{"grpPath", "GLO/GRP/GRP", "Path of the grp file"}; Configurable grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"}; @@ -259,7 +261,7 @@ struct lnnRecoTask { ConfigurableAxis betaBins{"betaBins", {550, 0.f, 1.1f}, "Binning for Beta"}; ConfigurableAxis dcaXYBins{"dcaXYBins", {550, -5.f, 5.f}, "Binning for dcaXY triton"}; ConfigurableAxis tpcNClusBins{"tpcNClusBins", {260, 30, 165}, "Binning for nClusTPC"}; - ConfigurableAxis tpcNClsCrossedRowsBins{"TPCNClsCrossedRowsBins", {260, 30, 165}, "Binning for TPCNClsCrossedRows"}; + ConfigurableAxis tpcNClsCrossedRowsBins{"tpcNClsCrossedRowsBins", {260, 30, 165}, "Binning for TPCNClsCrossedRows"}; ConfigurableAxis tpcChi2NClusBins{"tpcChi2NClusBins", {20, 0.5, 10}, "Binning for chi2NClusTPC"}; ConfigurableAxis itsChi2NClusBins{"itsChi2NClusBins", {72, 0, 36}, "Binning for chi2NClusTPC"}; ConfigurableAxis candPtBins{"candPtBins", {160, 0, 8}, "Binning for lnn cand pt"}; @@ -282,6 +284,11 @@ struct lnnRecoTask { float d_bz; std::array mBBparams3H; + static constexpr float KallEvents = 0.; + static constexpr float KevAfterSel8 = 1.; + static constexpr float KevZVertexCut = 2.; + static constexpr float KevPileupCut = 3.; + // Definiton of histograms to real data [hNsigma3HSelected, hdEdx3HSelected, dEdxtotal, hEVents, hCentFT0(A/C/M) and hCentFV0A] and MC [hDecayChannel, hIsMatterGen, hIsMatterGenTwoBody] void init(InitContext const&) { @@ -313,7 +320,6 @@ struct lnnRecoTask { const AxisSpec tPosRigidityAxis{tPPosBins, "#it{p}^{TPC}/#it{z}"}; const AxisSpec tPNegRigidityAxis{tPNegBins, "#it{p}^{TPC}/#it{z}"}; const AxisSpec betaAxis{betaBins, "#beta_{TOF}"}; - const AxisSpec dcaXYAxis(dcaXYBins, "DCA_{xy} ({}^{3}H (cm)"); const AxisSpec tpcNClusAxis(tpcNClusBins, "N_{clus}^{TPC}"); const AxisSpec tpcNClsCrossedRowsAxis(tpcNClsCrossedRowsBins, "N_{TPC} crossed rows"); const AxisSpec tpcChi2NClusAxis(tpcChi2NClusBins, "{#Chi}^{2}/N_{clus}^{TPC}"); @@ -401,12 +407,12 @@ struct lnnRecoTask { o2::parameters::GRPMagField* grpmag = 0x0; if (grpo) { o2::base::Propagator::initFieldFromGRP(grpo); - if (d_bz_input < kBzAutoThreshold) { + if (dBzInput < kBzAutoThreshold) { // Fetch magnetic field from ccdb for current collision d_bz = grpo->getNominalL3Field(); LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << d_bz << " kZG"; } else { - d_bz = d_bz_input; + d_bz = dBzInput; } } else { grpmag = ccdb->getForTimeStamp(grpmagPath, run3grp_timestamp); @@ -414,22 +420,24 @@ struct lnnRecoTask { LOG(fatal) << "Got nullptr from CCDB for path " << grpmagPath << " of object GRPMagField and " << grpPath << " of object GRPObject for timestamp " << run3grp_timestamp; } o2::base::Propagator::initFieldFromGRP(grpmag); - if (d_bz_input < kBzAutoThreshold) { + if (dBzInput < kBzAutoThreshold) { // Fetch magnetic field from ccdb for current collision d_bz = std::lround(5.f * grpmag->getL3Current() / 30000.f); LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << d_bz << " kZG"; } else { - d_bz = d_bz_input; + d_bz = dBzInput; } } if (!pidPath.value.empty()) { auto h3pid = ccdb->getForTimeStamp>(pidPath.value + "_3H", run3grp_timestamp); std::copy(h3pid->begin(), h3pid->end(), mBBparams3H.begin()); } else { - for (int i = 0; i < 5; i++) { + int kNBetheBlochParams = 5; + int kResolutionIndex = 5; + for (int i = 0; i < kNBetheBlochParams; i++) { mBBparams3H[i] = cfgBetheBlochParams->get("3H", Form("p%i", i)); } - mBBparams3H[5] = cfgBetheBlochParams->get("3H", "resolution"); + mBBparams3H[kResolutionIndex] = cfgBetheBlochParams->get("3H", "resolution"); } fitter.setBz(d_bz); mRunNumber = bc.runNumber(); @@ -586,11 +594,13 @@ struct lnnRecoTask { float h3lE = h3E + piE; // Building the mother particle: lnn - constexpr std::size_t kMomDim = 3; - std::array lnnMom; + constexpr std::size_t KMomDim= 3; + std::array lnnMom; const auto& vtx = fitter.getPCACandidate(); - for (int i = 0; i < 3; i++) { + + int kNDim = 3; + for (int i = 0; i < kNDim; i++) { lnnCand.decVtx[i] = vtx[i]; lnnMom[i] = lnnCand.mom3H[i] + lnnCand.momPi[i]; } @@ -619,8 +629,8 @@ struct lnnRecoTask { continue; } - constexpr std::size_t kprimVtxDim = 3; - std::array primVtx = {collision.posX(), collision.posY(), collision.posZ()}; + constexpr std::size_t KPrimVtxDim = 3; + std::array primVtx = {collision.posX(), collision.posY(), collision.posZ()}; double cosPA = RecoDecay::cpa(primVtx, lnnCand.decVtx, lnnMom); if (cosPA < v0cospa) { @@ -628,7 +638,7 @@ struct lnnRecoTask { continue; } - for (int i = 0; i < 3; i++) { + for (int i = 0; i < kNDim; i++) { lnnCand.decVtx[i] = lnnCand.decVtx[i] - primVtx[i]; } @@ -675,8 +685,8 @@ struct lnnRecoTask { auto mcTrackNeg = mcLabNeg.mcParticle_as(); if (mcTrackPos.has_mothers() && mcTrackNeg.has_mothers()) { - for (auto& negMother : mcTrackNeg.mothers_as()) { - for (auto& posMother : mcTrackPos.mothers_as()) { + for (auto const& negMother : mcTrackNeg.mothers_as()) { + for (auto const& posMother : mcTrackPos.mothers_as()) { if (posMother.globalIndex() != negMother.globalIndex()) continue; if (!((mcTrackPos.pdgCode() == h3DauPdg && mcTrackNeg.pdgCode() == -1 * piDauPdg) || (mcTrackPos.pdgCode() == piDauPdg && mcTrackNeg.pdgCode() == -1 * h3DauPdg))) @@ -685,10 +695,10 @@ struct lnnRecoTask { continue; // Checking primary and second vertex with MC simulations - constexpr std::size_t kposVtxDim = 3; - std::array posPrimVtx = {posMother.vx(), posMother.vy(), posMother.vz()}; - constexpr std::size_t ksecVtxDim = 3; - std::array secVtx = {mcTrackPos.vx(), mcTrackPos.vy(), mcTrackPos.vz()}; + constexpr std::size_t KPosVtxDim = 3; + std::array posPrimVtx = {posMother.vx(), posMother.vy(), posMother.vz()}; + constexpr std::size_t KSecVtxDim = 3; + std::array secVtx = {mcTrackPos.vx(), mcTrackPos.vy(), mcTrackPos.vz()}; lnnCand.gMom = posMother.pVector(); @@ -697,8 +707,9 @@ struct lnnRecoTask { lnnCand.gMom3H = isTrTrack ? mcTrackPos.pVector() : mcTrackNeg.pVector(); lnnCand.gMomPi = isTrTrack ? mcTrackNeg.pVector() : mcTrackPos.pVector(); - - for (int i = 0; i < 3; i++) { + + int kNDimGen = 3; + for (int i = 0; i < kNDimGen; i++) { lnnCand.gDecVtx[i] = secVtx[i] - posPrimVtx[i]; } @@ -718,8 +729,9 @@ struct lnnRecoTask { { if (!mcPart.has_mothers()) return false; - - if (mcPart.getProcess() != 4) + + int decayProcess = 4; + if (mcPart.getProcess() != decayProcess) return false; bool motherIsAccepted = false; @@ -773,19 +785,19 @@ struct lnnRecoTask { auto bc = collision.bc_as(); initCCDB(bc); - hEvents->Fill(0.); + hEvents->Fill(KallEvents); if ((!collision.sel8())) { continue; } - hEvents->Fill(1.); - if (std::abs(collision.posZ()) > 10) { + hEvents->Fill(KevAfterSel8); + if (std::abs(collision.posZ()) > vtxZCut) { continue; } - hEvents->Fill(2.); + hEvents->Fill(KevZVertexCut); if (useNoSameBunchPileup && !collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { continue; } - hEvents->Fill(3.); + hEvents->Fill(KevPileupCut); hZvtx->Fill(collision.posZ()); hCentFT0A->Fill(collision.centFT0A()); @@ -794,10 +806,10 @@ struct lnnRecoTask { hCentFV0A->Fill(collision.centFV0A()); const uint64_t collIdx = collision.globalIndex(); - auto V0Table_thisCollision = V0s.sliceBy(perCollision, collIdx); - V0Table_thisCollision.bindExternalIndices(&tracks); + auto v0Table_thisCollision = V0s.sliceBy(perCollision, collIdx); + v0Table_thisCollision.bindExternalIndices(&tracks); - fillCandidateData(collision, V0Table_thisCollision); + fillCandidateData(collision, v0Table_thisCollision); for (const auto& lnnCand : lnnCandidates) { outputDataTable(collision.centFT0A(), collision.centFT0C(), collision.centFT0M(), @@ -845,7 +857,7 @@ struct lnnRecoTask { auto bc = collision.bc_as(); initCCDB(bc); - hEvents->Fill(0.); + hEvents->Fill(KallEvents); if (collision.has_mcCollision()) { recoCollisionIds[collision.mcCollisionId()] = collision.globalIndex(); } @@ -853,15 +865,15 @@ struct lnnRecoTask { if ((!collision.sel8())) { continue; } - hEvents->Fill(1.); - if (std::abs(collision.posZ()) > 10) { + hEvents->Fill(KevAfterSel8); + if (std::abs(collision.posZ()) > vtxZCut) { continue; } - hEvents->Fill(2.); + hEvents->Fill(KevZVertexCut); if (useNoSameBunchPileup && !collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { continue; } - hEvents->Fill(3.); + hEvents->Fill(KevPileupCut); hZvtx->Fill(collision.posZ()); hCentFT0A->Fill(collision.centFT0A()); @@ -875,10 +887,10 @@ struct lnnRecoTask { } const uint64_t collIdx = collision.globalIndex(); - auto V0Table_thisCollision = V0s.sliceBy(perCollision, collIdx); - V0Table_thisCollision.bindExternalIndices(&tracks); + auto v0Table_thisCollision = V0s.sliceBy(perCollision, collIdx); + v0Table_thisCollision.bindExternalIndices(&tracks); - fillCandidateData(collision, V0Table_thisCollision); + fillCandidateData(collision, v0Table_thisCollision); fillMCinfo(trackLabelsMC, particlesMC); for (const auto& lnnCand : lnnCandidates) { @@ -905,93 +917,95 @@ struct lnnRecoTask { chargeFactor * lnnCand.genPt(), lnnCand.genPhi(), lnnCand.genEta(), chargeFactor * lnnCand.genPt3H(), lnnCand.gDecVtx[0], lnnCand.gDecVtx[1], lnnCand.gDecVtx[2], lnnCand.isReco, lnnCand.isSignal, lnnCand.recoMcColl, lnnCand.survEvSelection); } + } - // now we fill only the signal candidates that were not reconstructed - for (const auto& mcPart : particlesMC) { - - if (std::abs(mcPart.pdgCode()) != lnnPdg) { - continue; - } - float cent = collisionFT0Ccent[mcPart.mcCollisionId()]; + // now we fill only the signal candidates that were not reconstructed + for (const auto& mcPart : particlesMC) { - h2FT0CPtGenColGenCandMC->Fill(cent, mcPart.pt()); + if (std::abs(mcPart.pdgCode()) != lnnPdg) { + continue; + } + float cent = collisionFT0Ccent[mcPart.mcCollisionId()]; - constexpr std::size_t kVtxDim = 3; - std::array secVtx; - std::array primVtx = {mcPart.vx(), mcPart.vy(), mcPart.vz()}; + h2FT0CPtGenColGenCandMC->Fill(cent, mcPart.pt()); - constexpr std::size_t kArrayDim = 3; - std::array momMother = mcPart.pVector(); + constexpr std::size_t KVtxDim = 3; + std::array secVtx; + std::array primVtx = {mcPart.vx(), mcPart.vy(), mcPart.vz()}; - std::array mom3H; - std::array momPi; - bool is3HFound = false; + constexpr std::size_t kArrayDim = 3; + std::array momMother = mcPart.pVector(); - for (const auto& mcDaught : mcPart.daughters_as()) { - int pdg = std::abs(mcDaught.pdgCode()); + std::array mom3H; + std::array momPi; + bool is3HFound = false; - if (pdg == h3DauPdg) { - secVtx = {mcDaught.vx(), mcDaught.vy(), mcDaught.vz()}; - mom3H = mcDaught.pVector(); - h2FT0CPtGenColGenTrStrMC->Fill(cent, mcDaught.pt()); - is3HFound = true; - } - if (pdg == piDauPdg) { - momPi = mcDaught.pVector(); - h2FT0CPtGenColGenPiStrMC->Fill(cent, mcDaught.pt()); - } - } + for (const auto& mcDaught : mcPart.daughters_as()) { + int pdg = std::abs(mcDaught.pdgCode()); - if (mcPart.pdgCode() > 0) { - hIsMatterGen->Fill(0.); - } else { - hIsMatterGen->Fill(1.); + if (pdg == h3DauPdg) { + secVtx = {mcDaught.vx(), mcDaught.vy(), mcDaught.vz()}; + mom3H = mcDaught.pVector(); + h2FT0CPtGenColGenTrStrMC->Fill(cent, mcDaught.pt()); + is3HFound = true; + break; } - - if (!is3HFound) { - hDecayChannel->Fill(1.); - } - hDecayChannel->Fill(0.); - if (std::find(filledMothers.begin(), filledMothers.end(), mcPart.globalIndex()) != std::end(filledMothers)) { - continue; - } - - LnnCandidate lnnCand; - lnnCand.pdgCode = mcPart.pdgCode(); - lnnCand.survEvSelection = isGoodCollision[mcPart.mcCollisionId()]; - int chargeFactor = -1 + 2 * (lnnCand.pdgCode > 0); - for (int i = 0; i < 3; i++) { - lnnCand.gDecVtx[i] = secVtx[i] - primVtx[i]; - lnnCand.gMom[i] = momMother[i]; - lnnCand.gMom3H[i] = mom3H[i]; - lnnCand.gMomPi[i] = momPi[i]; + if (pdg == piDauPdg) { + momPi = mcDaught.pVector(); + h2FT0CPtGenColGenPiStrMC->Fill(cent, mcDaught.pt()); } + } - lnnCand.posTrackID = -1; - lnnCand.negTrackID = -1; - lnnCand.isSignal = true; + if (mcPart.pdgCode() > 0) { + hIsMatterGen->Fill(0.); + } else { + hIsMatterGen->Fill(1.); + } - float centFT0A = -1, centFT0C = -1, centFT0M = -1; - if (lnnCand.recoMcColl) { - auto recoCollision = collisions.rawIteratorAt(recoCollisionIds[mcPart.mcCollisionId()]); - centFT0A = recoCollision.centFT0A(); - centFT0C = recoCollision.centFT0C(); - centFT0M = recoCollision.centFT0M(); - } - outputMCTable(centFT0A, centFT0C, centFT0M, - -1, -1, -1, - 0, - -1, -1, -1, - -1, -1, -1, - -1, -1, -1, - -1, -1, -1, - -1, -1, -1, -1, -1, - -1, -1, -1, -1, - -1, -1, - -1, -1, -1, - chargeFactor * lnnCand.genPt(), lnnCand.genPhi(), lnnCand.genEta(), lnnCand.genPt3H(), - lnnCand.gDecVtx[0], lnnCand.gDecVtx[1], lnnCand.gDecVtx[2], lnnCand.isReco, lnnCand.isSignal, lnnCand.recoMcColl, lnnCand.survEvSelection); + if (!is3HFound) { + hDecayChannel->Fill(1.); + continue; } + hDecayChannel->Fill(0.); + if (std::find(filledMothers.begin(), filledMothers.end(), mcPart.globalIndex()) != std::end(filledMothers)) { + continue; + } + + LnnCandidate lnnCand; + lnnCand.pdgCode = mcPart.pdgCode(); + lnnCand.survEvSelection = isGoodCollision[mcPart.mcCollisionId()]; + int chargeFactor = -1 + 2 * (lnnCand.pdgCode > 0); + + int kDimGen = 3; + for (int i = 0; i < kDimGen; i++) { + lnnCand.gDecVtx[i] = secVtx[i] - primVtx[i]; + lnnCand.gMom[i] = momMother[i]; + lnnCand.gMom3H[i] = mom3H[i]; + lnnCand.gMomPi[i] = momPi[i]; + } + + lnnCand.posTrackID = -1; + lnnCand.negTrackID = -1; + lnnCand.isSignal = true; + + float centFT0C = -1; + if (lnnCand.recoMcColl) { + auto recoCollision = collisions.rawIteratorAt(recoCollisionIds[mcPart.mcCollisionId()]); + centFT0C = recoCollision.centFT0C(); + } + outputMCTable(-1, centFT0C, -1, + -1, -1, -1, + 0, + -1, -1, -1, + -1, -1, -1, + -1, -1, -1, + -1, -1, -1, + -1, -1, -1, -1, -1, + -1, -1, -1, -1, + -1, -1, + -1, -1, -1, + chargeFactor * lnnCand.genPt(), lnnCand.genPhi(), lnnCand.genEta(), lnnCand.genPt3H(), + lnnCand.gDecVtx[0], lnnCand.gDecVtx[1], lnnCand.gDecVtx[2], lnnCand.isReco, lnnCand.isSignal, lnnCand.recoMcColl, lnnCand.survEvSelection); } } PROCESS_SWITCH(lnnRecoTask, processMC, "MC analysis", false); From 157fe595a4d2a4aceee5de4162cb7de8a8ee3c20 Mon Sep 17 00:00:00 2001 From: ALICE Action Bot Date: Mon, 27 Apr 2026 13:22:57 +0000 Subject: [PATCH 2/2] Please consider the following formatting changes --- PWGLF/TableProducer/Nuspex/lnnRecoTask.cxx | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/PWGLF/TableProducer/Nuspex/lnnRecoTask.cxx b/PWGLF/TableProducer/Nuspex/lnnRecoTask.cxx index 2d4720caddd..a9a823d364c 100644 --- a/PWGLF/TableProducer/Nuspex/lnnRecoTask.cxx +++ b/PWGLF/TableProducer/Nuspex/lnnRecoTask.cxx @@ -220,7 +220,6 @@ struct lnnRecoTask { Configurable mcSignalOnly{"mcSignalOnly", true, "If true, save only signal in MC"}; Configurable doTrackQA{"doTrackQA", true, "if true, compute the QA studies beased on detectors (ITS-TPC-TOF) signals"}; Configurable useNoSameBunchPileup{"useNoSameBunchPileup", false, "reject collisions in case of pileup with another collision in the same foundBC"}; - // Define o2 fitter, 2-prong, active memory (no need to redefine per event) o2::vertexing::DCAFitterN<2> fitter; @@ -594,7 +593,7 @@ struct lnnRecoTask { float h3lE = h3E + piE; // Building the mother particle: lnn - constexpr std::size_t KMomDim= 3; + constexpr std::size_t KMomDim = 3; std::array lnnMom; const auto& vtx = fitter.getPCACandidate(); @@ -707,8 +706,8 @@ struct lnnRecoTask { lnnCand.gMom3H = isTrTrack ? mcTrackPos.pVector() : mcTrackNeg.pVector(); lnnCand.gMomPi = isTrTrack ? mcTrackNeg.pVector() : mcTrackPos.pVector(); - - int kNDimGen = 3; + + int kNDimGen = 3; for (int i = 0; i < kNDimGen; i++) { lnnCand.gDecVtx[i] = secVtx[i] - posPrimVtx[i]; } @@ -729,7 +728,7 @@ struct lnnRecoTask { { if (!mcPart.has_mothers()) return false; - + int decayProcess = 4; if (mcPart.getProcess() != decayProcess) return false; @@ -976,7 +975,7 @@ struct lnnRecoTask { lnnCand.survEvSelection = isGoodCollision[mcPart.mcCollisionId()]; int chargeFactor = -1 + 2 * (lnnCand.pdgCode > 0); - int kDimGen = 3; + int kDimGen = 3; for (int i = 0; i < kDimGen; i++) { lnnCand.gDecVtx[i] = secVtx[i] - primVtx[i]; lnnCand.gMom[i] = momMother[i];