#ifndef ICDCWIREINFO_HXX_SEEN #define ICDCWIREINFO_HXX_SEEN #include #include #include #include namespace COMET{ class ICDCWireInfo; } /// A class to hold all the information about a wire in the CDC. /// This is used by COMET::ICDCWireManager to store detailed information about /// the CDC wire geometry class COMET::ICDCWireInfo { public: /// Constructor ICDCWireInfo(); /// Destructor ~ICDCWireInfo(); /// Print information about this wire void ls()const; private: int fWireNode; /// node id int fWireId; /// wire id int fLayerId; /// layer id int fBoardId; /// board id int fIsSenseWire; /// 0: no double fLength; /// wire length TVector3 fPosition; /// wire position TVector3 fEnd01Unit; /// wire vector of end0 and end1 TVector3 fEnd0Pos; /// wire end0 position TVector3 fEnd1Pos; /// wire end1 position public: /// @name Getters /// Get information about the wire /// /// @{ int GetWireNode() const {return fWireNode;} /// Get wire node int GetWireId() const {return fWireId;} /// Get wire number int GetLayerId() const {return fLayerId;} /// Get layer number int GetBoardId() const {return fBoardId;} /// Get the board ID int GetIsSenseWire() const {return fIsSenseWire;} /// Get is sense wire double GetLength() const {return fLength;} /// Get wire length const TVector3& GetEnd01Unit() const {return fEnd01Unit;} /// Get direction const TVector3& GetPosition() const {return fPosition;} /// Get position const TVector3& GetEnd0Pos() const {return fEnd0Pos;} /// Get End0 const TVector3& GetEnd1Pos() const {return fEnd1Pos;} /// Get End1 /// @} /// @name Setters /// Set information about the wire /// /// @{ void SetWireNode(const int& wireNode) {fWireNode = wireNode;} /// Set wire node void SetWireId(const int& wireId) {fWireId = wireId;} /// Set wire number void SetLayerId(const int& layerId) {fLayerId = layerId;} /// Set layer number void SetBoardId(const int& boardId) {fBoardId = boardId;} /// Set RECBE board void SetLength(const double& length) {fLength = length;} /// Set wire length void SetIsSenseWire(const double &sense){ fIsSenseWire = sense; } void SetEnd01Unit(const TVector3 &end01){fEnd01Unit = end01;} /// Set end01 void SetPosition(const TVector3& position) {fPosition = position;} /// Set position void SetEnd0Pos(const TVector3& end0) {fEnd0Pos = end0;} /// Set end0 void SetEnd1Pos(const TVector3& end1) {fEnd1Pos = end1;} /// Set end1 /// @} private: ///@name Member Comparators /// Functions to compare components of wire information /// /// @{ /// Check if the lengths agree within a given tolerance bool CompareDouble(const double aDbl, const double bDbl, const double eps) const{ return fabs(aDbl - bDbl) < eps;} /// General function to compare vectors bool CompareVectors(const TVector3& aVect, const TVector3& bVect, const double eps) const { return (aVect - bVect).Mag() < eps;} /// Vector less than bool VectorLessThan(const TVector3& aVect, const TVector3& bVect, const double eps) const{ if (!CompareDouble(aVect.X(), bVect.X(), eps)) return aVect.X() < bVect.X(); else if (!CompareDouble(aVect.Y(), bVect.Y(), eps)) return aVect.Y() < bVect.Y(); else if (!CompareDouble(aVect.Z(), bVect.Z(), eps)) return aVect.Z() < bVect.Z(); } /// Compare the length of another wire information to this one bool CompareLength(const ICDCWireInfo& rhs, double eps) const{ return CompareDouble(rhs.GetLength(), fLength, eps);} /// Compare the position in the centre bool ComparePosition(const ICDCWireInfo& rhs, double eps) const{ return CompareVectors(rhs.GetPosition(), fPosition, eps);} /// Compare the angle of the wire bool CompareEnd01(const ICDCWireInfo& rhs, double eps) const{ return CompareVectors(rhs.GetEnd01Unit(), fEnd01Unit, eps);} /// Compare the position at end plate 0 bool CompareEnd0(const ICDCWireInfo& rhs, double eps) const{ return CompareVectors(rhs.GetEnd0Pos(), fEnd0Pos, eps);} /// Compare the position at end plate 1 bool CompareEnd1(const ICDCWireInfo& rhs, double eps) const{ return CompareVectors(rhs.GetEnd1Pos(), fEnd1Pos, eps);} /// @} public: ///@name Comparators /// Functions to compare wire information /// /// @{ /// Check if the two have the same information bool operator==(const ICDCWireInfo& rhs)const{ //double eps = 0.25*unit::cm; double eps = 0.1*unit::mm; return (rhs.GetWireId() == fWireId && rhs.GetLayerId() == fLayerId && rhs.GetBoardId() == fBoardId && CompareLength(rhs, eps) && ComparePosition(rhs, eps) && CompareEnd01(rhs, eps)); } /// Check if the two have different information bool operator!=(const ICDCWireInfo& rhs)const{ return !(operator==(rhs));} /// Sorting function bool operator<(const ICDCWireInfo& rhs)const{ // Sort by id's first if (GetWireId() != rhs.GetWireId()) return GetWireId() < rhs.GetWireId(); else if (GetLayerId() != rhs.GetLayerId()) return GetLayerId() < rhs.GetLayerId(); else if (GetBoardId() != rhs.GetBoardId()) return GetBoardId() < rhs.GetBoardId(); else if (!ComparePosition(rhs, 0.1*unit::mm)) return VectorLessThan(GetPosition(), rhs.GetPosition(), 0.01*unit::mm); else if (!CompareEnd0(rhs, 0.1*unit::mm)) return VectorLessThan(GetEnd0Pos(), rhs.GetEnd0Pos(), 0.01*unit::mm); else if (!CompareEnd1(rhs, 0.1*unit::mm)) return VectorLessThan(GetEnd1Pos(), rhs.GetEnd1Pos(), 0.01*unit::mm); else if (GetLength() != rhs.GetLength()) return GetLength() < rhs.GetLength(); } bool operator>(const ICDCWireInfo& rhs)const{ return !(operator<(rhs) || operator==(rhs)); } /// @} }; #endif