3 #include <evt/ShowerRecData.h>
4 #include <evt/ShowerRRecData.h>
6 #include <revt/REvent.h>
7 #include <revt/Station.h>
8 #include <revt/StationRecData.h>
9 #include <revt/StationSimData.h>
10 #include <revt/ChannelRecData.h>
11 #include <revt/Channel.h>
12 #include <revt/Header.h>
14 #include <det/Detector.h>
15 #include <rdet/RDetector.h>
16 #include <rdet/Channel.h>
17 #include <rdet/RDetector.h>
18 #include <rdet/Station.h>
19 #include <rdet/Channel.h>
21 #include <fwk/LocalCoordinateSystem.h>
22 #include <fwk/CoordinateSystemRegistry.h>
24 #include <utl/config.h>
25 #include <utl/CoordinateSystemPtr.h>
26 #include <utl/CoordinateSystem.h>
27 #include <utl/TimeStamp.h>
28 #include <utl/AugerUnits.h>
29 #include <utl/Point.h>
30 #include <utl/RadioGeometryUtilities.h>
31 #include <utl/UTMPoint.h>
32 #include <utl/AugerUnits.h>
37 #include <DetectorGeometry.h>
52 using std::ostringstream;
56 using std::numeric_limits;
57 using std::out_of_range;
61 RdFiller::FillRadioStations(
const evt::Event& theev,
bool saveTrace,
bool storeExcludedStations)
67 (fRdEvent.GetRdRecLevel() == eNoRdEvent))
68 fRdEvent.SetRdRecLevel(eHasRdSignalStations);
70 for (
const auto& station : therev.AllStationsRange()) {
72 if (!storeExcludedStations && station.IsExcluded())
78 if (!fRdEvent.HasRdStation(station.GetId()))
79 fRdEvent.AddRdStationWithId(station.GetId());
81 RdRecStation& rstation = fRdEvent.GetRdStationById(station.GetId());
83 if (station.HasRecData()) {
87 const std::vector<StationRRecDataQuantities>& enumVector = recStation.
GetEnumVector();
88 for (
const auto& index : enumVector) {
90 rstation.SetParameter((index), recStation.
GetParameter(index));
92 std::cout <<
"WARNING: RdFiller: Parameter " << index <<
" does not exist" << std::endl;
98 for (
const auto& index2 : covarianceEnumVector) {
100 rstation.SetParameterCovariance(
101 index2.first, index2.second,
110 WARNING(std::to_string(ncount) +
string(
" ParameterCovariance pairs does not exist"));
112 rstation.SetHasPulse(station.GetRecData().GetPulseFound());
113 rstation.SetSaturated(station.IsSaturated());
114 rstation.SetExcluded(station.GetExcludedReason());
115 rstation.SetRejectionStatus(station.GetRejectedReason());
122 vector<Float_t> vectr[3];
123 vector<Float_t> vecsp[3];
126 for (
unsigned int i = 0; i < trace.
GetSize(); ++i) {
127 for (
unsigned int j = 0; j < trace[i].
GetSize(); ++j) {
129 Float_t val = trace[i][j];
131 vectr[j].push_back(val);
132 }
catch (std::out_of_range& e) {
133 cerr <<
" Caught std::out_of_range\n"
140 for (
unsigned int i = 0; i < spectr.
GetSize(); ++i) {
141 for (
unsigned int j = 0; j < spectr[i].
GetSize(); ++j) {
143 Float_t val =
abs(spectr[i][j]);
145 vecsp[j].push_back(val);
146 }
catch (std::out_of_range& e) {
147 cerr <<
"Caught std::out_of_range\n"
153 for (
int i = 0; i < 3; ++i) {
154 rtra.SetTimeTrace(vectr[i]);
156 rtra.SetFreqRange(station.GetFrequencyOfBin(0) /
megahertz,
158 rtra.SetAbsoluteFreqSpectrum(vecsp[i]);
159 rstation.SetRdTrace(rtra, i);
178 vector<Float_t> vectraceShowerPlane[3];
179 for (
unsigned int i = 0; i < traceShowerPlane.GetSize(); ++i) {
180 for (
unsigned int j = 0; j < traceShowerPlane[i].GetSize(); ++j) {
181 Float_t val = traceShowerPlane[i][j];
183 vectraceShowerPlane[j].push_back(val);
186 for (
int i = 0; i < 3; ++i) {
187 rtra.SetTimeTrace(vectraceShowerPlane[i]);
188 rtra.SetSamplingRate(traceShowerPlane.GetBinning() /
nanosecond);
189 rstation.SetRdTraceShowerPlane(rtra, i);
190 vectraceShowerPlane[i].clear();
195 }
catch (std::out_of_range& e) {
196 WARNING(
string(
"Caught std::out_of_range ") + e.what() + string(
" \n"));
209 for (
const auto& station : therev.AllStationsRange()) {
213 if (!fRdEvent.HasRdSimStation(station.GetId()))
214 fRdEvent.AddRdSimStationWithId(station.GetId());
216 RdSimStation& rstation = fRdEvent.GetRdSimStationById(station.GetId());
218 if (station.HasSimData()) {
222 const std::vector<StationRRecDataQuantities>& enumVector = simStation.
GetEnumVector();
223 for (
const auto& it : enumVector) {
225 rstation.SetParameter((it), simStation.
GetParameter(it));
228 std::cout <<
"WARNING: RdFiller: Parameter " << it <<
" does not exist" << std::endl;
234 for (
const auto& it2 : covarianceEnumVector) {
236 rstation.SetParameterCovariance(
237 it2.first, it2.second,
246 WARNING(std::to_string(ncount) +
string(
" ParameterCovariance pairs does not exist"));
251 }
catch (std::out_of_range& e) {
252 WARNING(
string(
"Caught std::out_of_range ") + e.what() + string(
" \n"));
264 const CoordinateSystemPtr referenceCS = det::Detector::GetInstance().GetReferenceCoordinateSystem();
266 RdRecShower& theShower = fRdEvent.GetRdRecShower();
273 fRdEvent.SetRdRecLevel(eHasRdArrivalDirection);
276 WARNING(
string(
"Caught utl::NonExistentComponentException") + e.
what());
278 theShower.SetAxisSiteCS(TVector3(
279 numeric_limits<double>::quiet_NaN(),
280 numeric_limits<double>::quiet_NaN(),
281 numeric_limits<double>::quiet_NaN()
283 theShower.SetAxisCoreCS(TVector3(
284 numeric_limits<double>::quiet_NaN(),
285 numeric_limits<double>::quiet_NaN(),
286 numeric_limits<double>::quiet_NaN())
301 theShower.SetCoreUTMCS(TVector3(easting, northing, altitude));
303 ERROR (
"UTMZoneException: radio rec shower invalid");
305 ERROR (
"UTMException: radio rec shower invalid");
311 WARNING(
string(
"Caught utl::NonExistentComponentException") + e.
what());
313 theShower.SetCoreSiteCS(TVector3(
314 numeric_limits<double>::quiet_NaN(),
315 numeric_limits<double>::quiet_NaN(),
316 numeric_limits<double>::quiet_NaN())
320 const std::vector<ShowerRRecDataQuantities>& enumVector = recShower.
GetEnumVector();
321 for (
auto it = enumVector.begin(); it != enumVector.end(); ++it) {
323 theShower.SetParameter((*it), recShower.
GetParameter(*it));
325 std::cout <<
"WARNING: RdFiller: Parameter " << *it <<
" does not exist" << std::endl;
331 for (
auto it2 = covarianceEnumVector.begin(); it2 != covarianceEnumVector.end(); ++it2) {
333 theShower.SetParameterCovariance(it2->first, it2->second,recShower.
GetParameterCovariance(it2->first,it2->second));
341 WARNING(std::to_string(ncount) +
string(
" ParameterCovariance pairs does not exist"));
358 if (recShower.
HasParameter(eReconstructedElectromagneticEnergy))
359 fRdEvent.SetRdRecLevel(eHasRdElectromagneticEnergy);
363 fRdEvent.SetRdRecLevel(eHasRdDepthOfMaximum);
370 RdFiller::FillRadioChannels(
const revt::REvent& therev,
bool saveTrace,
bool storeExcludedStations)
372 const rdet::RDetector& rDetector = det::Detector::GetInstance().GetRDetector();
374 for (
const auto& station : therev.AllStationsRange()) {
376 if (!storeExcludedStations && station.IsExcluded())
381 if (!fRdEvent.HasRdStation(station.GetId()))
382 fRdEvent.AddRdStationWithId(station.GetId());
385 RdRecStation& rstation = fRdEvent.GetRdStationById(station.GetId());
388 for (
const auto& channel : station.ChannelsRange()) {
390 RdRecChannel rchannel;
392 rchannel.SetId(channel.GetId());
393 rchannel.SetADCSignalThreshold(channel.GetSignalThreshold());
394 rchannel.SetADCNoiseThreshold(channel.GetNoiseThreshold());
395 rchannel.SetSaturated(channel.IsSaturated());
398 rDetector.
GetStation(station.GetId()).GetChannel(channel.GetId());
401 rchannel.SetScintillatorTop(
true);
403 rchannel.SetScintillatorBottom(
true);
406 if (channel.HasRecData()) {
410 const std::vector<ChannelRRecDataQuantities>& enumVector = recChannel.
GetEnumVector();
411 for (
const auto& index : enumVector) {
413 rchannel.SetParameter((index),recChannel.
GetParameter(index));
415 std::cout <<
"WARNING: RdFiller: Channel parameter " << index <<
" does not exist" << std::endl;
421 for (
const auto& index2 : covarianceEnumVector) {
423 rchannel.SetParameterCovariance(index2.first, index2.second, recChannel.
GetParameterCovariance(index2.first, index2.second));
431 WARNING(std::to_string(ncount) +
string(
" ParameterCovariance pairs does not exist"));
437 std::vector<Float_t> timetrace;
439 ctimt != channel.GetChannelTimeSeries().End(); ++ctimt) {
440 timetrace.push_back(*ctimt / (
micro *
volt));
443 std::vector<Float_t> freqtrace;
445 cfreqit != channel.GetChannelFrequencySpectrum().End(); ++cfreqit) {
450 rchannel.SetRdTimeTrace(timetrace);
451 rchannel.SetRdAbsSpectrum(freqtrace);
452 rchannel.GetRdTrace().SetFreqRange(
453 channel.GetFrequencyOfBin(0) /
megahertz,
454 channel.GetFrequencyOfBin(channel.GetChannelFrequencySpectrum().GetSize()-1) /
megahertz
456 rchannel.GetRdTrace().SetSamplingRate(channel.GetChannelTimeSeries().GetBinning() /
nanosecond);
459 std::vector<Int_t> adctrace;
461 for (
unsigned int idx = 0; idx < adctrace_offline.
GetSize(); ++idx)
462 adctrace.push_back(adctrace_offline[idx]);
464 RdADCTrace& rchannel_adc_trace = rchannel.GetRdADCTrace();
465 rchannel_adc_trace.SetTimeTrace(adctrace);
466 rchannel_adc_trace.SetSamplingRate(channel.GetChannelADCTimeSeries().GetBinning() /
nanosecond);
467 rchannel_adc_trace.SetMinVoltage(cDetChannel.
GetMinVoltage());
468 rchannel_adc_trace.SetMaxVoltage(cDetChannel.
GetMaxVoltage());
469 rchannel_adc_trace.SetBitDepth(cDetChannel.
GetBitDepth());
473 rstation.GetRdChannelVector().push_back(rchannel);
475 }
catch (out_of_range& e) {
476 WARNING(
string(
"Caught std::out_of_range") + e.what());
495 RdFiller::AddRadioDetector(
const det::Detector& offlineDet, Detector& adstDet)
499 for (
const auto& station : rdt.StationsRange()) {
501 const utl::Point& position = station.GetPosition();
502 double x = position.
GetX(referenceCS);
503 double y = position.
GetY(referenceCS);
504 double z = position.
GetZ(referenceCS);
505 adstDet.SetRdStation(station.GetId(), x/
m, y/
m, z/
m);
512 RdFiller::AddRadioInfo(FileInfo*
const info,
const int radioSaveLevel)
514 if (radioSaveLevel >= 1)
515 info->SetHasRdStation();
516 if (radioSaveLevel >= 2)
517 info->SetHasRdChannel();
523 RdFiller::AddRadioDetectorGeometry(
const det::Detector& offlineDet, DetectorGeometry*
const adstGeo)
527 for (
const auto& station : rdt.StationsRange()) {
528 const string& stationName = station.GetName();
529 adstGeo->SetRdStationName(station.GetId(), stationName);
534 const utl::Point& position = station.GetPosition();
535 x = position.
GetX(referenceCS);
536 y = position.
GetY(referenceCS);
537 z = position.
GetZ(referenceCS);
539 const string warn =
"RdStation position information cannot be read from RDetector. "
540 "Station position will be set to 0,0,0";
543 adstGeo->SetRdStation(station.GetId(), x/
m, y/
m, z/
m);
Class to access channel level reconstructed data.
int GetBitDepth() const
Get number of bits of ADC.
bool HasParameterCovariance(const Parameter i1, const Parameter i2) const
Class to access station level reconstructed data.
std::vector< Parameter > GetEnumVector() const
bool HasParameter(const Parameter i) const
utl::Vector GetAxis() const
Returns vector of the shower axis.
double GetZenithError() const
returns the error of the zenith angle (from the wave fit)
Station Level Simulated Data
double GetParameterCovariance(const Parameter i1, const Parameter i2) const
Interface class to access to the Radio part of an event.
Class to hold and convert a point in geodetic coordinates.
std::vector< Parameter > GetEnumVector() const
ShowerRecData & GetRecShower()
Interface class to access to the RD Reconstruction of a Shower.
double GetParameterCovariance(const Parameter i1, const Parameter i2) const
double GetParameter(const Parameter i) const
double GetBinning() const
size of one slot
bool HasCorePosition() const
Return true if all 3 core parameter are set.
double GetParameter(const Parameter i) const
double GetMaxVoltage() const
Get voltage corresponding to max number of counts.
bool HasParameterCovariance(const Parameter i1, const Parameter i2) const
revt::REvent & GetREvent()
Base class for exceptions trying to access non-existing components.
Detector description interface for Channel-related data.
double GetNorthing() const
Get the northing.
ShowerRRecData & GetRRecShower()
Report attempts to use invalid UTM zone.
double GetAzimuthError() const
returns the error of the azimuth angle (from the wave fit)
std::vector< double >::const_iterator ConstIterator
Detector description interface for RDetector-related data.
std::vector< std::pair< Parameter, Parameter > > GetCovarianceEnumVector() const
unsigned long long int GetRejectionStatus() const
std::vector< Parameter > GetEnumVector() const
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
const std::string & GetChannelType() const
Get description of Channel Type.
utl::Point GetCoordinateOrigin() const
double GetMinVoltage() const
Get voltage corresponding to 0 counts.
bool HasAxis() const
Return true if all 3 axis parameter are set.
double GetHeight() const
Get the height.
double GetX(const CoordinateSystemPtr &coordinateSystem) const
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.
bool HasParameterCovariance(const Parameter i1, const Parameter i2) const
double GetEasting() const
Get the easting.
static const ReferenceEllipsoid & GetWGS84()
Get the auger standard ellipsoid: wgs84.
constexpr double megahertz
#define WARNING(message)
Macro for logging warning messages.
std::vector< std::pair< Parameter, Parameter > > GetCovarianceEnumVector() const
std::vector< std::pair< Parameter, Parameter > > GetCovarianceEnumVector() const
std::vector< Parameter > GetEnumVector() const
bool HasParameter(const Parameter i) const
double GetParameterCovariance(const Parameter i1, const Parameter i2) const
int GetNumberOfSignalStations() const
Get number of signal stations in the event.
double GetZenithPreFitError() const
returns the error of the zenith angle (from the pre wave fit -> on voltage level) ...
double GetParameter(const Parameter i) const
double GetY(const CoordinateSystemPtr &coordinateSystem) const
bool HasParameter(const Parameter i) const
std::vector< std::pair< Parameter, Parameter > > GetCovarianceEnumVector() const
unsigned long GetGPSSecond() const
GPS second.
Report problems in UTM handling.
double GetGPSNanoSecond() const
GPS nanosecond.
Template class for a FADC data or calibrated data container. Use the typedefs (TraceD, TraceI, etc.) defined in Trace-fwd.h.
utl::CoordinateSystemPtr GetReferenceCoordinateSystem() const
Get the reference coordinate system used for analysis (usually PampaAmarilla for Auger) ...
double GetParameterCovariance(const Parameter i1, const Parameter i2) const
utl::Point GetCorePosition() const
returns pointer of the position vector of the core in the reference coor system
const rdet::RDetector & GetRDetector() const
double GetParameter(const Parameter i) const
TVector3 ToTVector3(const T &v, const utl::CoordinateSystemPtr &cs, const double unit=1)
double GetZ(const CoordinateSystemPtr &coordinateSystem) const
static Policy::type Create(const utl::Point &theOrigin)
Create the standard local coordinate system for a Point.
utl::Vector GetMagneticFieldVector() const
returns the magnetic field vector from the components stored in the parameter storage ...
#define ERROR(message)
Macro for logging error messages.
const Station & GetStation(const int stationId) const
Get station by Station Id.
bool HasParameter(const Parameter i) const
utl::TraceV3D GetTraceInShowerPlaneVxB(const utl::TraceV3D &trace) const
double GetRadiusError() const
returns the error of the radius (from the spherical wave fit)
bool HasParameterCovariance(const Parameter i1, const Parameter i2) const
double GetAzimuthPreFitError() const
returns the error of the azimuth angle (from the pre wave fit -> on voltage level) ...
const char * what() const
std::exception will print this on crash