Public Member Functions | Private Member Functions | Private Attributes | List of all members
beamlinereco::CFDHitFinder< T > Class Template Reference

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N21-01-21/BeamlineReco/CFDHitFinderAlg.h"

Public Member Functions

 CFDHitFinder ()
 
virtual ~CFDHitFinder ()=default
 
void SetWaveform (std::vector< uint16_t > &waveform, unsigned int channelNo, uint32_t timestamp)
 
void SetParams (const std::map< CFDParams, double > &paramSet)
 
void SetDiscriminationType (const std::string type)
 
void SetInterpolationType (const std::string type)
 
void SetFilterType (const std::string type)
 
const std::string GetDiscriminationType () const
 
const std::string GetInterpolationType () const
 
const std::string GetFilterType () const
 
const std::map< T, hit_t< T > > & GetHitCollection () const
 
const TGetPedestal () const
 
const TGetNoiseSigma () const
 
const TGetDiscriminationThreshold () const
 
virtual void Go ()
 

Private Member Functions

void SetChannel (unsigned int channelNo)
 
void SetTimestamp (uint32_t timestamp)
 
void SetParam (CFDParams param, T value)
 
virtual void FindPedestal ()
 
virtual void FindRawHitLogic ()
 
virtual void FindCFDHits ()
 
virtual bool BackwardFindingOfHitStart (size_t hitPeakTimeIndex, T hitPeakValue, T &hitStartTimeIndex, T &hitRiseTimeInIndex)
 
virtual bool ForwardFindingOfHitFallTime (size_t hitPeakTimeIndex, T &hitFallTimeInIndex)
 
virtual T IntegrateWaveformInADC (size_t hitStartTimeIndex, size_t hitEndTimeIndex)
 
virtual T FindHitWidth (size_t hitPeakTimeIndex, T hitPeakValueADC)
 
virtual T FindPeakValue (size_t hitPeakTimeIndex, T &hitPeakValue)
 
virtual void Reset ()
 

Private Attributes

unsigned int _ChannelNumber
 
uint32_t _Timestamp
 
std::string _DiscriminationType
 
std::string _InterpolationType
 
std::string _FilterType
 
std::vector< T_WaveformADCNanosec
 
std::vector< T_NonfilterWaveformADCNanosec
 
std::vector< bool > _RawHitLogicNanosec
 
T _PedestalInADC
 
T _NoiseSigmaInADC
 
T _DiscriminationThresholdInADC
 
std::map< CFDParams, T_CFDParamSet
 
std::map< T, hit_t< T > > _HitCollection
 

Detailed Description

template<class T>
class beamlinereco::CFDHitFinder< T >

Definition at line 71 of file CFDHitFinderAlg.h.

Constructor & Destructor Documentation

template<class T>
beamlinereco::CFDHitFinder< T >::CFDHitFinder ( )
inline

Definition at line 73 of file CFDHitFinderAlg.h.

73  {
74  _HitCollection.clear();
75  _RawHitLogicNanosec.clear();
76  _PedestalInADC = 0;
77  _NoiseSigmaInADC = 0;
79  _WaveformADCNanosec.clear();
80  _ChannelNumber = 993;
81  _Timestamp = 0;
83  _CFDParamSet.clear();
84  }
std::map< T, hit_t< T > > _HitCollection
std::vector< T > _WaveformADCNanosec
std::map< CFDParams, T > _CFDParamSet
std::vector< T > _NonfilterWaveformADCNanosec
std::vector< bool > _RawHitLogicNanosec
template<class T>
virtual beamlinereco::CFDHitFinder< T >::~CFDHitFinder ( )
virtualdefault

Member Function Documentation

template<class T>
bool beamlinereco::CFDHitFinder< T >::BackwardFindingOfHitStart ( size_t  hitPeakTimeIndex,
T  hitPeakValue,
T hitStartTimeIndex,
T hitRiseTimeInIndex 
)
privatevirtual

Definition at line 452 of file CFDHitFinderAlg.h.

References art::errors::Configuration, allTimeWatchdog::endl, beamlinereco::kDiscriminationThreshold, PandAna.Demos.pi0_spectra::p0, plot_validation_datamc::p1, T, confusionMatrixTree::t, getGoodRuns4SAM::t1, t2, submit_syst::x, and submit_syst::y.

