RdDummyStationToChannelConverter.cc
Go to the documentation of this file.
2 
3 #include <fwk/CentralConfig.h>
4 
5 #include <utl/ErrorLogger.h>
6 #include <utl/Reader.h>
7 #include <utl/config.h>
8 #include <utl/TraceAlgorithm.h>
9 
10 #include <evt/Event.h>
11 #include <revt/REvent.h>
12 #include <revt/Station.h>
13 #include <revt/Channel.h>
14 #include <rdet/RDetector.h>
15 #include <rdet/Channel.h>
16 
17 
18 using namespace revt;
19 using namespace fwk;
20 using namespace utl;
21 using namespace std;
22 
24 
26  {
27  }
28 
29 
30  RdDummyStationToChannelConverter::~RdDummyStationToChannelConverter()
31  {
32  }
33 
34 
37  {
38  // Initialize your module here. This method
39  // is called once at the beginning of the run.
40  // The eSuccess flag indicates the method ended
41  // successfully. For other possible return types,
42  // see the VModule documentation.
43 
44  INFO("RdDummyStationToChannelConverter::Init()");
45 
46 
47  return eSuccess;
48  }
49 
50 
52  RdDummyStationToChannelConverter::Run(evt::Event& event)
53  {
54  // Check if there are events at all
55  if(!event.HasREvent()) {
56  WARNING("No radio event found!");
57  return eContinueLoop;
58  }
59 
60  REvent& rEvent = event.GetREvent();
61 
62  // loop through stations and for every station through every channel
63  for (REvent::StationIterator sIt = rEvent.StationsBegin();
64  sIt != rEvent.StationsEnd(); ++sIt) {
65  Station& station = *sIt;
66 // stringstream fMessage;
67  const revt::StationTimeSeries& stationtrace =
68  station.GetStationTimeSeries();
69 
70  for (Station::ChannelIterator cIt = station.ChannelsBegin();
71  cIt != station.ChannelsEnd(); ++cIt) {
72  Channel& channel = *cIt;
73 /* fMessage.str("");
74  fMessage << "Copying channel "
75  << channel.GetId()
76  << " over from the StationTimeSeries of station "
77  << channel.GetStationId()
78  << ".";
79  INFO(fMessage.str()); */
80 
81  // Work on the trace of this channel
82  revt::ChannelTimeSeries& channeltrace =
83  channel.GetChannelTimeSeries();
84 
85  // first clear the trace
86  channeltrace.Clear();
87  channeltrace.SetBinning(stationtrace.GetBinning());
88  channel.SetNyquistZone(station.GetNyquistZone());
89 
90  const rdet::RDetector& rDetector =
91  det::Detector::GetInstance().GetRDetector();
92  const rdet::Channel& detChannel =
93  rDetector.GetStation(station.GetId()).GetChannel(channel.GetId());
94  double orientAzimuth = detChannel.GetOrientationAzimuth();
95  double orientZenith = detChannel.GetOrientationZenith();
96 
97  if (orientAzimuth < 0 && orientAzimuth > -360 * deg)
98  orientAzimuth += 360 * deg;
99 
100  // Doing some kind of dodgy association of the channels to the coordinates
101  // The design-decision is that this module is only for testing purposes so
102  // a proper coordinate transformation is not done here.
103  stringstream fMessage;
104  fMessage.str("");
105  double alignMargin = 5*deg;
106  if ( orientZenith > alignMargin ) {
107  fMessage << "Encountering a channel that seems to be vertically aligned, not converting.";
108  WARNING(fMessage.str());
109  continue;
110  }
111 
112  double correspondingCoordinate; // Will always be initialized or ignored in the code below
113  double correspondingSign; // Will always be initialized or ignored in the code below
114  fMessage.str("");
115  fMessage << "Associating channel " << channel.GetId() << " for station " << station.GetId() << " at " <<
116  orientAzimuth/deg << " deg azimuthal angle";
117  if ( orientAzimuth < alignMargin or orientAzimuth > 360 * deg - alignMargin ) {
118  fMessage << "with a positive x coordinate.";
119  INFO(fMessage.str());
120  correspondingCoordinate = 0;
121  correspondingSign = 1;
122  } else if ( orientAzimuth > 90 * deg - alignMargin or orientAzimuth < 90 * deg + alignMargin ) {
123  fMessage << " with a positive y coordinate.";
124  INFO(fMessage.str());
125  correspondingCoordinate = 1;
126  correspondingSign = 1;
127  } else if ( orientAzimuth > 180 * deg - alignMargin or orientAzimuth < 180 * deg + alignMargin ) {
128  fMessage << " with a negative x coordinate.";
129  INFO(fMessage.str());
130  correspondingCoordinate = 0;
131  correspondingSign = -1;
132  } else if ( orientAzimuth > 270 * deg - alignMargin or orientAzimuth < 270 * deg + alignMargin ) {
133  fMessage << " with a negative y coordinate.";
134  INFO(fMessage.str());
135  correspondingCoordinate = 1;
136  correspondingSign = -1;
137  } else {
138  fMessage.str("");
139  fMessage << "No good dodgy conversion possible because the antenna does not seem to be aligned with " <<
140  "any spatial coordinate within " << alignMargin/deg << "deg.";
141  WARNING(fMessage.str());
142  continue;
143  }
144  for (StationTimeSeries::SizeType i=0; i<stationtrace.GetSize(); ++i) {
145  channeltrace.PushBack(stationtrace[i][correspondingCoordinate]*correspondingSign);
146  }
147  }
148  }
149 
150  return eSuccess;
151  }
152 
153 
155  RdDummyStationToChannelConverter::Finish()
156  {
157  // Put any termination or cleanup code here.
158  // This method is called once at the end of the run.
159 
160  INFO("RdDummyStationToChannelConverter::Finish()");
161 
162  return eSuccess;
163  }
164 
165 }
int GetId() const
Return Id of the Channel.
boost::indirect_iterator< InternalChannelIterator, Channel & > ChannelIterator
Iterator over station for read/write.
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
#define INFO(message)
Macro for logging informational messages.
Definition: ErrorLogger.h:161
StationIterator StationsEnd()
Definition: REvent.h:130
StationIterator StationsBegin()
Definition: REvent.h:128
void Init()
Initialise the registry.
Detector description interface for Channel-related data.
double GetOrientationZenith() const
Get zenith-direction of Antenna for this Channel.
ChannelIterator ChannelsBegin()
begin Channel iterator for read/write
boost::filter_iterator< StationFilter, AllStationIterator > StationIterator
Iterator over all (non-exculded) stations.
Definition: REvent.h:125
unsigned int GetNyquistZone() const
Get the Nyquist zone.
bool HasREvent() const
StationTimeSeries & GetStationTimeSeries()
retrieve Station Time Series (write access, only use this if you intend to change the data) ...
ChannelTimeSeries & GetChannelTimeSeries()
retrieve Channel Time Series (write access, only use this if you intend to change the data) ...
ChannelIterator ChannelsEnd()
end Channel iterator for read/write
Detector description interface for RDetector-related data.
Definition: RDetector.h:46
constexpr double deg
Definition: AugerUnits.h:140
class to hold data at the radio Station level.
std::vector< T >::size_type SizeType
Definition: Trace.h:58
void Clear()
Definition: Trace.h:158
SizeType GetSize() const
Definition: Trace.h:156
#define WARNING(message)
Macro for logging warning messages.
Definition: ErrorLogger.h:163
int GetId() const
Get the station Id.
void SetBinning(const double binning)
Definition: Trace.h:139
ResultFlag
Flag returned by module methods to the RunController.
Definition: VModule.h:60
Template class for a FADC data or calibrated data container. Use the typedefs (TraceD, TraceI, etc.) defined in Trace-fwd.h.
Definition: Trace-fwd.h:19
Class that holds the data associated to an individual radio channel.
void SetNyquistZone(const unsigned int zone)
Set the Nyquist zone.
void PushBack(const T &value)
Insert a single value at the end.
Definition: Trace.h:119
const Station & GetStation(const int stationId) const
Get station by Station Id.
Definition: RDetector.cc:141
double GetOrientationAzimuth() const
Get azimuth-direction of Antenna for this Channel.

, generated on Tue Sep 26 2023.