3 #include <fwk/CentralConfig.h>
4 #include <fwk/VModule.h>
6 #include <utl/config.h>
7 #include <utl/AugerUnits.h>
8 #include <utl/ErrorLogger.h>
9 #include <utl/Reader.h>
10 #include <utl/TraceAlgorithm.h>
12 #include <evt/Event.h>
13 #include <revt/REvent.h>
14 #include <revt/Station.h>
15 #include <revt/Channel.h>
17 #include <rdet/RDetector.h>
18 #include <rdet/Station.h>
19 #include <rdet/Channel.h>
26 using std::ostringstream;
36 CentralConfig::GetInstance()->
GetTopBranch(
"RdChannelADCToVoltageConverter");
39 fFailOnWrongADCFrequency =
40 topBranch.
GetChild(
"FailOnWrongADCFrequency").
Get<std::string>() ==
"yes";
51 WARNING(
"No radio event found!");
57 REvent& rEvent =
event.GetREvent();
60 for (
auto& station : rEvent.StationsRange()) {
61 for (
auto& channel : station.ChannelsRange()) {
63 if (!channel.IsActive())
75 const double voltagePerCount = (maxVoltage - minVoltage) /
pow(2, bitDepth);
76 const double traceBinning = adcTrace.
GetBinning();
77 const double traceMax = TraceAlgorithm::Max(adcTrace, 0, adcTrace.
GetSize() - 1);
78 const double traceMin = TraceAlgorithm::Min(adcTrace, 0, adcTrace.
GetSize() - 1);
80 if (!
CloseTo(1.0 / traceBinning, samplingFrequency, 1e-6)) {
82 info <<
"ADC Sampling Frequency of station " << station.GetId()
83 <<
", Channel " << channel.GetId()
84 <<
" according to detector config is "
86 <<
" MHz and does not match sampling frequency of data, which is "
87 << 1.0 / traceBinning / (
mega *
hertz) <<
" MHz.";
89 if (fFailOnWrongADCFrequency) {
94 info <<
"Excluding station.";
102 if ((traceMin < minVoltage / voltagePerCount) || (traceMax > maxVoltage / voltagePerCount - 1)) {
104 info <<
"ADC trace of Channel " << channel.GetId()
105 <<
", Station " << station.GetId() <<
" has illegal entries.\n"
106 <<
"Allowed trace minimum is: " << minVoltage / voltagePerCount
107 <<
" and current trace minimum: " << traceMin <<
".\n"
108 <<
"Allowed trace maximum is: " << maxVoltage / voltagePerCount - 1
109 <<
" and current trace maximum: " << traceMax <<
".\nAborting ...";
117 if ((traceMin == minVoltage / voltagePerCount) || (traceMax == minVoltage / voltagePerCount - 1)) {
119 info <<
"ADC trace of Channel " << channel.GetId()
120 <<
", Station " << station.GetId() <<
" has saturated samples!";
123 channel.SetSaturated();
124 fNumberOfSaturatedChannels++;
131 trace = minVoltage + adcTrace * voltagePerCount;
133 if(fInfoLevel >= eInfoDebug) {
135 info <<
"Station " << station.GetId() <<
" Channel " << channel.GetId()
136 <<
" has minVoltage = " << minVoltage <<
" and voltageperCount = "
148 RdChannelADCToVoltageConverter::Finish()
151 info <<
"There were " << fNumberOfSaturatedChannels <<
" saturated channels!";
159 RdChannelADCToVoltageConverter::CloseTo(
const double a,
const double b,
const double tolerance)
161 return fabs(a - b) < tolerance;
int GetBitDepth() const
Get number of bits of ADC.
Branch GetTopBranch() const
Interface class to access to the Radio part of an event.
double GetBinning() const
size of one slot
#define INFO(message)
Macro for logging informational messages.
double GetMaxVoltage() const
Get voltage corresponding to max number of counts.
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.
double pow(const double x, const unsigned int i)
#define INFOIntermediate(y)
Class representing a document branch.
double GetMinVoltage() const
Get voltage corresponding to 0 counts.
Top of the hierarchy of the detector description interface.
#define WARNING(message)
Macro for logging warning messages.
void GetData(bool &b) const
Overloads of the GetData member template function.
void SetBinning(const double binning)
ResultFlag
Flag returned by module methods to the RunController.
const rdet::RDetector & GetRDetector() const
double GetSamplingFrequency() const
Get sampling Frequency of ADC (unit?)
#define ERROR(message)
Macro for logging error messages.
const Station & GetStation(const int stationId) const
Get station by Station Id.
Predicate for approximate equality (for floating point)