Cheetah - SKA - PSS - Prototype Time Domain Search Pipeline
RfiDetectionPipeline.h
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 #ifndef SKA_CHEETAH_PIPELINE_RFIDETECTIONPIPELINE_H
25 #define SKA_CHEETAH_PIPELINE_RFIDETECTIONPIPELINE_H
26 
27 #include "cheetah/pipeline/PipelineHandler.h"
28 #include "cheetah/rfim/Rfim.h"
29 #include "cheetah/rfim/policy/LastUnflagged.h"
30 #include "cheetah/channel_mask/ConfigurableChannelMask.h"
31 #include "cheetah/channel_mask/PolicyFactory.h"
32 #include "panda/ModuloNumber.h"
33 
34 namespace ska {
35 namespace cheetah {
36 namespace pipeline {
37 
38 template<typename NumericalT>
39 class CheetahConfig;
40 
41 template<typename NumericalT>
42 class BeamConfig;
43 
44 namespace {
45  class NullHandler
46  {
47  public:
48  template<typename TimeFrequencyType>
49  inline void operator()(TimeFrequencyType) {}
50  };
51 }
52 
57 template<typename NumericalT, typename RfimOutputHandler=NullHandler, typename RfiPolicy=rfim::LastUnflagged<typename PipelineHandler<NumericalT>::TimeFrequencyType>>
58 class RfiDetectionPipeline : public PipelineHandler<NumericalT>
59 {
61 
62  public:
64 
65  public:
66  template<typename... HandlerArgs>
67  RfiDetectionPipeline(CheetahConfig<NumericalT> const& config, BeamConfig<NumericalT> const& beam_config, HandlerArgs&&...);
68  virtual ~RfiDetectionPipeline();
69 
70  void operator()(TimeFrequencyType&) override;
71 
73  RfimOutputHandler& output_handler();
74 
75  private:
76  class RfiOutputHandler {
77  typedef typename rfim::PolicyInfo<RfiPolicy>::ReturnType ReturnType;
78 
79  public:
80  template<typename... HandlerArgs>
81  RfiOutputHandler(RfiDetectionPipeline&, HandlerArgs&&...);
82  inline void operator()(ReturnType);
83 
84  RfiDetectionPipeline& _pipeline;
85  RfimOutputHandler _output; // user defined RfimOutputHandler
86  };
87 
88  class BandPassOutputHandler {
89  typedef rfim::ampp::Spectrum<NumericalT> BandPassType;
90 
91  public:
92  BandPassOutputHandler(RfiDetectionPipeline&);
93  inline void operator()(BandPassType const&);
94 
95  private:
96  RfiDetectionPipeline& _pipeline;
97  };
98 
99  struct RfimTraits {
100  typedef RfiOutputHandler RfimHandler;
101  typedef BandPassOutputHandler BandPassHandler;
102  typedef RfiPolicy Policy;
103  typedef NumericalT NumericalRep;
104  };
105 
107 
108  public:
109  typedef typename RfimType::ReturnType ReturnType;
110 
111  private:
113  RfiOutputHandler _rfim_handler;
114  BandPassOutputHandler _bandpass_handler;
115  RfimType _rfim;
116  std::vector<TimeFrequencyType*> _data_sequence;
117  panda::AtomicModuloNumber<unsigned, std::memory_order_relaxed> _last_data_sequence_index;
118  panda::AtomicModuloNumber<unsigned, std::memory_order_relaxed> _next_data_sequence_index;
119 };
120 
121 } // namespace pipeline
122 } // namespace cheetah
123 } // namespace ska
124 #include "detail/RfiDetectionPipeline.cpp"
125 
126 #endif // SKA_CHEETAH_PIPELINE_RFIDETECTIONPIPELINE_H
std::conditional< std::is_same< void, AdapterDataReturnType >::value, DataArgumentType, AdapterDataReturnType >::type ReturnType
the data type the policy will return
Definition: PolicyInfo.h:67
Some limits and constants for FLDO.
Definition: Brdz.h:35
Parse configuration parameters for a single beam in the pipeline instance of cheetah.
Definition: BeamConfig.h:48
Base class for Cheetah Pipeline Handlers.
Definition: Pipeline.h:37
Pipeline that performs only RFI detection.
A single dimension representation of the bandPass.
Definition: Spectrum.h:42