testAnalyticWindows.cc
Go to the documentation of this file.
1 
8 #include <iostream>
9 
10 #include <tst/Verify.h>
11 
12 #include <revt/Channel.h>
13 #include <revt/Station.h>
14 #include <utl/HannWindow.h>
15 #include <utl/AugerException.h>
16 #include <utl/AugerUnits.h>
17 #include <utl/PhysicalConstants.h>
18 #include <cmath>
19 
20 #include <cppunit/extensions/HelperMacros.h>
21 
22 using namespace std;
23 using namespace utl;
24 using namespace tst;
25 using namespace revt;
26 
27 
31 class testAnalyticWindows : public CppUnit::TestFixture {
32 
33  CPPUNIT_TEST_SUITE(testAnalyticWindows);
34  CPPUNIT_TEST(testHannWindow);
35  CPPUNIT_TEST_SUITE_END();
36 
37 private:
38 
39 public:
40  void
42  {
43  }
44 
45  void
47  {
48  }
49 
50  void
52  {
53  long traceLength = 1000;
54  double windowWidth = 0.1;
55 
56  HannWindow ourWindow(windowWidth, traceLength);
57 
58  // check edges of the window
59  CPPUNIT_ASSERT(Verify<CloseTo>(ourWindow.GetWeightAtBin(long(windowWidth*traceLength)+1),1.0));
60  CPPUNIT_ASSERT(Verify<CloseTo>(ourWindow.GetWeightAtBin(traceLength-long(windowWidth*traceLength+1)),1.0));
61  CPPUNIT_ASSERT(Verify<CloseTo>(ourWindow.GetWeightAtBin(0),0.0));
62  CPPUNIT_ASSERT(Verify<CloseTo>(ourWindow.GetWeightAtBin(traceLength-1),0.0));
63 
64  double testLocation = 0.3; // relative location inside each side of the Hann window to test for
65 
66  // check weights inside the window
67  CPPUNIT_ASSERT(Verify<CloseTo>(ourWindow.GetWeightAtBin(testLocation*long(windowWidth*traceLength)),0.5*(1-std::cos(2*kPi*testLocation*long(windowWidth*traceLength)/(long(2*windowWidth*traceLength)-1)))));
68  CPPUNIT_ASSERT(Verify<CloseTo>(ourWindow.GetWeightAtBin(traceLength-1-(testLocation*long(windowWidth*traceLength))),0.5*(1-std::cos(2*kPi*testLocation*long(windowWidth*traceLength)/(long(2*windowWidth*traceLength)-1)))));
69 
70  // redefine trace length of Hann window
71  traceLength = 2500;
72  ourWindow.SetTraceLength(traceLength);
73 
74  // check redefinition of trace length
75  CPPUNIT_ASSERT(Verify<Equal>(ourWindow.GetTraceLength(),traceLength));
76 
77  testLocation = 0.4; // relative location inside each side of the Hann window to test for
78 
79  // check weights inside the window with the new trace length
80  CPPUNIT_ASSERT(Verify<CloseTo>(ourWindow.GetWeightAtBin(testLocation*long(windowWidth*traceLength)),0.5*(1-std::cos(2*kPi*testLocation*long(windowWidth*traceLength)/(long(2*windowWidth*traceLength)-1)))));
81  CPPUNIT_ASSERT(Verify<CloseTo>(ourWindow.GetWeightAtBin(traceLength-1-(testLocation*long(windowWidth*traceLength))),0.5*(1-std::cos(2*kPi*testLocation*long(windowWidth*traceLength)/(long(2*windowWidth*traceLength)-1)))));
82  }
83 
84 };
85 
87 
88 // Configure (x)emacs for this file ...
89 // Local Variables:
90 // mode: c++
91 // End:
virtual double GetWeightAtBin(long parBin) const
Definition: HannWindow.h:40
Abstract base class for analytic windows.
Definition: HannWindow.h:27
virtual long GetTraceLength() const
CPPUNIT_TEST_SUITE_REGISTRATION(testAiresShowerFile)
constexpr double kPi
Definition: MathConstants.h:24
virtual void SetTraceLength(long parTraceLength)
Definition: HannWindow.h:53

, generated on Tue Sep 26 2023.