Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

AcdId.cxx

Go to the documentation of this file.
00001 
00002 //                                                                        
00003 // The AcdId class contains a tile ID number.   
00004 // AcdId is used in the AcdTile class.
00005 //                                                                        
00007 
00008 // Apr 2000 Daniel Flath - Minor changes to function names, etc.
00009 // Jan 1999 Daniel Flath - ROOT HTML Documentation added
00010 // Dec 1999 Daniel Flath - Rewrite for GLAST
00011 // Version 1.1 25 Oct 1999 R.Dubois Clone from LCD towerID
00012 
00013 #include "digiRootData/AcdId.h"
00014 
00015 ClassImp(AcdId)
00016 
00017 UShort_t AcdId::badId = 3799;
00018 
00020 AcdId::AcdId() : m_id(0), m_used(1) {
00021 }
00022 
00023 AcdId::AcdId(const AcdId& id) : m_id(id.m_id), m_used(id.m_used) 
00024 { 
00025 };
00026 
00027 AcdId::AcdId(short l, short f, short r, short c) {
00028     m_used = 1;
00029     m_id = 0;
00030     setLayer(l);
00031     setFace(f);
00032     setRow(r);
00033     setColumn(c);
00034 };
00035 
00036 AcdId::AcdId(UInt_t i, short base, short used) {
00037     setId(i, used, base);
00038 }
00039 
00041 UInt_t AcdId::getId(short base) const { 
00042     // Returns the tile ID number
00043     if (base == 2) return m_id; 
00044     return (getLayer() * 1000 + getFace() * 100 + getRow() * 10 + getColumn());
00045 }
00046 
00048 void AcdId::setId(UInt_t newVal, short used, short base) { 
00049 // Sets the ACD ID number to newVal
00050 // If this is an unused PMT, store that information
00051     if (used <= 0) {
00052         m_used = 0;
00053         m_id = 0;
00054         setLayer(3);
00055         setFace(7);
00056         setRow(9);
00057         setColumn(9);
00058     } else {
00059         m_used = 1;
00060         if (base == 2) {
00061             m_id = newVal;
00062         } else if (base == 10) {
00063             short lay, face, row, col;
00064             base10ToAcdId(newVal, lay, face, row, col);
00065             setLayer(lay);
00066             setFace(face);
00067             setRow(row);
00068             setColumn(col);
00069         }
00070     }
00071 }
00072 
00073 
00074 bool AcdId::isTop () const 
00075 { 
00076     return (getFace() == 0); 
00077 }
00078 
00079 bool AcdId::isSide () const 
00080 { 
00081     return (getFace() != 0); 
00082 }
00083 
00084 short AcdId::getLayer () const 
00085 { 
00086     return ((m_id & _layermask) >> layerShift); 
00087 }
00088 
00089 short AcdId::getFace () const
00090 { 
00091     return (word(2, (m_id & _facemask))); 
00092 }
00093 
00094 short AcdId::getRow () const 
00095 { 
00096     return(word (1, m_id)); 
00097 }
00098 
00099 short AcdId::getColumn () const 
00100 { 
00101     return(word (0, m_id)); 
00102 }
00103 
00104 void AcdId::setLayer( unsigned int val)
00105 { 
00106     m_id &= ~_layermask;
00107     m_id |= (val << layerShift);
00108     //short two = 2;
00109     
00110    // set_word( two, m_id, 
00111    //     ((val == 0) ? 0 : 8) | ((_facemask & m_id) >> 8) );
00112 }
00113 
00114 void AcdId::setFace( unsigned int f )
00115 {
00116     short two = 2;
00117     set_word( two, m_id, 
00118         f | ((_layermask & m_id ) >> 8) );
00119 }
00120 
00121 void AcdId::setRow( unsigned int r ) 
00122 { 
00123     short one = 1;
00124     set_word( one, m_id, r );
00125 }
00126 
00127 void AcdId::setColumn( unsigned int c ) 
00128 { 
00129     short zero = 0;
00130     set_word( zero, m_id, c ); 
00131 }
00132 
00133 bool AcdId::wasConnected() const
00134 {
00135     return ( (m_used == 1) ? true : false);
00136 }
00137 
00138 void AcdId::setConnected(Char_t c) {
00139     m_used = c;
00140 }
00141 
00142 void AcdId::base10ToAcdId(UInt_t val, short &lay, short &face, short &row, short &col) {
00143     lay = val / 1000;
00144     val -= lay*1000;
00145     face = val / 100;
00146     val -= face*100;
00147     row = val / 10;
00148     val -= row*10;
00149     col = val;
00150 }

Generated at Wed Nov 21 12:22:44 2001 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000