452  {
453  bool isThisHitContainedFromTheRisingEdge = true;
454 
455  if (_DiscriminationType == "CFD") {
457  } else if (_DiscriminationType == "LE") {
459  } else {
461  << "Unknown DiscriminationType: " << _DiscriminationType << "." << std::endl;
462  }
463 
464  size_t tmp_index = hitPeakTimeIndex;
465  while (_WaveformADCNanosec.at(tmp_index) < _DiscriminationThresholdInADC) {
466  if (tmp_index == 2 && _WaveformADCNanosec.at(tmp_index - 1) < _DiscriminationThresholdInADC) {
467  isThisHitContainedFromTheRisingEdge = false;
468  break;
469  }
470  tmp_index = tmp_index - 1;
471  }
472 
473  if ((_InterpolationType == "LinearNearest") || (tmp_index < 2)) {
474  // Draw a line between two points
475  T V1 = _WaveformADCNanosec.at(tmp_index);
476  T V2 = _WaveformADCNanosec.at(tmp_index - 1);
477  size_t t1 = tmp_index;
478  size_t t2 = tmp_index - 1;
479  T slope = (V2 - V1) / ((T)t2 - (T)t1);
480  hitStartTimeIndex = (_DiscriminationThresholdInADC - V1) / slope + (T)t1;
481  }
482  if ((_InterpolationType == "LinearFit") && (tmp_index >= 2)) {
483  // Fit the surrounding 4
484  T x[4] = {
485  (T)(tmp_index - 2),
486  (T)(tmp_index - 1),
487  (T)(tmp_index),
488  (T)(tmp_index + 1)
489  };
490  T y[4] = {
491  _WaveformADCNanosec.at(tmp_index - 2),
492  _WaveformADCNanosec.at(tmp_index - 1),
493  _WaveformADCNanosec.at(tmp_index),
494  _WaveformADCNanosec.at(tmp_index + 1)
495  };
496  TGraph *gfit = new TGraph(4, x, y);
497  TFitResultPtr frp = gfit->Fit("pol1", "SQNF");
498  double p0 = frp->Parameter(0);
499  double p1 = frp->Parameter(1);
500  T V = p0 + p1 * (T)tmp_index;
501  T t = (T)tmp_index;
502  hitStartTimeIndex = (T)t + (_DiscriminationThresholdInADC - V) / p1;
503  }
504 
505  if (!isThisHitContainedFromTheRisingEdge) {
506  hitRiseTimeInIndex = (T) hitPeakTimeIndex - (T) tmp_index;
507  } else {
508  tmp_index = hitPeakTimeIndex;
509  while (_WaveformADCNanosec.at(tmp_index) <= _PedestalInADC) {
510  if (tmp_index == 2 && _WaveformADCNanosec.at(tmp_index - 1) < _PedestalInADC) {
511  isThisHitContainedFromTheRisingEdge = false;
512  break;
513  }
514  tmp_index = tmp_index - 1;
515  }
516  hitRiseTimeInIndex = (T) hitPeakTimeIndex - (T) tmp_index;
517  }
518 
519  return isThisHitContainedFromTheRisingEdge;
520 }
std::vector< T > _WaveformADCNanosec
std::map< CFDParams, T > _CFDParamSet
double t2
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
double T
Definition: Xdiff_gwt.C:5
template<class T >
void beamlinereco::CFDHitFinder< T >::FindCFDHits ( )
privatevirtual

Definition at line 330 of file CFDHitFinderAlg.h.

References beamlinereco::hit_t< T >::AmplitudeInADC, beamlinereco::hit_t< T >::AmplitudeInMiliVolt, beamlinereco::hit_t< T >::DigitizerChannel, beamlinereco::hit_t< T >::FallTimeInNanoSec, MECModelEnuComparisons::i, beamlinereco::hit_t< T >::IntegratedChargeInADCNanoSec, beamlinereco::hit_t< T >::IntegratedChargeInADCTimeTicks, beamlinereco::hit_t< T >::IsContained, calib::j, beamlinereco::kADCDynamicRange, beamlinereco::kADCNBits, beamlinereco::kRawHitFinderTicksFromEnd, beamlinereco::kTimeSamplingInterval, beamlinereco::hit_t< T >::RiseTimeInNanoSec, T, beamlinereco::hit_t< T >::Timestamp, beamlinereco::hit_t< T >::TPeakInNanoSec, beamlinereco::hit_t< T >::TStartInNanoSec, and beamlinereco::hit_t< T >::WidthInNanoSec.

