Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 20 additions & 11 deletions sbncode/HitFinder/GaussHitFinderSBN_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,8 @@ namespace hit {
fPeakFitterTool->findPeakParameters(
range.data(), mergedCands, peakParamsVec, chi2PerNDF, NDF);

// If the chi2 is infinite then there is a real problem so we bail
if (!(chi2PerNDF < std::numeric_limits<double>::infinity())) {
// If the chi2 is not finite then there is a real problem so we bail
if (!std::isfinite(chi2PerNDF)) {
chi2PerNDF = 2. * fChi2NDF.at(plane);
NDF = 2;
}
Expand Down Expand Up @@ -464,14 +464,13 @@ namespace hit {
float nsigmaADC(2.0);
float newright(0);
float newleft(0);

for (const auto& peakParams : peakParamsVec) {
// Extract values for this hit
float peakAmp = peakParams.peakAmplitude;
float peakMean = peakParams.peakCenter;
float peakWidth = peakParams.peakSigma;

//std::cout<<" ans hits "<<numHits<<" gaus "<<nGausForFit<<std::endl;

//ANS get prev and next
if (numHits == 0) {
newleft = -9999;
Expand All @@ -484,12 +483,10 @@ namespace hit {
if (numHits < nGausForFit - 1) {
nextpeak = (peakParamsVec.at(numHits + 1)).peakCenter;
nextpeakSig = (peakParamsVec.at(numHits + 1)).peakSigma;
//std::cout<<" ans size "<<peakParamsVec.size()<<" hit "<<numHits<<" next peak "<<nextpeak<<" sig "<<nextpeakSig<<std::endl;
}
if (numHits > 0) {
prevpeak = (peakParamsVec.at(numHits - 1)).peakCenter;
prevpeakSig = (peakParamsVec.at(numHits - 1)).peakSigma;
//std::cout<<" ans size "<<peakParamsVec.size()<<"hit "<<numHits<<" prev peak "<<prevpeak<<" sig "<<prevpeakSig<<std::endl;
}

// Place one bit of protection here
Expand All @@ -499,6 +496,10 @@ namespace hit {
continue;
}

// Another protection: if peak is outside of the range,
// we skip this hit: this should however be avoided before... see LL407-411
if ((peakMean < startT) || (peakMean >= endT)) continue;

// Extract errors
float peakAmpErr = peakParams.peakAmplitudeError;
float peakMeanErr = peakParams.peakCenterError;
Expand Down Expand Up @@ -550,6 +551,9 @@ namespace hit {

if (HitsumEndItr > sumEndItr) HitsumEndItr = sumEndItr;

// This prevents L577 and L579 to make any possible boundaty flip
if (HitsumStartItr > HitsumEndItr) continue;

// ### Sum of ADC counts
float ROIsumADC = std::accumulate(sumStartItr, sumEndItr, 0.);
float HitsumADC = std::accumulate(HitsumStartItr, HitsumEndItr, 0.);
Expand Down Expand Up @@ -588,6 +592,11 @@ namespace hit {
numHits++;
} // <---End loop over gaussians

// THIS IS NOT USED
// THIS IS NOT USED
// THIS IS NOT USED
// THIS IS NOT USED

// Should we filter hits?
if (filteredHitCol && !filteredHitVec.empty()) {
// #######################################################################
Expand Down Expand Up @@ -646,11 +655,11 @@ namespace hit {
//
if (fFillHists) fChi2->Fill(chi2PerNDF);
}
} //<---End loop over merged candidate hits
} //<---End looping over ROI's
); //end tbb parallel for
} //<---End looping over all the wires
); //end tbb parallel for
} //< End loop over merged candidate hits
} //< End looping over ROI's
); //< End tbb::parallel_for(ROI)
} //< End looping over all the wires
); //< End tbb::parallel_for(channelROI)

for (size_t i = 0; i < hitstruct_vec.size(); i++) {
allHitCol.emplace_back(hitstruct_vec[i].hit_tbb, hitstruct_vec[i].channelROI_tbb);
Expand Down
2 changes: 1 addition & 1 deletion sbncode/HitFinder/hitfindermodules_sbn.fcl
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ gauss_hitfinder:
# Define sbn version of gaushit finder
gausshit_sbn: @local::gauss_hitfinder

END_PROLOG
END_PROLOG