// MuoIndex.cpp // // Purpose: Container for ID information // relevant to a single element in // the muon system // // Created: May 1998 Michael R. Fortner // Modified: May 2001 M. Fortner - add cell test to isValid // DH add chanID and modID to is Valid // June 2002 MF - put modID and chanID tests in Cell and SectionIndex #include "muon_index/MuoIndex.hpp" namespace Muon { // MuoIndex Default Constructor MuoIndex::MuoIndex() : _section(), _cell() {} // MuoIndex Normal Constructor MuoIndex::MuoIndex(const MuoSectionIndex& section, const MuoCellIndex& cell) : _section(section), _cell(cell) {} // Detailed Constructor MuoIndex::MuoIndex(int region, int type, int layer, int octant, int barrel, int plane, int eta, int phi, int tube) : _section(region, type, layer, octant, barrel), _cell(plane, eta, phi, tube) {} // Constructor from vector of detailed atributes MuoIndex::MuoIndex(std::vector vatt) : _section(vatt[0], vatt[1], vatt[2], vatt[3], vatt[4]), _cell(vatt[5], vatt[6], vatt[7], vatt[8]) {} // Copy Constructor MuoIndex::MuoIndex(const MuoIndex& id) : _section(id._section), _cell(id._cell) {} // Destructor MuoIndex::~MuoIndex() {} // Assignment MuoIndex& MuoIndex::operator=(const MuoIndex& id) { if (&id == this) return *this; this->_section = id._section; this->_cell = id._cell; return *this; } // Print std::ostream& operator<<(std::ostream& os, const MuoIndex& id) { id.print(os); return os; } void MuoIndex::print(std::ostream &os) const { os << _section << _cell; } // Equality bool operator==(const MuoIndex& id1, const MuoIndex& id2) { if (id1.section() != id2.section()) return false; if (id1.cell() != id2.cell()) return false; return true; } // Inequality bool operator!=(const MuoIndex& id1, const MuoIndex& id2) { return ! (id1 == id2); } // Less-Than bool operator<(const MuoIndex& id1, const MuoIndex& id2) { if (id1.section() < id2.section()) return true; if (id1.section() > id2.section()) return false; if (id1.cell() >= id2.cell()) return false; return true; } // Less-or-Equal bool operator<=(const MuoIndex& id1, const MuoIndex& id2) { return ((id1 < id2) || (id1 == id2)); } // Greater-Than bool operator>(const MuoIndex& id1, const MuoIndex& id2) { return ! (id1 <= id2); } // Greater-or-Equal bool operator>=(const MuoIndex& id1, const MuoIndex& id2) { return ! (id1 < id2); } bool MuoIndex::isValid() const // only does section { if (!section().isValid()) return false; return true; } bool MuoIndex::isValid(const int modID,const int chanID) const { if (!section().isValid(modID)) return false; if (!cell().isValid( section(),chanID ) ) return false; return true; } }