6 #include "art/Utilities/ToolMacros.h"
7 #include "art/Utilities/make_tool.h"
8 #include "art/Framework/Principal/Handle.h"
9 #include "art_root_io/TFileService.h"
10 #include "messagefacility/MessageLogger/MessageLogger.h"
11 #include "cetlib_except/exception.h"
25 explicit OpHitFinder(
const fhicl::ParameterSet& pset);
29 void configure(
const fhicl::ParameterSet& pset)
override;
60 fSPEArea = pset.get<
float >(
"SPEArea" );
66 fHitFinderTool = art::make_tool<reco_tool::ICandidateHitFinder>(pset.get<fhicl::ParameterSet>(
"CandidateHits"));
82 std::vector<float> locWaveform;
84 locWaveform.resize(opDetWaveform.size());
87 std::transform(opDetWaveform.begin(),opDetWaveform.end(),locWaveform.begin(),[
baseline](
const auto& val){
return baseline - val;});
89 std::pair<std::vector<float>::iterator,std::vector<float>::iterator> minMaxItr = std::minmax_element(locWaveform.begin(),locWaveform.end());
94 bool notSaturated(
true);
96 float maxAdc = *minMaxItr.second;
97 float minAdc = *minMaxItr.first;
101 float unSatAdc = 0.5 * (maxAdc - minAdc) + minAdc;
102 std::vector<float>::iterator unSatItr = std::find_if(minMaxItr.second,locWaveform.end(),[unSatAdc](
const auto& elem){
return elem < unSatAdc;});
111 std::vector<float> tempVec = locWaveform;
112 recob::Wire::RegionsOfInterest_t::datarange_t rangeData(
size_t(0),std::move(tempVec));
115 fHitFinderTool->MergeHitCandidates(rangeData, hitCandidateVec, mergedCandidateHitVec);
128 hitCandidate.
hitSigma = std::min(40,numSatChans);
129 hitCandidate.
hitHeight = maxAdc - minAdc;
131 std::cout <<
"***>> Saturated PMT, numSatChans: " << numSatChans <<
", range: " << maxAdc-minAdc << std::endl;
133 hitCandidateVec.push_back(hitCandidate);
134 mergedCandidateHitVec.push_back(hitCandidateVec);
143 for(
const auto& mergedCands : mergedCandidateHitVec)
145 for(
const auto& candidateHit : mergedCands)
147 float peakMean = candidateHit.hitCenter;
148 float peakSigma = candidateHit.hitSigma;
149 float amplitude = candidateHit.hitHeight;
150 float peakArea = amplitude * peakSigma * 2.5066;
151 float nPhotoElec = peakArea /
fSPEArea;
153 float peakTimeAbs = peakMean;
155 float fastTotal = 0.;
157 opHitVec.emplace_back(chNumber, peakMean, peakTimeAbs, frame, 2.35 * peakSigma, peakArea, amplitude, nPhotoElec, fastTotal);
169 std::map<raw::ADC_Count_t,int> adcFrequencyMap;
174 for(
const auto& adc : locWaveform)
176 int& adcFrequency = adcFrequencyMap[adc];
178 if (++adcFrequency > maxCount)
181 maxCount = adcFrequency;
185 float mostProbableBaseline(0.);
186 int mostProbableCount(0);
191 mostProbableBaseline += adcFrequencyMap.at(adcBin) * float(adcBin);
192 mostProbableCount += adcFrequencyMap.at(adcBin);
197 mostProbableBaseline /= mostProbableCount;
199 return mostProbableBaseline;
void configure(const fhicl::ParameterSet &pset) override
void FindOpHits(const raw::OpDetWaveform &, OpHitVec &) const override
float getBaseline(const raw::OpDetWaveform &) const
std::unique_ptr< reco_tool::ICandidateHitFinder > fHitFinderTool
For finding candidate hits.
OpHitFinder(const fhicl::ParameterSet &pset)
double distance(geo::Point_t const &point, CathodeDesc_t const &cathode)
Returns the distance of a point from the cathode.
This provides an interface for tools which are tasked with finding the baselines in input waveforms...
This provides an interface for tools which are tasked with finding candidate hits on input waveforms...
void outputHistograms(art::TFileDirectory &) const override
std::vector< recob::OpHit > OpHitVec
BEGIN_PROLOG could also be cout