diff --git a/sbncode/CAFMaker/CAFMakerParams.h b/sbncode/CAFMaker/CAFMakerParams.h index 9a5d8fb40..d7bddf295 100644 --- a/sbncode/CAFMaker/CAFMakerParams.h +++ b/sbncode/CAFMaker/CAFMakerParams.h @@ -201,6 +201,15 @@ namespace caf false // default is false; set to true if you want SRHits filled }; + Atom FillUnassociatedHits { + Name("FillUnassociatedHits"), + Comment("If FillHits, also fill slice hits that have no PFParticle/SpacePoint " + "association, leaving spacepoint.pfpID = -1. Needed for second-shower and " + "isolation studies, which work from the hits Pandora left unclustered. " + "Increases the per-slice hit count substantially."), + false // default is false; preserves the historical FillHits behaviour + }; + Atom HitLabel { Name("HitLabel"), Comment("Base label of the TPC Hit producer."), diff --git a/sbncode/CAFMaker/CAFMaker_module.cc b/sbncode/CAFMaker/CAFMaker_module.cc index b38ed1f6a..69a3cf90e 100644 --- a/sbncode/CAFMaker/CAFMaker_module.cc +++ b/sbncode/CAFMaker/CAFMaker_module.cc @@ -2417,16 +2417,23 @@ void CAFMaker::produce(art::Event& evt) noexcept { if (fmSpacePoint.isValid()) { thisPoint = fmSpacePoint.at(iHit); } - if (!thisParticle.empty() && !thisPoint.empty()) { + const bool associated = !thisParticle.empty() && !thisPoint.empty(); + if (!associated && !fParams.FillUnassociatedHits()) continue; + + rec.reco.nhit++; + rec.reco.hit.push_back(SRHit()); + + if (associated) { assert(thisParticle.size() == 1); assert(thisPoint.size() == 1); - rec.reco.nhit++; - rec.reco.hit.push_back(SRHit()); - FillHitVars(thisHit, producer, *thisPoint[0], *thisParticle[0], rec.reco.hit.back()); - recslc.reco.hit.push_back(rec.reco.hit.back()); - recslc.reco.nhit = recslc.reco.hit.size(); } + else { + FillHitVars(thisHit, producer, rec.reco.hit.back()); + } + + recslc.reco.hit.push_back(rec.reco.hit.back()); + recslc.reco.nhit = recslc.reco.hit.size(); } } diff --git a/sbncode/CAFMaker/FillReco.cxx b/sbncode/CAFMaker/FillReco.cxx index 2a45ff525..e26611a84 100644 --- a/sbncode/CAFMaker/FillReco.cxx +++ b/sbncode/CAFMaker/FillReco.cxx @@ -1296,8 +1296,6 @@ namespace caf void FillHitVars(const recob::Hit& hit, unsigned producer, - const recob::SpacePoint& spacepoint, - const recob::PFParticle& particle, caf::SRHit& srhit, bool allowEmpty) { @@ -1314,6 +1312,20 @@ namespace caf srhit.tpcID = wire.TPC; srhit.planeID = wire.Plane; srhit.wireID = wire.Wire; + + // setDefault() leaves spacepoint.pfpID and spacepoint.ID at -1, which is + // the "no PFP" state SRSpacePoint already documents. + } + + void FillHitVars(const recob::Hit& hit, + unsigned producer, + const recob::SpacePoint& spacepoint, + const recob::PFParticle& particle, + caf::SRHit& srhit, + bool allowEmpty) + { + FillHitVars(hit, producer, srhit, allowEmpty); + srhit.spacepoint.XYZ = SRVector3D (spacepoint.XYZ()); srhit.spacepoint.chisq = spacepoint.Chisq(); srhit.spacepoint.pfpID = particle.Self(); diff --git a/sbncode/CAFMaker/FillReco.h b/sbncode/CAFMaker/FillReco.h index 6401aa01d..f81e0f894 100644 --- a/sbncode/CAFMaker/FillReco.h +++ b/sbncode/CAFMaker/FillReco.h @@ -140,6 +140,11 @@ namespace caf caf::SRTrack& srtrk, bool allowEmpty = false); + void FillHitVars(const recob::Hit& hit, + unsigned producer, + caf::SRHit& srhit, + bool allowEmpty = false); + void FillHitVars(const recob::Hit& hit, unsigned producer, const recob::SpacePoint& spacepoint,