#ifndef __JDETECTOR__JDETECTORHEADER__ #define __JDETECTOR__JDETECTORHEADER__ #include #include #include #include "JUTC/JUTCTimeRange.hh" #include "JUTM/JUTMGrid.hh" #include "JUTM/JUTMPosition.hh" #include "JIO/JSerialisable.hh" #include "JLang/JEquals.hh" #include "JLang/JEquationParameters.hh" #include "Jeep/JProperties.hh" /** * \author mdejong */ namespace JDETECTOR {} namespace JPP { using namespace JDETECTOR; } namespace JDETECTOR { using JUTC::JUTCTimeRange; using JUTM::JUTMGrid; using JUTM::JUTMPosition; using JIO::JReader; using JIO::JWriter; using JLANG::JEquals; using JLANG::JEquationParameters; /** * Data structure for detector header. */ class JDetectorHeader : public JUTCTimeRange, public JUTMGrid, public JUTMPosition, public JEquals { public: /** * Default constructor. */ JDetectorHeader() : JUTCTimeRange(), JUTMGrid (), JUTMPosition () {} /** * Constructor. * * \param range UTC time range * \param grid UTM grid * \param pos UTM position */ JDetectorHeader(const JUTCTimeRange& range, const JUTMGrid& grid, const JUTMPosition& pos) : JUTCTimeRange(range), JUTMGrid (grid), JUTMPosition (pos) {} /** * Get detector header. * * \return header */ const JDetectorHeader& getDetectorHeader() const { return static_cast(*this); } /** * Check equality. * * \param header header * \param precision precision * \return true if headers are equal; else false */ bool equals(const JDetectorHeader& header, const double precision = std::numeric_limits::min()) const { return (this->getUTMGrid() == header.getUTMGrid() && this->getDisplacement(header.getUTMPosition()) < precision); } /** * Read detector header from input. * * \param in input stream * \param header header * \return input stream */ friend inline std::istream& operator>>(std::istream& in, JDetectorHeader& header) { in >> static_cast(header); in >> static_cast (header); in >> static_cast (header); return in; } /** * Write detector header to output. * * \param out output stream * \param header header * \return output stream */ friend inline std::ostream& operator<<(std::ostream& out, const JDetectorHeader& header) { using namespace std; out << static_cast(header); out << endl; out << static_cast (header); out << ' '; out << static_cast (header); return out; } /** * Read detector header from input. * * \param in input stream * \param header header * \return input stream */ friend inline JReader& operator>>(JReader& in, JDetectorHeader& header) { in >> static_cast(header); in >> static_cast (header); in >> static_cast (header); return in; } /** * Write detector header to output. * * \param out output stream * \param header header * \return output stream */ friend inline JWriter& operator<<(JWriter& out, const JDetectorHeader& header) { out << static_cast(header); out << static_cast (header); out << static_cast (header); return out; } /** * Get equation parameters. * * \return equation parameters */ static inline JEquationParameters& getEquationParameters() { static JEquationParameters equation; return equation; } /** * Set equation parameters. * * \param equation equation parameters */ static inline void setEquationParameters(const JEquationParameters& equation) { getEquationParameters() = equation; } /** * Get properties of this class. * * \param equation equation parameters */ JProperties getProperties(const JEquationParameters& equation = JDetectorHeader::getEquationParameters()) { return JDetectorHeaderHelper(*this, equation); } /** * Get properties of this class. * * \param equation equation parameters */ JProperties getProperties(const JEquationParameters& equation = JDetectorHeader::getEquationParameters()) const { return JDetectorHeaderHelper(*this, equation); } private: /** * Auxiliary class for I/O of detector header. */ class JDetectorHeaderHelper : public JProperties { public: /** * Constructor. * * \param object header * \param equation equation parameters */ template JDetectorHeaderHelper(JDetectorHeader_t& object, const JEquationParameters& equation) : JProperties(equation, 1) { insert(gmake_property(object.first)); insert(gmake_property(object.second)); insert(gmake_property(object.east)); insert(gmake_property(object.north)); insert(gmake_property(object.z)); insert(gmake_property(object.key)); insert(gmake_property(object.wgs)); insert(gmake_property(object.zone)); } }; }; /** * Get UTM grid for ARCA. * * \return UTM grid */ inline JUTMGrid getARCAUTMGrid() { return JUTMGrid("UTM", "WGS84", "33N"); } /** * Get UTM grid for ORCA. * * \return UTM grid */ inline JUTMGrid getORCAUTMGrid() { return JUTMGrid("UTM", "WGS84", "32N"); } /** * Get detector header for ARCA. * * \return detector header */ inline JDetectorHeader getARCADetectorHeader() { return JDetectorHeader(JUTCTimeRange(0.0, 999999999999.9), getARCAUTMGrid(), JUTMPosition(587600, 4016800, -3450)); } /** * Get detector header for ORCA. * * \return detector header */ inline JDetectorHeader getORCADetectorHeader() { return JDetectorHeader(JUTCTimeRange(0.0, 999999999999.9), getORCAUTMGrid(), JUTMPosition(256500, 4743000, -2440)); } /** * Check if given detector header is compatible with tat of ARCA. * * \param header header * \return true if ARCA; else false */ inline bool isARCADetector(const JDetectorHeader& header) { return header.getUTMGrid() == getARCADetectorHeader(); } /** * Check if given detector header is compatible with that of ORCA. * * \param header header * \return true if ORCA; else false */ inline bool isORCADetector(const JDetectorHeader& header) { return header.getUTMGrid() == getORCADetectorHeader(); } } #endif