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

CalDigi.h

Go to the documentation of this file.
00001 
00002 #ifndef GlastEvent_CalDigi_H
00003 #define GlastEvent_CalDigi_H 1
00004 
00005 
00006 // Include files
00007 #include <iostream>
00008 #include <vector>
00009 #include "idents/CalLogId.h"
00010 
00011 #include "GaudiKernel/Kernel.h"
00012 #include "GaudiKernel/StreamBuffer.h"
00013 #include "GaudiKernel/ContainedObject.h"
00014 #include "GaudiKernel/ObjectVector.h"
00015 #include "GlastEvent/TopLevel/Definitions.h"
00016 
00017 
00029 class CalLogReadout : virtual public ContainedObject  { 
00030 
00031 public:
00032         CalLogReadout(char rangeP, short adcP, char rangeM, short adcM) :
00033                 m_rangeP(rangeP), 
00034                 m_adcP(adcP), 
00035                 m_rangeM(adcM), 
00036                 m_adcM(adcM)
00037         {};
00038 
00040         ~CalLogReadout() {};
00041 
00043         typedef enum
00044         {
00045                 POS = 0,
00046                 NEG
00047         } LogFace;
00048 
00049         // retrieve pulse height from specified face
00050         inline short getAdc(LogFace face) const {return face == POS ? m_adcP : m_adcM;};
00051 
00052         // retrieve energy range from specified face
00053         inline char getRange(LogFace face) const {return face == POS ? m_rangeP : m_rangeM;};
00054 
00056         inline StreamBuffer& serialize( StreamBuffer& s ) const
00057         {
00058                 s = ContainedObject::serialize(s);
00059                 return s << m_rangeP 
00060                                  << m_adcP 
00061                                  << m_rangeM 
00062                                  << m_adcM;
00063         }
00065         inline StreamBuffer& serialize( StreamBuffer& s )
00066         {
00067                 s = ContainedObject::serialize(s);
00068                 s >> m_rangeP
00069                   >> m_adcP
00070                   >> m_rangeM
00071                   >> m_adcM;
00072                 return s;
00073         }
00074 
00075 private:
00076 
00077         short m_adcP, m_adcM;
00078         char  m_rangeP, m_rangeM;
00079 
00080 };
00081 
00082 
00083 
00084 
00097 extern const CLID& CLID_CalDigi;
00098 
00099 class CalDigi : virtual public ContainedObject  { 
00100 
00101 public:
00103         typedef enum
00104         {
00105                 LEX8 = 0,
00106                 LEX1,
00107                 HEX8,
00108                 HEX1
00109         } AdcRange;
00110 
00112         typedef enum
00113         {
00114             BESTRANGE = 0,
00115             ALLRANGE = 2
00116         } CalTrigMode;
00117 
00119         enum {POS_OFFSET = 14,                                          // shift for POSitive face
00120                 RANGE_OFFSET = 12, RANGE_MASK = 0x3000,         // energy range bits
00121                 ADC_VAL_MASK = 0xfff};                                          // Adc value bits
00122 
00123         CalDigi() {};
00124 
00125         CalDigi(CalTrigMode mode, idents::CalLogId CalLogId, ObjectVector<CalLogReadout> readout) : 
00126                 m_mode(mode),
00127                 m_logId(CalLogId),
00128                 m_readout(readout)
00129         {};
00130 
00132         virtual ~CalDigi() { };
00133 
00135         virtual const CLID& clID() const   { return CalDigi::classID(); }
00136         static const CLID& classID()       { return CLID_CalDigi; }
00137 
00139         inline const CalTrigMode getMode() const { return m_mode; };
00140 
00142         inline const idents::CalLogId getPackedId() const { return m_logId; };
00143         
00145         inline char getRange(short readoutIndex, CalLogReadout::LogFace face) const
00146         {
00147                 return (readoutIndex < m_readout.size()) ? (*(m_readout[readoutIndex])).getRange(face) : (char)-1;
00148         }
00149 
00151         inline short getAdc(short readoutIndex, CalLogReadout::LogFace face) const
00152         {
00153                 return (readoutIndex < m_readout.size()) ? (*(m_readout[readoutIndex])).getAdc(face) : (short)-1;
00154         }
00155 
00157         inline const CalLogReadout* getLogReadout(short readoutIndex)
00158         {
00159                 return (readoutIndex < m_readout.size()) ? m_readout[readoutIndex] : NULL;
00160         }
00161 
00163         inline short getAdcSelectedRange(char range, CalLogReadout::LogFace face) const
00164         {
00165                 char nRanges = (char)m_readout.size();
00166                 if (nRanges == 1)
00167                         return (range == (*(m_readout[0])).getRange(face)) ? (*(m_readout[0])).getAdc(face) : (short)-1;
00168                 else
00169                         return (*(m_readout[(nRanges + range - (*(m_readout[0])).getRange(face)) % nRanges])).getAdc(face);
00170         }
00171 
00173         virtual StreamBuffer& serialize( StreamBuffer& s ) const;
00175         virtual StreamBuffer& serialize( StreamBuffer& s );
00177         virtual std::ostream& fillStream( std::ostream& s ) const;
00178 
00179 private:
00180 
00182         CalTrigMode m_mode;
00184         idents::CalLogId m_logId;
00186         ObjectVector<CalLogReadout> m_readout;
00187 
00188 };
00189 
00190 
00192 template <class TYPE> class ObjectVector;
00193 typedef ObjectVector<CalDigi> CalDigiVector;
00194 
00195 
00197 inline StreamBuffer& CalDigi::serialize( StreamBuffer& s ) const
00198 {
00199         s = ContainedObject::serialize(s);
00200         s << m_mode;
00201         s = m_logId.serialize(s);
00202         s = (*(m_readout[0])).serialize(s);
00203         if (m_mode == ALLRANGE)
00204                 for (int rangeIndex=1; rangeIndex<4; rangeIndex++)
00205                         s = (*(m_readout[rangeIndex])).serialize(s);
00206   
00207         return s;
00208 }
00209 
00210 
00212 inline StreamBuffer& CalDigi::serialize( StreamBuffer& s )
00213 {
00214         s = ContainedObject::serialize(s);
00215         int mode;
00216         s >> mode; m_mode = (mode==CalTrigMode::ALLRANGE) ? ALLRANGE:BESTRANGE;
00217 // For now by default m_mode is considered to be BESTRANGE
00218         
00219         s = m_logId.serialize(s);
00220         s = (*(m_readout[0])).serialize(s);
00221         if (m_mode == ALLRANGE)
00222                 for (int rangeIndex = 1; rangeIndex < 4; rangeIndex++)
00223                         s = (*(m_readout[rangeIndex])).serialize(s);
00224 
00225         return s;
00226 }
00227 
00228 
00230 inline std::ostream& CalDigi::fillStream( std::ostream& s ) const
00231 {
00232     s << "    base class CalDigi :"
00233     << "\n        CalTrigMode = ( "
00234     << GlastEventFloatFormat( GlastEvent::width, GlastEvent::precision )
00235     << m_mode << " )"
00236     << "\n        ID = ( "
00237     << GlastEventFloatFormat( GlastEvent::width, GlastEvent::precision )
00238     << m_logId << " )"
00239     << "\n        Best plus-face range and pulseheight  = ( "
00240     << GlastEventFloatFormat( GlastEvent::width, GlastEvent::precision )
00241     << CalDigi::getRange(BESTRANGE,CalLogReadout::LogFace::POS) << ", " << CalDigi::getAdc(BESTRANGE,CalLogReadout::LogFace::POS) << " )"
00242     << "\n        Best minus-face range and pulseheight = "
00243     << GlastEventFloatFormat( GlastEvent::width, GlastEvent::precision )
00244     << CalDigi::getRange(BESTRANGE,CalLogReadout::LogFace::NEG) << ", " << CalDigi::getAdc(BESTRANGE,CalLogReadout::LogFace::NEG) << " )";
00245 
00246         if (m_mode == ALLRANGE)
00247         {
00248                 for (int rangeIndex = 1; rangeIndex < 4; rangeIndex++)
00249                 {
00250                         s << "\n        Next plus-face range and pulseheight  = "
00251                     << GlastEventFloatFormat( GlastEvent::width, GlastEvent::precision )
00252                         << CalDigi::getRange(rangeIndex,CalLogReadout::LogFace::POS) << ", " << CalDigi::getAdc(rangeIndex,CalLogReadout::LogFace::POS) << " )"
00253                         << "\n        Next minus-face range and pulseheight = "
00254                         << GlastEventFloatFormat( GlastEvent::width, GlastEvent::precision )
00255                         << CalDigi::getRange(rangeIndex,CalLogReadout::LogFace::NEG) << ", " << CalDigi::getAdc(rangeIndex,CalLogReadout::LogFace::NEG) << " )";
00256                 }
00257         }
00258 
00259         s << " )\n";
00260 
00261         return s;
00262 }
00263 #endif

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