From e92fee96d740df96473bd538c87a4d81856fd32b Mon Sep 17 00:00:00 2001 From: rosstom Date: Wed, 29 Apr 2026 16:56:25 -0400 Subject: [PATCH 1/5] Merge with local changes --- .../HFTrackEfficiency/HFTrackEfficiency.cc | 79 ++++++++++++++++- .../KFParticle_sPHENIX/KFParticle_Tools.cc | 6 +- .../KFParticle_eventReconstruction.cc | 86 +++++++++++++++++-- .../KFParticle_sPHENIX/KFParticle_nTuple.cc | 16 +++- .../KFParticle_sPHENIX/KFParticle_sPHENIX.cc | 10 ++- offline/packages/decayfinder/DecayFinder.cc | 49 +++++++++-- offline/packages/decayfinder/DecayFinder.h | 2 +- 7 files changed, 226 insertions(+), 22 deletions(-) diff --git a/offline/packages/HFTrackEfficiency/HFTrackEfficiency.cc b/offline/packages/HFTrackEfficiency/HFTrackEfficiency.cc index 09de461fe9..7e5283ffe1 100644 --- a/offline/packages/HFTrackEfficiency/HFTrackEfficiency.cc +++ b/offline/packages/HFTrackEfficiency/HFTrackEfficiency.cc @@ -232,6 +232,13 @@ bool HFTrackEfficiency::findTracks(PHCompositeNode *topNode, Decay decay) int index = -1; + std::cout << "Particle truth barcodes and PIDs" << std::endl; + std::cout << "decay[0].first.second: " << decay[0].first.second << ", decay[0].second: " << decay[0].second << std::endl; + std::cout << "decay[1].first.second: " << decay[1].first.second << ", decay[1].second: " << decay[1].second << std::endl; + std::cout << "decay[2].first.second: " << decay[2].first.second << ", decay[2].second: " << decay[2].second << std::endl; + std::cout << "decay[3].first.second: " << decay[3].first.second << ", decay[3].second: " << decay[3].second << std::endl; + std::cout << "decay[4].first.second: " << decay[4].first.second << ", decay[4].second: " << decay[4].second << std::endl; + for (unsigned int i = 1; i < decay.size(); ++i) { m_dst_track = nullptr; @@ -241,6 +248,7 @@ bool HFTrackEfficiency::findTracks(PHCompositeNode *topNode, Decay decay) std::abs(decay[i].second)) != std::end(trackableParticles)) { ++index; + if (theEvent && decay[i].first.second > -1) { HepMC::GenParticle *daughterHepMC = theEvent->barcode_to_particle(decay[i].first.second); @@ -297,8 +305,74 @@ bool HFTrackEfficiency::findTracks(PHCompositeNode *topNode, Decay decay) continue; } - if (motherG4->get_pid() == decay[0].second && motherG4->get_barcode() == decay[0].first.second && daughterG4->get_pid() == decay[i].second && daughterG4->get_barcode() == decay[i].first.second) + if (motherG4->get_pid() == decay[0].second && motherG4->get_barcode() == decay[0].first.second && daughterG4->get_pid() == decay[i].second && daughterG4->get_barcode() == decay[i].first.second && m_nDaughters == 2) + { + if (Verbosity() >= VERBOSITY_MORE || true) // fix later + { + daughterG4->identify(); + } + + m_is_primary = m_truthInfo->is_sPHENIX_primary(motherG4); + + CLHEP::Hep3Vector *mother3Vector = new CLHEP::Hep3Vector(motherG4->get_px(), motherG4->get_py(), motherG4->get_pz()); + motherTrueLV->setVectM((*mother3Vector), getParticleMass(decay[0].second)); + m_true_mother_pT = motherTrueLV->perp(); + m_true_mother_p = mother3Vector->mag(); + m_true_mother_eta = motherTrueLV->pseudoRapidity(); + m_true_mother_phi = motherTrueLV->phi(); + + PHG4VtxPoint *thisVtx = m_truthInfo->GetVtx(motherG4->get_vtx_id()); + m_primary_vtx_x = thisVtx->get_x(); + m_primary_vtx_y = thisVtx->get_y(); + m_primary_vtx_z = thisVtx->get_z(); + + daughterTrueLV->setVectM(CLHEP::Hep3Vector(daughterG4->get_px(), daughterG4->get_py(), daughterG4->get_pz()), getParticleMass(decay[i].second)); + daughterSumTrueLV += *daughterTrueLV; + + // Now get the decay vertex position + thisVtx = m_truthInfo->GetVtx(daughterG4->get_vtx_id()); + m_secondary_vtx_x = thisVtx->get_x(); + m_secondary_vtx_y = thisVtx->get_y(); + m_secondary_vtx_z = thisVtx->get_z(); + + m_true_track_PID[index] = daughterG4->get_pid(); + truth_ID = daughterG4->get_track_id(); + + delete mother3Vector; + } + else if (m_nDaughters == 3) { + if (i != 4 && motherG4->get_pid() == decay[3].second && motherG4->get_barcode() == decay[3].first.second && daughterG4->get_pid() == decay[i].second && daughterG4->get_barcode() == decay[i].first.second) + { + PHG4Particle *motherG4_temp = nullptr; + if (motherG4->get_parent_id() != 0) + { + motherG4_temp = m_truthInfo->GetParticle(motherG4->get_parent_id()); + } + else + { + continue; + } + + if (motherG4_temp->get_pid() == decay[0].second && motherG4_temp->get_barcode() == decay[0].first.second) + { + motherG4 = motherG4_temp; + } + else + { + continue; + } + } + else if (i != 4) + { + continue; + } + + if (i==4 && !(motherG4->get_pid() == decay[0].second && motherG4->get_barcode() == decay[0].first.second && daughterG4->get_pid() == decay[i].second && daughterG4->get_barcode() == decay[i].first.second)) + { + continue; + } + if (Verbosity() >= VERBOSITY_MORE) { daughterG4->identify(); @@ -327,10 +401,11 @@ bool HFTrackEfficiency::findTracks(PHCompositeNode *topNode, Decay decay) m_secondary_vtx_y = thisVtx->get_y(); m_secondary_vtx_z = thisVtx->get_z(); - m_true_track_PID[index] = daughterG4->get_pid(); + m_true_track_PID[index] = daughterG4->get_pid(); truth_ID = daughterG4->get_track_id(); delete mother3Vector; + break; } } } diff --git a/offline/packages/KFParticle_sPHENIX/KFParticle_Tools.cc b/offline/packages/KFParticle_sPHENIX/KFParticle_Tools.cc index 9bb76608ee..15312138a1 100644 --- a/offline/packages/KFParticle_sPHENIX/KFParticle_Tools.cc +++ b/offline/packages/KFParticle_sPHENIX/KFParticle_Tools.cc @@ -986,7 +986,7 @@ std::tuple KFParticle_Tools::getCombination(KFParticle vDaught isGoodCandidate = checkTrackAndVertexMatch(vDaughters, nTracks, vertex); } - if (isGoodCandidate) + if (isGoodCandidate || m_use_truth_pv) { constrainToVertex(candidate, isGoodCandidate, vertex); } @@ -1257,6 +1257,10 @@ bool KFParticle_Tools::checkTrackAndVertexMatch(KFParticle vDaughters[], int nTr m_dst_mbdvertex = m_dst_mbdvertexmap->get(vertex.Id()); vertexCrossing = m_dst_mbdvertex->get_beam_crossing(); } + else if (m_use_truth_pv) + { + vertexCrossing = ; + } else { m_dst_vertex = m_dst_vertexmap->get(vertex.Id()); diff --git a/offline/packages/KFParticle_sPHENIX/KFParticle_eventReconstruction.cc b/offline/packages/KFParticle_sPHENIX/KFParticle_eventReconstruction.cc index 64d6b932fa..c09cbc88d3 100644 --- a/offline/packages/KFParticle_sPHENIX/KFParticle_eventReconstruction.cc +++ b/offline/packages/KFParticle_sPHENIX/KFParticle_eventReconstruction.cc @@ -31,10 +31,17 @@ //sPHENIX stuff #include +#include +#include +#include +#include // KFParticle stuff #include +#include +#include + #include #include #include // for begin, distance, end @@ -52,6 +59,7 @@ KFParticle_eventReconstruction::KFParticle_eventReconstruction() : m_constrain_to_vertex(false) , m_constrain_int_mass(false) , m_use_fake_pv(false) + , m_use_truth_pv(false) { } @@ -65,6 +73,14 @@ void KFParticle_eventReconstruction::createDecay(PHCompositeNode* topNode, std:: { primaryVertices.push_back(createFakePV()); } + else if (m_use_truth_pv) + { + std::vector KFP_PVs = createTruthPV(topNode); + for (const auto& pv: KFP_PVs) + { + primaryVertices.push_back(pv); + } + } else { primaryVertices = makeAllPrimaryVertices(topNode, m_vtx_map_node_name); @@ -74,15 +90,19 @@ void KFParticle_eventReconstruction::createDecay(PHCompositeNode* topNode, std:: nPVs = primaryVertices.size(); - std::vector goodTrackIndex = findAllGoodTracks(daughterParticles, primaryVertices); - - if (!m_has_intermediates) + if (!m_use_truth_pv || nPVs != 0) { - buildBasicChain(selectedMother, selectedVertex, selectedDaughters, daughterParticles, goodTrackIndex, primaryVertices, topNode); - } - else - { - buildChain(selectedMother, selectedVertex, selectedDaughters, selectedIntermediates, daughterParticles, goodTrackIndex, primaryVertices, topNode); + std::vector goodTrackIndex = findAllGoodTracks(daughterParticles, primaryVertices); + + if (!m_has_intermediates) + { + buildBasicChain(selectedMother, selectedVertex, selectedDaughters, daughterParticles, goodTrackIndex, primaryVertices, topNode); + } + else + { + std::cout << "Gets to buildChain" << std::endl; + buildChain(selectedMother, selectedVertex, selectedDaughters, selectedIntermediates, daughterParticles, goodTrackIndex, primaryVertices, topNode); + } } } @@ -590,3 +610,53 @@ KFParticle KFParticle_eventReconstruction::createFakePV() kfp_vertex.SetId(0); return kfp_vertex; } + +std::vector KFParticle_eventReconstruction::createTruthPV(PHCompositeNode* topNode) +{ + std::vector kfp_vertex = {}; + + PHG4InEvent *ineve = findNode::getClass(topNode, "PHG4INEVENT"); + if (!ineve) + { + std::cout << PHWHERE << "no PHG4INEVENT node" << std::endl; + return kfp_vertex; + } + + auto vtxRange = ineve->GetVertices(); + // find the PV + std::vector primaryVtx = {}; + for (auto it = vtxRange.first; it != vtxRange.second; ++it) + { + if (it->first == 1) + { + primaryVtx.push_back(it->second); + } + } + + if (primaryVtx.size() == 0) + { + std::cerr << "getPrimaryVertex: No primary vertex found!" << std::endl; + return kfp_vertex; // return default empty vertex + } + + for (const auto& v : primaryVtx) + { + float pos[3] = { + static_cast(v->get_x()), + static_cast(v->get_y()), + static_cast(v->get_z()) + }; + float f_vertexParameters[6] = {pos[0], pos[1], pos[2], 0, 0, 0}; + + float f_vertexCovariance[21] = {0}; + + KFParticle kfp_v; + kfp_v.Create(f_vertexParameters, f_vertexCovariance, 0, -1); + kfp_v.NDF() = 0; + kfp_v.Chi2() = 0; + kfp_v.SetId(0); + kfp_vertex.push_back(kfp_v); + } + + return kfp_vertex; +} diff --git a/offline/packages/KFParticle_sPHENIX/KFParticle_nTuple.cc b/offline/packages/KFParticle_sPHENIX/KFParticle_nTuple.cc index b3b119e4f6..304b155674 100644 --- a/offline/packages/KFParticle_sPHENIX/KFParticle_nTuple.cc +++ b/offline/packages/KFParticle_sPHENIX/KFParticle_nTuple.cc @@ -270,6 +270,14 @@ void KFParticle_nTuple::initializeBranches(PHCompositeNode* topNode) std::string dca_branch_name_xy = dca_branch_name + "_xy"; std::string dca_leaf_name_xy = dca_branch_name_xy + "/F"; m_tree->Branch(dca_branch_name_xy.c_str(), &m_daughter_dca_xy[iter], dca_leaf_name_xy.c_str()); + + std::string dca_sig_branch_name = "track_" + std::to_string(i + 1) + "_track_" + std::to_string(j + 1) + "_DCA_sig"; + std::string dca_sig_leaf_name = dca_sig_branch_name + "/F"; + m_tree->Branch(dca_sig_branch_name.c_str(), &m_daughter_dca_sig[iter], dca_sig_leaf_name.c_str()); + + std::string dca_sig_branch_name_xy = dca_sig_branch_name + "_xy"; + std::string dca_sig_leaf_name_xy = dca_sig_branch_name_xy + "/F"; + m_tree->Branch(dca_sig_branch_name_xy.c_str(), &m_daughter_dca_sig_xy[iter], dca_sig_leaf_name_xy.c_str()); ++iter; } @@ -496,6 +504,8 @@ void KFParticle_nTuple::fillBranch(PHCompositeNode* topNode, m_calculated_daughter_ipchi2[i] = daughterArray[i].GetDeviationFromVertex(vertex_fillbranch); m_calculated_daughter_ip_err[i] = m_calculated_daughter_ip[i] / std::sqrt(m_calculated_daughter_ipchi2[i]); m_calculated_daughter_ip_xy[i] = daughterArray[i].GetDistanceFromVertexXY(vertex_fillbranch); + m_calculated_daughter_PV_dca_sig[i] = daughterArray[i].GetDeviationFromVertex(vertex_fillbranch); + m_calculated_daughter_PV_dca_xy_sig[i] = daughterArray[i].GetDeviationFromVertexXY(vertex_fillbranch); } m_calculated_daughter_x[i] = daughterArray[i].GetX(); m_calculated_daughter_y[i] = daughterArray[i].GetY(); @@ -596,6 +606,8 @@ void KFParticle_nTuple::fillBranch(PHCompositeNode* topNode, { m_daughter_dca[iter] = daughterArray[i].GetDistanceFromParticle(daughterArray[j]); m_daughter_dca_xy[iter] = daughterArray[i].GetDistanceFromParticleXY(daughterArray[j]); + m_daughter_dca_sig[iter] = daughterArray[i].GetDeviationFromParticle(daughterArray[j]); + m_daughter_dca_sig_xy[iter] = daughterArray[i].GetDeviationFromParticleXY(daughterArray[j]); ++iter; } } @@ -631,7 +643,7 @@ void KFParticle_nTuple::fillBranch(PHCompositeNode* topNode, // it only makes sense to calculate PVID for non-fake vertex // (this otherwise crashes if m_use_fake_pv_nTuple is true in an event with no real vertices) - if (m_use_fake_pv_nTuple) + if (m_use_fake_pv_nTuple || m_use_truth_pv_nTuple) { m_calculated_vertex_ID = -100; // error value returned by getPVID } @@ -650,7 +662,7 @@ void KFParticle_nTuple::fillBranch(PHCompositeNode* topNode, kfpTupleTools.getTracksFromBC(topNode, m_calculated_daughter_bunch_crossing[0], m_vtx_map_node_name_nTuple, m_multiplicity, m_nPVs); // cannot retrieve vertex map info from fake PV, hence the second condition - if (m_constrain_to_vertex_nTuple && !m_use_fake_pv_nTuple) + if (m_constrain_to_vertex_nTuple && !m_use_fake_pv_nTuple && !m_use_truth_pv_nTuple) { m_nTracksOfVertex = kfpTupleTools.getTracksFromVertex(topNode, vertex_fillbranch, m_vtx_map_node_name_nTuple); } diff --git a/offline/packages/KFParticle_sPHENIX/KFParticle_sPHENIX.cc b/offline/packages/KFParticle_sPHENIX/KFParticle_sPHENIX.cc index db46bffafe..cd9e18de8d 100644 --- a/offline/packages/KFParticle_sPHENIX/KFParticle_sPHENIX.cc +++ b/offline/packages/KFParticle_sPHENIX/KFParticle_sPHENIX.cc @@ -213,7 +213,7 @@ int KFParticle_sPHENIX::process_event(PHCompositeNode *topNode) m_prev_eventNumber = -1; } // End BCO matching here - if (!m_use_fake_pv) + if (!m_use_fake_pv && !m_use_truth_pv) { if (m_use_mbd_vertex) { @@ -242,6 +242,14 @@ int KFParticle_sPHENIX::process_event(PHCompositeNode *topNode) } createDecay(topNode, mother, vertex_kfparticle, daughters, intermediates, nPVs); + if (m_use_truth_pv && nPVs == 0) + { + if (Verbosity() >= VERBOSITY_SOME) + { + std::cout << "No Truth Vertices Found For This Event, Skipping" << std::endl; + } + return Fun4AllReturnCodes::EVENT_OK; + } if (!m_has_intermediates_sPHENIX) { intermediates = daughters; diff --git a/offline/packages/decayfinder/DecayFinder.cc b/offline/packages/decayfinder/DecayFinder.cc index a3521df780..000b1c4861 100644 --- a/offline/packages/decayfinder/DecayFinder.cc +++ b/offline/packages/decayfinder/DecayFinder.cc @@ -93,14 +93,14 @@ int DecayFinder::Init(PHCompositeNode* topNode) int DecayFinder::process_event(PHCompositeNode* topNode) { - bool decayFound = findDecay(topNode); + int decayFound = findDecay(topNode); - if (decayFound && m_save_dst && Verbosity() >= VERBOSITY_MORE) + if (decayFound > 0 && m_save_dst && Verbosity() >= VERBOSITY_MORE) { printNode(topNode); } - if (m_triggerOnDecay && !decayFound) + if (m_triggerOnDecay && decayFound < 1) { if (Verbosity() >= VERBOSITY_MORE) { @@ -317,10 +317,10 @@ int DecayFinder::parseDecayDescriptor() * as decays wont enter the HepMC record * need a switch to go to Geant4 record */ -bool DecayFinder::findDecay(PHCompositeNode* topNode) +int DecayFinder::findDecay(PHCompositeNode* topNode) { bool decayWasFound = false; - bool reconstructableDecayWasFound = false; + int reconstructableDecayWasFound = 0; bool aTrackFailedPT = false; bool aTrackFailedETA = false; bool aMotherHasPhoton = false; @@ -384,9 +384,16 @@ bool DecayFinder::findDecay(PHCompositeNode* topNode) std::cout << "parent->pdg_id(): " << g4particle->get_pid() << std::endl; } + aTrackFailedPT = false; + aTrackFailedETA = false; + aMotherHasPhoton = false; + aMotherHasPi0 = false; + bool breakOut = false; correctMotherProducts.clear(); decayChain.clear(); + std::cout << __LINE__ << std::endl; + std::cout << "g4particle->get_barcode()" << g4particle->get_barcode() << std::endl; decayChain.emplace_back(std::make_pair(g4particle->get_primary_id(), g4particle->get_barcode()), g4particle->get_pid()); searchGeant4Record(g4particle->get_barcode(), g4particle->get_pid(), positive_motherDecayProducts, breakOut, aMotherHasPhoton, aMotherHasPi0, aTrackFailedPT, aTrackFailedETA, correctMotherProducts); @@ -416,7 +423,7 @@ bool DecayFinder::findDecay(PHCompositeNode* topNode) else { m_nCandReconstructable += 1; - reconstructableDecayWasFound = true; + ++reconstructableDecayWasFound; if (m_save_dst) { fillDecayNode(topNode, decayChain); @@ -465,18 +472,27 @@ bool DecayFinder::findDecay(PHCompositeNode* topNode) std::cout << "parent->pdg_id(): " << (*p)->pdg_id() << std::endl; } + aTrackFailedPT = false; + aTrackFailedETA = false; + aMotherHasPhoton = false; + aMotherHasPi0 = false; + bool breakOut = false; correctMotherProducts.clear(); decayChain.clear(); + std::cout << __LINE__ << std::endl; + std::cout << "(*p)->barcode()" << (*p)->barcode() << std::endl; decayChain.emplace_back(std::make_pair(m_genevt->get_embedding_id(), (*p)->barcode()), (*p)->pdg_id()); // Make sure that the mother has a decay in our record if (!(*p)->end_vertex()) // Mother has no end vertex, decay volume was limited { + std::cout << "Searching G4 Record" << std::endl; searchGeant4Record((*p)->barcode(), (*p)->pdg_id(), positive_motherDecayProducts, breakOut, aMotherHasPhoton, aMotherHasPi0, aTrackFailedPT, aTrackFailedETA, correctMotherProducts); } else { + std::cout << "Searching HepMC Record" << std::endl; searchHepMCRecord((*p), positive_motherDecayProducts, breakOut, aMotherHasPhoton, aMotherHasPi0, aTrackFailedPT, aTrackFailedETA, correctMotherProducts); } @@ -505,7 +521,7 @@ bool DecayFinder::findDecay(PHCompositeNode* topNode) else { m_nCandReconstructable += 1; - reconstructableDecayWasFound = true; + ++reconstructableDecayWasFound; if (m_save_dst) { fillDecayNode(topNode, decayChain); @@ -611,6 +627,8 @@ void DecayFinder::searchHepMCRecord(HepMC::GenParticle* particle, std::vectorbarcode()" << (*children)->barcode() << std::endl; searchGeant4Record((*children)->barcode(), (*children)->pdg_id(), positive_requiredIntermediateDecayProducts, breakLoop, hasPhoton, hasPi0, failedPT, failedETA, actualIntermediateDecayProducts); @@ -647,6 +665,8 @@ void DecayFinder::searchHepMCRecord(HepMC::GenParticle* particle, std::vectorend_vertex()) { + std::cout << __LINE__ << std::endl; + std::cout << "(*children)->barcode()" << (*children)->barcode() << std::endl; searchGeant4Record((*children)->barcode(), (*children)->pdg_id(), decayProducts, breakLoop, hasPhoton, hasPi0, failedPT, failedETA, actualDecayProducts); } @@ -659,6 +679,8 @@ void DecayFinder::searchHepMCRecord(HepMC::GenParticle* particle, std::vectorpdg_id()); + std::cout << __LINE__ << std::endl; + std::cout << "(*grandchildren)->barcode()" << (*grandchildren)->barcode() << std::endl; decayChain.emplace_back(std::make_pair(m_genevt->get_embedding_id(), (*grandchildren)->barcode()), (*grandchildren)->pdg_id()); } } @@ -678,6 +700,7 @@ void DecayFinder::searchHepMCRecord(HepMC::GenParticle* particle, std::vector decayProducts, bool& breakLoop, bool& hasPhoton, bool& hasPi0, bool& failedPT, bool& failedETA, std::vector& actualDecayProducts) { + std::cout << "searchGeant4Record barcode: " << barcode << std::endl; PHG4TruthInfoContainer::ConstRange range = m_truthinfo->GetParticleRange(); for (PHG4TruthInfoContainer::ConstIterator iter = range.first; iter != range.second; ++iter) { @@ -699,6 +722,8 @@ void DecayFinder::searchGeant4Record(int barcode, int pid, std::vector deca } if (mother->get_barcode() == barcode && abs(mother->get_pid()) == abs(pid)) { + std::cout << __LINE__ << std::endl; + std::cout << "mother->get_barcode()" << mother->get_barcode() << std::endl; int particleID = g4particle->get_pid(); if (Verbosity() >= VERBOSITY_MAX) { @@ -731,6 +756,8 @@ void DecayFinder::searchGeant4Record(int barcode, int pid, std::vector deca } actualDecayProducts.push_back(particleID); int embedding_id = m_geneventmap ? m_genevt->get_embedding_id() : g4particle->get_primary_id(); + std::cout << __LINE__ << std::endl; + std::cout << "g4particle->get_barcode()" << g4particle->get_barcode() << std::endl; decayChain.emplace_back(std::make_pair(embedding_id, g4particle->get_barcode()), particleID); } } // Now check if it's part of the other resonance list @@ -745,6 +772,8 @@ void DecayFinder::searchGeant4Record(int barcode, int pid, std::vector deca { std::cout << "This is a resonance to investigate further" << std::endl; } + std::cout << __LINE__ << std::endl; + std::cout << "g4particle->get_barcode()" << g4particle->get_barcode() << std::endl; searchGeant4Record(g4particle->get_barcode(), g4particle->get_pid(), decayProducts, breakLoop, hasPhoton, hasPi0, failedPT, failedETA, actualDecayProducts); } @@ -830,6 +859,8 @@ bool DecayFinder::checkIfCorrectHepMCParticle(HepMC::GenParticle* particle, bool } actualIntermediateDecayProducts.push_back((*greatgrandchildren)->pdg_id()); + std::cout << __LINE__ << std::endl; + std::cout << "(*greatgrandchildren)->barcode()" << (*greatgrandchildren)->barcode() << std::endl; decayChain.emplace_back(std::make_pair(m_genevt->get_embedding_id(), (*greatgrandchildren)->barcode()), (*greatgrandchildren)->pdg_id()); ++m_intermediate_product_counter; @@ -870,6 +901,8 @@ bool DecayFinder::checkIfCorrectHepMCParticle(HepMC::GenParticle* particle, bool else { actualIntermediateDecayProducts.push_back((*grandchildren)->pdg_id()); + std::cout << __LINE__ << std::endl; + std::cout << "(*grandchildren)->barcode()" << (*grandchildren)->barcode() << std::endl; decayChain.emplace_back(std::make_pair(m_genevt->get_embedding_id(), (*grandchildren)->barcode()), (*grandchildren)->pdg_id()); ++m_intermediate_product_counter; @@ -988,6 +1021,8 @@ bool DecayFinder::checkIfCorrectGeant4Particle(PHG4Particle* particle, bool& has } bool fakeBreak = false; + std::cout << __LINE__ << std::endl; + std::cout << "particle->get_barcode()" << particle->get_barcode() << std::endl; searchGeant4Record(particle->get_barcode(), particle->get_pid(), positive_intermediateDecayProducts, fakeBreak, hasPhoton, hasPi0, trackFailedPT, trackFailedETA, actualIntermediateDecayProducts); diff --git a/offline/packages/decayfinder/DecayFinder.h b/offline/packages/decayfinder/DecayFinder.h index bd893546a1..3605733e9f 100644 --- a/offline/packages/decayfinder/DecayFinder.h +++ b/offline/packages/decayfinder/DecayFinder.h @@ -42,7 +42,7 @@ class DecayFinder : public SubsysReco int parseDecayDescriptor(); - bool findDecay(PHCompositeNode *topNode); + int findDecay(PHCompositeNode *topNode); bool findParticle(const std::string &particle); From 80d3dea675e2b0b1994482c397e00582124a1de4 Mon Sep 17 00:00:00 2001 From: rosstom Date: Thu, 30 Apr 2026 20:12:55 -0400 Subject: [PATCH 2/5] Minor fixes --- .../KFParticle_eventReconstruction.cc | 57 ------------------- .../KFParticle_sPHENIX/KFParticle_sPHENIX.h | 3 +- offline/packages/decayfinder/DecayFinder.cc | 3 - 3 files changed, 1 insertion(+), 62 deletions(-) diff --git a/offline/packages/KFParticle_sPHENIX/KFParticle_eventReconstruction.cc b/offline/packages/KFParticle_sPHENIX/KFParticle_eventReconstruction.cc index 9db00ec4d1..3c40fd4e58 100644 --- a/offline/packages/KFParticle_sPHENIX/KFParticle_eventReconstruction.cc +++ b/offline/packages/KFParticle_sPHENIX/KFParticle_eventReconstruction.cc @@ -31,17 +31,10 @@ //sPHENIX stuff #include -#include -#include -#include -#include // KFParticle stuff #include -#include -#include - #include #include #include // for begin, distance, end @@ -615,53 +608,3 @@ KFParticle KFParticle_eventReconstruction::createFakePV() kfp_vertex.SetId(0); return kfp_vertex; } - -std::vector KFParticle_eventReconstruction::createTruthPV(PHCompositeNode* topNode) -{ - std::vector kfp_vertex = {}; - - PHG4InEvent *ineve = findNode::getClass(topNode, "PHG4INEVENT"); - if (!ineve) - { - std::cout << PHWHERE << "no PHG4INEVENT node" << std::endl; - return kfp_vertex; - } - - auto vtxRange = ineve->GetVertices(); - // find the PV - std::vector primaryVtx = {}; - for (auto it = vtxRange.first; it != vtxRange.second; ++it) - { - if (it->first == 1) - { - primaryVtx.push_back(it->second); - } - } - - if (primaryVtx.size() == 0) - { - std::cerr << "getPrimaryVertex: No primary vertex found!" << std::endl; - return kfp_vertex; // return default empty vertex - } - - for (const auto& v : primaryVtx) - { - float pos[3] = { - static_cast(v->get_x()), - static_cast(v->get_y()), - static_cast(v->get_z()) - }; - float f_vertexParameters[6] = {pos[0], pos[1], pos[2], 0, 0, 0}; - - float f_vertexCovariance[21] = {0}; - - KFParticle kfp_v; - kfp_v.Create(f_vertexParameters, f_vertexCovariance, 0, -1); - kfp_v.NDF() = 0; - kfp_v.Chi2() = 0; - kfp_v.SetId(0); - kfp_vertex.push_back(kfp_v); - } - - return kfp_vertex; -} diff --git a/offline/packages/KFParticle_sPHENIX/KFParticle_sPHENIX.h b/offline/packages/KFParticle_sPHENIX/KFParticle_sPHENIX.h index 46ca9fea8a..a732d59ece 100644 --- a/offline/packages/KFParticle_sPHENIX/KFParticle_sPHENIX.h +++ b/offline/packages/KFParticle_sPHENIX/KFParticle_sPHENIX.h @@ -253,8 +253,7 @@ class KFParticle_sPHENIX : public SubsysReco, public KFParticle_nTuple, public K { m_use_fake_pv = use_fake; m_use_fake_pv_nTuple = use_fake; - } - + } void allowZeroMassTracks(bool allow = true) { m_allowZeroMassTracks = allow; } void extraolateTracksToSV(bool extrapolate = true) diff --git a/offline/packages/decayfinder/DecayFinder.cc b/offline/packages/decayfinder/DecayFinder.cc index ed66e3bc73..596cce9c63 100644 --- a/offline/packages/decayfinder/DecayFinder.cc +++ b/offline/packages/decayfinder/DecayFinder.cc @@ -483,12 +483,10 @@ int DecayFinder::findDecay(PHCompositeNode* topNode) // Make sure that the mother has a decay in our record if (!(*p)->end_vertex()) // Mother has no end vertex, decay volume was limited { - std::cout << "Searching G4 Record" << std::endl; searchGeant4Record((*p)->barcode(), (*p)->pdg_id(), positive_motherDecayProducts, breakOut, aMotherHasPhoton, aMotherHasPi0, aTrackFailedPT, aTrackFailedETA, correctMotherProducts); } else { - std::cout << "Searching HepMC Record" << std::endl; searchHepMCRecord((*p), positive_motherDecayProducts, breakOut, aMotherHasPhoton, aMotherHasPi0, aTrackFailedPT, aTrackFailedETA, correctMotherProducts); } @@ -690,7 +688,6 @@ void DecayFinder::searchHepMCRecord(HepMC::GenParticle* particle, std::vector decayProducts, bool& breakLoop, bool& hasPhoton, bool& hasPi0, bool& failedPT, bool& failedETA, std::vector& actualDecayProducts) { - std::cout << "searchGeant4Record barcode: " << barcode << std::endl; PHG4TruthInfoContainer::ConstRange range = m_truthinfo->GetParticleRange(); for (PHG4TruthInfoContainer::ConstIterator iter = range.first; iter != range.second; ++iter) { From 55d4b1abf61d12720a0ef7bff3921270c00d6cf4 Mon Sep 17 00:00:00 2001 From: rosstom Date: Thu, 30 Apr 2026 20:14:16 -0400 Subject: [PATCH 3/5] Last fix --- .../packages/KFParticle_sPHENIX/KFParticle_eventReconstruction.h | 1 - 1 file changed, 1 deletion(-) diff --git a/offline/packages/KFParticle_sPHENIX/KFParticle_eventReconstruction.h b/offline/packages/KFParticle_sPHENIX/KFParticle_eventReconstruction.h index 2493388bc2..9cbba08a70 100644 --- a/offline/packages/KFParticle_sPHENIX/KFParticle_eventReconstruction.h +++ b/offline/packages/KFParticle_sPHENIX/KFParticle_eventReconstruction.h @@ -83,7 +83,6 @@ class KFParticle_eventReconstruction : public KFParticle_Tools std::vector possibleVertex); KFParticle createFakePV(); - std::vector createTruthPV(PHCompositeNode* topNode); protected: bool m_constrain_to_vertex; From fd05ef936db2705d1b3bb4afaaa5091f81d3eed7 Mon Sep 17 00:00:00 2001 From: rosstom Date: Thu, 30 Apr 2026 20:15:47 -0400 Subject: [PATCH 4/5] Last last fix --- offline/packages/KFParticle_sPHENIX/KFParticle_sPHENIX.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/offline/packages/KFParticle_sPHENIX/KFParticle_sPHENIX.h b/offline/packages/KFParticle_sPHENIX/KFParticle_sPHENIX.h index a732d59ece..14c282e165 100644 --- a/offline/packages/KFParticle_sPHENIX/KFParticle_sPHENIX.h +++ b/offline/packages/KFParticle_sPHENIX/KFParticle_sPHENIX.h @@ -253,7 +253,7 @@ class KFParticle_sPHENIX : public SubsysReco, public KFParticle_nTuple, public K { m_use_fake_pv = use_fake; m_use_fake_pv_nTuple = use_fake; - } + } void allowZeroMassTracks(bool allow = true) { m_allowZeroMassTracks = allow; } void extraolateTracksToSV(bool extrapolate = true) From dd98db258886298d85a63a02faedbb2e0eeafe31 Mon Sep 17 00:00:00 2001 From: rosstom Date: Thu, 30 Apr 2026 20:16:35 -0400 Subject: [PATCH 5/5] Last last fix --- offline/packages/KFParticle_sPHENIX/KFParticle_sPHENIX.h | 1 + 1 file changed, 1 insertion(+) diff --git a/offline/packages/KFParticle_sPHENIX/KFParticle_sPHENIX.h b/offline/packages/KFParticle_sPHENIX/KFParticle_sPHENIX.h index 14c282e165..0812ed8f14 100644 --- a/offline/packages/KFParticle_sPHENIX/KFParticle_sPHENIX.h +++ b/offline/packages/KFParticle_sPHENIX/KFParticle_sPHENIX.h @@ -254,6 +254,7 @@ class KFParticle_sPHENIX : public SubsysReco, public KFParticle_nTuple, public K m_use_fake_pv = use_fake; m_use_fake_pv_nTuple = use_fake; } + void allowZeroMassTracks(bool allow = true) { m_allowZeroMassTracks = allow; } void extraolateTracksToSV(bool extrapolate = true)