diff --git a/duneana/CAFMaker/CAFMaker_module.cc b/duneana/CAFMaker/CAFMaker_module.cc index 81ce922d..32bfe065 100644 --- a/duneana/CAFMaker/CAFMaker_module.cc +++ b/duneana/CAFMaker/CAFMaker_module.cc @@ -943,6 +943,9 @@ namespace caf { //Creating the FD interaction record where we are going to save the tracks/showers in parallel to the PFPs objects caf::SRFDInt fdIxn; + //Mapping particle idx in the vector to their Pandora ID for later use + std::map pandoraIDToPFPIdx; + //Iterating on all the PFParticles to fill the reco particles for (unsigned int n = 0; n < particleVector.size(); ++n) { const art::Ptr particle = particleVector.at(n); @@ -960,6 +963,13 @@ namespace caf { //TODO: Not filling the momentum information as it requires some specific PID to be made. // particle_record.p; + //Pre-fill the parent and daughter fields with the Pandora IDs. They will be converted to SR indices later. + particle_record.parent = (particle_record.primary) ? -1 : particle->Parent(); //Setting to -1 if primary as there is no saved record for the neutrino + for(auto const& daughter_id : particle->Daughters()){ + particle_record.daughters.push_back(daughter_id); + } + pandoraIDToPFPIdx[particle->Self()] = fdIxn.npfps; + FillTruthMatchingAndOverlap(particle, evt, particle_record.truth, particle_record.truthOverlap); particle_record.walldist = GetWallDistance(*particle, evt); //Getting the distance to the wall for this PFP particle_record.contained = (particle_record.walldist < fContainedDistThreshold); //Setting the contained flag based on the distance to the wall @@ -1095,6 +1105,34 @@ namespace caf { } + //Now that all particles are saved, we can convert the parent/daughter fields from Pandora IDs to SR indices + for(auto &particle : recoParticlesBranch.pandora){ + //Parent + if(particle.parent == -1) continue; //Skipping if primary + unsigned int parent_pfpID = particle.parent; + //Finding the SR index in the map + if(pandoraIDToPFPIdx.count(parent_pfpID) == 0){ + mf::LogWarning("CAFMaker") << "No SR index found for parent PFP ID " << parent_pfpID; + particle.parent = -1; //Setting to -1 to avoid confusion + } + else{ + particle.parent = pandoraIDToPFPIdx.at(parent_pfpID); + } + + //Daughters + for(auto &daughter_idx : particle.daughters){ + unsigned int daughter_pfpID = daughter_idx; + //Finding the SR index in the map + if(pandoraIDToPFPIdx.count(daughter_pfpID) == 0){ + mf::LogWarning("CAFMaker") << "No SR index found for daughter PFP ID " << daughter_pfpID; + daughter_idx = -1; //Setting to -1 to avoid confusion + } + else{ + daughter_idx = pandoraIDToPFPIdx.at(daughter_pfpID); + } + } + } + //Saving the FD interaction record fdBranch.pandora.push_back(std::move(fdIxn)); fdBranch.npandora++; diff --git a/ups/product_deps b/ups/product_deps index 83310b2e..c46b74f7 100644 --- a/ups/product_deps +++ b/ups/product_deps @@ -248,7 +248,7 @@ product version cetmodules v3_24_01 - only_for_build dunereco v10_14_00d00 duneopdet v10_14_00d00 -duneanaobj v03_11_00 +duneanaobj v03_12_00 systematicstools v01_04_04 end_product_list ####################################