HannWindow.h
Go to the documentation of this file.
1 #ifndef _utl_HannWindow_h_
2 #define _utl_HannWindow_h_
3 
12 #include <utl/AnalyticWindow.h>
13 #include <utl/AugerException.h>
14 #include <utl/PhysicalConstants.h>
15 #include <cmath>
16 
17 namespace utl {
18 
27  class HannWindow : public AnalyticWindow {
28  public:
29  HannWindow(double relativeWidthOnEachSide, long traceLength = 0);
30  virtual ~HannWindow();
31  virtual double GetWeightAtBin(long parBin) const;
32  virtual void SetTraceLength(long parTraceLength);
33  protected:
34  double fRise;
35  double fFall;
37  };
38 
39  inline
40  double HannWindow::GetWeightAtBin(long parBin) const
41  {
42  if ((parBin < 0) || (parBin >= fTraceLength))
43  throw(OutOfBoundException("Bin is outside of trace."));
44  if (parBin < fRise)
45  return 0.5 * (1 - std::cos(2 * kPi * parBin / (fWindowSize-1)));
46  else if (parBin > fFall)
47  return 0.5 * (1 - std::cos(2 * kPi * (long(parBin - fFall + fRise)) / (fWindowSize-1)));
48  else
49  return 1.0;
50  }
51 
52  inline
53  void HannWindow::SetTraceLength(long parTraceLength)
54  {
55  fTraceLength = parTraceLength;
58  fWindowSize = 2 * long(fRise);
59  fRenormalizationFactor = 0.0; // delete cached renormalization factor (will usually only change slightly with trace length, but anyway ...)
60  }
61 
62 } // utl
63 
64 #endif
virtual double GetWeightAtBin(long parBin) const
Definition: HannWindow.h:40
Abstract base class for analytic windows.
Definition: HannWindow.h:27
Exception for reporting variable out of valid range.
constexpr double kPi
Definition: MathConstants.h:24
HannWindow(double relativeWidthOnEachSide, long traceLength=0)
Definition: HannWindow.cc:9
virtual void SetTraceLength(long parTraceLength)
Definition: HannWindow.h:53
double fRelativeWidthOnEachSide
virtual ~HannWindow()
Definition: HannWindow.cc:17
Abstract base class for analytic windows.

, generated on Tue Sep 26 2023.