Skip to content

Commit fc33b4e

Browse files
committed
Merge branch 'feature/msotgia_hit_finder_tuning_fix' into develop
2 parents 2cde707 + dc0eb00 commit fc33b4e

2 files changed

Lines changed: 27 additions & 20 deletions

File tree

sbncode/HitFinder/GaussHitFinderSBN_module.cc

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,8 @@ namespace hit {
388388
fPeakFitterTool->findPeakParameters(
389389
range.data(), mergedCands, peakParamsVec, chi2PerNDF, NDF);
390390

391-
// If the chi2 is infinite then there is a real problem so we bail
392-
if (!(chi2PerNDF < std::numeric_limits<double>::infinity())) {
391+
// If the chi2 is not finite then there is a real problem so we bail
392+
if (!std::isfinite(chi2PerNDF)) {
393393
chi2PerNDF = 2. * fChi2NDF.at(plane);
394394
NDF = 2;
395395
}
@@ -464,14 +464,13 @@ namespace hit {
464464
float nsigmaADC(2.0);
465465
float newright(0);
466466
float newleft(0);
467+
467468
for (const auto& peakParams : peakParamsVec) {
468469
// Extract values for this hit
469470
float peakAmp = peakParams.peakAmplitude;
470471
float peakMean = peakParams.peakCenter;
471472
float peakWidth = peakParams.peakSigma;
472473

473-
//std::cout<<" ans hits "<<numHits<<" gaus "<<nGausForFit<<std::endl;
474-
475474
//ANS get prev and next
476475
if (numHits == 0) {
477476
newleft = -9999;
@@ -484,12 +483,10 @@ namespace hit {
484483
if (numHits < nGausForFit - 1) {
485484
nextpeak = (peakParamsVec.at(numHits + 1)).peakCenter;
486485
nextpeakSig = (peakParamsVec.at(numHits + 1)).peakSigma;
487-
//std::cout<<" ans size "<<peakParamsVec.size()<<" hit "<<numHits<<" next peak "<<nextpeak<<" sig "<<nextpeakSig<<std::endl;
488486
}
489487
if (numHits > 0) {
490488
prevpeak = (peakParamsVec.at(numHits - 1)).peakCenter;
491489
prevpeakSig = (peakParamsVec.at(numHits - 1)).peakSigma;
492-
//std::cout<<" ans size "<<peakParamsVec.size()<<"hit "<<numHits<<" prev peak "<<prevpeak<<" sig "<<prevpeakSig<<std::endl;
493490
}
494491

495492
// Place one bit of protection here
@@ -499,6 +496,11 @@ namespace hit {
499496
continue;
500497
}
501498

499+
// Another protection: if peak is outside of the range,
500+
// skip the hit creation
501+
// For details on this issue refer to SBN DocDB 47092
502+
if ((peakMean < startT) || (peakMean >= endT)) continue;
503+
502504
// Extract errors
503505
float peakAmpErr = peakParams.peakAmplitudeError;
504506
float peakMeanErr = peakParams.peakCenterError;
@@ -546,9 +548,14 @@ namespace hit {
546548
if (HitsumStartItr > HitsumEndItr) continue;
547549

548550
//avoid ranges out of ROI if it happens
549-
if (HitsumStartItr < sumStartItr) HitsumStartItr = sumStartItr;
551+
if (HitsumStartItr < sumStartItr) HitsumStartItr = sumStartItr; // COMMENT [1] below
552+
if (HitsumEndItr > sumEndItr) HitsumEndItr = sumEndItr; // COMMENT [1] below
550553

551-
if (HitsumEndItr > sumEndItr) HitsumEndItr = sumEndItr;
554+
// COMMENT [1]
555+
// This line prevents the two checks [1] before to
556+
// make any possible boundary flip
557+
// For details on this issue refer to SBN DocDB 47092
558+
if (HitsumStartItr > HitsumEndItr) continue;
552559

553560
// ### Sum of ADC counts
554561
float ROIsumADC = std::accumulate(sumStartItr, sumEndItr, 0.);
@@ -638,19 +645,19 @@ namespace hit {
638645
}
639646

640647
// Copy the hits we want to keep to the filtered hit collection
641-
// for (const auto& filteredHit : filteredHitVec)
642-
// if (!fHitFilterAlg || fHitFilterAlg->IsGoodHit(filteredHit)) {
643-
// hitstruct tmp{std::move(filteredHit), channelROI};
644-
// filthitstruct_vec.push_back(std::move(tmp));
645-
// }
646-
//
648+
// for (const auto& filteredHit : filteredHitVec)
649+
// if (!fHitFilterAlg || fHitFilterAlg->IsGoodHit(filteredHit)) {
650+
// hitstruct tmp{std::move(filteredHit), channelROI};
651+
// filthitstruct_vec.push_back(std::move(tmp));
652+
// }
653+
647654
if (fFillHists) fChi2->Fill(chi2PerNDF);
648655
}
649-
} //<---End loop over merged candidate hits
650-
} //<---End looping over ROI's
651-
); //end tbb parallel for
652-
} //<---End looping over all the wires
653-
); //end tbb parallel for
656+
} //< End loop over merged candidate hits
657+
} //< End looping over ROI's
658+
); //< End tbb::parallel_for(ROI)
659+
} //< End looping over all the wires
660+
); //< End tbb::parallel_for(channelROI)
654661

655662
for (size_t i = 0; i < hitstruct_vec.size(); i++) {
656663
allHitCol.emplace_back(hitstruct_vec[i].hit_tbb, hitstruct_vec[i].channelROI_tbb);

sbncode/HitFinder/hitfindermodules_sbn.fcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,4 @@ gauss_hitfinder:
5151
# Define sbn version of gaushit finder
5252
gausshit_sbn: @local::gauss_hitfinder
5353

54-
END_PROLOG
54+
END_PROLOG

0 commit comments

Comments
 (0)