RdStationTimeWindowConsolidator.cc
Go to the documentation of this file.
2 
3 #include <fwk/CentralConfig.h>
4 
5 #include <utl/Branch.h>
6 #include <utl/ErrorLogger.h>
7 
8 #include <evt/Event.h>
9 #include <revt/REvent.h>
10 #include <revt/Channel.h>
11 #include <revt/StationRecData.h>
12 
13 #include <string>
14 
15 
16 using namespace evt;
17 using namespace revt;
18 using namespace std;
19 using namespace utl;
20 using namespace fwk;
21 
22 
23 namespace RdStationTimeWindowConsolidatorOG {
24 
25 
28  {
29  Branch topBranch =
30  CentralConfig::GetInstance()->GetTopBranch("RdStationTimeWindowConsolidator");
31 
32  topBranch.GetChild("InfoLevel").GetData(fInfoLevel);
33  fRejectStationIfWindowTruncated =
34  (topBranch.GetChild("RejectStationIfSignalSearchWindowTruncated").Get<string>() == "yes");
35 
36  return eSuccess;
37  }
38 
39 
41  RdStationTimeWindowConsolidator::Run(Event& event)
42  {
43  if (!event.HasREvent())
44  return eSuccess;
45 
46  REvent& rEvent = event.GetREvent();
47 
48  for (auto& station : rEvent.StationsRange()) {
49  if (!station.HasRecData())
50  continue;
51 
52  StationRecData& recData = station.GetRecData();
53 
54  if (!recData.HasParameter(eSignalSearchWindowStart)) {
55  ostringstream err;
56  err << "Trying to consolidate signal search window start-time for "
57  << "station id=" << station.GetId() << ", but no signal search "
58  << "window information available in ParameterStorage!";
59  ERROR(err);
60  return eFailure;
61  }
62 
63  // by default, the signal search windows have not been truncated
64  bool windowTruncated = false;
65 
66  // fixme TH: why do we obey the trace stop time (but interpret it as inclusive rather than exclusive), but not the trace start time?
67  double maximaltime = 0;
68 
69  for(const auto& channel : station.ChannelsRange()) {
70  if(!channel.IsActive())
71  continue;
72 
73  const double tsstop = channel.GetChannelTimeSeries().GetStop()
74  * channel.GetChannelTimeSeries().GetBinning();
75  if(maximaltime < tsstop)
76  maximaltime = tsstop;
77  }
78 
79  // retrieve currently stored signal search window of the station
80  double searchWindowStart = recData.GetParameter(eSignalSearchWindowStart);
81  double searchWindowStop = recData.GetParameter(eSignalSearchWindowStop);
82 
83  ostringstream info;
84  info << "Signal seach window of station " << station.GetId() << ": "
85  << searchWindowStart << " to " << searchWindowStop;
86  INFODebug(info);
87 
88  // check start time
89  if(searchWindowStart < 0) {
90  if(fRejectStationIfWindowTruncated) {
91  INFOFinal("eSignalSearchWindowStart < 0, rejecting station" + to_string(station.GetId()));
92  station.SetRejectedReason(eSignalSearchWindowInvalid);
93  } else {
94  searchWindowStart = 0;
95  windowTruncated = true;
96  }
97  }
98 
99  // check stop time
100  if(searchWindowStop > maximaltime) {
101  if(fRejectStationIfWindowTruncated) {
102  INFOFinal("End of the signal window after trace end, rejecting station" +
103  to_string(station.GetId()));
104  station.SetRejectedReason(eSignalSearchWindowInvalid);
105 
106  ostringstream info;
107  info << "searchWindowStop ( " << searchWindowStop << " ) > maximaltime ( "
108  << maximaltime << " )";
109  INFODebug(info);
110  } else {
111  searchWindowStop = maximaltime;
112  windowTruncated = true;
113  }
114  }
115 
116  // reject a station completely if no part of the signalsearchwindow is in the trace
117  if(searchWindowStart >= maximaltime || searchWindowStop <= 0) {
118  ostringstream info;
119  info << "No part of the signal search window (" << searchWindowStart / ns
120  << " to " << searchWindowStop / ns << " ns) is inside the trace."
121  << " Rejecting station " << station.GetId();
122  INFOFinal(info);
123  station.SetRejectedReason(eSignalSearchWindowInvalid);
124  }
125 
126  // store the consolidated values in the parameter storage
127  recData.SetParameter(eSignalSearchWindowStart, searchWindowStart, false);
128  recData.SetParameter(eSignalSearchWindowStop, searchWindowStop, false);
129 
130  //store information whether signal search window has been truncated
131  recData.SetParameter(eSignalSearchWindowTruncated, windowTruncated);
132 
133  if (windowTruncated)
134  fStationsWithTruncatedWindows++;
135  }
136 
137  return eSuccess;
138  }
139 
140 
142  RdStationTimeWindowConsolidator::Finish()
143  {
144  ostringstream info;
145  info << "Found " << fStationsWithTruncatedWindows
146  << " stations with a truncated signal search window.";
147  INFO(info);
148 
149  return eSuccess;
150  }
151 
152 }
Branch GetTopBranch() const
Definition: Branch.cc:63
Class to access station level reconstructed data.
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
const double ns
void GetData(bool &b) const
Overloads of the GetData member template function.
Definition: Branch.cc:644
#define INFODebug(y)
Definition: VModule.h:163
double GetParameter(const Parameter i) const
ResultFlag
Flag returned by module methods to the RunController.
Definition: VModule.h:60
bool HasParameter(const Parameter i) const
void SetParameter(Parameter i, double value, bool lock=true)
#define INFOFinal(y)
Definition: VModule.h:161
#define ERROR(message)
Macro for logging error messages.
Definition: ErrorLogger.h:165

, generated on Tue Sep 26 2023.