00001
00002 #ifndef LHCBEVENT_CELLID_H
00003 #define LHCBEVENT_CELLID_H 1
00004
00005
00006
00007 #include <iostream>
00008 #include "GaudiKernel/StreamBuffer.h"
00009 #include "GlastEvent/TopLevel/Definitions.h"
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 class CellID {
00025
00026
00027
00028
00029 enum { CalorimeterEncoding=1000000, RawEncoding=1000, ColumnEncoding=1 };
00030
00031 public:
00032
00034 CellID()
00035 : m_id(0) { }
00036 CellID( long cellID )
00037 : m_id(cellID) { }
00038 CellID( long calorimeterNumber, long rawNumber, long columnNumber ) {
00039 setID( calorimeterNumber, rawNumber, columnNumber );
00040 }
00042 ~CellID() { }
00043
00045 long calorimeterNumber() const {
00046 return long( m_id / CalorimeterEncoding );
00047 }
00049 long rawNumber() const {
00050 return long( (m_id - calorimeterNumber()*CalorimeterEncoding)
00051 / RawEncoding );
00052 }
00054 long columnNumber() const {
00055 return long( (m_id - calorimeterNumber()*CalorimeterEncoding
00056 - rawNumber()*RawEncoding)
00057 / ColumnEncoding );
00058 }
00060 long id() const {
00061 return m_id;
00062 }
00064 void setID( long calorimeterNumber, long rawNumber, long columnNumber ) {
00065 m_id = CalorimeterEncoding*calorimeterNumber
00066 + RawEncoding*rawNumber
00067 + ColumnEncoding*columnNumber;
00068 }
00069
00071 friend StreamBuffer& operator<< ( StreamBuffer& s, const CellID& obj ) {
00072 return s << obj.m_id;
00073 }
00075 friend StreamBuffer& operator>> ( StreamBuffer& s, CellID& obj ) {
00076 return s >> obj.m_id;
00077 }
00078
00080 friend std::ostream& operator<< ( std::ostream& s, const CellID& obj ) {
00081 return obj.fillStream(s);
00082 }
00084 std::ostream& fillStream( std::ostream& s ) const {
00085 return s
00086 << "class CellID (calorimeter, raw, column) : ( "
00087 << GlastEventField( GlastEvent::field5 )
00088 << calorimeterNumber()
00089 << ", "
00090 << GlastEventField( GlastEvent::field5 )
00091 << rawNumber()
00092 << ", "
00093 << GlastEventField( GlastEvent::field5 )
00094 << columnNumber() << " )";
00095 }
00096
00097 private:
00098
00099
00100 long m_id;
00101
00102 };
00103
00104
00105 #endif // LHCBEVENT_CELLID_H