00001 #ifndef TBID_h 00002 #define TBID_h 00003 00004 //#include <function> 00005 00006 /*! - Class: TBID 00007 - Author: Ian Gable (igable@uvic.ca) 00008 Naoko Kanaya (nkanaya@uvic.ca) 00009 - Date: 07/07/2003 00010 - Description: TBID is a test beam cell ID class that provides a unique integer for each cell in the combined 00011 Beam Test of 2002. This class can be used in two different ways. In the first way the class holds as a 00012 member, the cells ID, which is created when the object is constructed or alternatively it can be used as 00013 a tool for converting between detector ID and the various integer coordinates (idet,ieta,iphi,iz). 00014 In the second case the constructor which takes no parameters is used. 00015 */ 00016 00017 00018 class TBID{ 00019 00020 public: 00021 00022 /** Constructor to be used when you what the class to store its cell ID and then later access the 00023 * various coordinates (idet,ieta,iphi,iz) without giving a detector id. 00024 *@param idet Detector id: hec = 2, emec = 1 00025 *@param ieta hec = [ 1,14], emec = [ 0,67] 00026 *@param iphi hec=[ 1, 6], emec = [ 0,31] 00027 *@param iz hec = [ 1, 3], emec = [ 0, 3] 00028 */ 00029 TBID(int idet, int ieta, int iphi, int iz); 00030 00031 /** Constructor to be used when the class used as simply a conversion tool. 00032 */ 00033 TBID(){}; 00034 00035 //! Return the stored cell id 00036 int id(); 00037 00038 /** Given cell integer coordinates return an ID. 00039 *@param idet Detector id: hec = 2, emec = 1 00040 *@param ieta hec = [ 1,14], emec = [ 0,67] 00041 *@param iphi hec=[ 1, 6], emec = [ 0,31] 00042 *@param iz hec = [ 1, 3], emec = [ 0, 3] 00043 */ 00044 int id(int idet, int ieta, int iphi, int iz); 00045 00046 //! Return the stored ieta coordinate 00047 int ieta(); 00048 00049 /** Given a cell ID return coresponding ieta coord 00050 *@param ID the ID of the cell to retrieve the ieta coordinate 00051 */ 00052 int ieta(int ID); 00053 00054 //! Return the stored iphi coordinate 00055 int iphi(); 00056 00057 /** Given a cell ID return coresponding iphi coord 00058 *@param ID the ID of the cell to retrieve the iphi coordinate 00059 */ 00060 int iphi(int ID); 00061 00062 //! Return the stored iz coordinate 00063 int iz(); 00064 00065 /** Given a cell ID return coresponding iz coord 00066 *@param ID the ID of the cell to retrieve the iz coordinate 00067 */ 00068 int iz(int ID); 00069 00070 //! Return the stored detector number (hec = 2, emec =1) 00071 int idet(); 00072 00073 /** Given a cell ID return coresponding detector number (hec = 2, emec =1) 00074 *@param ID the ID of the cell to retrieve the iz coordinate 00075 */ 00076 int idet(int ID); 00077 00078 //! The less than operator 00079 friend bool operator<(const TBID &,const TBID &); 00080 00081 //! The equal operator 00082 friend bool operator==(const TBID &,const TBID &); 00083 00084 private: 00085 00086 // enum { BIT_PHI=7, BIT_Z=14, BIT_DET=21 }; 00087 enum { BIT_PHI=8, BIT_Z=16, BIT_DET=24 }; 00088 00089 int m_id; 00090 00091 00092 }; 00093 00094 inline bool operator<(const TBID &id1,const TBID &id2){ 00095 return id1.m_id < id2.m_id; 00096 } 00097 00098 inline bool operator==(const TBID &id1,const TBID &id2){ 00099 return id1.m_id == id2.m_id; 00100 } 00101 00102 00103 #endif