13 #include <fwk/CentralConfig.h>
15 #include <utl/ErrorLogger.h>
16 #include <utl/Reader.h>
17 #include <utl/config.h>
18 #include <utl/TimeStamp.h>
19 #include <utl/UTCDateTime.h>
21 #include <evt/Event.h>
22 #include <revt/REvent.h>
23 #include <revt/Station.h>
24 #include <revt/Channel.h>
26 #include <det/Detector.h>
27 #include <rdet/RDetector.h>
28 #include <rdet/Station.h>
29 #include <rdet/Channel.h>
43 INFO(
"RdChannelBeaconSuppressor::Init()");
51 topBranch.
GetChild(
"GetBeaconFrequenciesFromDatabase").
GetData(fGetBeaconFrequenciesFromDatabase);
53 topBranch.
GetChild(
"NeighbouringBinsToBeSurpressed").
GetData(fNeighbouringBinsToBeSurpressed);
54 topBranch.
GetChild(
"NeighbouringBandwidthToBeSurpressed").
GetData(fNeighbouringBandwidthToBeSurpressed);
55 topBranch.
GetChild(
"CompensateTotalSpectrumPower").
GetData(fCompensateTotalSpectrumPower);
69 REvent& rEvent =
event.GetREvent();
72 std::vector<double> frequencies = fXMLFrequencies;
75 if (fGetBeaconFrequenciesFromDatabase) {
79 for (
auto it = BeaconFrequencies.begin(); it != BeaconFrequencies.end(); ++it)
80 frequencies.push_back(*it);
88 std::set<int> frequencyBins;
95 message <<
"Suppressing sine waves of channel " << channel.
GetId()
104 for (
unsigned int freqN=0; freqN < frequencies.size(); ++freqN) {
106 if( (frequencies[freqN] <
108 || (frequencies[freqN] >
110 ERROR(
"Frequency must be inside of the spectrum!");
115 double bin = (frequencies[freqN]-channel.
GetFrequencyOfBin(0)) * (spectrum.GetSize()-1)
118 unsigned int intBin = round(bin);
121 if (
abs(
double(intBin)/bin -1.) > 1e-3) {
123 stringstream message;
124 message <<
"Frequency does not correspond to approxemately integer bin of spectrum! The nearest integer frequency is "
125 << nearestIntFreq /
MHz <<
" MHz (bin #" << intBin <<
")" ;
130 frequencyBins.insert(intBin);
134 if (fNeighbouringBandwidthToBeSurpressed > 0)
135 fNeighbouringBinsToBeSurpressed = round(fNeighbouringBandwidthToBeSurpressed/spectrum.GetBinning());
138 for (
unsigned int i = 1; i <= fNeighbouringBinsToBeSurpressed; ++i) {
140 frequencyBins.insert(intBin-i);
141 if ( (intBin+i) < spectrum.GetSize())
142 frequencyBins.insert(intBin+i);
147 unsigned int numberOfbinsInDesignBandwidth = 0;
148 double lowerDesignFreq = 0;
149 double upperDesignFreq = 0;
151 if (fCompensateTotalSpectrumPower) {
158 for (
auto it = frequencyBins.begin(); it != frequencyBins.end(); ++it) {
160 message <<
"Suppressing spectral bin " << *it <<
" corresponding to frequency "
164 spectrum[*it] *= fSurpressionFactor;
165 if (fCompensateTotalSpectrumPower)
167 ++numberOfbinsInDesignBandwidth;
173 if (fCompensateTotalSpectrumPower) {
175 double maxFrequency = 0;
181 const double relativeBandWidth = (upperDesignFreq-lowerDesignFreq)/maxFrequency;
183 double compensationFactor =
sqrt(1.+
double(numberOfbinsInDesignBandwidth)/
double(spectrum.GetSize())/relativeBandWidth);
186 message <<
"Multiplying each bin in the spectrum by " << compensationFactor
187 <<
" such that the total signal power within the design bandwidth is preserved.";
192 spectrum[i]*=compensationFactor;
202 RdChannelBeaconSuppressor::Finish()
204 INFOFinal(
"RdChannelBeaconSuppressor::Finish()");
int GetId() const
Return Id of the Channel.
double GetDesignUpperFreq() const
Get design value of the freq-band.
Interface class to access to the Radio part of an event.
double GetDesignLowerFreq() const
Get design value of the freq-band.
#define INFO(message)
Macro for logging informational messages.
StationIterator StationsEnd()
StationIterator StationsBegin()
void Init()
Initialise the registry.
Detector description interface for Channel-related data.
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
ChannelIterator ChannelsBegin()
begin Channel iterator for read/write
int GetStationId() const
Return Id of the station to which this Channel belongs.
const std::vector< double > & GetBeaconFrequencies() const
Get vector of Beacon Frequencies for given detector-time from Manager.
ChannelIterator ChannelsEnd()
end Channel iterator for read/write
Detector description interface for RDetector-related data.
#define INFOIntermediate(y)
Class representing a document branch.
class to hold data at the radio Station level.
std::vector< std::complex< double > >::size_type SizeType
double abs(const SVector< n, T > &v)
Top of the hierarchy of the detector description interface.
constexpr double megahertz
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.
ChannelFrequencySpectrum & GetChannelFrequencySpectrum()
retrieve Channel Frequency Spectrum (write access, only use this if you intend to change the data) ...
double GetFrequencyOfBin(const ChannelFrequencySpectrum::SizeType bin) const
Get the frequency corresponding to a bin of the frequency spectrum.
Class that holds the data associated to an individual radio channel.
const rdet::RDetector & GetRDetector() const
#define ERROR(message)
Macro for logging error messages.
const Station & GetStation(const int stationId) const
Get station by Station Id.
utl::Branch GetTopBranch(const std::string &id)
Get top branch for moduleConfigLink with given id (XML files)