3 #include <utl/ErrorLogger.h>
4 #include <utl/AugerException.h>
9 #include <evt/Header.h>
10 #include <revt/REvent.h>
11 #include <revt/Station.h>
12 #include <revt/Channel.h>
13 #include <revt/Header.h>
14 #include <revt/StationTriggerData.h>
15 #include <revt/StationGPSData.h>
16 #include <revt/EventTrigger.h>
17 #include <revt/StationHeader.h>
18 #include <utl/Trace.h>
19 #include <utl/TimeStamp.h>
20 #include <utl/UTCDateTime.h>
21 #include <utl/LeapSeconds.h>
23 #include <det/Detector.h>
24 #include <rdet/RDetector.h>
25 #include <rdet/Station.h>
37 #include <AeraEvent.h>
49 RadioFileAERA::RadioFileAERA(
const std::string&
filename,
53 Open(filename, mode, b);
62 setAevreadLoglevel(0);
63 setAevreadBufferedRead(
true);
64 if (openAeraEventFile(filename.c_str())) {
68 const string msg =
"Something wrong occured when opening " +
filename;
75 RadioFileAERA::Close()
88 WARNING(
"RadioFileAERA::Write not implemented!");
95 AeraEvent*
const aev = fIsFirstevent ? getFirstAeraEvent() : getNextAeraEvent();
96 fIsFirstevent =
false;
104 WARNING(
"Event not cleared - has REvent");
108 REvent& revent =
event.GetREvent();
109 const int event_id = getAeraEventEventId();
110 const int run_id = getAeraEventRunId();
111 const int file_id = getAeraFileHeaderFileId();
113 const int eventversion = getAeraEventEventVersion();
114 const int numberofstations = getAeraEventLsCount();
122 id <<
"revt_"<< run_id<<
"_" << event_id;
123 event.GetHeader().SetId(
id.str());
124 unsigned int ts_s = getAeraEventGPSSeconds();
125 unsigned int ts_ns = getAeraEventNanoSeconds();
129 WARNING(
"Event skipped! TimeStamp was not filled correctly.");
133 if (ts_s > 1293494416) {
138 unsigned long ts_s_gps = 0;
146 WARNING(
"Event skipped! TimeStamp was not filled correctly.");
149 det::Detector::GetInstance().Update(ts);
150 event.GetHeader().SetTime(ts);
153 if (!getAeraEventFirstLsData()) {
154 WARNING(
"No Local station data found");
159 const string msg =
"Warning overwrites Event Trigger information";
164 if (getAeraEventIsSelfTriggered())
166 if (getAeraEventIsExternalT3Trigger())
168 if (getAeraEventIsExternalElTrigger())
170 if (getAeraEventIsRandomTrigger())
172 if (getAeraEventIsCalibTrigger())
176 for (
int i = 0; i < getAeraEventLsCount(); ++i) {
178 const int station_id = LSPOS(getAeraEvbLsId());
180 if (!getAeraEvbChannelPresentCount()) {
181 if (!getAeraEventNextLsData())
187 ostringstream stationname;
189 if (station_id > 200 && station_id < 210)
190 stationname <<
'M' << (station_id - 200);
192 stationname <<
"AERA_" << station_id;
195 const string msg =
"Warning overwrites station information";
201 det::Detector::GetInstance().GetRDetector().GetStation(station);
203 const string msg =
"Overwriting station trigger information";
208 if (getAeraEvbIsSelfTriggered() ||
209 (getAeraEvbHardwareIsDutch() && !getAeraEvbIsRandomTrigger() && !getAeraEvbIsCalibTrigger())) {
212 }
else if (getAeraEvbIsExternalElTrigger())
214 else if (getAeraEvbIsExternalT3Trigger()) {
218 if ((run_id >= 100210 && run_id < 100220) && (ts_ns < 5e8+20) && (ts_ns > 5e8-20)) {
223 if (run_id >= 100220 && (ts_ns < 7 || ts_ns > 1e9-7)) {
228 }
else if (getAeraEvbIsCalibTrigger())
230 else if (getAeraEvbIsRandomTrigger())
234 const string msg =
"Warning overwrites station GPS information";
241 const string msg =
"Warning overwrites station header";
245 if (getAeraEvbHardwareIsDutch())
247 else if (getAeraEvbHardwareIsFrench())
249 else if (getAeraEvbHardwareIsGerman())
253 msg <<
" Unknown Hardware type :: getAeraEvbHardwareType() = " << getAeraEvbHardwareType() <<
"\n"
254 " Event ID is << " <<
id.str() <<
" File is " << file_id <<
"\n"
255 " Skip to next event";
261 const double samplingfreq = double(getAeraEvbSamplingFreq()) *
utl::megahertz;
262 ts_s = getAeraEvbGPSseconds();
264 if (ts_s > 1293494416) {
267 unsigned long ts_s_gps = 0;
274 stationts.
SetGPSTime(ts_s, getAeraEvbGPSnanoseconds());
278 WARNING(
"Event skipped! TimeStamp was not filled correctly.");
281 double pretrigtime = 0;
282 if (getAeraEvbHardwareIsDutch()) {
283 const char*
const raw = (
const char*)getAeraEvbInfoADCbuffer();
284 const UINT16
s = (raw[5] << 8) + (raw[6] & 0xff);
285 const UINT16 t = (raw[7] << 8) + (raw[8] & 0xff);
286 pretrigtime = (s + t) / samplingfreq;
288 pretrigtime = double(getAeraEvbTriggerPos()) / samplingfreq;
293 WARNING(
"Event skipped! TimeStamp was not filled correctly.");
297 const int numberofsamples = getAeraEvbTracelength();
301 for (
int ch_id = 1; ch_id <= detstation.
GetNChannels(); ++ch_id) {
305 if (!getAeraEvbChannelXPresent(ch_id)) {
306 if (!((ch_id == 3 || ch_id == 4) && getAeraEvbHardwareIsGerman())) {
309 info <<
" Channel " << ch_id <<
" Not present in data\n Channel will be marked as non active";
316 if ((ch_id == 3 || ch_id == 4) && getAeraEvbHardwareIsDutch()) {
322 if (getAeraEvbHardwareIsGerman()) {
325 if (getAevreadVersion() > 10201)
328 INT16*
const tmpseries = (INT16*)getAeraEvbChannelXData(ch_id);
331 info <<
" Pointer to time serie is NULL for channel " << ch_id
332 <<
" Channel will be marked as not active ";
337 for (
int ii = 0; ii < numberofsamples; ++ii) {
338 thistrace.
PushBack(tmpseries[ii] + offset);
341 }
else if (getAeraEvbHardwareIsDutch()) {
343 UINT16*
const tmpseries = getAeraEvbChannelXData(ch_id);
346 info <<
" Pointer to time serie is NULL for channel " << ch_id
347 <<
" Channel will be marked as not active ";
352 for (
int ii = 0; ii < numberofsamples; ++ii) {
358 info <<
"Electronic readout is not implemented, Electronic type is " << getAeraEvbHardwareType()
359 <<
" Channel is Set has inactive";
365 if (getAeraEvbHardwareIsDutch()) {
366 thresh = getAeraEvbSignalThresholdX(ch_id);
368 if (thresh != 0xFFFF)
370 thresh = getAeraEvbNoiseThresholdX(ch_id);
371 if (thresh != 0xFFFF)
377 if (!getAeraEventNextLsData())
383 if (i+1 < getAeraEventLsCount())
384 getAeraEventNextLsData();
394 RadioFileAERA::FileStatus()
401 RadioFileAERA::FindEvent(
const unsigned int )
403 WARNING(
"RadioFileAERA::FindEvent not implemented!");
409 RadioFileAERA::GotoPosition(
const unsigned int )
411 WARNING(
"RadioFileAERA::GotoPosition not implemented!");
417 RadioFileAERA::GetNEvents()
419 WARNING(
"RadioFileAERA::GetNEvents not implemented!");
bool HasTrigger() const
check whether the central trigger object exists
StationTriggerData & GetTriggerData()
Get Trigger data for the station.
Detector description interface for Station-related data.
bool HasTriggerData() const
Check whether trigger data object exists.
void SetPeriodicTrigger(const bool trig)
Set if Event comes from PERIODIC trigger.
void SetOffset(const int offset)
Set postTrigger time in bins.
Station & GetStationByName(const std::string &name)
retrieve station by name, throw utl::NonExistentComponentException if n.a.
Interface class to access to the Radio part of an event.
EventTrigger & GetTrigger()
Get the object with central trigger data, throw if n.a.
void SetCorrectedNanosecond(const unsigned int &ns)
Set corrected trigger nanosecond.
Mode
Available open modes.
void SetBitPattern(const uint16_t BitPattern)
Set the Trigger Bit Pattern.
#define INFO(message)
Macro for logging informational messages.
Base class for exceptions trying to access non-existing components.
void SetNoiseThreshold(const unsigned int thresh)
From DAQ.
A TimeStamp holds GPS second and nanosecond for some event.
void SetCalibrationTrigger(const bool trig)
Set if Event comes from calibration trigger.
Exception for reporting variable out of valid range.
void MakeGPSData()
Make GPS data object.
Base class to report exceptions in IO.
void MakeTriggerData()
Make trigger data object.
void SetExternalTrigger(const bool trig)
Set if Event was externally triggered.
void SetSelfTrigger(const bool trig)
Set if Event was selftriggered.
bool HasStationHeader() const
Check whether StationHeader exists.
Class representing a document branch.
Status
Return code for seek operation.
class to hold data at the radio Station level.
void SetRawTraceStartTime(const utl::TimeStamp &time)
Set absolute start time of the station-level trace as originally provided in raw data, for reconstructions use eTraceStartTime in StationRecData!
void SetGPSTime(const unsigned long sec, const double nsec=0)
Set GPS second and (optionally) nanosecond.
void MakeStationHeader()
Make Station Header object.
void MakeTrigger()
Create the central trigger object.
Header & GetHeader()
access to REvent Header
int GetNChannels() const
Number of channels in station.
constexpr double megahertz
StationGPSData & GetGPSData()
Get GPS data for the station.
#define WARNING(message)
Macro for logging warning messages.
void SetBinning(const double binning)
Channel & GetChannel(const int pmtId)
Retrieve a Channel by Id.
void SetSecond(const unsigned int &sec)
Set end of traces raw time.
A TimeInterval is used to represent time elapsed between two events.
void SetSignalThreshold(const unsigned int thresh)
ChannelADCTimeSeries & GetChannelADCTimeSeries()
Get Channel ADC trace (write access, only use this if you intend to change the data) ...
Class that holds the data associated to an individual radio channel.
bool HasStation(const int stationId) const
Check whether station exists.
StationHeader & GetStationHeader()
Get the Station Header.
void SetNyquistZone(const unsigned int zone)
Set the Nyquist zone.
void PushBack(const T &value)
Insert a single value at the end.
#define ERROR(message)
Macro for logging error messages.
bool HasGPSData() const
Check whether GPS data object exists.
void MakeStation(const int stationId)
make a station with specifying Id, throw if invalid stationId
void SetActive()
Active means that it is used in reconstruction. By default this is true after read-in, but can be deactivated later.
void SetTriggerSource(const TriggerSource TrigSource)
Set the Trigger Source of the station, i.e. if it triggered itself or was triggered by the central st...
void ConvertUnixToGPS(const time_t unixSecond, unsigned long &gpsSecond) const
const char * what() const
std::exception will print this on crash