2 #include <utl/ErrorLogger.h>
5 #include <revt/REvent.h>
6 #include <revt/Header.h>
7 #include <revt/Station.h>
8 #include <revt/Channel.h>
9 #include <revt/StationRecData.h>
10 #include <revt/ChannelRRecDataQuantities.h>
12 #include <utl/Point.h>
13 #include <utl/Trace.h>
14 #include <utl/TraceAlgorithm.h>
15 #include <utl/ErrorLogger.h>
16 #include <utl/Reader.h>
17 #include <utl/config.h>
18 #include <utl/AugerUnits.h>
19 #include <utl/RadioGeometryUtilities.h>
20 #include <utl/TimeStamp.h>
21 #include <utl/UTCDate.h>
22 #include <fwk/CentralConfig.h>
24 #include <det/Detector.h>
25 #include <rdet/RDetector.h>
30 #include "TProfile2D.h"
36 #include <utl/LeapSeconds.h>
38 #define INFO2(x,y) if ((x) <= fInfoLevel) INFO(y)
45 double RdChannelNoisePowerAnalyser::GPSSecToLSTHourAuger(
const unsigned long gps)
47 const double J2000 = 2451545.0;
48 const double Dtohr = 0.066666666666666;
49 const double auger_longitude = -69.6;
53 utl::LeapSeconds::GetInstance().ConvertGPSToUnix(gps, utc);
55 const tm*
const t = gmtime(&utc);
56 int year = t->tm_year + 1900;
57 int month = t->tm_mon + 1;
58 const int day = t->tm_mday;
59 const int hour = t->tm_hour;
60 const int min = t->tm_min;
61 const int sec = t->tm_sec;
63 #warning can you use the utl::ModifiedJulianDate here?
69 const int a = int(floor(year / 100.));
70 const int b = 2 - a + a / 4;
71 double jd = floor(365.25 * (year + 4716)) + floor(30.6001 * (month + 1)) + day + b - 1524.5;
72 const double fd = double(60 * 60 * hour + 60 * min + sec) / 86400;
75 static double sidereal_coeff[4] = { 280.46061837, 360.98564736629, 0.000387933, 38710000 };
76 const double dt = jd -
J2000;
77 const double dt0 = dt / 36525.;
78 const double theta = sidereal_coeff[0] + dt * sidereal_coeff[1]
79 + dt0 * dt0 * (sidereal_coeff[2] - dt0 / sidereal_coeff[3]);
82 const double lst = fmod(theta + (360 + auger_longitude), 360.) *
Dtohr;
88 fUnbinnedASCIIOutput(false),
89 fFrequencyBinWidth(1 * utl::
MHz),
90 fMinFrequency(30 * utl::
MHz),
91 fMaxFrequency(80 * utl::
MHz),
92 fOutputPath(
"output"),
93 fOutputFilename(
"noise_amplitudes"),
94 fMinimumStationId(101),
95 fMaximumStationId(224),
98 fLocalSiderealDay(86164.090530833 * utl::
second),
99 fNumberOfBinsPerDay(144),
101 fReferenceTime(utl::UTCDateTime(2011, 1, 1, 0, 0, 0, 0.)),
115 INFO(
"RdChannelNoisePowerAnalyser::Init()");
117 "RdChannelNoisePowerAnalyser");
126 if (outputfilename.substr(outputfilename.size() - 1, 1) !=
"/") {
127 outputfilename.append(
"/");
130 std::string rootOutputFilename = outputfilename +
".root";
131 fRootOut =
new TFile(rootOutputFilename.c_str(),
"RECREATE");
138 cout <<
"creating data structure...";
140 cout <<
"." << std::flush;
143 Key key(iStation, iChannel, iFrequency);
147 title <<
"station " << boost::get<0>(key) <<
", channel " << boost::get<1>(key)
171 sstr <<
"Power2DSparse_" << boost::get<0>(key) <<
"_" << boost::get<1>(key) <<
"_"
172 << boost::get<2>(key);
175 Double_t xmin[2] = { 0, -14 };
176 Double_t xmax[2] = { 24, -6 };
177 THnSparseF* hs =
new THnSparseF(sstr.str().c_str(), title.str().c_str(), 2, bins, xmin,
180 hs->GetAxis(0)->SetTitle(
"LST [h]");
181 hs->GetAxis(1)->SetTitle(
"Log (power spectral density [W/MHz])");
188 sstr <<
"Power2DSparseLinear_" << boost::get<0>(key) <<
"_" << boost::get<1>(key) <<
"_"
189 << boost::get<2>(key);
192 Double_t xmin2[2] = { 0, 1e-12 };
193 Double_t xmax2[2] = { 24, 50e-12 };
194 THnSparseF* hs2 =
new THnSparseF(sstr.str().c_str(), title.str().c_str(), 2, bins2, xmin2,
196 hs2->GetAxis(0)->SetTitle(
"LST [h]");
197 hs2->GetAxis(1)->SetTitle(
"power spectral density [W/MHz]");
217 INFO2(
eDebug,
"RdChannelNoisePowerAnalyser::Run()");
220 WARNING(
"RdChannelNoisePowerAnalyser::No radio event found!");
238 sstr <<
"initializing dynamic power spectrum for month " << month <<
" and year " <<
year;
245 sstr <<
"DynamicSpectrum_" << boost::get<0>(key) <<
"_" << boost::get<1>(key) <<
"_"
246 << boost::get<2>(key) <<
"_" << boost::get<3>(key);
248 title <<
"station " << boost::get<0>(key) <<
", channel " << boost::get<1>(key) <<
", "
249 << month <<
" " <<
year;
251 int nextMonth = month + 1;
253 if (nextMonth > 12) {
263 TProfile2D *hHist2dPower =
new TProfile2D(
264 sstr.str().c_str(), title.str().c_str(), numberOfBins,
271 hHist2dPower->SetDirectory(
fRootOut);
272 hHist2dPower->GetYaxis()->SetTitle(
"frequency [GHz]");
273 hHist2dPower->GetXaxis()->SetTitle(
"GPS seconds");
274 hHist2dPower->GetZaxis()->SetTitle(
"log(power spectral density [W/MHz])");
277 info <<
"initializing dynamic power spectrum for month " << month <<
" and year " << year
278 <<
"station " << iStation <<
" and channel " << iChannel;
287 std::vector<double> LSDBinBorders;
292 int deltaLSTBin = -1;
294 if (deltaLST >= LSDBinBorders[i] and deltaLST < LSDBinBorders[i + 1]) {
298 if (deltaLSTBin == -1) {
299 cout <<
"delta LSTBin == -1, deltaLST = " << deltaLST << endl;
302 std::map<int, std::vector<std::vector<double> > > noiseMap;
308 info <<
"station " << iS->GetId() <<
" is out of range, skipping station.";
312 std::vector<std::vector<double> > tmpChannels;
315 if (not iC->IsActive()) {
317 info <<
"channel " << iC->GetId() <<
" is inactive. Skipping channel";
324 info <<
"channel " << iC->GetId() <<
" is out of range, skipping channel";
329 const double timeBinSize = iC->GetFFTDataContainer().GetConstTimeSeries().GetBinning();
330 const double traceLength = iC->GetFFTDataContainer().GetConstTimeSeries().GetSize()
337 std::vector<double> noiseAmplitudes;
354 Key key(iS->GetId(), iC->GetId(), i);
355 int binStart = iC->GetFFTDataContainer().GetBinOfFrequency(
fFrequencies[i]);
356 int binStop = iC->GetFFTDataContainer().GetBinOfFrequency(
fFrequencies[i + 1]);
357 double frequencyInterval = iC->GetFFTDataContainer().GetFrequencyOfBin(binStop)
358 - iC->GetFFTDataContainer().GetFrequencyOfBin(binStart);
359 double noiseAmplitude(0.);
360 double noisePower(0.);
362 for (
int j = binStart; j < binStop; ++j) {
363 noiseAmplitude +=
abs(spectrum[j]);
364 noisePower +=
abs(spectrum[j]) *
abs(spectrum[j]);
367 noiseAmplitude *= 1. / (binStop - binStart);
368 noisePower *= 1. / (binStop - binStart);
372 noisePower /= traceLength;
384 double x[2] = { deltaLST, TMath::Log10(noisePower) };
387 double x2[2] = { deltaLST, noisePower};
392 TMath::Log10(noisePower));
394 tmpChannels.push_back(noiseAmplitudes);
405 INFO(
"RdChannelNoisePowerAnalyser::Finish()");
409 typedef std::map<KeyYearMonth, TProfile2D*>::iterator it_type;
411 iterator->second->Write();
440 Key key(iStation, iChannel, iFrequency);
double fFrequencyBinWidth
Report success to RunController.
CandidateStationIterator CandidateStationsEnd()
boost::indirect_iterator< InternalConstChannelIterator, const Channel & > ConstChannelIterator
Iterator over station for read.
Interface class to access to the Radio part of an event.
Skip remaining modules in the current loop and continue with next iteration of the loop...
double GPSSecToLSTHourAuger(const unsigned long gps)
const int fMaximumChannelId
#define INFO(message)
Macro for logging informational messages.
void Init()
Initialise the registry.
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
const int fNumberOfBinsPerDay
std::map< KeyYearMonth, TProfile2D * > fDynamicPowerSpectrum
A TimeStamp holds GPS second and nanosecond for some event.
boost::filter_iterator< CandidateStationFilter, ConstAllStationIterator > ConstCandidateStationIterator
Class representing a document branch.
static int NumberOfDaysInMonth(const int year, const int month)
double abs(const SVector< n, T > &v)
Header & GetHeader()
access to REvent Header
CandidateStationIterator CandidateStationsBegin()
boost::tuple< int, int, int > Key
#define WARNING(message)
Macro for logging warning messages.
void GetData(bool &b) const
Overloads of the GetData member template function.
std::string fOutputFilename
ResultFlag
Flag returned by module methods to the RunController.
unsigned long GetGPSSecond() const
GPS second.
static CentralConfig * GetInstance()
Use this the first time you get an instance of central configuration.
boost::tuple< int, int, int, int > KeyYearMonth
const int fMinimumChannelId
TimeStamp GetTimeStamp() const
std::vector< double > fFrequencies
utl::Branch GetTopBranch(const std::string &id)
Get top branch for moduleConfigLink with given id (XML files)
std::map< Key, THnSparseF * > fHistogramPowerMap
std::map< Key, THnSparseF * > fHistogramPowerMapLinear