#ifndef __JTRIGGER__JPMTIDENTIFIER_T__ #define __JTRIGGER__JPMTIDENTIFIER_T__ #include #include #include "km3net-dataformat/online/JDAQPMTIdentifier.hh" /** * \author rgruiz */ namespace JTRIGGER { using KM3NETDAQ::JDAQPMTIdentifier; /* * Auxiliary class to read the pmt identifiers from an ascii file to the trigger parameters */ class JPMTIdentifier_t : public TObject { public: /** * Default constructor. */ JPMTIdentifier_t() : moduleID (-1), pmtAddress(-1) {} /** * Constructor. * * \param id module identifier * \param tdc PMT readout channel */ JPMTIdentifier_t(int id , int tdc) { moduleID = id; pmtAddress = tdc; } /** * Copy constructor. * * \param pmt PMT identifier */ JPMTIdentifier_t(const JDAQPMTIdentifier& pmt) { moduleID = pmt.getModuleID(); pmtAddress = pmt.getPMTAddress(); } /** * Virtual destructor. */ virtual ~JPMTIdentifier_t() {} /** * Get module identifier. * * \return module identifier */ int getModuleID() const { return moduleID; } /** * Get PMT address. * * \return PMT address */ int getPMTAddress() const { return pmtAddress; } /** * Compare PMT identifiers. * * The comparison is applied to the module identifer and to the PMT address. * If the module identifier or PMT address is -1, the corresponding comparison evaluates to true. * * \param first first PMT identifier * \param second second PMT identifier * \result true if first and second PMT identifier are equal; else false */ static inline bool compare(const JPMTIdentifier_t& first, const JPMTIdentifier_t& second) { return ((first .getModuleID() == second.getModuleID() || first .getModuleID() == -1 || second.getModuleID() == -1) && (first .getPMTAddress() == second.getPMTAddress() || first .getPMTAddress() == -1 || second.getPMTAddress() == -1)); } /** * Read PMT identifier from input. * * \param in input stream * \param id PMT identifier * \return input stream */ friend inline std::istream& operator>>(std::istream& in, JPMTIdentifier_t& id) { in >> id.moduleID; in >> id.pmtAddress; return in; } /** * Write PMT identifier to output. * * \param out output stream * \param id PMT identifier * \return output stream */ friend inline std::ostream& operator<<(std::ostream& out, const JPMTIdentifier_t& id) { out << id.moduleID << ' '; out << id.pmtAddress; return out; } /** * Type conversion operator. * * \return PMT identifier */ operator JDAQPMTIdentifier () const { return JDAQPMTIdentifier (moduleID , pmtAddress); } ClassDef(JPMTIdentifier_t,8); protected: int moduleID; int pmtAddress; }; /** * Equal operator for PMT identifiers. * * \param first PMT identifier * \param second PMT identifier * \result true if first PMT equal second PMT; else false */ inline bool operator==(const JPMTIdentifier_t& first, const JPMTIdentifier_t& second) { return (first.getModuleID() == second.getModuleID() && first.getPMTAddress() == second.getPMTAddress()); } /** * Less than operator for PMT identifiers. * * The less than operator is applied first to the module identifer and then to the PMT address. * * \param first PMT identifier * \param second PMT identifier * \result true if first PMT lower than second PMT; else false */ inline bool operator<(const JPMTIdentifier_t& first, const JPMTIdentifier_t& second) { if (first.getModuleID() == second.getModuleID()) return first.getPMTAddress() < second.getPMTAddress(); else return first.getModuleID() < second.getModuleID(); } } #endif