11 #include <fwk/CentralConfig.h>
13 #include <utl/ErrorLogger.h>
14 #include <utl/Reader.h>
15 #include <utl/config.h>
16 #include <utl/AugerUnits.h>
17 #include <utl/MathConstants.h>
18 #include <utl/TraceAlgorithm.h>
19 #include <utl/TimeStamp.h>
20 #include <utl/TimeInterval.h>
21 #include <utl/FFTDataContainerAlgorithm.h>
22 #include <utl/CoordinateSystem.h>
23 #include <utl/PhysicalConstants.h>
24 #include <utl/Point.h>
25 #include <utl/Vector.h>
27 #include <evt/Event.h>
28 #include <revt/REvent.h>
29 #include <revt/Header.h>
30 #include <revt/Station.h>
31 #include <revt/Channel.h>
32 #include <revt/StationRecData.h>
34 #include <det/Detector.h>
35 #include <rdet/RDetector.h>
37 #include <rdet/Station.h>
38 #include <rdet/Channel.h>
52 #include <CLHEP/Matrix/Matrix.h>
53 #include <CLHEP/Matrix/Vector.h>
73 topBranch.
GetChild(
"FixedReferenceStationID").
GetData(fFixedReferenceStationID);
79 topBranch.
GetChild(
"EqualizeStationTimeStamps").
GetData(fEqualizeStationTimeStamps);
82 vector<int> dummyStationIDlist;
84 fDebugStationIds = set<int>(dummyStationIDlist.begin(), dummyStationIDlist.end());
87 topBranch.
GetChild(
"RejectIfNoRefPhaseAvailable").
GetData(fRejectIfNoRefPhaseAvailable);
88 topBranch.
GetChild(
"RejectIfCorrectionFailed").
GetData(fRejectIfCorrectionFailed);
89 topBranch.
GetChild(
"UseCrossCorrelationMethod").
GetData(fUseCrossCorrelationMethod);
90 topBranch.
GetChild(
"UseBeaconDistanceInsteadOfDatabaseValues").
GetData(fUseBeaconDistanceInsteadOfDatabaseValues);
92 topBranch.
GetChild(
"BeaconTimeCalibrationUncertainty").
GetData(fBeaconTimeCalibrationUncertainty);
93 topBranch.
GetChild(
"StartingDateTimeForBeaconCorrection").
GetData(fStartingDateTimeForBeaconCorrection);
96 if(fBeaconPosition.size() < 3) {
97 ERROR(
"Incorrect definition of beacon position in XML file: One or more coordinates are missing!");
111 std::map<int, std::map<int, double>> phases;
114 std::map<int, std::map<int, double>> modPhases;
117 std::map<int, std::map<int, double>> timeDiffsFreq;
120 std::map<int, std::map<int, double>> SNRs;
123 std::map<int, double> timeOffsets;
126 std::map<int, double> timeOffsetUncertainty;
130 WARNING(
"RdChannelBeaconTimingCalibrator::No radio event found!");
131 return eContinueLoop;
133 REvent& rEvent =
event.GetREvent();
134 stringstream message;
135 message <<
"Radio event found with "
138 if (fInfoLevel >= eInfoDebug)
144 message <<
"Found header with ID "
146 <<
" and timestamp: "
147 << rHeader.GetTime();
148 if (fInfoLevel >= eInfoDebug)
151 if (rHeader.GetTime() < fStartingDateTimeForBeaconCorrection) {
153 message <<
"Skipped event with ID "
155 <<
" because event time is before: "
156 << fStartingDateTimeForBeaconCorrection;
157 if (fInfoLevel >= eInfoFinal)
168 if (fBeaconCorrectionSuccesses.find(station.
GetId()) == fBeaconCorrectionSuccesses.end() )
169 fBeaconCorrectionSuccesses[station.
GetId()] = 0;
170 if (fBeaconCorrectionFailures.find(station.
GetId()) == fBeaconCorrectionFailures.end() )
171 fBeaconCorrectionFailures[station.
GetId()] = 0;
173 ++fBeaconCorrectionFailures[station.
GetId()];
182 std::vector<double> beaconFrequencies(fBeaconFrequencies);
183 if(beaconFrequencies.size() < 1) {
187 ERROR (
"Error reading Beacon frequencies from database, skipping event!");
188 return eContinueLoop;
193 std::vector<std::map<int, double> > referencePhases;
194 if (fInputPhaseFile !=
"") {
195 referencePhases = getReferencePhases(beaconFrequencies);
197 referencePhases = vector<map<int, double> > (beaconFrequencies.size());
201 const int stationId = station.
GetId();
203 for (
unsigned int beaconFreqN=0; beaconFreqN < beaconFrequencies.size(); ++beaconFreqN) {
204 referencePhases[beaconFreqN][stationId] = RDetector.
GetBeaconReferencePhase(stationId, beaconFrequencies[beaconFreqN]);
208 message <<
"Could not read beacon reference phases for station "
210 <<
" from database.";
211 if (fInfoLevel >= eInfoFinal)
217 if (referencePhases.size() != beaconFrequencies.size()) {
218 ERROR(
"Could not read reference phases correctly.");
223 if (referencePhases[0].size() < 2) {
225 message <<
"Event has only "
226 << referencePhases[0].size()
227 <<
" stations with available reference phases. At least 2 are needed for the beacon correction.";
228 ERROR(message.str());
229 return eContinueLoop;
233 if (fFixedReferenceStationID > 0)
234 if (!rEvent.
HasStation(fFixedReferenceStationID)) {
236 message <<
"Reference station with ID "
237 << fFixedReferenceStationID
238 <<
" is not contained in the event: No Beacon correction possible!";
239 ERROR(message.str());
240 return eContinueLoop;
244 vector<double> beaconFreqsInSpectrum;
248 unsigned int numberOfNotRejectedStations = 0;
253 bool skipStation =
false;
254 for (
unsigned int beaconFreqN = 0; beaconFreqN < beaconFrequencies.size(); ++beaconFreqN) {
255 if (referencePhases[beaconFreqN].find(station.
GetId()) == referencePhases[beaconFreqN].end() ) {
257 message <<
"No reference phase for station "
259 <<
" and frequency #"
262 if (fRejectIfNoRefPhaseAvailable)
263 message <<
" Station will be rejected.\n";
266 if (fInfoLevel >= eInfoFinal)
268 if (fRejectIfNoRefPhaseAvailable)
276 if ( (beaconFrequencies[beaconFreqN] < RDetector.
GetStation(station.
GetId()).GetChannel(fReferenceChannel).GetDesignLowerFreq())
277 || (beaconFrequencies[beaconFreqN] > RDetector.
GetStation(station.
GetId()).GetChannel(fReferenceChannel).GetDesignUpperFreq()) ) {
279 message <<
"Beacon frequency "
280 << beaconFrequencies[beaconFreqN]/
megahertz
281 <<
" MHz is outside of the design frequency band of station "
283 <<
". --> Station will be rejected.\n";
284 if (fInfoLevel >= eInfoFinal)
298 message <<
"Calculating the phases of the beacon frequencies for channel "
303 if (fInfoLevel >= eInfoDebug)
311 if ( ((spectrum.GetSize()-1) % 1024) != 0 ) {
313 message <<
"Trace should consist of 2048 samples or an integer multiple of it! It has:"
314 << (spectrum.GetSize()-1)*2;
315 if (fInfoLevel >= eInfoFinal)
329 for (
unsigned int beaconFreqN=0; beaconFreqN < beaconFrequencies.size(); ++beaconFreqN) {
331 if( (beaconFrequencies[beaconFreqN] <
333 || (beaconFrequencies[beaconFreqN] >
335 ERROR(
"Beacon frequency must be inside of the spectrum!");
339 double bin = (beaconFrequencies[beaconFreqN]-channel.
GetFrequencyOfBin(0)) * (spectrum.GetSize()-1)
345 if (beaconFreqsInSpectrum.size() < beaconFrequencies.size())
349 if (
abs(beaconFreqsInSpectrum[beaconFreqN] / channel.
GetFrequencyOfBin(round(bin)) - 1.) > 1e-6) {
351 message <<
"Frequency of bin corresponding to beacon frequency "
354 << beaconFreqsInSpectrum[beaconFreqN]/
megahertz <<
"MHz"
357 ERROR(message.str());
363 double phase = arg(spectrum[round(bin)]);
364 double amplitude =
abs(spectrum[round(bin)]);
367 double modPhase = phase - referencePhases[beaconFreqN][channel.
GetStationId()];
368 if (modPhase >
kPi) {
370 }
else if (modPhase < -
kPi) {
375 phases[beaconFreqN][station.
GetId()] = phase;
376 modPhases[beaconFreqN][station.
GetId()] = modPhase;
379 double noise = TraceAlgorithm::Median(amplitudeSpectrum,
380 round(bin)-trunc(fNoiseFilterSize/2.0),
381 round(bin)+ceil(fNoiseFilterSize/2.0)-1.);
382 double snr = (amplitude*amplitude)/(noise*noise) ;
383 SNRs[beaconFreqN][station.
GetId()] = snr;
387 if (fBeaconSNRs.find(station.
GetId()) == fBeaconSNRs.end())
388 fBeaconSNRs[station.
GetId()] = std::map<int,double>();
390 if (fBeaconSNRs[station.
GetId()].find(beaconFreqN) == fBeaconSNRs[station.
GetId()].end())
391 fBeaconSNRs[station.
GetId()][beaconFreqN] = snr;
393 fBeaconSNRs[station.
GetId()][beaconFreqN] += snr;
396 ++numberOfNotRejectedStations;
399 if (fBeaconSNRcounter.find(station.
GetId()) == fBeaconSNRcounter.end() )
400 fBeaconSNRcounter[station.
GetId()] = 1;
402 ++fBeaconSNRcounter[station.
GetId()];
406 if (numberOfNotRejectedStations < 2) {
408 message <<
"Event has only "
409 << numberOfNotRejectedStations
410 <<
" stations which are not rejected. At least 2 are needed for the beacon correction.";
411 ERROR(message.str());
412 return eContinueLoop;
418 int refStationID = 0;
419 double refStationTimeStamp = 0;
420 double refStationPhases[beaconFrequencies.size()];
426 if ((fFixedReferenceStationID>0) && (station.
GetId()!=fFixedReferenceStationID))
430 bool skipStation =
false;
431 for (
unsigned int beaconFreqN=0; beaconFreqN < beaconFrequencies.size(); ++beaconFreqN) {
432 if ( referencePhases[beaconFreqN].find(station.
GetId()) == referencePhases[beaconFreqN].end() )
441 double smallestSNRofFreq = 1e99;
443 for (
unsigned int beaconFreqN=0; beaconFreqN < beaconFrequencies.size(); ++beaconFreqN) {
444 if (SNRs[beaconFreqN][station.
GetId()] < smallestSNRofFreq)
445 smallestSNRofFreq = SNRs[beaconFreqN][station.
GetId()];
449 if (smallestSNRofFreq > bestSNR) {
450 bestSNR = smallestSNRofFreq;
451 refStationID = station.
GetId();
453 for (
unsigned int beaconFreqN=0; beaconFreqN < beaconFrequencies.size(); ++beaconFreqN)
454 refStationPhases[beaconFreqN] = modPhases[beaconFreqN][station.
GetId()];
460 message <<
"SNR (in power) for station "
463 for (
unsigned int beaconFreqN=0; beaconFreqN < beaconFrequencies.size(); ++beaconFreqN)
464 message << SNRs[beaconFreqN][station.
GetId()] <<
" \t ";
465 if (fInfoLevel >= eInfoDebug)
471 message <<
"Selected station "
473 <<
" as reference, since its SNR (power) in the worst frequency is: "
475 if ((fInfoLevel >= eInfoIntermediate) && (fFixedReferenceStationID>0))
479 if (bestSNR < fMinSNR) {
481 message <<
"The SNR (power) of the worst frequency of the reference station is insufficient: "
486 if (fInfoLevel >= eInfoFinal)
492 double referenceDelay = 0;
494 if (fUseBeaconDistanceInsteadOfDatabaseValues) {
501 referenceDelay = (refStationPosition - beaconPosition).GetMag() /
speedOfLight;
511 timeOffsets[station.
GetId()] = 0;
512 timeOffsetUncertainty[station.
GetId()] = 99.;
515 bool skipStation =
false;
516 for (
unsigned int beaconFreqN=0; beaconFreqN < beaconFrequencies.size(); ++beaconFreqN) {
517 if ( referencePhases[beaconFreqN].find(station.
GetId()) == referencePhases[beaconFreqN].end() )
527 unsigned int goodSNRfreqs = 0;
529 for (
unsigned int beaconFreqN=0; beaconFreqN < beaconFrequencies.size(); ++beaconFreqN) {
530 if ((SNRs[beaconFreqN][station.
GetId()] > fMinSNR) && (SNRs[beaconFreqN][refStationID] > fMinSNR))
534 if (goodSNRfreqs < fMinGoodFreqs) {
536 message <<
"Station " << station.
GetId() <<
" has " << goodSNRfreqs
537 <<
" beacon signals with good SNR. At least "
538 << fMinGoodFreqs <<
" are requiered."
539 <<
" No timing correction possible.";
540 if (fInfoLevel >= eInfoFinal)
543 timeOffsets[station.
GetId()] = 0;
552 if (
abs(timeStampOffsetGPS) > 1e7) {
554 message <<
"Trace start time of station "
557 << timeStampOffsetGPS
558 <<
" ns larger than event time stamp! --> Station ignored!";
559 if (fInfoLevel >= eInfoFinal)
569 if (fUseCrossCorrelationMethod) {
570 double expectedDelay = 0;
573 if (fUseBeaconDistanceInsteadOfDatabaseValues) {
578 expectedDelay = (stationPosition - beaconPosition).GetMag() /
speedOfLight - referenceDelay;
583 const double mainstepsize = 0.5;
584 const double finestepsize = 0.01;
585 double maxShiftValue = 0;
586 double lastSum = -1e99;
587 double secondLastSum = -1e99;
588 double currentMaxSum = -1e99;
589 for (
double shift = - fMaxTimeDifference; shift <= fMaxTimeDifference; shift += mainstepsize) {
590 double currentSum = 0;
591 for (
unsigned int beaconFreqN=0; beaconFreqN < beaconFrequencies.size(); ++beaconFreqN) {
592 double phasediff = phases[beaconFreqN][station.
GetId()] - phases[beaconFreqN][refStationID]
593 - timeStampOffsetGPS * (
kTwoPi * beaconFreqsInSpectrum[beaconFreqN])
594 - shift * (
kTwoPi * beaconFreqsInSpectrum[beaconFreqN]);
595 if (fUseBeaconDistanceInsteadOfDatabaseValues)
596 phasediff += expectedDelay * (
kTwoPi * beaconFreqsInSpectrum[beaconFreqN]);
598 phasediff += referencePhases[beaconFreqN][refStationID] - referencePhases[beaconFreqN][station.
GetId()];
614 if (SNRs[beaconFreqN][station.
GetId()] < fMinSNR)
615 weight *=
sqrt(SNRs[beaconFreqN][station.
GetId()]/fMinSNR);
616 if (SNRs[beaconFreqN][refStationID] < fMinSNR)
617 weight *=
sqrt(SNRs[beaconFreqN][refStationID]/fMinSNR);
618 currentSum += weight*cos(phasediff);
624 if ((lastSum>currentSum)&&(lastSum>secondLastSum)) {
625 for (
double fineshift = shift-2*mainstepsize; fineshift < shift; fineshift += finestepsize) {
626 double newFineSearchSum = 0;
627 for (
unsigned int beaconFreqN=0; beaconFreqN < beaconFrequencies.size(); ++beaconFreqN) {
628 double phasediff = phases[beaconFreqN][station.
GetId()] - phases[beaconFreqN][refStationID]
629 - timeStampOffsetGPS * (
kTwoPi * beaconFreqsInSpectrum[beaconFreqN])
630 - fineshift * (
kTwoPi * beaconFreqsInSpectrum[beaconFreqN]);
631 if (fUseBeaconDistanceInsteadOfDatabaseValues)
632 phasediff += expectedDelay * (
kTwoPi * beaconFreqsInSpectrum[beaconFreqN]);
634 phasediff += referencePhases[beaconFreqN][refStationID] - referencePhases[beaconFreqN][station.
GetId()];
637 if (SNRs[beaconFreqN][station.
GetId()] < fMinSNR)
638 weight *=
sqrt(SNRs[beaconFreqN][station.
GetId()]/fMinSNR);
639 if (SNRs[beaconFreqN][refStationID] < fMinSNR)
640 weight *=
sqrt(SNRs[beaconFreqN][refStationID]/fMinSNR);
641 newFineSearchSum += weight*cos(phasediff);
644 if (newFineSearchSum > currentMaxSum) {
645 maxShiftValue = fineshift;
646 currentMaxSum = newFineSearchSum;
652 secondLastSum = lastSum;
653 lastSum = currentSum;
655 timeOffsets[station.
GetId()] = maxShiftValue;
656 timeOffsetUncertainty[station.
GetId()] = 0;
661 double timeOffset = 0;
665 while (
abs(timeOffset) <= fMaxTimeDifference) {
668 for (
unsigned int beaconFreqN=0; beaconFreqN < beaconFrequencies.size(); ++beaconFreqN) {
669 double phasediff = modPhases[beaconFreqN][station.
GetId()] - refStationPhases[beaconFreqN]
670 - timeOffset * (
kTwoPi * beaconFreqsInSpectrum[beaconFreqN])
671 - timeStampOffsetGPS * (
kTwoPi * beaconFreqsInSpectrum[beaconFreqN]);
674 while (phasediff >
kPi)
676 while (phasediff < -
kPi)
679 double timediff = phasediff / (
kTwoPi * beaconFreqsInSpectrum[beaconFreqN] ) + timeOffset;
680 timeDiffsFreq[beaconFreqN][station.
GetId()] = timediff;
684 vector<double> stationTimeDiffs;
685 for (
unsigned int beaconFreqN=0; beaconFreqN < beaconFrequencies.size(); ++beaconFreqN)
686 if ((SNRs[beaconFreqN][station.
GetId()] > fMinSNR) && (SNRs[beaconFreqN][refStationID] > fMinSNR))
687 stationTimeDiffs.push_back(timeDiffsFreq[beaconFreqN][station.
GetId()]);
692 message <<
"Timediffs for station "
695 for (
unsigned int beaconFreqN=0; beaconFreqN < beaconFrequencies.size(); ++beaconFreqN)
696 message << timeDiffsFreq[beaconFreqN][station.
GetId()] <<
" \t";
697 if (fInfoLevel >= eInfoDebug)
702 double meanTdiff = accumulate(stationTimeDiffs.begin(), stationTimeDiffs.end(), 0.) / double(stationTimeDiffs.size());
703 double deviationFromMean = 0;
706 message <<
"Mean tdiff = "
708 <<
" ns, deviations per beacon freq: ";
710 bool tDiffsGood =
true;
711 for (vector<double>::iterator it = stationTimeDiffs.begin();
712 it != stationTimeDiffs.end(); ++it) {
713 message <<
abs(*it - meanTdiff)
715 deviationFromMean +=
abs(*it - meanTdiff) / stationTimeDiffs.size();
718 if (
abs(*it - meanTdiff) > fEpsilon)
721 if (fInfoLevel >= eInfoDebug) {
724 message <<
"Absolute mean deviation = "
734 timeOffsets[station.
GetId()] = meanTdiff;
735 timeOffsetUncertainty[station.
GetId()] = deviationFromMean;
738 if (timeOffset > 0.) {
758 if (timeOffsetUncertainty[station.
GetId()] < 99.) {
770 message <<
"Shifted trace starttime of station "
773 << timeOffsets[station.
GetId()]
774 <<
" ns; \tuncert. ~ "
775 << timeOffsetUncertainty[station.
GetId()]
777 if (fInfoLevel >= eInfoIntermediate)
781 --fBeaconCorrectionFailures[station.
GetId()];
782 ++fBeaconCorrectionSuccesses[station.
GetId()];
784 if (fRejectIfCorrectionFailed)
787 message <<
"Shifted trace starttime of station "
789 <<
" by 0 ns - Beacon correction failed!";
790 if (fRejectIfCorrectionFailed)
791 message <<
" Station will be rejected.\n";
794 if (fInfoLevel >= eInfoIntermediate)
801 if (fEqualizeStationTimeStamps)
802 matchStationTimeStamps(rEvent);
805 if (fDebugStationIds.size() > 0)
806 if (!writeDebugFile(refStationID, timeOffsets, timeOffsetUncertainty, rEvent.
GetHeader().
GetTime()+ refStationTimeStamp)) {
808 message <<
"Error while writing debug file: "
810 ERROR(message.str());
817 fFirstModuleCall =
false;
824 RdChannelBeaconTimingCalibrator::Finish()
829 info <<
"Statistics of Beacon correction:\n"
830 "Station ID #successes #failures SNR(freq1) SNR(freq2) SNR(freq3) SNR(freq4)\n"
831 "--------------------------------------------------------------------------------------------\n";
833 for (
const auto& ie : fBeaconCorrectionFailures) {
834 const auto id = ie.first;
835 info <<
" " <<
id <<
" \t"
836 << fBeaconCorrectionSuccesses[id] <<
" \t "
837 << fBeaconCorrectionFailures[id] <<
" \t "
838 << fBeaconSNRs[id][0] / fBeaconSNRcounter[id] <<
" \t "
839 << fBeaconSNRs[id][1] / fBeaconSNRcounter[id] <<
" \t "
840 << fBeaconSNRs[id][2] / fBeaconSNRcounter[id] <<
" \t "
841 << fBeaconSNRs[id][3] / fBeaconSNRcounter[id] <<
'\n';
844 info <<
"--------------------------------------------------------------------------------------------";
850 std::vector<std::map<int, double> >
851 RdChannelBeaconTimingCalibrator::getReferencePhases(std::vector<double> beaconFrequencies)
853 static std::vector<std::map<int, double> > referencePhases;
856 if (referencePhases.size() > 0)
857 return referencePhases;
864 phasefile.open(fInputPhaseFile.c_str());
866 stringstream message;
867 if ((phasefile.is_open()) && (phasefile.good())) {
869 message <<
"Reading reference phases from file: "
871 if (fInfoLevel >= eInfoDebug)
875 message <<
"Cannot open file for reference phases: "
877 ERROR(message.str());
878 return referencePhases;
882 stringstream headerDummy;
884 phasefile >> readString;
886 if (readString !=
"Station") {
887 ERROR(
"Wrong format of file header");
889 return referencePhases;
892 for (
unsigned int beaconFreqN = 0; beaconFreqN < beaconFrequencies.size(); ++beaconFreqN) {
893 if (!phasefile.good() ) {
894 ERROR(
"Wrong format of file header");
895 return referencePhases;
898 phasefile >> readString;
900 headerDummy <<
"RefPhase[rad]_for_" << beaconFrequencies[beaconFreqN]/
megahertz <<
"MHz";
901 if (readString != headerDummy.str()) {
902 if (fBeaconFrequencies.size() < 1)
903 ERROR(
"Beacon frequencies in file header do not match frequencies read from database! Maybe only the order of the frequencies is wrong.");
905 ERROR(
"Beacon frequencies in file header do not match XML file!");
907 return referencePhases;
912 referencePhases = vector<map<int, double> > (beaconFrequencies.size());
914 while (phasefile.good()) {
915 unsigned int stationID=0;
916 phasefile >> stationID;
918 if (!phasefile.good())
920 for (
unsigned int beaconFreqN = 0; beaconFreqN < beaconFrequencies.size(); ++beaconFreqN) {
922 phasefile >> refPhase;
923 referencePhases[beaconFreqN][stationID] = refPhase;
929 return referencePhases;
934 RdChannelBeaconTimingCalibrator::matchStationTimeStamps(
revt::REvent& rEvent)
const
937 double firstTimeStamp = rEvent.
StationsBegin()->GetRecData().GetParameter(eTraceStartTime);
944 if (stationTimeStamp != firstTimeStamp) {
950 FFTDataContainerAlgorithm::ShiftTimeSeries(channel.
GetFFTDataContainer(), stationTimeStamp-firstTimeStamp);
964 RdChannelBeaconTimingCalibrator::writeDebugFile(
const int& refStationID,
965 const std::map<int,double>& timeOffsets,
966 const std::map<int,double>& timeUncertainties,
971 if (fFirstModuleCall) {
972 if (!fOverwriteDebugFile) {
973 ifstream testReading;
974 testReading.open(fDebugOutputFile.c_str());
975 if (testReading.is_open()) {
976 stringstream message;
977 message <<
"Debug file '"
979 <<
"' already exists! No debug output written!\n";
980 ERROR(message.str());
987 ofstream debugFileHeaderWriting(fDebugOutputFile.c_str());
988 debugFileHeaderWriting <<
"GPStime[s] \tRefStationID";
989 for (set<int>::iterator it=fDebugStationIds.begin(); it != fDebugStationIds.end(); ++it)
990 debugFileHeaderWriting <<
" \t" << *it <<
"_offset[ns] \t" << *it <<
"_uncert[ns]";
991 debugFileHeaderWriting << endl;
992 debugFileHeaderWriting.close();
997 outputfile.open(fDebugOutputFile.c_str(), ofstream::app);
1000 if (!(outputfile.is_open())) {
1001 stringstream message;
1002 message <<
"Failed to open beacon debug file: "
1003 << fDebugOutputFile;
1004 ERROR(message.str());
1010 << setfill (
'0') << setw(9) << int(round(eventGPStimeStamp.
GetGPSNanoSecond()))
1011 <<
" \t" << refStationID;
1014 for (
auto it = fDebugStationIds.begin(); it != fDebugStationIds.end(); ++it) {
1016 if ( timeUncertainties.find(*it) != timeUncertainties.end() ) {
1018 if ( timeUncertainties.find(*it)->second != 99. )
1019 outputfile <<
" \t" << setfill (
' ') << setw(7) << timeOffsets.find(*it)->second
1020 <<
" \t" << setfill (
' ') << setw(7) << timeUncertainties.find(*it)->second;
1022 outputfile <<
" \t" <<
" xxx " <<
" \t" <<
" xxx ";
1024 outputfile <<
" \t" <<
" --- " <<
" \t" <<
" --- ";
ChannelFFTDataContainer & GetFFTDataContainer()
retrieve Channel FFTDataContainer (write access)
void SetParameterError(Parameter i, double value, bool lock=true)
double GetBeaconReferencePhase(const int stationId, const double beaconFreq) const
Get beacon reference phases for one station.
int GetId() const
Return Id of the Channel.
StationRecData & GetRecData()
Get station level reconstructed data.
Interface class to access to the Radio part of an event.
#define INFO(message)
Macro for logging informational messages.
StationIterator StationsEnd()
StationIterator StationsBegin()
const double speedOfLight
void Init()
Initialise the registry.
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
ChannelIterator ChannelsBegin()
begin Channel iterator for read/write
boost::filter_iterator< StationFilter, AllStationIterator > StationIterator
Iterator over all (non-exculded) stations.
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
A TimeStamp holds GPS second and nanosecond for some event.
Detector description interface for RDetector-related data.
Class representing a document branch.
Exception to use in case requested data not found in the database with detailed printout.
class to hold data at the radio Station level.
std::vector< std::complex< double > >::size_type SizeType
constexpr double nanosecond
double abs(const SVector< n, T > &v)
Header & GetHeader()
access to REvent Header
Top of the hierarchy of the detector description interface.
int GetNumberOfStations() const
Get total number of stations in the event.
constexpr double megahertz
#define WARNING(message)
Macro for logging warning messages.
void GetData(bool &b) const
Overloads of the GetData member template function.
void SetRejectedReason(const unsigned long long int reason)
int GetId() const
Get the station Id.
boost::filter_iterator< StationFilter, ConstAllStationIterator > ConstStationIterator
double GetParameter(const Parameter i) const
Channel & GetChannel(const int pmtId)
Retrieve a Channel by Id.
constexpr double kSpeedOfLight
ResultFlag
Flag returned by module methods to the RunController.
unsigned long GetGPSSecond() const
GPS second.
double GetGPSNanoSecond() const
GPS nanosecond.
static CentralConfig * GetInstance()
Use this the first time you get an instance of central configuration.
utl::CoordinateSystemPtr GetReferenceCoordinateSystem() const
Get the reference coordinate system used for analysis (usually PampaAmarilla for Auger) ...
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.
void SetParameter(Parameter i, double value, bool lock=true)
Class that holds the data associated to an individual radio channel.
const rdet::RDetector & GetRDetector() const
bool HasStation(const int stationId) const
Check whether station exists.
utl::Point GetPosition() const
Tank position in Site Cartesian Coordinates.
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.
utl::Branch GetTopBranch(const std::string &id)
Get top branch for moduleConfigLink with given id (XML files)