330  {
331  std::vector<T> hitPeakValueVector; hitPeakValueVector.clear();
332  std::vector<size_t> hitPeakTimeIndexVector; hitPeakTimeIndexVector.clear();
333  std::vector<T> hitPeakTimeInNanoSecVector; hitPeakTimeInNanoSecVector.clear();
334  std::vector<T> hitStartTimeIndexVector; hitStartTimeIndexVector.clear();
335  std::vector<T> hitRiseTimeInIndexVector; hitRiseTimeInIndexVector.clear();
336  std::vector<T> hitFallTimeInIndexVector; hitFallTimeInIndexVector.clear();
337  std::vector<T> hitWidthValueVector; hitWidthValueVector.clear();
338  std::vector<bool> isHitContainedVector; isHitContainedVector.clear();
339 
340  bool logicFallingPart = true;
341  for (size_t i = 1; i < _RawHitLogicNanosec.size() - 1; i++) {
342  T hitPeakValue = 1E10;
343  size_t hitPeakTimeIndex = 0;
344  if (_RawHitLogicNanosec.at(i) && !(_RawHitLogicNanosec.at(i - 1)) && logicFallingPart) {
345  logicFallingPart = false;
346  for (size_t j = i; j < _RawHitLogicNanosec.size() - 1; j++) {
347  hitPeakValue = hitPeakValue > _WaveformADCNanosec.at(j) ? (T) _WaveformADCNanosec.at(j) : hitPeakValue;
348  hitPeakTimeIndex = hitPeakValue == _WaveformADCNanosec.at(j) ? j : hitPeakTimeIndex;
349  if (((_RawHitLogicNanosec.at(j) && !(_RawHitLogicNanosec.at(j + 1))) || ((_RawHitLogicNanosec.size() - j) < _CFDParamSet[kRawHitFinderTicksFromEnd])) && !logicFallingPart) {
350  logicFallingPart = true;
351  T hitStartTimeIndex = (T)hitPeakTimeIndex;
352  T hitRiseTimeInIndex = (T)hitPeakTimeIndex;
353  T hitFallTimeInIndex = (T)hitPeakTimeIndex;
354  T hitPeakTimeInNanoSec = FindPeakValue(hitPeakTimeIndex, hitPeakValue);
355  T hitWidthInTicks = FindHitWidth(hitPeakTimeIndex, hitPeakValue);
356  bool containedFromRisingEdge = BackwardFindingOfHitStart(hitPeakTimeIndex, hitPeakValue, hitStartTimeIndex, hitRiseTimeInIndex);
357  bool containedFromFallingEdge = ForwardFindingOfHitFallTime(hitPeakTimeIndex, hitFallTimeInIndex);
358 
359  hitPeakValueVector.push_back(hitPeakValue);
360  hitPeakTimeIndexVector.push_back(hitPeakTimeIndex);
361  hitPeakTimeInNanoSecVector.push_back(hitPeakTimeInNanoSec);
362  hitStartTimeIndexVector.push_back(hitStartTimeIndex);
363  hitRiseTimeInIndexVector.push_back(hitRiseTimeInIndex);
364  hitFallTimeInIndexVector.push_back(hitFallTimeInIndex);
365  hitWidthValueVector.push_back(hitWidthInTicks);
366  isHitContainedVector.push_back(containedFromRisingEdge && containedFromFallingEdge);
367  break;
368  }
369  }
370  }
371  }
372 
373  for (size_t i = 0; i < hitStartTimeIndexVector.size(); i++) {
374  hit_t<double> aHit;
375  aHit.Timestamp = _Timestamp;
376  aHit.DigitizerChannel = _ChannelNumber;
377  aHit.TStartInNanoSec = hitStartTimeIndexVector.at(i) * _CFDParamSet[kTimeSamplingInterval];
378  aHit.TPeakInNanoSec = hitPeakTimeInNanoSecVector.at(i) * _CFDParamSet[kTimeSamplingInterval];
379  aHit.AmplitudeInMiliVolt = hitPeakValueVector.at(i) * (_CFDParamSet[kADCDynamicRange] / (TMath::Power(2, _CFDParamSet[kADCNBits]) - 1));
380  aHit.AmplitudeInADC = hitPeakValueVector.at(i);
381  aHit.WidthInNanoSec = hitWidthValueVector.at(i) * _CFDParamSet[kTimeSamplingInterval];
382  aHit.RiseTimeInNanoSec = hitRiseTimeInIndexVector.at(i) * _CFDParamSet[kTimeSamplingInterval];
383  aHit.FallTimeInNanoSec = hitFallTimeInIndexVector.at(i) * _CFDParamSet[kTimeSamplingInterval];
384  aHit.IsContained = isHitContainedVector.at(i);
385  aHit.IntegratedChargeInADCTimeTicks = IntegrateWaveformInADC(hitPeakTimeIndexVector.at(i) - hitRiseTimeInIndexVector.at(i),
386  hitPeakTimeIndexVector.at(i) + hitFallTimeInIndexVector.at(i));
387  aHit.IntegratedChargeInADCNanoSec = aHit.IntegratedChargeInADCTimeTicks * _CFDParamSet[kTimeSamplingInterval];
388 
389  _HitCollection[hitStartTimeIndexVector.at(i)] = aHit;
390  }
391 }
std::map< T, hit_t< T > > _HitCollection
std::vector< T > _WaveformADCNanosec
virtual bool BackwardFindingOfHitStart(size_t hitPeakTimeIndex, T hitPeakValue, T &hitStartTimeIndex, T &hitRiseTimeInIndex)
std::map< CFDParams, T > _CFDParamSet
virtual T FindPeakValue(size_t hitPeakTimeIndex, T &hitPeakValue)
virtual T FindHitWidth(size_t hitPeakTimeIndex, T hitPeakValueADC)
virtual bool ForwardFindingOfHitFallTime(size_t hitPeakTimeIndex, T &hitFallTimeInIndex)
const double j
Definition: BetheBloch.cxx:29
virtual T IntegrateWaveformInADC(size_t hitStartTimeIndex, size_t hitEndTimeIndex)
double T
Definition: Xdiff_gwt.C:5
std::vector< bool > _RawHitLogicNanosec
template<class T>
T beamlinereco::CFDHitFinder< T >::FindHitWidth ( size_t  hitPeakTimeIndex,
T  hitPeakValueADC 
)
privatevirtual

