RdChannelTimeSeriesTaperer.cc
Go to the documentation of this file.
2 
3 #include <fwk/CentralConfig.h>
4 
5 #include <utl/config.h>
6 #include <utl/ErrorLogger.h>
7 #include <utl/Reader.h>
8 #include <utl/HannWindow.h>
9 
10 #include <evt/Event.h>
11 #include <revt/REvent.h>
12 #include <revt/Channel.h>
13 #include <revt/Station.h>
14 
15 
16 using namespace revt;
17 using namespace fwk;
18 using namespace utl;
19 using namespace std;
20 
21 
23 
26  {
27  Branch topBranch =
28  CentralConfig::GetInstance()->GetTopBranch("RdChannelTimeSeriesTaperer");
29  topBranch.GetChild("RelativeWindowWidthOnEachSide").GetData(fWindowSizeOnEachSide);
30  topBranch.GetChild("Renormalize").GetData(fRenormalize);
31 
32  string tmpstring = topBranch.GetChild("WindowType").Get<string>();
33  if (tmpstring == "Hann") {
34  fWindowType = Hann;
35  fWindow = new HannWindow(fWindowSizeOnEachSide);
36  }
37 
38  ostringstream info;
39  info << "Channel TimeSeries Windower is set up as " << tmpstring
40  << " window with a relative width of " << fWindowSizeOnEachSide
41  << " on each side.\n";
42  INFO(info);
43 
44  return eSuccess;
45  }
46 
47 
49  RdChannelTimeSeriesTaperer::Run(evt::Event& event)
50  {
51  // Check if there are events at all
52  if(!event.HasREvent()) {
53  WARNING("No radio event found!");
54  return eContinueLoop;
55  }
56 
57  REvent& rEvent = event.GetREvent();
58 
59  // loop through stations and for every station through every channel
60  for (auto& station : rEvent.StationsRange()) {
61  for (auto& channel : station.ChannelsRange()) {
62 
63  if (!channel.IsActive())
64  continue;
65 
66  // Work on the time series this channel
67  ChannelTimeSeries& timeSeries = channel.GetChannelTimeSeries();
68 
69  // set the trace length of the window for the specific channel
70  fWindow->SetTraceLength(timeSeries.GetSize());
71 
72  // apply the window
73  for (ChannelTimeSeries::SizeType i = 0; i < timeSeries.GetSize(); ++i) {
74  timeSeries[i] *= fWindow->GetWeightAtBin(i);
75  if (fRenormalize)
76  timeSeries[i] *= fWindow->GetRenormalizationFactor();
77  }
78  }
79  }
80 
81  return eSuccess;
82  }
83 
84 
86  RdChannelTimeSeriesTaperer::Finish()
87  {
88  delete fWindow;
89 
90  return eSuccess;
91  }
92 
93 }
Branch GetTopBranch() const
Definition: Branch.cc:63
Abstract base class for analytic windows.
Definition: HannWindow.h:27
Interface class to access to the Radio part of an event.
Definition: REvent.h:42
#define INFO(message)
Macro for logging informational messages.
Definition: ErrorLogger.h:161
void Init()
Initialise the registry.
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
Definition: Branch.cc:211
bool HasREvent() const
T Get() const
Definition: Branch.h:271
Class representing a document branch.
Definition: Branch.h:107
std::vector< double >::size_type SizeType
Definition: Trace.h:58
SizeType GetSize() const
Definition: Trace.h:156
#define WARNING(message)
Macro for logging warning messages.
Definition: ErrorLogger.h:163
void GetData(bool &b) const
Overloads of the GetData member template function.
Definition: Branch.cc:644
ResultFlag
Flag returned by module methods to the RunController.
Definition: VModule.h:60

, generated on Tue Sep 26 2023.