RdChannelResampler.cc
Go to the documentation of this file.
1 #include "RdChannelResampler.h"
2 
3 #include <fwk/CentralConfig.h>
4 #include <fwk/RunController.h>
5 
6 #include <utl/ErrorLogger.h>
7 #include <utl/Reader.h>
8 #include <utl/config.h>
9 #include <utl/FFTDataContainerAlgorithm.h>
10 #include <utl/AugerUnits.h>
11 
12 #include <evt/Event.h>
13 #include <revt/REvent.h>
14 #include <revt/Station.h>
15 #include <revt/Channel.h>
16 
17 #include <det/Detector.h>
18 #include <rdet/RDetector.h>
19 #include <rdet/Channel.h>
20 
21 
22 using namespace fwk;
23 using namespace utl;
24 using namespace std;
25 
26 
27 namespace RdChannelResampler {
28 
31  {
32  // Read in the configurations of the xml file
33  Branch topBranch =
34  CentralConfig::GetInstance()->GetTopBranch("RdChannelResampler");
35  topBranch.GetChild("InfoLevel").GetData(fInfoLevel);
36 
37  fOverrideChannelSampleRate =
38  topBranch.GetChild("OverrideChannelSampleRate").Get<string>() == "yes";
39 
40  topBranch.GetChild("OverrideResampleBinning").GetData(fOverrideResampleBinning);
41 
42  ostringstream info;
43  if (fOverrideChannelSampleRate) {
44  info << "\n\tRdChannelResampler uses an OverrideChannelSampleRate with an OverrideResampleBinning of "
45  << fOverrideResampleBinning / nanosecond << " ns.\n";
46  } else {
47  info << "\n\tRdChannelResampler uses sampling rate provided by the detector.\n";
48  }
49  INFODebug(info);
50 
51  return eSuccess;
52  }
53 
54 
56  RdChannelResampler::Run(evt::Event& event)
57  {
58  // Check if there is event data at all
59  if(!event.HasREvent()) {
60  WARNING("No radio event found!");
61  return eContinueLoop;
62  }
63 
64  det::Detector& thedet = det::Detector::GetInstance();
65  revt::REvent& rEvent = event.GetREvent();
66 
67  ostringstream info;
68 
69  // loop through stations and for every station through every channel
70  for (auto& station : rEvent.StationsRange()) {
71  for (auto& channel : station.ChannelsRange()) {
72 
73  const rdet::Channel& channeldet =
74  thedet.GetRDetector().GetStation(station.GetId()).GetChannel(channel.GetId());
75 
76  double channelBinning = 1. / channeldet.GetSamplingFrequency();
77  if (fOverrideChannelSampleRate) {
78  channelBinning = fOverrideResampleBinning;
79  }
80 
81  info << "Resampling channel " << channel.GetId() << " of station "
82  << channel.GetStationId() << " from a binning of "
83  << channel.GetChannelTimeSeries().GetBinning()<< " to "
84  << channelBinning << ".";
85  INFODebug(info);
86 
87  FFTDataContainerAlgorithm::ResampleTimeSeries(channel.GetFFTDataContainer(), channelBinning);
88  }
89  }
90 
91  return eSuccess;
92  }
93 
94 
96  RdChannelResampler::Finish()
97  {
98  return eSuccess;
99  }
100 
101 }
Interface class to access to the Radio part of an event.
Definition: REvent.h:42
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.
Definition: Branch.cc:211
bool HasREvent() const
T Get() const
Definition: Branch.h:271
Class representing a document branch.
Definition: Branch.h:107
constexpr double nanosecond
Definition: AugerUnits.h:143
Top of the hierarchy of the detector description interface.
Definition: Detector.h:81
#define WARNING(message)
Macro for logging warning messages.
Definition: ErrorLogger.h:163
void GetData(bool &b) const
Overloads of the GetData member template function.
Definition: Branch.cc:644
#define INFODebug(y)
Definition: VModule.h:163
ResultFlag
Flag returned by module methods to the RunController.
Definition: VModule.h:60
static CentralConfig * GetInstance()
Use this the first time you get an instance of central configuration.
const rdet::RDetector & GetRDetector() const
Definition: Detector.cc:143
double GetSamplingFrequency() const
Get sampling Frequency of ADC (unit?)
const Station & GetStation(const int stationId) const
Get station by Station Id.
Definition: RDetector.cc:141
utl::Branch GetTopBranch(const std::string &id)
Get top branch for moduleConfigLink with given id (XML files)

, generated on Tue Sep 26 2023.