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>
11 #include <utl/Point.h>
12 #include <utl/Trace.h>
13 #include <utl/TraceAlgorithm.h>
14 #include <utl/ErrorLogger.h>
15 #include <utl/Reader.h>
16 #include <utl/config.h>
17 #include <utl/AugerUnits.h>
18 #include <utl/RadioGeometryUtilities.h>
19 #include <fwk/CentralConfig.h>
21 #include <det/Detector.h>
22 #include <rdet/RDetector.h>
26 #define INFO2(x,y) if ((x) <= fInfoLevel) INFO(y)
39 fOutputPath(
"output"),
40 fOutputFilename(
"noisecounter"),
41 fMinimumStationId(100),
42 fMaximumStationId(124),
43 fMaximumNeighborDistance(200 * utl::
meter)
56 INFO(
"RdChannelNoisePulseCounter::Init()");
80 vector<revt::Station::ConstChannelIterator> usableChannels;
84 usableChannels.push_back(cIt);
87 if (usableChannels.size() == 0) {
90 info << station.
GetId();
92 <<
" does not have any channels, removing it! Should treat this case beforehand, e.g. in RdChannelSelector.";
98 if (usableChannels.size() != 2) {
99 if (usableChannels.size() == 3) {
102 info << station.
GetId();
104 <<
" does have three active channels! The PreWaveFitter does only support two active channel for the moment. The first two active channels will be used.";
109 info << station.
GetId();
111 <<
" does not have exactly two active channels! Have you forgotten to include the RdChannelSelector?";
114 "RdPreWaveFitter does not support stations with number of Channels != 2 or != 3.");
125 channelTrace.ClearTrace();
127 for (
unsigned int i = 0; i < channelTrace1.
GetSize(); ++i) {
129 sqrt((channelTrace1[i] * channelTrace1[i]) + (channelTrace2[i] * channelTrace2[i])));
132 unsigned int start = NoiseSearchWindowStart / channelTrace1.
GetBinning();
133 unsigned int stop = NoiseSearchWindowStop / channelTrace1.
GetBinning();
134 unsigned int startSignal = SignalSearchWindowStart / channelTrace1.
GetBinning();
135 unsigned int stopSignal = SignalSearchWindowStop / channelTrace1.
GetBinning();
139 return amplitude * amplitude / (rms * rms);
146 INFO(
"RdChannelNoisePulseCounter::Run()");
149 WARNING(
"RdChannelNoisePulseCounter::No radio event found!");
154 const det::Detector& detector = det::Detector::GetInstance();
157 std::map<int, std::vector<int> > mNeighbors;
158 for (std::vector<int>::const_iterator sIt = fullStationList.begin(); sIt != fullStationList.end(); ++sIt) {
163 if (!mNeighbors.count(
id)) {
164 std::vector<int> neighbors;
165 mNeighbors[id] = neighbors;
168 for (std::vector<int>::const_iterator sIt2 = fullStationList.begin(); sIt2 != fullStationList.end(); ++sIt2) {
169 const int id2 = *sIt2;
178 mNeighbors[id].push_back(id2);
183 for (std::map<
int, std::vector<int> >::iterator it=mNeighbors.begin(); it!=mNeighbors.end(); ++it) {
185 info <<
"Station " << it->first <<
" has neighbors: ";
186 for(std::vector<int>::iterator itNeighbor = it->second.begin(); itNeighbor!=it->second.end(); ++itNeighbor) {
187 info << *itNeighbor <<
" ";
193 std::map<int, bool> pulseFoundMap;
197 const int id = station.
GetId();
214 pulseFoundMap[id] =
true;
218 pulseFoundMap[id] =
false;
224 - SignalSearchWindowStart);
229 std::map<int, int> coincidentPulses_tmp;
230 for (std::map<int, bool>::iterator it=pulseFoundMap.begin(); it!=pulseFoundMap.end(); ++it) {
233 int nCoincidences = 1;
234 for(std::vector<int>::iterator itNeighbor = mNeighbors[
id].begin(); itNeighbor!=mNeighbors[id].end(); ++itNeighbor) {
235 if(pulseFoundMap[*itNeighbor]) {
239 if (!coincidentPulses_tmp.count(nCoincidences)) {
240 coincidentPulses_tmp[nCoincidences] = 1;
242 coincidentPulses_tmp[nCoincidences]++;
247 for (std::map<int, int>::iterator it = coincidentPulses_tmp.begin(); it != coincidentPulses_tmp.end(); ++it) {
262 INFO(
"RdChannelNoisePulseCounter::Finish()");
265 std::ofstream ofs_SNR;
266 std::ofstream ofs_GPS;
269 if(outputfilename.substr(outputfilename.size()-1, 1) !=
"/") {
270 outputfilename.append(
"/");
274 ofs_SNR.open ((outputfilename+
"_SNRs.out").c_str(), std::ofstream::app);
275 ofs_SNR.precision(5);
277 ofs_SNR <<
"\t" << *itSNR;
280 ofs_GPS.open ((outputfilename+
"_GPSSeconds.out").c_str(), std::ofstream::app);
282 ofs_GPS <<
"\t" << *itGPS;
286 ofs.open ((outputfilename+
".out").c_str(), std::ofstream::app);
287 ofs <<
"# nTraces\tnPulseFounds\ttotalSignalSerachWindow\n";
291 ofs.open ((outputfilename+
"_stationwise.out").c_str(), std::ofstream::app);
292 ofs_SNR.open ((outputfilename+
"_SNRs_stationwise.out").c_str(), std::ofstream::app);
293 ofs_GPS.open ((outputfilename+
"_GPSSeconds_stationwise.out").c_str(), std::ofstream::app);
294 ofs_SNR.precision(5);
296 ofs << it->first <<
"\t" << it->second.numberOfTraces <<
"\t" << it->second.numberOfPulses <<
"\t" << it->second.totalSignalSerachWindow << endl;
297 ofs_SNR << it->first;
298 for (std::vector<double>::iterator itSNR = it->second.SNRs.begin(); itSNR!=it->second.SNRs.end(); ++itSNR) {
299 ofs_SNR <<
"\t" << *itSNR;
303 ofs_GPS << it->first;
304 for (std::vector<int>::iterator itSNR = it->second.GPSsecods.begin(); itSNR!=it->second.GPSsecods.end(); ++itSNR) {
305 ofs_GPS <<
"\t" << *itSNR;
313 std::ofstream ofs_CoincidentPulses;
314 ofs_CoincidentPulses.open((outputfilename+
"_spatial_coincidences.out").c_str(), std::ofstream::app);
316 ofs_CoincidentPulses << it->first <<
"\t" << it->second <<
"\t" <<
fNumberOfEvents << endl;
318 ofs_CoincidentPulses.close();
Branch GetTopBranch() const
static double Max(const Trace< T > &trace, const unsigned int bin1, const unsigned int bin2)
Evaluate the maximum of trace between bin1 and bin2.
NoisePulseData fNoisePulseData
std::vector< int > GPSsecods
Report success to RunController.
StationRecData & GetRecData()
Get station level reconstructed data.
std::vector< double > SNRs
boost::indirect_iterator< InternalConstChannelIterator, const Channel & > ConstChannelIterator
Iterator over station for read.
Interface class to access to the Radio part of an event.
long unsigned int numberOfTraces
Skip remaining modules in the current loop and continue with next iteration of the loop...
double GetBinning() const
size of one slot
const std::vector< int > & GetFullStationList() const
Get list of ID's for all stations available in the database or configuration file.
#define INFO(message)
Macro for logging informational messages.
StationIterator StationsEnd()
StationIterator StationsBegin()
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.
ChannelTimeSeries & GetChannelTimeSeries()
retrieve Channel Time Series (write access, only use this if you intend to change the data) ...
ChannelIterator ChannelsEnd()
end Channel iterator for read/write
Detector description interface for RDetector-related data.
std::map< int, int > fCoincidentPulses
Class representing a document branch.
class to hold data at the radio Station level.
long unsigned int numberOfPulses
double totalSignalSerachWindow
Header & GetHeader()
access to REvent Header
std::string fOutputFilename
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.
int GetId() const
Get the station Id.
static double RootMeanSquare(const Trace< T > &trace, const unsigned int bin1, const unsigned int bin2)
Evaluate the RootMeanSquare of trace between bin1 and bin2.
Base class for inconsistency/illogicality exceptions.
double GetParameter(const Parameter i) const
void SetBinning(const double binning)
ResultFlag
Flag returned by module methods to the RunController.
unsigned long GetGPSSecond() const
GPS second.
double FindPulse(revt::Station &station)
Class that holds the data associated to an individual radio channel.
const rdet::RDetector & GetRDetector() const
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.
double fMaximumNeighborDistance
std::map< int, NoisePulseData > fStationNoisePulseData