diff --git a/sbndcode/OpDetReco/OpHit/SBNDOpHitFinder_module.cc b/sbndcode/OpDetReco/OpHit/SBNDOpHitFinder_module.cc index 3f9f66236..670b6ba62 100644 --- a/sbndcode/OpDetReco/OpHit/SBNDOpHitFinder_module.cc +++ b/sbndcode/OpDetReco/OpHit/SBNDOpHitFinder_module.cc @@ -91,7 +91,8 @@ namespace opdet { std::vector _pd_to_use; ///< PDS to use (ex: "pmt", "barepmt") std::string fElectronics; ///< PDS readouts to use (ex: "CAEN", "Daphne") std::vector _opch_to_use; ///< List of of opch (will be infered from _pd_to_use) - + std::vector fADCThresholdVector; + bool fUseIndividualHitThreshold; pmtana::PulseRecoManager fPulseRecoMgr; pmtana::PMTPulseRecoBase* fThreshAlg; pmtana::PMTPedestalBase* fPedAlg; @@ -131,6 +132,9 @@ namespace opdet { fElectronics = pset.get< std::string >("Electronics"); _opch_to_use = this->PDNamesToList(_pd_to_use); + + fADCThresholdVector = pset.get< std::vector>("ADCThresholdVector", {0}); + fUseIndividualHitThreshold = pset.get< bool>("UseIndividualHitThreshold", false); fDaphne_Freq = pset.get< float >("DaphneFreq"); fHitThreshold = pset.get< float >("HitThreshold"); bool useCalibrator = pset.get< bool > ("UseCalibrator", false); @@ -164,7 +168,9 @@ namespace opdet { auto const rise_alg_pset = pset.get_if_present("RiseTimeCalculator"); // Initialize the hit finder algorithm - auto const hit_alg_pset = pset.get("HitAlgoPset"); + // If we need to apply and individual threshold for each channel, set the algorithm threhsold to the lowest value + auto hit_alg_pset = pset.get("HitAlgoPset"); + if(fUseIndividualHitThreshold) hit_alg_pset.put_or_replace("ADCThreshold", *min_element(fADCThresholdVector.begin(), fADCThresholdVector.end())); std::string threshAlgName = hit_alg_pset.get("Name"); if (threshAlgName == "Threshold") fThreshAlg = thresholdAlgorithm(hit_alg_pset, rise_alg_pset); @@ -318,6 +324,12 @@ namespace opdet { // Now correct the time. Unfortunately, there are no setter methods for OpHits, // so we have to make a new OpHit vector. for (auto h : *HitPtr) { + + // Apply individual threshold + int channelNumber = h.OpChannel(); + int PeakAmplitude = h.Amplitude(); + if(fUseIndividualHitThreshold && (PeakAmplitude < fADCThresholdVector[channelNumber]) ) continue; + (*HitPtrFinal).emplace_back(h.OpChannel(), h.PeakTime() + clockData.TriggerTime(), h.PeakTimeAbs(),