Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
SiftTester.cpp
1 /*
2  * The MIT License (MIT)
3  *
4  * Copyright (c) 2016 The SKA organisation
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in all
14  * copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
24 #include "cheetah/sift/test_utils/SiftTester.h"
25 #include "cheetah/data/Ccl.h"
26 #include "cheetah/data/Scl.h"
27 #include "cheetah/utils/Architectures.h"
28 #include "panda/Log.h"
29 
30 namespace ska {
31 namespace cheetah {
32 namespace sift {
33 namespace test {
34 
35 template<typename SiftAlgo>
36 void SiftTesterTraits<SiftAlgo>::SiftHandler::operator()(std::shared_ptr<data::Scl> data)
37 {
38  ASSERT_TRUE(data.get() != nullptr);
39  _data = data;
40  static_cast<BaseT&>(*this)();
41 }
42 
43 template<typename SiftAlgo>
44 typename SiftTesterTraits<SiftAlgo>::Api& SiftTesterTraits<SiftAlgo>::api(PoolType& pool)
45 {
46  if(!_api)
47  {
48  _config.pool(pool);
49  _config.template config<typename SiftAlgo::Config>().active(true);
50  _api.reset(new Api(_config, _handler));
51  }
52  return *_api;
53 }
54 
55 template<typename SiftAlgo>
56 typename SiftTesterTraits<SiftAlgo>::SiftHandler& SiftTesterTraits<SiftAlgo>::handler()
57 {
58  return _handler;
59 }
60 
61 template<typename SiftAlgo>
62 typename SiftTesterTraits<SiftAlgo>::TestConfig& SiftTesterTraits<SiftAlgo>::config()
63 {
64  return _config;
65 }
66 
67 template <typename SiftAlgo>
69 {
70  inline static void test(SiftAlgo& api)
71  {
72  data::Ccl::CandidateType::MsecTimeType candidate1_period_val(0.050 * boost::units::si::seconds);
73  data::Ccl::CandidateType::SecPerSecType candidate1_pdot_val = 0.00000000000001;
74  data::Ccl::CandidateType::Dm candidate1_dm_val = 5 * data::parsecs_per_cube_cm;
75  data::Ccl::CandidateType::MsecTimeType candidate1_width_val(0.001 * boost::units::si::seconds);
76  data::Ccl::CandidateType candidate1(candidate1_period_val, candidate1_pdot_val, candidate1_dm_val, candidate1_width_val, 10., 1);
77 
78  data::Ccl::CandidateType::MsecTimeType candidate1_harm_period_val(0.100 * boost::units::si::seconds);
79  data::Ccl::CandidateType::SecPerSecType candidate1_harm_pdot_val = 0.00000000000001;
80  data::Ccl::CandidateType::Dm candidate1_harm_dm_val = 5 * data::parsecs_per_cube_cm;
81  data::Ccl::CandidateType::MsecTimeType candidate1_harm_width_val(0.001 * boost::units::si::seconds);
82  data::Ccl::CandidateType candidate1_harm(candidate1_harm_period_val, candidate1_harm_pdot_val, candidate1_harm_dm_val, candidate1_harm_width_val, 5., 2);
83 
84  data::Ccl::CandidateType::MsecTimeType candidate2_period_val(0.033 * boost::units::si::seconds);
85  data::Ccl::CandidateType::SecPerSecType candidate2_pdot_val = 0.00000000000001;
86  data::Ccl::CandidateType::Dm candidate2_dm_val = 95 * data::parsecs_per_cube_cm;
87  data::Ccl::CandidateType::MsecTimeType candidate2_width_val(0.0005 * boost::units::si::seconds);
88  data::Ccl::CandidateType candidate2(candidate2_period_val, candidate2_pdot_val, candidate2_dm_val, candidate2_width_val, 100., 3);
89 
90  data::Ccl::CandidateType::MsecTimeType candidate2_harm_period_val(0.231 * boost::units::si::seconds);
91  data::Ccl::CandidateType::SecPerSecType candidate2_harm_pdot_val = 0.00000000000001;
92  data::Ccl::CandidateType::Dm candidate2_harm_dm_val = 95 * data::parsecs_per_cube_cm;
93  data::Ccl::CandidateType::MsecTimeType candidate2_harm_width_val(0.0005 * boost::units::si::seconds);
94  data::Ccl::CandidateType candidate2_harm(candidate2_harm_period_val, candidate2_harm_pdot_val, candidate2_harm_dm_val, candidate2_harm_width_val, 10., 4);
95 
96  data::Ccl::CandidateType::MsecTimeType candidate3_period_val(0.027467 * boost::units::si::seconds);
97  data::Ccl::CandidateType::SecPerSecType candidate3_pdot_val = 0.00000000000001;
98  data::Ccl::CandidateType::Dm candidate3_dm_val = 29 * data::parsecs_per_cube_cm;
99  data::Ccl::CandidateType::MsecTimeType candidate3_width_val(0.00005 * boost::units::si::seconds);
100  data::Ccl::CandidateType candidate3(candidate3_period_val, candidate3_pdot_val, candidate3_dm_val, candidate3_width_val, 12., 5);
101 
102  data::Ccl::CandidateType::MsecTimeType candidate4_period_val(0.10982 * boost::units::si::seconds);
103  data::Ccl::CandidateType::SecPerSecType candidate4_pdot_val = 0.00000000000001;
104  data::Ccl::CandidateType::Dm candidate4_dm_val = 95 * data::parsecs_per_cube_cm;
105  data::Ccl::CandidateType::MsecTimeType candidate4_width_val(0.0009 * boost::units::si::seconds);
106  data::Ccl::CandidateType candidate4(candidate4_period_val, candidate4_pdot_val, candidate4_dm_val, candidate4_width_val, 7., 6);
107 
108  std::shared_ptr<data::Ccl> ccl(new data::Ccl());;
109  ccl->push_back(candidate1);
110  ccl->push_back(candidate1_harm);
111  ccl->push_back(candidate2);
112  ccl->push_back(candidate2_harm);
113  ccl->push_back(candidate3);
114  ccl->push_back(candidate4);
115 
116  api(ccl);
117 
118 
119 // ASSERT_EQ((*scl)[0].period(), ccl[0].period());
120 // ASSERT_EQ((*scl)[1].period(), ccl[1].period());
121 // ASSERT_EQ((*scl)[2].period(), ccl[2].period());
122 // ASSERT_EQ((*scl)[3].period(), ccl[3].period());
123 
124  }
125 };
126 
127 template <typename TestTraits>
130 {
131 }
132 
133 template <typename TestTraits>
135 {
136 }
137 
138 template<typename TestTraits>
140 {
141 }
142 
143 template<typename TestTraits>
145 {
146 }
147 
148 POOL_ALGORITHM_TYPED_TEST_P(SiftTester, test_execution)
149 {
150  TypeParam traits;
152  ASSERT_TRUE(traits.handler().wait(std::chrono::seconds(5))) << "timed out waiting for handler to be called";
153 
154  auto const& scl = *traits.handler().data();
155  ASSERT_EQ(scl.size(), std::size_t(4));
156 }
157 
158 // each test defined by ALGORITHM_TYPED_TEST_P must be added to the
159 // test register (each one as an element of the comma seperated list)
160 REGISTER_TYPED_TEST_CASE_P(SiftTester, test_execution);
161 
162 } // namespace test
163 } // namespace sift
164 } // namespace cheetah
165 } // namespace ska
Some limits and constants for FLDO.
Definition: Brdz.h:35
Candidate list.
Definition: Ccl.h:45
A simple record to hold &#39;candidate&#39; proprerties.
Definition: Candidate.h:60