#ifndef __JDETECTOR__JPMTADDRESS__ #define __JDETECTOR__JPMTADDRESS__ #include #include #include "JLang/JComparable.hh" #include "JDetector/JModuleAddress.hh" /** * \author mdejong */ namespace JDETECTOR {} namespace JPP { using namespace JDETECTOR; } namespace JDETECTOR { using JLANG::JComparable; /** * Address of PMT in detector data structure. * * The address of a PMT consists of a pair of integer values, where * - JPMTAddress::first refers to the index of the parent module in the detector data structure; and * - JPMTAddress::second refers to the index of the PMT in the corresponding module data structure. * * This class implements the JLANG::JComparable interface. */ class JPMTAddress : public JModuleAddress, public JComparable { public: /** * Default constructor. */ JPMTAddress() : JModuleAddress(-1), second(-1) {} /** * Constructor. * * \param module module address * \param pmt PMT index */ JPMTAddress(const JModuleAddress& module, const int pmt) : JModuleAddress(module), second(pmt) {} /** * Less than method. * * \param address PMT address * \result true if this PMT address is less than given PMT address; else false */ inline bool less(const JPMTAddress& address) const { if (this->first == address.first) return this->second < address.second; else return this->first < address.first; } /** * Read PMT address from input. * * \param in input stream * \param object PMT address * \return input stream */ friend inline std::istream& operator>>(std::istream& in, JPMTAddress& object) { return in >> static_cast(object) >> object.second; } /** * Write PMT address to output. * * \param out output stream * \param object PMT address * \return output stream */ friend inline std::ostream& operator<<(std::ostream& out, const JPMTAddress& object) { return out << static_cast(object) << ' ' << object.second; } int second; //!< index of PMT in module data structure. }; } #endif