3 #include <fwk/CentralConfig.h>
5 #include <utl/config.h>
6 #include <utl/ErrorLogger.h>
7 #include <utl/Reader.h>
8 #include <utl/TraceAlgorithm.h>
10 #include <evt/Event.h>
11 #include <revt/REvent.h>
12 #include <revt/Station.h>
14 #include <det/Detector.h>
15 #include <rdet/RDetector.h>
16 #include <rdet/Station.h>
30 Branch topBranch = CentralConfig::GetInstance()->
GetTopBranch(
"RdChannelBandstopFilter");
36 topBranch.
GetChild(
"UseOnlineBandstopFilter").
GetData(fUseOnlineBandstopFilter);
37 topBranch.
GetChild(
"OnlineBandstopFilterSpectrumBaseline").
GetData(fOnlineBandstopFilterSpectrumBaseline);
38 topBranch.
GetChild(
"OnlineBandstopFilterDeviationFactor").
GetData(fOnlineBandstopFilterDeviationFactor);
41 if (fLowerBoundsNS.size() != fUpperBoundsNS.size()) {
42 ERROR(
"not same amount of upper/lower bounds in NS channel");
46 for(
unsigned int i = 0; i < fLowerBoundsNS.size(); ++i) {
47 if(fLowerBoundsNS[i] > fUpperBoundsNS[i]) {
48 ERROR(
"NoiseStartFrequency greater than NoiseStopFrequency for NS channel");
53 if (fLowerBoundsEW.size() != fUpperBoundsEW.size()) {
54 ERROR(
"not same amount of upper/lower bounds in EW channel");
58 for(
unsigned int i = 0; i < fLowerBoundsEW.size(); ++i) {
59 if(fLowerBoundsEW[i] > fUpperBoundsEW[i]) {
60 ERROR(
"NoiseStartFrequency greater than NoiseStopFrequency for EW channel 2");
74 WARNING(
"No radio event found!");
78 REvent& rEvent =
event.GetREvent();
82 for (
auto& station : rEvent.StationsRange()) {
83 for (
auto& channel : station.ChannelsRange()) {
85 if (!channel.IsActive())
88 const rdet::RDetector& rDetector = det::Detector::GetInstance().GetRDetector();
96 if (fUseOnlineBandstopFilter) {
98 for (
const auto&
freq : freqSpectrum)
105 const unsigned int idxLowFreq = myFFTDataContainer.GetBinOfFrequency(lowerfreq);
106 const unsigned int idxUpFreq = myFFTDataContainer.GetBinOfFrequency(upperfreq);
109 if (fOnlineBandstopFilterSpectrumBaseline ==
"Mean")
111 else if (fOnlineBandstopFilterSpectrumBaseline ==
"Median")
112 baseline = TraceAlgorithm::Median(amplitude, idxLowFreq, idxUpFreq, 50);
117 info <<
"Channel " << channel.GetId()
118 <<
" in Station " << channel.GetStationId()
119 <<
" has a baseline of: " << baseline
120 <<
" (" << fOnlineBandstopFilterSpectrumBaseline <<
") "
121 <<
" and a std. deviation of: " << deviation
122 <<
" with a deviation factor of: " << fOnlineBandstopFilterDeviationFactor <<
".";
125 for (
auto& frequency : freqSpectrum) {
126 if (
abs(frequency) > baseline + fOnlineBandstopFilterDeviationFactor * deviation) {
128 info <<
"Suppress frequency " << frequency /
MHz
129 <<
" of Channel " << channel.GetId()
130 <<
" in Station " << channel.GetStationId()
131 <<
" with a deviation factor of " <<
abs(
abs(frequency) - baseline) / deviation
140 CutNoiseFrequencies(channel, detChannel);
149 RdChannelBandstopFilter::Finish()
159 vector<double> lowerBounds, upperBounds;
162 lowerBounds = fLowerBoundsNS;
163 upperBounds = fUpperBoundsNS;
166 lowerBounds = fLowerBoundsEW;
167 upperBounds = fUpperBoundsEW;
169 INFOIntermediate(
"Channel not NS or EW oriented, not cutting out frequencies");
178 for(
unsigned int i = 0; i < lowerBounds.size(); ++i) {
179 const int idxNoiseStart = fftContainer.GetBinOfFrequency(lowerBounds[i]);
180 const int idxNoiseStop = fftContainer.GetBinOfFrequency(upperBounds[i]);
182 info <<
"Cut out noise frequency from " << lowerBounds[i] /
MHz <<
" MHz to "
183 << upperBounds[i] /
MHz <<
" MHz (Bin " << idxNoiseStart<<
" to " << idxNoiseStop
184 <<
") in Channel " << channel.
GetId() << endl;
187 for(
int j=idxNoiseStart; j<=idxNoiseStop; ++j) {
195 RdChannelBandstopFilter::CloseTo(
const double a,
const double b,
const double tolerance)
197 return fabs(a - b) < tolerance;
ChannelFFTDataContainer & GetFFTDataContainer()
retrieve Channel FFTDataContainer (write access)
Branch GetTopBranch() const
double StandardDeviation(const std::vector< double > &v, const double mean)
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.
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.
Detector description interface for RDetector-related data.
#define INFOIntermediate(y)
Class representing a document branch.
C< F > & GetFrequencySpectrum()
read out the frequency spectrum (write access)
double abs(const SVector< n, T > &v)
#define WARNING(message)
Macro for logging warning messages.
void GetData(bool &b) const
Overloads of the GetData member template function.
ResultFlag
Flag returned by module methods to the RunController.
Class that holds the data associated to an individual radio channel.
double Mean(const std::vector< double > &v)
void PushBack(const T &value)
Insert a single value at the end.
#define ERROR(message)
Macro for logging error messages.
const Station & GetStation(const int stationId) const
Get station by Station Id.
double GetOrientationAzimuth() const
Get azimuth-direction of Antenna for this Channel.
Predicate for approximate equality (for floating point)