3 #include <fwk/CentralConfig.h>
5 #include <utl/ErrorLogger.h>
6 #include <utl/Reader.h>
7 #include <utl/config.h>
10 #include <revt/REvent.h>
12 #include <det/Detector.h>
13 #include <rdet/Channel.h>
30 topBranch.
GetChild(
"UseLowGainIfHighGainIsSaturated").
GetData(fUseLowGainIfHighGainIsSaturated);
32 if(!fUseLowGainIfHighGainIsSaturated) {
34 info <<
"RdChannelSelector set up to replace saturated high gain channels.";
47 WARNING(
"No radio event found!");
53 REvent& rEvent =
event.GetREvent();
54 const rdet::RDetector& rDetector = det::Detector::GetInstance().GetRDetector();
56 const double tolerance = 1e-3;
58 for (
auto& station : rEvent.StationsRange()) {
59 unsigned int activeChannels = 0;
61 for (
auto& channel : station.ChannelsRange()) {
62 const auto& detChannel = rDetector.
GetStation(station.GetId()).GetChannel(channel.GetId());
63 const string channelType = detChannel.GetChannelType();
66 info <<
"station " << station.
GetId() <<
" channel " << channel.GetId() <<
" has type "
67 << channelType <<
" and is active? " << channel.IsActive();
70 if (!channel.IsActive())
75 if (channelType ==
"Empty") {
77 info <<
"station " << station.GetId() <<
" Channel " << channel.GetId()
78 <<
" has type Empty but is active. Set to not active.";
81 channel.SetNotActive();
87 if (channelType ==
"FilteredHighGain" || channelType ==
"FilteredLowGain") {
89 info <<
"station " << station.GetId() <<
" Channel " << channel.GetId()
90 <<
" has type " << channelType <<
" but is active. Set to not active.";
93 channel.SetNotActive();
99 if (channelType ==
"AntennaHighGain") {
103 const auto& lowGainChannel = GetLowGainChannel(station, rDetector, detChannel, tolerance);
104 const bool hasLowGainChannel = lowGainChannel.is_initialized();
107 if (fUseLowGainIfHighGainIsSaturated &&
108 channel.IsSaturated() && hasLowGainChannel) {
109 channel.SetNotActive();
112 info <<
"Saturated high gain channel " << channel.GetId() <<
" of station " << station.GetId()
113 <<
" deactivated. Use low gain channel " << lowGainChannel->GetId() <<
" instead.";
119 if (hasLowGainChannel)
120 lowGainChannel->SetNotActive();
123 info <<
"Using high gain channel " << channel.GetId() <<
" of station " << station.GetId() <<
".";
129 if (activeChannels < 2 || activeChannels > 3) {
131 info <<
"Station " << station.GetId() <<
" does not have two or three active channels, "
132 <<
"station will be excluded.";
143 RdChannelSelector::Finish()
149 boost::optional<revt::Channel&>
153 const double tolerance)
155 for (
auto& newChannel : station.ChannelsRange()) {
156 const auto& newDetChannel = rDetector.
GetStation(station.
GetId()).GetChannel(newChannel.GetId());
160 && IsClose(detChannel.
GetOrientationZeta(), newDetChannel.GetOrientationZeta(), tolerance)
161 && newDetChannel.GetChannelType() ==
"AntennaLowGain") {
172 RdChannelSelector::IsClose(
const double a,
const double b,
const double tolerance)
174 return fabs(a - b) < tolerance;
double GetOrientationZeta() const
Get zeta-tilt of Antenna for this Channel.
Interface class to access to the Radio part of an event.
#define INFO(message)
Macro for logging informational messages.
void Init()
Initialise the registry.
Detector description interface for Channel-related data.
double GetOrientationZenith() const
Get zenith-direction of Antenna for this Channel.
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
Detector description interface for RDetector-related data.
#define INFOIntermediate(y)
Class representing a document branch.
class to hold data at the radio Station level.
int GetId() const
Station ID.
#define WARNING(message)
Macro for logging warning messages.
void GetData(bool &b) const
Overloads of the GetData member template function.
int GetId() const
Get the station Id.
ResultFlag
Flag returned by module methods to the RunController.
static CentralConfig * GetInstance()
Use this the first time you get an instance of central configuration.
const Station & GetStation(const int stationId) const
Get station by Station Id.
double GetOrientationAzimuth() const
Get azimuth-direction of Antenna for this Channel.
utl::Branch GetTopBranch(const std::string &id)
Get top branch for moduleConfigLink with given id (XML files)