3 #include <fwk/CentralConfig.h>
5 #include <utl/config.h>
6 #include <utl/ErrorLogger.h>
7 #include <utl/Reader.h>
8 #include <utl/AugerUnits.h>
10 #include <evt/Event.h>
11 #include <revt/REvent.h>
12 #include <revt/Channel.h>
13 #include <revt/ChannelRecData.h>
14 #include <revt/ChannelRRecDataQuantities.h>
15 #include <revt/Station.h>
17 #include <det/Detector.h>
18 #include <rdet/RDetector.h>
19 #include <rdet/Channel.h>
39 CentralConfig::GetInstance()->
GetTopBranch(
"RdChannelAmplitudeTemperatureDependenceCorrector");
41 topBranch.
GetChild(
"RejectIfCorrectionFailed").
GetData(fRejectIfCorrectionFailed);
48 RdChannelAmplitudeTemperatureDependenceCorrector::Run(
evt::Event& event)
52 WARNING(
"No radio event found!");
57 REvent& rEvent =
event.GetREvent();
63 const bool hasCrsTemp = isnan(crsTemperature);
64 INFODebug(
"CRS temperature: " + to_string(crsTemperature) +
"deg kelvin");
67 for (
auto& station : rEvent.StationsRange()) {
69 info <<
"Current station id " << station.GetId();
73 if (fRejectIfCorrectionFailed && hasCrsTemp) {
74 WARNING(
"No CRS temperature available. Station will be rejected.\n");
79 for (
auto& channel : station.ChannelsRange()) {
80 if (!channel.IsActive())
83 auto& timeSeries = channel.GetChannelTimeSeries();
87 const auto& adcType = GetAdcType(detChannel.GetADCType());
89 WARNING(
"unknown filteramplifier. Station will be rejected, temp correction can't be applied.");
96 const string AntennaType = detChannel.GetAntennaTypeName();
97 if ((AntennaType.substr(0,
string(
"SmallBlackSpider").length()) !=
"SmallBlackSpider") &&
98 (AntennaType.substr(0,
string(
"Butterfly").length()) !=
"Butterfly")) {
100 info <<
"unknown antenna type: " << AntennaType
101 <<
" Station will be rejected, temp correction can't be applied.";
109 info <<
"Antenna type: " << AntennaType <<
", ADC type: " << adcType;
113 double stationTemp = std::nan(
"1");
114 if (adcType == eDE_Phase1 || adcType == eDE_Phase2) {
116 stationTemp = station.GetHWTemperatureExt();
119 stationTemp = station.GetHWTemperature() + 273.15;
122 if (fRejectIfCorrectionFailed && isnan(stationTemp)) {
123 WARNING(
"No station temperature data available. Station will be rejected");
129 if(fRejectIfCorrectionFailed && (stationTemp < 223.15 || stationTemp > 373.15)) {
130 WARNING(
"Incorrect sensor temperature. Station will be rejected");
136 info <<
"Temperatures used for correction of LNA amplitudes: T = " << crsTemperature
137 <<
"Temperatures for correction of FilterAmplifier amplitudes: T = " << stationTemp
138 <<
", Tref= " << fReferenceTemperatur;
142 const double FAfactor = GetFilterAmplifierAmplitudeCorrectionFactor(adcType);
143 const double filterAmplifierAmplitudeCorrectionFactor =
144 pow(10, FAfactor * 1e-3 * (fReferenceTemperatur - stationTemp) * 0.05);
147 const double LNAfactor = GetLNAAmplitudeCorrectionFactor(detChannel.GetAntennaTypeName());
148 const double LNAAmplitudeCorrectionFactor =
149 pow(10, LNAfactor * 1e-3 * (fReferenceTemperatur - crsTemperature) * 0.05);
152 if (!channel.HasRecData()) {
153 channel.MakeRecData();
156 channel.GetRecData().SetParameter(eAmplitudeLNATemperatureCorrectionFactor,
157 LNAAmplitudeCorrectionFactor);
158 channel.GetRecData().SetParameter(eAmplitudeFilterAmpTemperatureCorrectionFactor,
159 filterAmplifierAmplitudeCorrectionFactor);
162 for (
auto& el : timeSeries) {
163 el *= LNAAmplitudeCorrectionFactor * filterAmplifierAmplitudeCorrectionFactor;
173 RdChannelAmplitudeTemperatureDependenceCorrector::Finish()
180 RdChannelAmplitudeTemperatureDependenceCorrector::GetAdcType(
const std::string adcString)
182 if (adcString.substr(0, 4) ==
"AERA") {
183 if (adcString.substr(4, 2) ==
"DE") {
193 if (adcString.substr(0, 6) ==
"ADC_DE") {
198 if (adcString.substr(0, 6) ==
"ADC_NL") {
207 RdChannelAmplitudeTemperatureDependenceCorrector::GetLNAAmplitudeCorrectionFactor(
208 const string AntennaType)
210 if (AntennaType.substr(0,
string(
"SmallBlackSpider").length()) ==
"SmallBlackSpider") {
215 if (AntennaType.substr(0,
string(
"Butterfly").length()) ==
"Butterfly") {
220 WARNING(
"unknown antenna type, no correction");
226 RdChannelAmplitudeTemperatureDependenceCorrector::GetFilterAmplifierAmplitudeCorrectionFactor(
241 WARNING(
"unknown filteramplifier, no correction.");
Branch GetTopBranch() const
double GetTemperature(const std::string &site) const
Interface class to access to the Radio part of an event.
void Init()
Initialise the registry.
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
double pow(const double x, const unsigned int i)
Detector description interface for RDetector-related data.
Class representing a document branch.
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.
const Channel & GetChannel(const int id) const
Get specified Channel by id.
ResultFlag
Flag returned by module methods to the RunController.
const rdet::RDetector & GetRDetector() const
const Station & GetStation(const int stationId) const
Get station by Station Id.