Definition at line 539 of file CFDHitFinderAlg.h.

References MECModelEnuComparisons::i, beamlinereco::kNSamplingPoints, T, getGoodRuns4SAM::t1, t2, y1, and submit_syst::y2.

539  {
540  // Calculate FWHM
541 
542  // Find half-max
543  T halfMax = _PedestalInADC - (_PedestalInADC - hitPeakValueADC)/2.;
544 
545  T halfMaxLeft = 9993; // left point of half-max in ticks
546  T halfMaxRight = 9993; // right point of half-max in ticks
547 
548  // Scan backwards
549  for (size_t i=hitPeakTimeIndex; i>0; i--) {
550  if (_WaveformADCNanosec.at(i) == halfMax) { // exactly equal
551  halfMaxLeft = (T)i;
552  break;
553  } else if (_WaveformADCNanosec.at(i) > halfMax) {
554  // Simple two-point linear interpolation
555  T y1 = _WaveformADCNanosec.at(i);
556  T y2 = _WaveformADCNanosec.at(i + 1);
557  size_t t1 = i;
558  size_t t2 = i + 1;
559  T slope = (y2 - y1) / ((T)t2 - (T)t1);
560  halfMaxLeft = (halfMax - y1) / slope + (T)t1;
561  break;
562  }
563  }
564 
565  // Scan forwards
566  for (size_t i=hitPeakTimeIndex; i<_CFDParamSet[kNSamplingPoints]-1; i++) {
567  if (_WaveformADCNanosec.at(i) == halfMax) { // exactly equal
568  halfMaxRight = (T)i;
569  break;
570  } else if (_WaveformADCNanosec.at(i) > halfMax) {
571  // Simple two-point linear interpolation
572  T y1 = _WaveformADCNanosec.at(i - 1);
573  T y2 = _WaveformADCNanosec.at(i);
574  size_t t1 = i - 1;
575  size_t t2 = i;
576  T slope = (y2 - y1) / ((T)t2 - (T)t1);
577  halfMaxRight = (halfMax - y1) / slope + (T)t1;
578  break;
579  }
580  }
581 
582  T widthInTicks = halfMaxRight - halfMaxLeft;
583  return widthInTicks;
584 }
std::vector< T > _WaveformADCNanosec
Float_t y1[n_points_granero]
Definition: compare.C:5
std::map< CFDParams, T > _CFDParamSet
double t2
double T
Definition: Xdiff_gwt.C:5
template<class T>
T beamlinereco::CFDHitFinder< T >::FindPeakValue ( size_t  hitPeakTimeIndex,
T hitPeakValue 
)
privatevirtual

Definition at line 394 of file CFDHitFinderAlg.h.

References PandAna.Demos.pi0_spectra::p0, plot_validation_datamc::p1, plot_validation_datamc::p2, make_associated_cosmic_defs::p3, std::sqrt(), T, submit_syst::x, and submit_syst::y.

