From 52a833f1a93751080a74071655163ef80b2b222b Mon Sep 17 00:00:00 2001 From: Joseph Zennamo Date: Tue, 10 Nov 2026 13:50:22 -0600 Subject: [PATCH] SimpleFlashAlgo: allocate the per-bin PE spectrum only where there are hits The static pespec_v table was (time bins) x (optical detectors) doubles, 142 MB in the reco1 job, and was zeroed in full for every flash finder call. Rows are now created when the first OpHit lands in a time bin and released at the next call; the integration loop skips empty rows. Flashes are unchanged. Co-Authored-By: Claude Fable 5.2 --- sbndcode/OpDetReco/OpFlash/FlashFinder/SimpleFlashAlgo.cxx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sbndcode/OpDetReco/OpFlash/FlashFinder/SimpleFlashAlgo.cxx b/sbndcode/OpDetReco/OpFlash/FlashFinder/SimpleFlashAlgo.cxx index 6cd62272e..8f0f2b79f 100644 --- a/sbndcode/OpDetReco/OpFlash/FlashFinder/SimpleFlashAlgo.cxx +++ b/sbndcode/OpDetReco/OpFlash/FlashFinder/SimpleFlashAlgo.cxx @@ -218,7 +218,8 @@ namespace lightana{ // resize static vectors to size = number of bins. Fill them with value 0 if(_pesum_v.size() < nbins_pesum_v) _pesum_v.resize(nbins_pesum_v,0); if(mult_v.size() < nbins_pesum_v) mult_v.resize(nbins_pesum_v,0); - if(pespec_v.size() < nbins_pesum_v) pespec_v.resize(nbins_pesum_v,std::vector(_nopdet_maxsize)); + // rows of pespec_v stay empty until a hit lands in that time bin (see the filling loop below) + if(pespec_v.size() < nbins_pesum_v) pespec_v.resize(nbins_pesum_v); if(hitidx_v.size() < nbins_pesum_v) hitidx_v.resize(nbins_pesum_v,std::vector()); // reset pe_sum_v, set to 0 for(size_t i=0; i<_pesum_v.size(); ++i) { @@ -228,7 +229,7 @@ namespace lightana{ for(size_t i=0; i().swap(pespec_v[i]); } // Fill _pesum_v: number of PE in each time bin @@ -251,6 +252,7 @@ namespace lightana{ // Fill _pesum_v, mult_v, pespec_v, hitidx_v _pesum_v[index] += oph.pe; mult_v[index] += 1; + if(pespec_v[index].empty()) pespec_v[index].resize(_nopdet_maxsize, 0.); pespec_v[index][_opch_to_index_v[oph.channel]] += oph.pe; hitidx_v[index].push_back(hitidx); } @@ -404,6 +406,7 @@ namespace lightana{ // Sum the PE in the integration window for each PMT // loop over time bins inside the integration window for(size_t index=start; index<(start+period) && index