00001 #ifndef GlastEvent_LOGID_H
00002 #define GlastEvent_LOGID_H 1
00003
00004
00005
00006 #include <iostream>
00007 using namespace std;
00008
00009 #include "GaudiKernel/Kernel.h"
00010 #include "GaudiKernel/ContainedObject.h"
00011
00012
00028 namespace idents {
00029 class CalLogId : public ContainedObject {
00030
00031 private:
00032
00033
00034 int m_packedId;
00035 short m_tower, m_layer, m_column;
00036
00037 inline void unpackId()
00038 {
00039 m_tower = getTower();
00040 m_layer = getLayer();
00041 m_column = getColumn();
00042 };
00043 inline void packId(short tower, short layer, short column)
00044 {m_packedId = (((tower<<3) + layer)<<4) + column;};
00045
00046 public:
00047
00048 CalLogId(int packedId=0) :
00049 m_packedId(packedId)
00050 {
00051 unpackId();
00052 };
00053
00054 CalLogId(short tower, short layer, short column)
00055 {
00056 packId(tower, layer, column);
00057 m_tower = tower;
00058 m_layer = layer;
00059 m_column = column;
00060 };
00061
00062 ~CalLogId();
00063
00064 void init();
00065
00066
00067 inline int getPackedId() const {return m_packedId;};
00068 void getUnpackedId(short& tower, short& layer, short& column);
00069
00070
00071 inline short getTower() const {return (m_packedId >> 0x7) & 0xf;};
00072 inline short getLayer() const {return (m_packedId >> 0x4) & 0x7;};
00073 inline short getColumn() const {return m_packedId & 0xf;};
00074
00075 friend ostream& operator<< (ostream &stream, CalLogId logId);
00076 friend istream& operator>> (istream &stream, CalLogId &logId);
00077
00079 virtual StreamBuffer& serialize( StreamBuffer& s ) const;
00081 virtual StreamBuffer& serialize( StreamBuffer& s );
00082
00083 };
00084
00085
00086
00087 ostream& operator<<(ostream &stream, CalLogId logId)
00088 {
00089 stream << logId.m_tower << " ";
00090 stream << logId.m_layer << " ";
00091 stream << logId.m_column << " ";
00092 return stream;
00093 }
00094
00095
00096
00097 istream& operator>> (istream &stream, CalLogId &logId)
00098 {
00099 stream >> logId.m_tower >> logId.m_layer >> logId.m_column;
00100 logId.packId(logId.m_tower, logId.m_layer, logId.m_column);
00101 return stream;
00102 }
00103
00104
00106 void CalLogId::getUnpackedId(short& tower, short& layer, short& column)
00107 {
00108 tower = m_tower;
00109 layer = m_layer;
00110 column = m_column;
00111 }
00112
00113
00115 inline StreamBuffer& CalLogId::serialize( StreamBuffer& s ) const
00116 {
00117 ContainedObject::serialize(s);
00118 return s << m_packedId;
00119 }
00120
00121
00123 inline StreamBuffer& CalLogId::serialize( StreamBuffer& s )
00124 {
00125 ContainedObject::serialize(s);
00126 s >> m_packedId;
00127 unpackId();
00128 return s;
00129 }
00130
00131 }
00132 #endif // GlastEvent_LOGID_H