394  {
395  // Fit a third-order polynomial
396  // Translate x to near zero to help out the fitter
397  T x[7] = { -3, -2, -1, 0, 1, 2, 3 };
398  T y[7] = {
399  _WaveformADCNanosec.at(hitPeakTimeIndex - 3),
400  _WaveformADCNanosec.at(hitPeakTimeIndex - 2),
401  _WaveformADCNanosec.at(hitPeakTimeIndex - 1),
402  _WaveformADCNanosec.at(hitPeakTimeIndex),
403  _WaveformADCNanosec.at(hitPeakTimeIndex + 1),
404  _WaveformADCNanosec.at(hitPeakTimeIndex + 2),
405  _WaveformADCNanosec.at(hitPeakTimeIndex + 3)
406  };
407 
408  TGraph *gfit = new TGraph(7, x, y);
409 
410  // Make sure fitter is Minuit2 -- works better than Minut here
411  TVirtualFitter::SetDefaultFitter("Minuit2");
412  TFitResultPtr frp = gfit->Fit("pol3", "SFNQ");
413  T p0 = frp->Parameter(0);
414  T p1 = frp->Parameter(1);
415  T p2 = frp->Parameter(2);
416  T p3 = frp->Parameter(3);
417 
418  T disc = p2*p2 - 3.*p1*p3;
419  if (disc < 0) { // Discriminant negative => no extrema
420  hitPeakValue = _WaveformADCNanosec.at(hitPeakTimeIndex);
421  return hitPeakTimeIndex;
422  }
423 
424  // Positive root corresponds to the minimum for a third-order polynomial
425  T hitPeakTime = (-p2 + sqrt(disc))/(3.*p3);
426  hitPeakValue = p0 + p1*hitPeakTime + p2*hitPeakTime*hitPeakTime + p3*hitPeakTime*hitPeakTime*hitPeakTime;
427  hitPeakTime += (T)hitPeakTimeIndex; // translate back to actual time
428  return hitPeakTime;
429 }
std::vector< T > _WaveformADCNanosec
T sqrt(T number)
Definition: d0nt_math.hpp:156
double T
Definition: Xdiff_gwt.C:5
template<class T >
void beamlinereco::CFDHitFinder< T >::FindPedestal ( )
privatevirtual

Definition at line 242 of file CFDHitFinderAlg.h.

References ana::Sqrt(), and T.

242  {
243 /* 2nd way
244  TH1D* pedHist = new TH1D("", "", 10000, 0, 5000);
245  for (size_t i = 700; i < 1024; i++) {
246  pedHist->Fill(_NonfilterWaveformADCNanosec.at(i));
247  }
248 
249  _PedestalInADC = (T) pedHist->GetMean();
250  _NoiseSigmaInADC = (T) pedHist->GetStdDev();
251 
252  delete (pedHist);
253 */
254 
255 /* 3rd way*/
256  T NoiseBand = 1E9;
257  T OldPedestal = 1E9;
258  T Pedestal = 0;
259 
260  while (TMath::Abs(Pedestal - OldPedestal) >= 2) {
261  T average = 0;
262  T stdDev = 0;
263  size_t countSamples = 0;
264  for (typename std::vector<T>::iterator itr = _NonfilterWaveformADCNanosec.begin(); itr != _NonfilterWaveformADCNanosec.end(); itr++) {
265  if ((*itr <= Pedestal + NoiseBand) && (*itr >= Pedestal - NoiseBand)) {
266  average += *itr;
267  countSamples++;
268  }
269  }
270  average = average / (T)countSamples;
271  for (typename std::vector<T>::iterator itr = _NonfilterWaveformADCNanosec.begin(); itr != _NonfilterWaveformADCNanosec.end(); itr++) {
272  if ((*itr <= Pedestal + NoiseBand) && (*itr >= Pedestal - NoiseBand)) {
273  stdDev += TMath::Power((*itr) - average, 2);
274  }
275  }
276 
277  stdDev = TMath::Sqrt(stdDev / (T)countSamples);
278  OldPedestal = Pedestal;
279  Pedestal = average;
280  NoiseBand = stdDev;
281  }
282 
283  _PedestalInADC = Pedestal;
284  _NoiseSigmaInADC = NoiseBand;
285 /**/
286 }
Var Sqrt(const Var &v)
Use to take sqrt of a var.
Definition: Var.cxx:326
std::vector< T > _NonfilterWaveformADCNanosec
double T
Definition: Xdiff_gwt.C:5
template<class T >
void beamlinereco::CFDHitFinder< T >::FindRawHitLogic ( )
privatevirtual

Definition at line 289 of file CFDHitFinderAlg.h.

References MECModelEnuComparisons::i, calib::j, beamlinereco::kConsecutiveHitSeperationDurationInTicks, beamlinereco::kRawHitFinderThresholdInNoiseSigma, beamlinereco::kShortRawHitIgnoringDurationInTicks, and T.

