00001 #ifndef GlastEvent_TkrDigi_H
00002 #define GlastEvent_TkrDigi_H 1
00003
00004
00005
00006 #include <iostream>
00007 #include <vector>
00008
00009 #include "GaudiKernel/Kernel.h"
00010 #include "GaudiKernel/ContainedObject.h"
00011 #include "GaudiKernel/SmartRefVector.h"
00012
00013 #include "GlastEvent/TopLevel/Definitions.h"
00014 #include "GaudiKernel/ObjectVector.h"
00015 #include "GaudiKernel/ObjectList.h"
00016
00026 extern const CLID& CLID_TkrDigi;
00027
00028 class TkrDigi : virtual public ContainedObject {
00029
00030 public:
00032 typedef std::vector<int> HitList;
00033 typedef HitList::const_iterator const_iterator;
00034
00037 TkrDigi() {};
00038
00040 TkrDigi(int l, int v, int t, int* tot)
00041 : m_layer (l), m_view (v), m_tower (t) {
00042 m_tot[0] = *tot;
00043 m_tot[1] = *(++tot);
00044 };
00046 virtual ~TkrDigi() {
00047 };
00048
00050 virtual const CLID& clID() const { return TkrDigi::classID(); }
00051 static const CLID& classID() { return CLID_TkrDigi; }
00052
00055 int layer() const {return m_layer;}
00057 int view () const {return m_view;}
00059 int tower() const {return m_tower;}
00061 int ToT( int i) const {return m_tot[i];}
00063 int num() const{ return m_hits.size(); }
00065 int hit( int i ) const { return m_hits[i];}
00066
00069 void setLayer( int layer) {m_layer = layer;}
00071 void setView( int view) {m_view = view;}
00073 void setTower( int tower ) {m_tower = tower;}
00075 void setToT ( int i, int tot) {m_tot[i] = tot;}
00077 void addHit( int strip ) {m_hits.push_back(strip);}
00078
00080 virtual StreamBuffer& serialize( StreamBuffer& s );
00082 virtual StreamBuffer& serialize( StreamBuffer& s ) const;
00084 virtual std::ostream& fillStream( std::ostream& s ) const;
00085
00087 const_iterator begin()const {return m_hits.begin();}
00089 const_iterator end()const {return m_hits.end();}
00090
00091 private:
00092
00093 int m_layer;
00094 int m_view;
00095 int m_tower;
00096 int m_tot[2];
00097 HitList m_hits;
00098 };
00099
00100
00102 inline StreamBuffer& TkrDigi::serialize( StreamBuffer& s ) const {
00103 ContainedObject::serialize(s);
00104 s << m_layer
00105 << m_view
00106 << m_tower
00107 << m_tot[0]
00108 << m_tot[1]
00109 << m_hits.size();
00110 const_iterator ih;
00111 for (ih = m_hits.begin(); ih!=m_hits.end(); ih++) {
00112 s << *ih;
00113 }
00114
00115 return s;
00116 }
00117
00119 inline StreamBuffer& TkrDigi::serialize( StreamBuffer& s ) {
00120 ContainedObject::serialize(s);
00121 int size;
00122 s >> m_layer
00123 >> m_view
00124 >> m_tower
00125 >> m_tot[0]
00126 >> m_tot[1]
00127 >> size;
00128
00129 m_hits.resize( size, 0);
00130 std::vector<int>::iterator ih;
00131 for (ih = m_hits.begin(); ih!=m_hits.end(); ih++) {
00132 s >> *ih;
00133 }
00134
00135 return s;
00136 }
00137
00139
00140 inline std::ostream& TkrDigi::fillStream( std::ostream& s ) const {
00141 int j;
00142 int size = m_hits.size();
00143 s << "class TkrDigi :" << std::endl
00144 << "Layer: " << m_layer
00145 << " view: " << m_view
00146 << " tower: " << m_tower
00147 << " ToT: " << m_tot[0] << " " << m_tot[1] << std::endl
00148 << "Number of hits strips: " << size << std::endl;
00149
00150 const_iterator ih;
00151 for(ih = m_hits.begin(), j=0; ih != m_hits.end();ih++,j++) {
00152 if (j==10) {j = 0; s << std::endl;}
00153 s << *ih << " ";
00154 }
00155 s << std::endl;
00156 return s;
00157 }
00158
00160
00163 template <class TYPE> class ObjectVector;
00164 template <class TYPE> class ObjectList;
00165
00166 typedef ObjectVector<TkrDigi> TkrDigiCol;
00167
00168 #endif