#ifndef __JDETECTOR__JPMT__ #define __JDETECTOR__JPMT__ #include #include #include #include "JLang/JObjectID.hh" #include "JLang/JMultiEquals.hh" #include "JGeometry3D/JAxis3D.hh" #include "JDetector/JCalibration.hh" #include "JDetector/JDetectorVersion.hh" #include "Jeep/JStatus.hh" #include "JIO/JSerialisable.hh" /** * \file * * Data structure for PMT geometry and calibration. * \author mdejong */ namespace JDETECTOR {} namespace JPP { using namespace JDETECTOR; } namespace JDETECTOR { using JLANG::JObjectID; using JLANG::JMultiEquals; using JGEOMETRY3D::JAxis3D; using JEEP::JStatus; using JIO::JReader; using JIO::JWriter; /** * Data structure for PMT geometry, calibration and status. * * The I/O of the status of the PMT depends on the detector version.\n * Note that the axis of the PMT points in the direction of the field of view of the photo-cathode.\n * Note also that the comparison between PMTs is based on the identifier only. */ class JPMT : public JObjectID, public JAxis3D, public JCalibration, public JStatus, public JMultiEquals { public: /** * Default constructor. */ JPMT() : JObjectID(), JAxis3D(), JCalibration(), JStatus() {} /** * Constructor. * * \param id identifier * \param axis axis * \param status status */ JPMT(const int id, const JAxis3D& axis, const JStatus& status = JStatus()) : JObjectID(id), JAxis3D(axis), JCalibration(), JStatus(status) {} /** * Constructor. * * \param id identifier * \param axis axis * \param cal calibration * \param status status */ JPMT(const int id, const JAxis3D& axis, const JCalibration& cal, const JStatus& status = JStatus()) : JObjectID(id), JAxis3D(axis), JCalibration(cal), JStatus(status) {} /** * Get detector version. */ static JDetectorVersion& getVersion() { static JDetectorVersion version; return version; } /** * Set detector version. * * \param version version */ static void setVersion(const JVersion& version) { getVersion() = JDetectorVersion(version); } /** * Dot product. * * The dot product is evaluated for the PMT orientation. * * \param pmt PMT * \return dot product */ inline double getDot(const JPMT& pmt) const { return this->getDirection().getDot(pmt.getDirection()); } /** * Read PMT from input. * * \param in input stream * \param pmt PMT * \return input stream */ friend inline std::istream& operator>>(std::istream& in, JPMT& pmt) { in >> static_cast (pmt); in >> static_cast (pmt); in >> static_cast(pmt); if (getDetectorVersion(getVersion()) >= JDetectorVersion::V3) { in >> static_cast(pmt); } return in; } /** * Write PMT to output. * * \param out output stream * \param pmt PMT * \return output stream */ friend inline std::ostream& operator<<(std::ostream& out, const JPMT& pmt) { using namespace std; out << setw(8); out << static_cast (pmt); out << ' '; out << static_cast (pmt); out << ' '; out << static_cast(pmt); if (getDetectorVersion(getVersion()) >= JDetectorVersion::V3) { out << ' '; out << static_cast(pmt); } return out; } /** * Read PMT from input. * * \param in reader * \param pmt PMT * \return reader */ friend inline JReader& operator>>(JReader& in, JPMT& pmt) { in >> static_cast (pmt); in >> static_cast (pmt); in >> static_cast(pmt); if (getDetectorVersion(getVersion()) >= JDetectorVersion::V3) { in >> static_cast(pmt); } return in; } /** * Write PMT to output. * * \param out writer * \param pmt PMT * \return writer */ friend inline JWriter& operator<<(JWriter& out, const JPMT& pmt) { out << static_cast (pmt); out << static_cast (pmt); out << static_cast(pmt); if (getDetectorVersion(getVersion()) >= JDetectorVersion::V3) { out << static_cast(pmt); } return out; } }; } #endif