289  {
291  for (size_t i = 0; i < _WaveformADCNanosec.size(); i++) {
292  _RawHitLogicNanosec.push_back(_WaveformADCNanosec.at(i) < rawHitThreshold);
293  }
294 
295  for (size_t i = 1; i < _RawHitLogicNanosec.size() - 1; i++) {
296  if ((not _RawHitLogicNanosec.at(i - 1)) and _RawHitLogicNanosec.at(i)) {
297  size_t countDuration = 0;
298  for (size_t j = i; j < _RawHitLogicNanosec.size() - 1; j++) {
299  if (_RawHitLogicNanosec.at(j)) countDuration++;
300  if (not(_RawHitLogicNanosec.at(j + 1))) break;
301  }
302 
303  if (countDuration < _CFDParamSet[kShortRawHitIgnoringDurationInTicks]) {
304  for (size_t j = i; j < i + countDuration; j++) {
305  _RawHitLogicNanosec.at(j) = false;
306  }
307  }
308  }
309  }
310 
311  for (size_t i = 1; i < _RawHitLogicNanosec.size() - 1; i++) {
312  if (_RawHitLogicNanosec.at(i - 1) && not(_RawHitLogicNanosec.at(i))) {
313  size_t countDuration = 0;
314  for (size_t j = i; j < _RawHitLogicNanosec.size() - 1; j++) {
315  if (not(_RawHitLogicNanosec.at(j))) countDuration++;
316  if (_RawHitLogicNanosec.at(j + 1)) break;
317  }
318 
320  for (size_t j = i; j < i + countDuration; j++) {
321  _RawHitLogicNanosec.at(j) = true;
322  }
323  }
324  }
325  }
326 
327 }
std::vector< T > _WaveformADCNanosec
std::map< CFDParams, T > _CFDParamSet
const double j
Definition: BetheBloch.cxx:29
double T
Definition: Xdiff_gwt.C:5
std::vector< bool > _RawHitLogicNanosec
template<class T>
bool beamlinereco::CFDHitFinder< T >::ForwardFindingOfHitFallTime ( size_t  hitPeakTimeIndex,
T hitFallTimeInIndex 
)
privatevirtual

Definition at line 523 of file CFDHitFinderAlg.h.

References beamlinereco::kNSamplingPoints, and T.

523  {
524  bool isThisHitContainedFromTheFallingEdge = true;
525  size_t tmp_index = hitPeakTimeIndex;
526  while (_WaveformADCNanosec.at(tmp_index) < _PedestalInADC) {
527  if (tmp_index == _CFDParamSet[kNSamplingPoints] - 2 && _WaveformADCNanosec.at(tmp_index + 1) < _PedestalInADC) {
528  isThisHitContainedFromTheFallingEdge = false;
529  break;
530  }
531  tmp_index = tmp_index + 1;
532  }
533 
534  hitFallTimeInIndex = (T)tmp_index - (T)hitPeakTimeIndex;
535  return isThisHitContainedFromTheFallingEdge;
536 }
std::vector< T > _WaveformADCNanosec
std::map< CFDParams, T > _CFDParamSet
double T
Definition: Xdiff_gwt.C:5
template<class T>
const T& beamlinereco::CFDHitFinder< T >::GetDiscriminationThreshold ( ) const
inline

Definition at line 100 of file CFDHitFinderAlg.h.

template<class T>
const std::string beamlinereco::CFDHitFinder< T >::GetDiscriminationType ( ) const
inline

Definition at line 94 of file CFDHitFinderAlg.h.

94 { return _DiscriminationType; }
template<class T>
const std::string beamlinereco::CFDHitFinder< T >::GetFilterType ( ) const
inline

Definition at line 96 of file CFDHitFinderAlg.h.

96 { return _FilterType; }
template<class T>
const std::map<T, hit_t<T> >& beamlinereco::CFDHitFinder< T >::GetHitCollection ( ) const
inline

Definition at line 97 of file CFDHitFinderAlg.h.

Referenced by beamlinereco::CFDHitReco::produce().

97 { return _HitCollection; }
std::map< T, hit_t< T > > _HitCollection
template<class T>
const std::string beamlinereco::CFDHitFinder< T >::GetInterpolationType ( ) const
inline

Definition at line 95 of file CFDHitFinderAlg.h.

95 { return _InterpolationType; }
template<class T>
const T& beamlinereco::CFDHitFinder< T >::GetNoiseSigma ( ) const
inline

Definition at line 99 of file CFDHitFinderAlg.h.

template<class T>
const T& beamlinereco::CFDHitFinder< T >::GetPedestal ( ) const
inline

Definition at line 98 of file CFDHitFinderAlg.h.

Referenced by beamlinereco::CFDHitReco::produce().

template<class T >
void beamlinereco::CFDHitFinder< T >::Go ( )
virtual

Definition at line 587 of file CFDHitFinderAlg.h.

Referenced by beamlinereco::CFDHitReco::produce().

587  {
588  if (_WaveformADCNanosec.size() == 0) return;
589 
590  FindPedestal(); // Get pedestal and noise band sigma
591  FindRawHitLogic(); // From pedestal and noise band, get rawHitThreshold and RawHitLogic vector
592  FindCFDHits(); // From RawHitLogic vector, get hitPeakValue and hitPeakTimeIndex. From hitPeakValue and pedestal, get cfdHitThresholdValue. Go back from hitPeakTimeIndex to the point when
593 }
std::vector< T > _WaveformADCNanosec
template<class T >
T beamlinereco::CFDHitFinder< T >::IntegrateWaveformInADC ( size_t  hitStartTimeIndex,
size_t  hitEndTimeIndex 
)
privatevirtual

Definition at line 432 of file CFDHitFinderAlg.h.

