RdChannelTimeSeriesWindowCutter.cc
Go to the documentation of this file.
2 
3 #include <fwk/CentralConfig.h>
4 
5 #include <utl/Branch.h>
6 #include <utl/config.h>
7 #include <utl/ErrorLogger.h>
8 
9 #include <evt/Event.h>
10 
11 #include <revt/REvent.h>
12 #include <revt/Station.h>
13 #include <revt/Channel.h>
14 #include <revt/StationRecData.h>
15 
16 
17 using namespace revt;
18 using namespace fwk;
19 using namespace utl;
20 using namespace std;
21 
22 
24 
27  {
28  Branch topBranch = CentralConfig::GetInstance()->GetTopBranch("RdChannelTimeSeriesWindowCutter");
29  topBranch.GetChild("InfoLevel").GetData(fInfoLevel);
30  topBranch.GetChild("WindowSize").GetData(fWindowSize);
31  topBranch.GetChild("WindowStart").GetData(fWindowStart);
32 
33  return eSuccess;
34  }
35 
36 
38  RdChannelTimeSeriesWindowCutter::Run(evt::Event& event)
39  {
40  // Check if there are events at all
41  if(!event.HasREvent()) {
42  WARNING("No radio event found!");
43  return eContinueLoop;
44  }
45 
46  REvent& rEvent = event.GetREvent();
47 
48  ostringstream info;
49 
50  // Loop through stations and channels
51  for (auto& station : rEvent.StationsRange()) {
52  for (auto& channel : station.ChannelsRange()) {
53 
54  if (!channel.IsActive()) // skip inactive channels
55  continue;
56 
57  // Work on the time trace of this channel
58  ChannelTimeSeries& timeSeries = channel.GetChannelTimeSeries();
59  const double binning = timeSeries.GetBinning();
60 
61  // Check if xml settings are sensible
62  if (fWindowStart > timeSeries.GetSize() * binning) {
63  info.str("");
64  info << "Station "<< station.GetId() << " Channel " << channel.GetId()
65  << " StartTime > Length of time series, not a good idea! Skip to next channel";
66  WARNING(info);
67 
68  continue;
69  }
70 
71  if (fWindowStart + fWindowSize > timeSeries.GetSize() * binning) {
72  info.str("");
73  info << "Station "<< station.GetId() << " Channel " << channel.GetId()
74  << " StopTime > Length of time series. Stop time will be set at end of the time series";
75  WARNING(info);
76 
77  fWindowSize = (timeSeries.GetSize() - 1) * binning - fWindowStart;
78  }
79 
80  ChannelTimeSeries tempTimeSeries;
81  tempTimeSeries.SetBinning(binning);
82 
83  // Clipping
84  const auto iBegin = ChannelTimeSeries::SizeType(fWindowStart / binning);
85  const auto iEnd = ChannelTimeSeries::SizeType((fWindowStart + fWindowSize) / binning);
86  for (auto i = iBegin; i < iEnd; ++i)
87  tempTimeSeries.PushBack(timeSeries[i]);
88  timeSeries = tempTimeSeries;
89  }
90 
91  // Redefining the start time (on station level)
92  const double traceStartTime = station.GetRecData().GetParameter(eTraceStartTime);
93 
94  // keep parameter open because it might be overwritten by other modules
95  station.GetRecData().SetParameter(eTraceStartTime, traceStartTime + fWindowStart, false);
96  }
97 
98  return eSuccess;
99  }
100 
101 
103  RdChannelTimeSeriesWindowCutter::Finish()
104  {
105  return eSuccess;
106  }
107 
108 }
Branch GetTopBranch() const
Definition: Branch.cc:63
Interface class to access to the Radio part of an event.
Definition: REvent.h:42
double GetBinning() const
size of one slot
Definition: Trace.h:138
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
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
void SetBinning(const double binning)
Definition: Trace.h:139
ResultFlag
Flag returned by module methods to the RunController.
Definition: VModule.h:60
void PushBack(const T &value)
Insert a single value at the end.
Definition: Trace.h:119

, generated on Tue Sep 26 2023.