00001 #ifndef GlastEvent_AcdDigi_H
00002 #define GlastEvent_AcdDigi_H 1
00003
00004
00005
00006 #include <iostream>
00007 #include "idents/AcdId.h"
00008 #include "GaudiKernel/Kernel.h"
00009 #include "GaudiKernel/StreamBuffer.h"
00010 #include "GaudiKernel/ContainedObject.h"
00011
00012 #include "GlastEvent/TopLevel/Definitions.h"
00013
00045 extern const CLID& CLID_AcdDigi;
00046
00047
00048 class AcdDigi : virtual public ContainedObject {
00049
00050 public:
00051 AcdDigi() {};
00052
00053 AcdDigi(idents::AcdId id, int pulseHeight, bool veto, bool lowThresh,
00054 bool highThresh)
00055 : m_ID(id),
00056 m_pulseHeight(pulseHeight),
00057 m_veto(veto),
00058 m_lowThreshold(lowThresh),
00059 m_highThreshold(highThresh),
00060 m_packedPHA(0)
00061 {
00062 m_packedPHA = m_pulseHeight;
00063 m_packedPHA |= (m_lowThreshold << ADC_V_LOWTHRESH);
00064 m_packedPHA |= (m_veto << ADC_V_VETO);
00065 m_packedPHA |= (m_highThreshold << ADC_V_HIGHTHRESH);
00066 };
00067
00069 virtual ~AcdDigi() { };
00070
00072 virtual const CLID& clID() const { return AcdDigi::classID(); }
00073 static const CLID& classID() { return CLID_AcdDigi; }
00074
00076 inline const idents::AcdId ID() const { return m_ID; };
00077
00079 inline int PulseHeight() const { return m_pulseHeight; };
00080
00081 inline bool Veto() const { return m_veto; };
00082
00083 inline bool LowThreshold() const { return m_lowThreshold; };
00084
00085 inline bool HighThreshold() const { return m_highThreshold; };
00086
00087
00089 virtual StreamBuffer& serialize( StreamBuffer& s ) const;
00091 virtual StreamBuffer& serialize( StreamBuffer& s );
00093 virtual std::ostream& fillStream( std::ostream& s ) const;
00094
00095
00096
00097 private:
00098
00099
00100 enum {
00101 ADC_K_VETO = 1,
00102 ADC_V_VETO = 12,
00103 ADC_M_VETO = ((1 << ADC_K_VETO) - 1),
00104
00105 ADC_K_LOWTHRESH = 1,
00106 ADC_V_LOWTHRESH = 13,
00107 ADC_M_LOWTHRESH = ((1 << ADC_K_LOWTHRESH) - 1),
00108
00109 ADC_K_HIGHTHRESH = 1,
00110 ADC_V_HIGHTHRESH = 14,
00111 ADC_M_HIGHTHRESH = ((1 << ADC_K_HIGHTHRESH) - 1)
00112 };
00113
00114
00115
00117 idents::AcdId m_ID;
00119 unsigned short m_pulseHeight;
00121 bool m_veto;
00123 bool m_lowThreshold;
00125 bool m_highThreshold;
00127 unsigned short m_packedPHA;
00128 };
00129
00130
00132 template <class TYPE> class ObjectVector;
00133 typedef ObjectVector<AcdDigi> AcdDigiVector;
00134
00135 template <class TYPE> class ObjectList;
00136 typedef ObjectList<AcdDigi> AcdDigiList;
00137
00139 inline StreamBuffer& AcdDigi::serialize( StreamBuffer& s ) const
00140 {
00141 ContainedObject::serialize(s);
00142 return s
00143 << m_ID
00144 << m_packedPHA;
00145 }
00146
00147
00149 inline StreamBuffer& AcdDigi::serialize( StreamBuffer& s )
00150 {
00151 ContainedObject::serialize(s);
00152
00153 unsigned int id;
00154
00155 s >> id
00156 >> m_packedPHA;
00157
00158 idents::AcdId persId(id);
00159 m_ID = persId;
00160
00161
00162 m_veto = (m_packedPHA >> ADC_V_VETO) & ADC_M_VETO;
00163 m_lowThreshold = (m_packedPHA >> ADC_V_LOWTHRESH) & ADC_M_LOWTHRESH;
00164 m_highThreshold = (m_packedPHA >> ADC_V_HIGHTHRESH) & ADC_M_HIGHTHRESH;
00165
00166 return s;
00167 }
00168
00169
00171 inline std::ostream& AcdDigi::fillStream( std::ostream& s ) const
00172 {
00173 return s
00174 << " base class AcdDigi :"
00175 << "\n ID = ( "
00176 << GlastEventFloatFormat( GlastEvent::width, GlastEvent::precision )
00177 << m_ID << ", "
00178 << "\n pulse height = "
00179 << GlastEventFloatFormat( GlastEvent::width, GlastEvent::precision )
00180 << m_pulseHeight << ", "
00181 << "\n veto = "
00182 << GlastEventFloatFormat( GlastEvent::width, GlastEvent::precision )
00183 << m_veto << " )"
00184 << "\n Low Threshold = "
00185 << m_lowThreshold << " )"
00186 << "\n High Threshold = "
00187 << GlastEventFloatFormat( GlastEvent::width, GlastEvent::precision )
00188 << m_highThreshold << " )"
00189 << "\n packed PHA = "
00190 << GlastEventFloatFormat( GlastEvent::width, GlastEvent::precision )
00191 << m_packedPHA << " )";
00192 }
00193
00194
00195
00196
00197 #endif // GlastEvent_AcdDigi_H
00198