References MECModelEnuComparisons::i, beamlinereco::kIntergratedWindowFixed, beamlinereco::kIntergratedWindowLowerLimitIndex, beamlinereco::kIntergratedWindowUpperLimitIndex, beamlinereco::kNSamplingPoints, and T.

432  {
433 
434  T integration = 0;
435 
437  hitStartTimeIndex = hitStartTimeIndex < 0 ? 0 : hitStartTimeIndex;
438  hitEndTimeIndex = hitEndTimeIndex > (_CFDParamSet[kNSamplingPoints] - 1) ? _CFDParamSet[kNSamplingPoints] - 1 : hitEndTimeIndex;
439  for (size_t i = hitStartTimeIndex; i <= hitEndTimeIndex; i++) {
440  integration = integration + (_WaveformADCNanosec.at(i) - _PedestalInADC);
441  }
442  } else {
444  integration = integration + (_WaveformADCNanosec.at(i) - _PedestalInADC);
445  }
446  }
447 
448  return integration;
449 }
std::vector< T > _WaveformADCNanosec
std::map< CFDParams, T > _CFDParamSet
double T
Definition: Xdiff_gwt.C:5
template<class T>
virtual void beamlinereco::CFDHitFinder< T >::Reset ( )
inlineprivatevirtual

Definition at line 136 of file CFDHitFinderAlg.h.

136  {
137  _HitCollection.clear();
138  _RawHitLogicNanosec.clear();
139  _PedestalInADC = 0;
140  _NoiseSigmaInADC = 0;
142  _WaveformADCNanosec.clear();
143  _ChannelNumber = 993;
144  _Timestamp = 0;
146  }
std::map< T, hit_t< T > > _HitCollection
std::vector< T > _WaveformADCNanosec
std::vector< T > _NonfilterWaveformADCNanosec
std::vector< bool > _RawHitLogicNanosec
template<class T >
void beamlinereco::CFDHitFinder< T >::SetChannel ( unsigned int  channelNo)
private

Definition at line 217 of file CFDHitFinderAlg.h.

217  {
218  _ChannelNumber = channelNo;
219 }
template<class T >
void beamlinereco::CFDHitFinder< T >::SetDiscriminationType ( const std::string  type)

Definition at line 232 of file CFDHitFinderAlg.h.

232  {
234 }
template<class T >
void beamlinereco::CFDHitFinder< T >::SetFilterType ( const std::string  type)

Definition at line 237 of file CFDHitFinderAlg.h.

237  {
238  _FilterType = type;
239 }
template<class T >
void beamlinereco::CFDHitFinder< T >::SetInterpolationType ( const std::string  type)

Definition at line 227 of file CFDHitFinderAlg.h.

227  {
229 }
template<class T>
void beamlinereco::CFDHitFinder< T >::SetParam ( CFDParams  param,
T  value 
)
private

Definition at line 205 of file CFDHitFinderAlg.h.

References ParseFluxesFile::param.

205  {
207 }
std::map< CFDParams, T > _CFDParamSet
const XML_Char int const XML_Char * value
Definition: expat.h:331
template<class T >
void beamlinereco::CFDHitFinder< T >::SetParams ( const std::map< CFDParams, double > &  paramSet)

Definition at line 210 of file CFDHitFinderAlg.h.

Referenced by beamlinereco::CFDHitReco::reconfigure().

210  {
211  for (auto & itr : paramSet) {
212  SetParam(itr.first, itr.second);
213  }
214 }
void SetParam(CFDParams param, T value)
template<class T >
void beamlinereco::CFDHitFinder< T >::SetTimestamp ( uint32_t  timestamp)
private

Definition at line 222 of file CFDHitFinderAlg.h.

222  {
223  _Timestamp = ts;
224 }
template<class T >
void beamlinereco::CFDHitFinder< T >::SetWaveform ( std::vector< uint16_t > &  waveform,
unsigned int  channelNo,
uint32_t  timestamp 
)

Definition at line 154 of file CFDHitFinderAlg.h.

References art::errors::Configuration, allTimeWatchdog::endl, beamlinereco::Kalman::GetFilteredValue(), MECModelEnuComparisons::i, K, beamlinereco::kGSFilterDegree, beamlinereco::kGSFilterWindow, beamlinereco::kIsWaveformNegativePolarity, beamlinereco::kKalmanFilterGain, beamlinereco::kKalmanFilterMeasurementNoiseCovariance, beamlinereco::kKalmanFilterProcessNoiseCovariance, beamlinereco::kNSamplingPoints, P, r(), slidt::Reset(), beamlinereco::SGSmoothing::Smooth(), and T.

Referenced by beamlinereco::CFDHitReco::produce().

