LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
reco_tool::CandHitMorphological Class Reference
Inheritance diagram for reco_tool::CandHitMorphological:
reco_tool::ICandidateHitFinder

Public Member Functions

 CandHitMorphological (const fhicl::ParameterSet &pset)
 
 ~CandHitMorphological ()
 
void configure (const fhicl::ParameterSet &pset) override
 
void findHitCandidates (const Waveform &, size_t, size_t, size_t, HitCandidateVec &) const override
 
void MergeHitCandidates (const Waveform &, const HitCandidateVec &, MergeHitCandidateVec &) const override
 

Private Types

using HitCandidate_t = struct HitCandidate{size_t startTick
 
using HitCandidateVec = std::vector< HitCandidate_t >
 
using MergeHitCandidateVec = std::vector< HitCandidateVec >
 
using Waveform = std::vector< float >
 

Private Member Functions

void findHitCandidates (Waveform::const_iterator, Waveform::const_iterator, Waveform::const_iterator, Waveform::const_iterator, Waveform::const_iterator, Waveform::const_iterator, size_t, float, HitCandidateVec &) const
 
void findHitCandidates (Waveform::const_iterator, Waveform::const_iterator, size_t, int, float, HitCandidateVec &) const
 
Waveform::const_iterator findNearestMax (Waveform::const_iterator, Waveform::const_iterator) const
 
Waveform::const_iterator findNearestMin (Waveform::const_iterator, Waveform::const_iterator) const
 
Waveform::const_iterator findStartTick (Waveform::const_iterator, Waveform::const_iterator) const
 
Waveform::const_iterator findStopTick (Waveform::const_iterator, Waveform::const_iterator) const
 

Private Attributes

size_t fPlane
 
float fDilationThreshold
 
float fDilationFraction
 
float fErosionFraction
 
int fMinDeltaTicks
 
float fMinDeltaPeaks
 
float fMinHitHeight
 
size_t fNumInterveningTicks
 
int fStructuringElement
 
bool fOutputHistograms
 
art::TFileDirectoryfHistDirectory
 
TH1F * fDStopStartHist
 
TH1F * fDMaxTickMinTickHist
 
TH1F * fDMaxDerivMinDerivHist
 
size_t fLastChannel
 
size_t fChannelCnt
 
std::unique_ptr< reco_tool::IWaveformToolfWaveformTool
 
const geo::GeometryCorefGeometry = lar::providerFrom<geo::Geometry>()
 
size_t stopTick
 
size_t maxTick
 
size_t minTick
 
float maxDerivative
 
float minDerivative
 
float hitCenter
 
float hitSigma
 
float hitHeight
 

Detailed Description

Definition at line 26 of file CandHitMorphological_tool.cc.

Member Typedef Documentation

using reco_tool::ICandidateHitFinder::HitCandidate_t = struct HitCandidate { size_t startTick
inherited

Definition at line 30 of file ICandidateHitFinder.h.

Definition at line 41 of file ICandidateHitFinder.h.

Definition at line 42 of file ICandidateHitFinder.h.

using reco_tool::ICandidateHitFinder::Waveform = std::vector<float>
inherited

Definition at line 44 of file ICandidateHitFinder.h.

Constructor & Destructor Documentation

reco_tool::CandHitMorphological::CandHitMorphological ( const fhicl::ParameterSet pset)
explicit

Definition at line 101 of file CandHitMorphological_tool.cc.

References configure().

102 {
103  configure(pset);
104 }
void configure(const fhicl::ParameterSet &pset) override
reco_tool::CandHitMorphological::~CandHitMorphological ( )

Definition at line 106 of file CandHitMorphological_tool.cc.

107 {
108 }

Member Function Documentation

void reco_tool::CandHitMorphological::configure ( const fhicl::ParameterSet pset)
overridevirtual

Implements reco_tool::ICandidateHitFinder.

Definition at line 110 of file CandHitMorphological_tool.cc.

References dir, fChannelCnt, fDilationFraction, fDilationThreshold, fDMaxDerivMinDerivHist, fDMaxTickMinTickHist, fDStopStartHist, fErosionFraction, fHistDirectory, fLastChannel, fMinDeltaPeaks, fMinDeltaTicks, fMinHitHeight, fNumInterveningTicks, fOutputHistograms, fPlane, fStructuringElement, fWaveformTool, art::ServiceHandle< T, SCOPE >::get(), fhicl::ParameterSet::get(), art::TFileDirectory::make(), max, and art::TFileDirectory::mkdir().

Referenced by CandHitMorphological().

111 {
112  // Recover our parameters
113  fPlane = pset.get< size_t >("Plane", 0);
114  fDilationThreshold = pset.get< float >("DilationThreshold", 4.);
115  fDilationFraction = pset.get< float >("DilationFraction", 0.75);
116  fErosionFraction = pset.get< float >("ErosionFraction", 0.2);
117  fMinDeltaTicks = pset.get< int >("MinDeltaTicks", 0);
118  fMinDeltaPeaks = pset.get< float >("MinDeltaPeaks", 0.025);
119  fMinHitHeight = pset.get< float >("MinHitHeight", 1.0);
120  fNumInterveningTicks = pset.get< size_t >("NumInterveningTicks", 6);
121  fStructuringElement = pset.get< int >("StructuringElement", 20);
122  fOutputHistograms = pset.get< bool >("OutputHistograms", false);
123 
124  // Recover the baseline tool
125  fWaveformTool = art::make_tool<reco_tool::IWaveformTool> (pset.get<fhicl::ParameterSet>("WaveformAlgs"));
126 
127  // Set the last channel to some nonsensical value
129  fChannelCnt = 0;
130 
131  // If asked, define the global histograms
132  if (fOutputHistograms)
133  {
134  // Access ART's TFileService, which will handle creating and writing
135  // histograms and n-tuples for us.
137 
138  fHistDirectory = tfs.get();
139 
140  // Make a directory for these histograms
141  art::TFileDirectory dir = fHistDirectory->mkdir(Form("HitPlane_%1zu",fPlane));
142 
143  fDStopStartHist = dir.make<TH1F>(Form("DStopStart_%1zu", fPlane), ";Delta Stop/Start;", 200, 0., 200.);
144  fDMaxTickMinTickHist = dir.make<TH1F>(Form("DMaxTMinT_%1zu", fPlane), ";Delta Max/Min Tick;", 200, 0., 200.);
145  fDMaxDerivMinDerivHist = dir.make<TH1F>(Form("DMaxDMinD_%1zu", fPlane), ";Delta Max/Min Deriv;", 200, 0., 200.);
146  }
147 
148  return;
149 }
T * get() const
Definition: ServiceHandle.h:71
TFileDirectory mkdir(std::string const &dir, std::string const &descr="")
Int_t max
Definition: plot.C:27
std::unique_ptr< reco_tool::IWaveformTool > fWaveformTool
T get(std::string const &key) const
Definition: ParameterSet.h:231
T * make(ARGS...args) const
TDirectory * dir
Definition: macro.C:5
void reco_tool::CandHitMorphological::findHitCandidates ( const Waveform waveform,
size_t  roiStartTick,
size_t  channel,
size_t  eventCount,
HitCandidateVec hitCandidateVec 
) const
overridevirtual

Implements reco_tool::ICandidateHitFinder.

Definition at line 151 of file CandHitMorphological_tool.cc.

References geo::GeometryCore::ChannelToWire(), dir, fChannelCnt, fDilationThreshold, fDMaxDerivMinDerivHist, fDMaxTickMinTickHist, fDStopStartHist, fGeometry, fHistDirectory, fLastChannel, fOutputHistograms, fStructuringElement, fWaveformTool, art::TFileDirectory::make(), and art::TFileDirectory::mkdir().

Referenced by findHitCandidates().

156 {
157  // In this case we want to find hit candidates based on the derivative of of the input waveform
158  // We get this from our waveform algs too...
159  Waveform rawDerivativeVec;
160  Waveform derivativeVec;
161 
162  fWaveformTool->firstDerivative(waveform, rawDerivativeVec);
163  fWaveformTool->triangleSmooth(rawDerivativeVec, derivativeVec);
164 
165  // Now we get the erosion/dilation vectors
166  Waveform erosionVec;
167  Waveform dilationVec;
168  Waveform averageVec;
169  Waveform differenceVec;
170 
171  reco_tool::HistogramMap histogramMap;
172 
173  // Compute the morphological filter vectors
174  fWaveformTool->getErosionDilationAverageDifference(waveform, fStructuringElement, histogramMap, erosionVec, dilationVec, averageVec, differenceVec);
175 
176  // Now find the hits
177  findHitCandidates(derivativeVec.begin(), derivativeVec.end(),
178  erosionVec.begin(), erosionVec.end(),
179  dilationVec.begin(), dilationVec.end(),
180  roiStartTick,
182  hitCandidateVec);
183 
184  // Reset the hit height from the input waveform
185  for(auto& hitCandidate : hitCandidateVec)
186  {
187  size_t centerIdx = hitCandidate.hitCenter;
188 
189  hitCandidate.hitHeight = waveform.at(centerIdx);
190  }
191 
192  // Keep track of histograms if requested
193  if (fOutputHistograms)
194  {
195  // Recover the details...
196  std::vector<geo::WireID> wids = fGeometry->ChannelToWire(channel);
197  size_t plane = wids[0].Plane;
198  size_t cryo = wids[0].Cryostat;
199  size_t tpc = wids[0].TPC;
200  size_t wire = wids[0].Wire;
201 
202  if (channel != fLastChannel) fChannelCnt = 0;
203 
204  // Make a directory for these histograms
205  art::TFileDirectory dir = fHistDirectory->mkdir(Form("HitPlane_%1zu/ev%04zu/c%1zut%1zuwire_%05zu",plane,eventCount,cryo,tpc,wire));
206 
207  size_t waveformSize = waveform.size();
208  int waveStart = roiStartTick;
209  int waveStop = waveStart + waveformSize;
210 
211  TProfile* waveHist = dir.make<TProfile>(Form("HWfm_%03zu_ctw%01zu-%01zu-%01zu-%05zu",fChannelCnt,cryo,tpc,plane,wire), "Waveform", waveformSize, waveStart, waveStop, -500., 500.);
212  TProfile* derivHist = dir.make<TProfile>(Form("HDer_%03zu_ctw%01zu-%01zu-%01zu-%05zu",fChannelCnt,cryo,tpc,plane,wire), "Derivative", waveformSize, waveStart, waveStop, -500., 500.);
213  TProfile* erosionHist = dir.make<TProfile>(Form("HEro_%03zu_ctw%01zu-%01zu-%01zu-%05zu",fChannelCnt,cryo,tpc,plane,wire), "Erosion", waveformSize, waveStart, waveStop, -500., 500.);
214  TProfile* dilationHist = dir.make<TProfile>(Form("HDil_%03zu_ctw%01zu-%01zu-%01zu-%05zu",fChannelCnt,cryo,tpc,plane,wire), "Dilation", waveformSize, waveStart, waveStop, -500., 500.);
215  TProfile* candHitHist = dir.make<TProfile>(Form("HCan_%03zu_ctw%01zu-%01zu-%01zu-%05zu",fChannelCnt,cryo,tpc,plane,wire), "Cand Hits", waveformSize, waveStart, waveStop, -500., 500.);
216  TProfile* maxDerivHist = dir.make<TProfile>(Form("HMax_%03zu_ctw%01zu-%01zu-%01zu-%05zu",fChannelCnt,cryo,tpc,plane,wire), "Maxima", waveformSize, waveStart, waveStop, -500., 500.);
217  TProfile* strtStopHist = dir.make<TProfile>(Form("HSSS_%03zu_ctw%01zu-%01zu-%01zu-%05zu",fChannelCnt,cryo,tpc,plane,wire), "Start/Stop", waveformSize, waveStart, waveStop, -500., 500.);
218 
219  // Fill wave/derivative
220  for(size_t idx = 0; idx < waveform.size(); idx++)
221  {
222  waveHist->Fill(roiStartTick + idx, waveform.at(idx));
223  derivHist->Fill(roiStartTick + idx, derivativeVec.at(idx));
224  erosionHist->Fill(roiStartTick + idx, erosionVec.at(idx));
225  dilationHist->Fill(roiStartTick + idx, dilationVec.at(idx));
226  }
227 
228  // Fill hits
229  for(const auto& hitCandidate : hitCandidateVec)
230  {
231  candHitHist->Fill(hitCandidate.hitCenter, hitCandidate.hitHeight);
232  maxDerivHist->Fill(hitCandidate.maxTick, hitCandidate.maxDerivative);
233  maxDerivHist->Fill(hitCandidate.minTick, hitCandidate.minDerivative);
234  strtStopHist->Fill(hitCandidate.startTick, waveform.at(hitCandidate.startTick));
235  strtStopHist->Fill(hitCandidate.stopTick, waveform.at(hitCandidate.stopTick));
236 
237  fDStopStartHist->Fill(hitCandidate.stopTick - hitCandidate.startTick, 1.);
238  fDMaxTickMinTickHist->Fill(hitCandidate.minTick - hitCandidate.maxTick, 1.);
239  fDMaxDerivMinDerivHist->Fill(hitCandidate.maxDerivative - hitCandidate.minDerivative, 1.);
240  }
241 
242  fLastChannel = channel;
243  fChannelCnt++;
244  }
245 
246  return;
247 }
std::vector< geo::WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
TFileDirectory mkdir(std::string const &dir, std::string const &descr="")
std::unique_ptr< reco_tool::IWaveformTool > fWaveformTool
void findHitCandidates(const Waveform &, size_t, size_t, size_t, HitCandidateVec &) const override
std::map< int, TProfile * > HistogramMap
Definition: IWaveformTool.h:37
T * make(ARGS...args) const
TDirectory * dir
Definition: macro.C:5
void reco_tool::CandHitMorphological::findHitCandidates ( Waveform::const_iterator  derivStartItr,
Waveform::const_iterator  derivStopItr,
Waveform::const_iterator  erosionStartItr,
Waveform::const_iterator  erosionStopItr,
Waveform::const_iterator  dilationStartItr,
Waveform::const_iterator  dilationStopItr,
size_t  roiStartTick,
float  dilationThreshold,
HitCandidateVec hitCandidateVec 
) const
private

Definition at line 249 of file CandHitMorphological_tool.cc.

References fDilationFraction, fDilationThreshold, fErosionFraction, findHitCandidates(), fMinDeltaPeaks, and fMinDeltaTicks.

255 {
256  // This function aims to use the erosion/dilation vectors to find candidate hit regions
257  // Once armed with a region then the "standard" differential approach is used to return the candidate peaks
258 
259  // This function is recursive, we start by finding the largest element of the dilation vector
260  Waveform::const_iterator maxItr = std::max_element(dilationStartItr,dilationStopItr);
261  float maxVal = *maxItr;
262 
263  // Check that the peak is of reasonable height...
264  if (maxVal < dilationThreshold) return;
265 
266  int maxBin = std::distance(dilationStartItr,maxItr);
267 
268  // The candidate hit region we want lies between the two nearest minima to the maximum we just found
269  // subject to the condition that the erosion vector has return to less than zero
270  Waveform::const_iterator firstDilItr = maxItr;
271  Waveform::const_iterator erosionItr = erosionStartItr + maxBin;
272 
273  float firstDilationValue = *firstDilItr;
274  float dilationCutValue = fDilationFraction * maxVal;
275  float erosionCutValue = fErosionFraction * maxVal;
276 
277  // Search for starting point
278  while(firstDilItr != dilationStartItr)
279  {
280  // Look for the turnover point
281  if (*erosionItr-- < erosionCutValue && *firstDilItr < dilationCutValue && *firstDilItr >= firstDilationValue) break;
282 
283  firstDilationValue = *firstDilItr--;
284  }
285 
286  // Set the start bin
287  int hitRegionStart = std::distance(dilationStartItr,firstDilItr);
288 
289  // Now go the other way
290  Waveform::const_iterator lastDilItr = maxItr;
291 
292  // Reset the local variables
293  float lastDilationValue = *lastDilItr;
294 
295  erosionItr = erosionStartItr + maxBin;
296 
297  // Search for starting point
298  while(++lastDilItr != dilationStopItr)
299  {
300  if (*++erosionItr <= erosionCutValue && *lastDilItr < dilationCutValue && *lastDilItr >= lastDilationValue) break;
301 
302  lastDilationValue = *lastDilItr;
303  }
304 
305  // Set the stop bin
306  int hitRegionStop = std::distance(dilationStartItr,lastDilItr);
307 
308  // Recursive call to find any hits in front of where we are now
309  if (hitRegionStart > fMinDeltaTicks)
310  findHitCandidates(derivStartItr, derivStartItr + hitRegionStart,
311  erosionStartItr, erosionStartItr + hitRegionStart,
312  dilationStartItr, dilationStartItr + hitRegionStart,
313  roiStartTick,
314  2. * fDilationThreshold,
315  hitCandidateVec);
316 
317  // Call the differential hit finding to get the actual hits within the region
318  findHitCandidates(derivStartItr + hitRegionStart,
319  derivStartItr + hitRegionStop,
320  roiStartTick + hitRegionStart,
323  hitCandidateVec);
324 
325  // Now call ourselves again to find any hits trailing the region we just identified
326  if (std::distance(lastDilItr,dilationStopItr) > fMinDeltaTicks)
327  findHitCandidates(derivStartItr + hitRegionStop, derivStopItr,
328  erosionStartItr + hitRegionStop, erosionStopItr,
329  dilationStartItr + hitRegionStop, dilationStopItr,
330  roiStartTick + hitRegionStop,
331  2. * fDilationThreshold,
332  hitCandidateVec);
333 
334  return;
335 }
intermediate_table::const_iterator const_iterator
void findHitCandidates(const Waveform &, size_t, size_t, size_t, HitCandidateVec &) const override
void reco_tool::CandHitMorphological::findHitCandidates ( Waveform::const_iterator  startItr,
Waveform::const_iterator  stopItr,
size_t  roiStartTick,
int  dTicksThreshold,
float  dPeakThreshold,
HitCandidateVec hitCandidateVec 
) const
private

Definition at line 337 of file CandHitMorphological_tool.cc.

References findHitCandidates(), findNearestMax(), findNearestMin(), findStartTick(), findStopTick(), fMinDeltaPeaks, fMinDeltaTicks, art::left(), art::right(), and reco_tool::ICandidateHitFinder::stopTick.

343 {
344  // Search for candidate hits...
345  // The idea will be to find the largest deviation in the input derivative waveform as the starting point. Depending
346  // on if a maximum or minimum, we search forward or backward to find the minimum or maximum that our extremum
347  // corresponds to.
348  std::pair<Waveform::const_iterator, Waveform::const_iterator> minMaxPair = std::minmax_element(startItr, stopItr);
349 
350  Waveform::const_iterator maxItr = minMaxPair.second;
351  Waveform::const_iterator minItr = minMaxPair.first;
352 
353  // Use the larger of the two as the starting point and recover the nearest max or min
354  if (std::fabs(*maxItr) > std::fabs(*minItr)) minItr = findNearestMin(maxItr, stopItr);
355  else maxItr = findNearestMax(minItr,startItr);
356 
357  int deltaTicks = std::distance(maxItr,minItr);
358  float range = *maxItr - *minItr;
359 
360  // At some point small rolling oscillations on the waveform need to be ignored...
361  if (deltaTicks >= dTicksThreshold && range > dPeakThreshold)
362  {
363  // Need to back up to find zero crossing, this will be the starting point of our
364  // candidate hit but also the endpoint of the pre sub-waveform we'll search next
365  Waveform::const_iterator newEndItr = findStartTick(maxItr, startItr);
366 
367  int startTick = std::distance(startItr,newEndItr);
368 
369  // Now need to go forward to again get close to zero, this will then be the end point
370  // of our candidate hit and the starting point for the post sub-waveform to search
371  Waveform::const_iterator newStartItr = findStopTick(minItr, stopItr);
372 
373  int stopTick = std::distance(startItr,newStartItr);
374 
375  // Find hits in the section of the waveform leading up to this candidate hit
376  if (startTick > 2)
377  {
378  // Special handling for merged hits
379  if (*(newEndItr-1) > 0.) {dTicksThreshold = 2; dPeakThreshold = 0.; }
380  else {dTicksThreshold = fMinDeltaTicks; dPeakThreshold = fMinDeltaPeaks;}
381 
382  findHitCandidates(startItr,newEndItr+1,roiStartTick,dTicksThreshold,dPeakThreshold,hitCandidateVec);
383  }
384 
385  // Create a new hit candidate and store away
386  HitCandidate_t hitCandidate;
387 
388  Waveform::const_iterator peakItr = std::min_element(maxItr,minItr,[](const auto& left, const auto& right){return std::fabs(left) < std::fabs(right);});
389 
390  // Check balance
391  if (2 * std::distance(peakItr,minItr) < std::distance(maxItr,peakItr)) peakItr--;
392  else if (2 * std::distance(maxItr,peakItr) < std::distance(peakItr,minItr)) peakItr++;
393 
394  // Special handling of the start tick for multiple hits
395  size_t hitCandidateStartTick = roiStartTick + startTick;
396 
397  if (!hitCandidateVec.empty())
398  {
399  int deltaTicks = hitCandidateStartTick - hitCandidateVec.back().stopTick;
400 
401  if (deltaTicks > 0)
402  {
403  hitCandidateStartTick -= deltaTicks / 2;
404  hitCandidateVec.back().stopTick += deltaTicks / 2;
405  }
406  }
407 
408  hitCandidate.startTick = hitCandidateStartTick;
409  hitCandidate.stopTick = roiStartTick + stopTick;
410  hitCandidate.maxTick = roiStartTick + std::distance(startItr,maxItr);
411  hitCandidate.minTick = roiStartTick + std::distance(startItr,minItr);
412  hitCandidate.maxDerivative = maxItr != stopItr ? *maxItr : 0.;
413  hitCandidate.minDerivative = minItr != stopItr ? *minItr : 0.;
414  hitCandidate.hitCenter = roiStartTick + std::distance(startItr,peakItr) + 0.5;
415  hitCandidate.hitSigma = 0.5 * float(hitCandidate.minTick - hitCandidate.maxTick);
416  hitCandidate.hitHeight = hitCandidate.hitSigma * (hitCandidate.maxDerivative - hitCandidate.minDerivative) / 1.2130;
417 
418  hitCandidateVec.push_back(hitCandidate);
419 
420  // Finally, search the section of the waveform following this candidate for more hits
421  if (std::distance(newStartItr,stopItr) > 2)
422  {
423  // Special handling for merged hits
424  if (*(newStartItr+1) < 0.) {dTicksThreshold = 2; dPeakThreshold = 0.; }
425  else {dTicksThreshold = fMinDeltaTicks; dPeakThreshold = fMinDeltaPeaks;}
426 
427  findHitCandidates(newStartItr,stopItr,roiStartTick + stopTick,dTicksThreshold,dPeakThreshold,hitCandidateVec);
428  }
429  }
430 
431  return;
432 }
Waveform::const_iterator findNearestMin(Waveform::const_iterator, Waveform::const_iterator) const
constexpr auto const & right(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
Definition: AssnsIter.h:112
Waveform::const_iterator findStopTick(Waveform::const_iterator, Waveform::const_iterator) const
struct HitCandidate{size_t startTick HitCandidate_t
Waveform::const_iterator findStartTick(Waveform::const_iterator, Waveform::const_iterator) const
intermediate_table::const_iterator const_iterator
void findHitCandidates(const Waveform &, size_t, size_t, size_t, HitCandidateVec &) const override
constexpr auto const & left(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
Definition: AssnsIter.h:104
Waveform::const_iterator findNearestMax(Waveform::const_iterator, Waveform::const_iterator) const
ICandidateHitFinder::Waveform::const_iterator reco_tool::CandHitMorphological::findNearestMax ( Waveform::const_iterator  minItr,
Waveform::const_iterator  startItr 
) const
private

Definition at line 494 of file CandHitMorphological_tool.cc.

Referenced by findHitCandidates().

495 {
496  // Set the internal loop variable...
497  Waveform::const_iterator lastItr = minItr;
498 
499  // One extra condition to watch for here, make sure we can actually back up!
500  if (std::distance(startItr,minItr) > 0)
501  {
502  // Similar to searching for a maximum, we loop backward over ticks looking for the waveform to start decreasing
503  while((lastItr - 1) != startItr)
504  {
505  if (*(lastItr - 1) < *lastItr) break;
506 
507  lastItr--;
508  }
509  }
510 
511  return lastItr;
512 }
intermediate_table::const_iterator const_iterator
ICandidateHitFinder::Waveform::const_iterator reco_tool::CandHitMorphological::findNearestMin ( Waveform::const_iterator  maxItr,
Waveform::const_iterator  stopItr 
) const
private

Definition at line 476 of file CandHitMorphological_tool.cc.

Referenced by findHitCandidates().

477 {
478  // reset the min iterator and search forward to find the nearest minimum
479  Waveform::const_iterator lastItr = maxItr;
480 
481  // The strategy is simple...
482  // We are at a maximum so we search forward until we find the lowest negative point
483  while((lastItr + 1) != stopItr)
484  {
485  if (*(lastItr + 1) > *lastItr) break;
486 
487  lastItr++;
488  }
489 
490  // The minimum will be the last iterator value...
491  return lastItr;
492 }
intermediate_table::const_iterator const_iterator
ICandidateHitFinder::Waveform::const_iterator reco_tool::CandHitMorphological::findStartTick ( Waveform::const_iterator  maxItr,
Waveform::const_iterator  startItr 
) const
private

Definition at line 514 of file CandHitMorphological_tool.cc.

Referenced by findHitCandidates().

515 {
516  Waveform::const_iterator lastItr = maxItr;
517 
518  // If we can't back up then there is nothing to do
519  if (std::distance(startItr,lastItr) > 0)
520  {
521  // In theory, we are starting at a maximum and want to find the "start" of the candidate peak
522  // Ideally we would look to search backward to the point where the (derivative) waveform crosses zero again.
523  // However, the complication is that we need to watch for the case where two peaks are merged together and
524  // we might run through another peak before crossing zero...
525  // So... loop until we hit the startItr...
526  Waveform::const_iterator loopItr = lastItr - 1;
527 
528  while(loopItr != startItr)
529  {
530  // Ideal world case, we cross zero... but we might encounter a minimum... or an inflection point
531  if (*loopItr < 0. || !(*loopItr < *lastItr)) break;
532 
533  lastItr = loopItr--;
534  }
535  }
536  else lastItr = startItr;
537 
538  return lastItr;
539 }
intermediate_table::const_iterator const_iterator
ICandidateHitFinder::Waveform::const_iterator reco_tool::CandHitMorphological::findStopTick ( Waveform::const_iterator  minItr,
Waveform::const_iterator  stopItr 
) const
private

Definition at line 541 of file CandHitMorphological_tool.cc.

References DEFINE_ART_CLASS_TOOL.

Referenced by findHitCandidates().

542 {
543  Waveform::const_iterator lastItr = minItr;
544 
545  // If we can't go forward then there is really nothing to do
546  if (std::distance(minItr,stopItr) > 1)
547  {
548  // Pretty much the same strategy as for finding the start tick...
549  Waveform::const_iterator loopItr = lastItr + 1;
550 
551  while(loopItr != stopItr)
552  {
553  // Ideal case that we have crossed zero coming from a minimum... but watch for a maximum as well
554  if (*loopItr > 0. || !(*loopItr > *lastItr)) break;
555 
556  lastItr = loopItr++;
557  }
558  }
559 
560  return lastItr;
561 }
intermediate_table::const_iterator const_iterator
void reco_tool::CandHitMorphological::MergeHitCandidates ( const Waveform signalVec,
const HitCandidateVec hitCandidateVec,
MergeHitCandidateVec mergedHitsVec 
) const
overridevirtual

Implements reco_tool::ICandidateHitFinder.

Definition at line 434 of file CandHitMorphological_tool.cc.

References fMinHitHeight, and fNumInterveningTicks.

437 {
438  // If nothing on the input end then nothing to do
439  if (hitCandidateVec.empty()) return;
440 
441  // The idea is to group hits that "touch" so they can be part of common fit, those that
442  // don't "touch" are fit independently. So here we build the output vector to achieve that
443  // Get a container for the hits...
444  HitCandidateVec groupedHitVec;
445 
446  // Initialize the end of the last hit which we'll set to the first input hit's stop
447  size_t lastStopTick = hitCandidateVec.front().stopTick;
448 
449  // Step through the input hit candidates and group them by proximity
450  for(const auto& hitCandidate : hitCandidateVec)
451  {
452  // Small pulse height hits should not be considered?
453  if (hitCandidate.hitHeight > fMinHitHeight)
454  {
455  // Check condition that we have a new grouping
456  if (hitCandidate.startTick > lastStopTick + fNumInterveningTicks && !groupedHitVec.empty())
457  {
458  mergedHitsVec.emplace_back(groupedHitVec);
459 
460  groupedHitVec.clear();
461  }
462 
463  // Add the current hit to the current group
464  groupedHitVec.emplace_back(hitCandidate);
465 
466  lastStopTick = hitCandidate.stopTick;
467  }
468  }
469 
470  // Check end condition
471  if (!groupedHitVec.empty()) mergedHitsVec.emplace_back(groupedHitVec);
472 
473  return;
474 }
std::vector< HitCandidate_t > HitCandidateVec

Member Data Documentation

size_t reco_tool::CandHitMorphological::fChannelCnt
mutableprivate

Definition at line 91 of file CandHitMorphological_tool.cc.

Referenced by configure(), and findHitCandidates().

float reco_tool::CandHitMorphological::fDilationFraction
private

Definition at line 74 of file CandHitMorphological_tool.cc.

Referenced by configure(), and findHitCandidates().

float reco_tool::CandHitMorphological::fDilationThreshold
private

Definition at line 73 of file CandHitMorphological_tool.cc.

Referenced by configure(), and findHitCandidates().

TH1F* reco_tool::CandHitMorphological::fDMaxDerivMinDerivHist
private

Definition at line 88 of file CandHitMorphological_tool.cc.

Referenced by configure(), and findHitCandidates().

TH1F* reco_tool::CandHitMorphological::fDMaxTickMinTickHist
private

Definition at line 87 of file CandHitMorphological_tool.cc.

Referenced by configure(), and findHitCandidates().

TH1F* reco_tool::CandHitMorphological::fDStopStartHist
private

Definition at line 86 of file CandHitMorphological_tool.cc.

Referenced by configure(), and findHitCandidates().

float reco_tool::CandHitMorphological::fErosionFraction
private

Definition at line 75 of file CandHitMorphological_tool.cc.

Referenced by configure(), and findHitCandidates().

const geo::GeometryCore* reco_tool::CandHitMorphological::fGeometry = lar::providerFrom<geo::Geometry>()
private

Definition at line 96 of file CandHitMorphological_tool.cc.

Referenced by findHitCandidates().

art::TFileDirectory* reco_tool::CandHitMorphological::fHistDirectory
private

Definition at line 83 of file CandHitMorphological_tool.cc.

Referenced by configure(), and findHitCandidates().

size_t reco_tool::CandHitMorphological::fLastChannel
mutableprivate

Definition at line 90 of file CandHitMorphological_tool.cc.

Referenced by configure(), and findHitCandidates().

float reco_tool::CandHitMorphological::fMinDeltaPeaks
private

Definition at line 77 of file CandHitMorphological_tool.cc.

Referenced by configure(), and findHitCandidates().

int reco_tool::CandHitMorphological::fMinDeltaTicks
private

Definition at line 76 of file CandHitMorphological_tool.cc.

Referenced by configure(), and findHitCandidates().

float reco_tool::CandHitMorphological::fMinHitHeight
private

Definition at line 78 of file CandHitMorphological_tool.cc.

Referenced by configure(), and MergeHitCandidates().

size_t reco_tool::CandHitMorphological::fNumInterveningTicks
private

Definition at line 79 of file CandHitMorphological_tool.cc.

Referenced by configure(), and MergeHitCandidates().

bool reco_tool::CandHitMorphological::fOutputHistograms
private

Definition at line 81 of file CandHitMorphological_tool.cc.

Referenced by configure(), and findHitCandidates().

size_t reco_tool::CandHitMorphological::fPlane
private

Definition at line 72 of file CandHitMorphological_tool.cc.

Referenced by configure().

int reco_tool::CandHitMorphological::fStructuringElement
private

Definition at line 80 of file CandHitMorphological_tool.cc.

Referenced by configure(), and findHitCandidates().

std::unique_ptr<reco_tool::IWaveformTool> reco_tool::CandHitMorphological::fWaveformTool
private

Definition at line 94 of file CandHitMorphological_tool.cc.

Referenced by configure(), and findHitCandidates().

float reco_tool::ICandidateHitFinder::hitCenter
inherited

Definition at line 36 of file ICandidateHitFinder.h.

float reco_tool::ICandidateHitFinder::hitHeight
inherited

Definition at line 38 of file ICandidateHitFinder.h.

float reco_tool::ICandidateHitFinder::hitSigma
inherited

Definition at line 37 of file ICandidateHitFinder.h.

float reco_tool::ICandidateHitFinder::maxDerivative
inherited

Definition at line 34 of file ICandidateHitFinder.h.

size_t reco_tool::ICandidateHitFinder::maxTick
inherited

Definition at line 32 of file ICandidateHitFinder.h.

float reco_tool::ICandidateHitFinder::minDerivative
inherited

Definition at line 35 of file ICandidateHitFinder.h.

size_t reco_tool::ICandidateHitFinder::minTick
inherited

Definition at line 33 of file ICandidateHitFinder.h.

size_t reco_tool::ICandidateHitFinder::stopTick
inherited

The documentation for this class was generated from the following file: