From 3c70d8e4500bddee226ffcb530403208768463a1 Mon Sep 17 00:00:00 2001 From: Henry Lay Date: Fri, 14 Nov 2025 12:01:35 -0600 Subject: [PATCH 1/2] Hot fix to how we fill the best plane variables for showers --- sbncode/CAFMaker/FillReco.cxx | 45 ++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 8 deletions(-) diff --git a/sbncode/CAFMaker/FillReco.cxx b/sbncode/CAFMaker/FillReco.cxx index 76c9a50b7..8d65925d3 100644 --- a/sbncode/CAFMaker/FillReco.cxx +++ b/sbncode/CAFMaker/FillReco.cxx @@ -395,11 +395,43 @@ namespace caf // It's sth like this but not quite. And will need to pass a simb::MCtruth object vtx position anyway. // srshower.conversion_gap = (shower.ShowerStart() - vertex.Position()).Mag(); - if(shower.best_plane() != -999){ - srshower.bestplane = shower.best_plane(); - srshower.bestplane_dEdx = srshower.plane[shower.best_plane()].dEdx; - srshower.bestplane_energy = srshower.plane[shower.best_plane()].energy; - } + for(int p = 0; p < 3; ++p) srshower.plane[p].nHits = 0; + for (auto const& hit:hits) ++srshower.plane[hit->WireID().Plane].nHits; + + int bestplane_for_energy = -999; + int mosthits = -1; + for(int p = 0; p < 3; ++p) + { + if((int)srshower.plane[p].nHits > mosthits) + { + mosthits = srshower.plane[p].nHits; + bestplane_for_energy = p; + } + } + + if(bestplane_for_energy != -999) + { + srshower.bestplane_for_energy = bestplane_for_energy; + srshower.bestplane_energy = srshower.plane[bestplane_for_energy].energy; + } + + if(shower.best_plane() != -999 && srshower.plane[shower.best_plane()].dEdx != -999) + { + srshower.bestplane_for_dedx = shower.best_plane(); + srshower.bestplane_dEdx = srshower.plane[shower.best_plane()].dEdx; + } + else + { + for(int p = 2; p >= 0; --p) + { + if(srshower.plane[p].dEdx != -999) + { + srshower.bestplane_for_dedx = p; + srshower.bestplane_dEdx = srshower.plane[shower.best_plane()].dEdx; + break; + } + } + } if(shower.has_open_angle()) srshower.open_angle = shower.OpenAngle(); @@ -422,9 +454,6 @@ namespace caf srshower.end = shower.ShowerStart()+ (shower.Length() * shower.Direction()); } - for(int p = 0; p < 3; ++p) srshower.plane[p].nHits = 0; - for (auto const& hit:hits) ++srshower.plane[hit->WireID().Plane].nHits; - for (geo::PlaneGeo const& plane: wireReadout.Iterate()) { const double angleToVert(wireReadout.WireAngleToVertical(plane.View(), plane.ID()) - 0.5*M_PI); From 8a0969654487383bcf607721a9b1211409f37713 Mon Sep 17 00:00:00 2001 From: Henry Lay Date: Mon, 17 Nov 2025 03:46:02 -0600 Subject: [PATCH 2/2] Make changes ICARUS friendly --- sbncode/CAFMaker/CAFMaker_module.cc | 2 +- sbncode/CAFMaker/FillReco.cxx | 60 ++++++++++++++++++----------- sbncode/CAFMaker/FillReco.h | 1 + 3 files changed, 39 insertions(+), 24 deletions(-) diff --git a/sbncode/CAFMaker/CAFMaker_module.cc b/sbncode/CAFMaker/CAFMaker_module.cc index 7baf6ef0c..c4aef400c 100644 --- a/sbncode/CAFMaker/CAFMaker_module.cc +++ b/sbncode/CAFMaker/CAFMaker_module.cc @@ -2481,7 +2481,7 @@ void CAFMaker::produce(art::Event& evt) noexcept { assert(thisShower.size() == 1); SRShower& shw = pfp.shw; - FillShowerVars(*thisShower[0], vertex, fmShowerHit.at(iPart), wireReadout, producer, shw); + FillShowerVars(*thisShower[0], vertex, fmShowerHit.at(iPart), wireReadout, producer, shw, fDet); // We may have many residuals per shower depending on how many showers ar in the slice if (fmShowerRazzle.isValid() && fmShowerRazzle.at(iPart).size()==1) { diff --git a/sbncode/CAFMaker/FillReco.cxx b/sbncode/CAFMaker/FillReco.cxx index 8d65925d3..e7ee532b1 100644 --- a/sbncode/CAFMaker/FillReco.cxx +++ b/sbncode/CAFMaker/FillReco.cxx @@ -375,6 +375,7 @@ namespace caf const geo::WireReadoutGeom& wireReadout, unsigned producer, caf::SRShower &srshower, + Det_t det, bool allowEmpty) { @@ -398,38 +399,51 @@ namespace caf for(int p = 0; p < 3; ++p) srshower.plane[p].nHits = 0; for (auto const& hit:hits) ++srshower.plane[hit->WireID().Plane].nHits; - int bestplane_for_energy = -999; - int mosthits = -1; - for(int p = 0; p < 3; ++p) + if(det == kSBND) { - if((int)srshower.plane[p].nHits > mosthits) + int bestplane_for_energy = -999; + int mosthits = -1; + for(int p = 0; p < 3; ++p) { - mosthits = srshower.plane[p].nHits; - bestplane_for_energy = p; + if((int)srshower.plane[p].nHits > mosthits) + { + mosthits = srshower.plane[p].nHits; + bestplane_for_energy = p; + } } - } - if(bestplane_for_energy != -999) - { - srshower.bestplane_for_energy = bestplane_for_energy; - srshower.bestplane_energy = srshower.plane[bestplane_for_energy].energy; - } + if(bestplane_for_energy != -999) + { + srshower.bestplane_for_energy = bestplane_for_energy; + srshower.bestplane_energy = srshower.plane[bestplane_for_energy].energy; + } - if(shower.best_plane() != -999 && srshower.plane[shower.best_plane()].dEdx != -999) - { - srshower.bestplane_for_dedx = shower.best_plane(); - srshower.bestplane_dEdx = srshower.plane[shower.best_plane()].dEdx; + if(shower.best_plane() != -999 && srshower.plane[shower.best_plane()].dEdx != -999) + { + srshower.bestplane_for_dedx = shower.best_plane(); + srshower.bestplane_dEdx = srshower.plane[shower.best_plane()].dEdx; + } + else + { + for(int p = 2; p >= 0; --p) + { + if(srshower.plane[p].dEdx != -999) + { + srshower.bestplane_for_dedx = p; + srshower.bestplane_dEdx = srshower.plane[shower.best_plane()].dEdx; + break; + } + } + } } else { - for(int p = 2; p >= 0; --p) + if(shower.best_plane() != -999) { - if(srshower.plane[p].dEdx != -999) - { - srshower.bestplane_for_dedx = p; - srshower.bestplane_dEdx = srshower.plane[shower.best_plane()].dEdx; - break; - } + srshower.bestplane_for_energy = shower.best_plane(); + srshower.bestplane_for_dedx = shower.best_plane(); + srshower.bestplane_dEdx = srshower.plane[shower.best_plane()].dEdx; + srshower.bestplane_energy = srshower.plane[shower.best_plane()].energy; } } diff --git a/sbncode/CAFMaker/FillReco.h b/sbncode/CAFMaker/FillReco.h index 85d0a3e67..e6199d690 100644 --- a/sbncode/CAFMaker/FillReco.h +++ b/sbncode/CAFMaker/FillReco.h @@ -69,6 +69,7 @@ namespace caf const geo::WireReadoutGeom& wireReadout, unsigned producer, caf::SRShower& srshower, + Det_t det, bool allowEmpty = false); void FillShowerRazzle(const art::Ptr razzle,