154  {
155  Reset();
156 
157  SetChannel(channelNo);
159 
160  double polaritySignFactor = _CFDParamSet[kIsWaveformNegativePolarity] ? 1. : -1.;
161 
162  T* nonfilterwaveform = (T*) malloc(_CFDParamSet[kNSamplingPoints] * sizeof(T));
163  T* filterwaveform = (T*) malloc(_CFDParamSet[kNSamplingPoints] * sizeof(T));
164 
165  for (auto itr = waveform.begin(); itr != waveform.end(); itr++) {
166  _NonfilterWaveformADCNanosec.push_back((T)(*itr) * polaritySignFactor);
167  nonfilterwaveform[itr - waveform.begin()] = (T)(*itr) * polaritySignFactor;
168  }
169 
170  if (_FilterType == "GS" || _FilterType == "gs") { // Savitzky-Golay smoothing
172  nonfilterwaveform,
173  filterwaveform,
176  } else if (_FilterType == "Kalman" || _FilterType == "kalman" || _FilterType == "KALMAN") { // Kalman filter
179  float P = .05;
181  Kalman filter = Kalman(q,r,P,K);
182  for (unsigned int i=0; i<_CFDParamSet[kNSamplingPoints]; i++) {
183  filterwaveform[i] = filter.GetFilteredValue(nonfilterwaveform[i]);
184  }
185  } else if (_FilterType == "" || _FilterType == "None" || _FilterType == "none" || _FilterType == "NONE") {
186  // no smoothing
187  for (auto itr = waveform.begin(); itr != waveform.end(); itr++) {
188  filterwaveform[itr - waveform.begin()] = (T)(*itr) * polaritySignFactor;
189  }
190  } else {
191  // unknown -- throw exception
193  << "Unknown raw hit finder filter type: " << _FilterType << "." << std::endl;
194  }
195 
196  for (size_t i = 0; i < _CFDParamSet[kNSamplingPoints]; i++) {
197  _WaveformADCNanosec.push_back(*(filterwaveform + i));
198  }
199 
200  free(nonfilterwaveform);
201  free(filterwaveform);
202 }
std::vector< T > _WaveformADCNanosec
static void Smooth(size_t nsamples, double *in, double *out, const int w, const int deg)
std::map< CFDParams, T > _CFDParamSet
Module that kips a configurable number of events between each that it allows through. Note that this module really skips (N-1) events, it uses a simple modular division as its critera. This module will cut down the data sample to 1/N of its original size.
Double_t K
#define P(a, b, c, d, e, x)
void SetChannel(unsigned int channelNo)
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::vector< T > _NonfilterWaveformADCNanosec
TRandom3 r(0)
double T
Definition: Xdiff_gwt.C:5
void SetTimestamp(uint32_t timestamp)

Member Data Documentation

template<class T>
std::map<CFDParams, T> beamlinereco::CFDHitFinder< T >::_CFDParamSet
private

Definition at line 123 of file CFDHitFinderAlg.h.

template<class T>
unsigned int beamlinereco::CFDHitFinder< T >::_ChannelNumber
private

Definition at line 111 of file CFDHitFinderAlg.h.

template<class T>
T beamlinereco::CFDHitFinder< T >::_DiscriminationThresholdInADC
private

Definition at line 121 of file CFDHitFinderAlg.h.

template<class T>
std::string beamlinereco::CFDHitFinder< T >::_DiscriminationType
private

Definition at line 113 of file CFDHitFinderAlg.h.

template<class T>
std::string beamlinereco::CFDHitFinder< T >::_FilterType
private

Definition at line 115 of file CFDHitFinderAlg.h.

template<class T>
std::map<T, hit_t<T> > beamlinereco::CFDHitFinder< T >::_HitCollection
private

Definition at line 124 of file CFDHitFinderAlg.h.

template<class T>
std::string beamlinereco::CFDHitFinder< T >::_InterpolationType
private

Definition at line 114 of file CFDHitFinderAlg.h.

template<class T>
T beamlinereco::CFDHitFinder< T >::_NoiseSigmaInADC
private

Definition at line 120 of file CFDHitFinderAlg.h.

template<class T>
std::vector<T> beamlinereco::CFDHitFinder< T >::_NonfilterWaveformADCNanosec
private

Definition at line 117 of file CFDHitFinderAlg.h.

template<class T>
T beamlinereco::CFDHitFinder< T >::_PedestalInADC
private

Definition at line 119 of file CFDHitFinderAlg.h.

template<class T>
std::vector<bool> beamlinereco::CFDHitFinder< T >::_RawHitLogicNanosec
private

Definition at line 118 of file CFDHitFinderAlg.h.

template<class T>
uint32_t beamlinereco::CFDHitFinder< T >::_Timestamp
private

Definition at line 112 of file CFDHitFinderAlg.h.

template<class T>
std::vector<T> beamlinereco::CFDHitFinder< T >::_WaveformADCNanosec
private

Definition at line 116 of file CFDHitFinderAlg.h.


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