From 1097a1e2fb42e7af9060d45fb69bc31b720a6d72 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 30 Aug 2026 16:09:06 +0000 Subject: [PATCH 1/3] Initial plan From 5bb8faa8605a96f8e3c320da69cc53c727134da0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 30 Aug 2026 16:11:16 +0000 Subject: [PATCH 2/3] Apply remaining changes Co-authored-by: wdconinc <4656391+wdconinc@users.noreply.github.com> --- episodes/files/uchannelrho.cxx | 10 +++++----- learners/files/uchannelrho.cxx | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/episodes/files/uchannelrho.cxx b/episodes/files/uchannelrho.cxx index 25b1e7e..43f9c6c 100644 --- a/episodes/files/uchannelrho.cxx +++ b/episodes/files/uchannelrho.cxx @@ -64,11 +64,11 @@ int uchannelrho(TString rec_file="input.root", TString outputfile="output.root") TTreeReaderArray reco_charge_array = {tree_reader, "ReconstructedChargedParticles.charge"}; TTreeReaderArray reco_type = {tree_reader,"ReconstructedChargedParticles.type"}; - // The association simID/recID are now stored as podio relation branches. - // _ReconstructedChargedParticleAssociations_sim.index is the index into the - // MCParticles collection; _..._rec.index is the index into ReconstructedChargedParticles. - TTreeReaderArray rec_id = {tree_reader, "_ReconstructedChargedParticleAssociations_rec.index"}; - TTreeReaderArray sim_id = {tree_reader, "_ReconstructedChargedParticleAssociations_sim.index"}; + // The link simID/recID are now stored as podio relation branches. + // _ReconstructedChargedParticleLinks_to.index is the index into the + // MCParticles collection; _..._from.index is the index into ReconstructedChargedParticles. + TTreeReaderArray rec_id = {tree_reader, "_ReconstructedChargedParticleLinks_from.index"}; + TTreeReaderArray sim_id = {tree_reader, "_ReconstructedChargedParticleLinks_to.index"}; TString output_name_dir = outputfile; cout << "Output file = " << output_name_dir << endl; diff --git a/learners/files/uchannelrho.cxx b/learners/files/uchannelrho.cxx index 9163783..b6e771b 100644 --- a/learners/files/uchannelrho.cxx +++ b/learners/files/uchannelrho.cxx @@ -60,8 +60,8 @@ int uchannelrho(TString rec_file="input.root", TString outputfile="output.root") TTreeReaderArray reco_charge_array = {tree_reader, "ReconstructedChargedParticles.charge"}; TTreeReaderArray reco_type = {tree_reader,"ReconstructedChargedParticles.type"}; - TTreeReaderArray rec_id = {tree_reader, "ReconstructedChargedParticleAssociations.recID"}; - TTreeReaderArray sim_id = {tree_reader, "ReconstructedChargedParticleAssociations.simID"}; + TTreeReaderArray rec_id = {tree_reader, "_ReconstructedChargedParticleLinks_from.index"}; + TTreeReaderArray sim_id = {tree_reader, "_ReconstructedChargedParticleLinks_to.index"}; TString output_name_dir = outputfile; cout << "Output file = " << output_name_dir << endl; From 31866ede5064aea3e89263ebedc3d0b90b2323b8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 30 Aug 2026 17:05:25 +0000 Subject: [PATCH 3/3] Align the track-to-MC mapping fix and note in the learner uchannelrho script Co-authored-by: wdconinc <4656391+wdconinc@users.noreply.github.com> --- learners/files/uchannelrho.cxx | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/learners/files/uchannelrho.cxx b/learners/files/uchannelrho.cxx index b6e771b..bf927b6 100644 --- a/learners/files/uchannelrho.cxx +++ b/learners/files/uchannelrho.cxx @@ -124,9 +124,22 @@ int uchannelrho(TString rec_file="input.root", TString outputfile="output.root") bool isPiPlusFound = false; bool isProtonFound = false; + // Map each reconstructed-track index to the MC-particle index it is + // associated with. The association is a separate collection: for entry ia + // rec_id[ia] is the ReconstructedChargedParticles index and sim_id[ia] the + // MCParticles index. We must look up by rec_id rather than assume the + // association collection is aligned with the track collection. + // Not creating this map would rely on the brittle assumption that the + // arrays stay in the same order, which is not guaranteed by podio's + // relation branches and can silently mis-associate tracks. + std::vector simForRec(reco_pz_array.GetSize(), -1); + for(unsigned int ia=0; ia=0 && ri<(int)simForRec.size()) simForRec[ri] = sim_id[ia]; + } + //track loop int numpositivetracks = 0; - int failed = 0; for(unsigned int itrk=0;itrk0){ numpositivetracks++; - if ((sim_id[itrk - failed]==4 || sim_id[itrk - failed]==5) && reco_charge_array[itrk - failed]==1){ + if ((thisSim==4 || thisSim==5) && reco_charge_array[itrk]==1){ piplusREC.SetVectM(trk,MASS_PION); isPiPlusFound=true; } - if(sim_id[itrk - failed]==6){ + if(thisSim==6){ protonRECasifpion.SetVectM(trk,MASS_PION); isProtonFound=true; } } if(reco_charge_array[itrk]<0){ piminusREC.SetVectM(trk,MASS_PION); - if((sim_id[itrk - failed]==4 || sim_id[itrk - failed]==5) && reco_charge_array[itrk - failed]==-1) isPiMinusFound=true; + if((thisSim==4 || thisSim==5) && reco_charge_array[itrk]==-1) isPiMinusFound=true; } }