00001 // ===================================================================== 00002 // $Id: TSoftwareAdcModule.hh,v 1.1.1.1 2003/06/27 02:56:41 goiwai Exp $ 00003 // $Name: CLDAQ-1-06-00 $ 00004 // ===================================================================== 00005 #ifndef __TSOFTWAREADCMODULE_HH 00006 #define __TSOFTWAREADCMODULE_HH 00007 00008 #include "Tglobals.h" 00009 #include "TSoftwareModule.hh" 00010 #include "TChannel.hh" 00011 #include "TRandomEngine.hh" 00012 #include "TRandomFlat.hh" 00013 #include "TRandomGaussian.hh" 00014 00015 class TDataSegment; 00016 class TDataElement; 00017 00018 class TSoftwareAdcModule 00019 : public TSoftwareModule 00020 { 00021 protected: 00022 enum { tDataOverFlow = -1 }; 00023 enum { tDefaultScale = 4096 }; 00024 enum { tDefaultChannel = 16 }; 00025 00026 protected: 00027 Tint theScale; 00028 TintList theMean; 00029 TintList theSigma; 00030 TChannel theChannel; 00031 Trandom_t theRandomType; 00032 00033 protected: 00034 static Tint theSeed; 00035 static TRandomEngine theRandomEngine; 00036 00037 public: 00038 TSoftwareAdcModule( Tint nchannel = tDefaultChannel, Tint scale = tDefaultScale, Trandom_t randtype = tRandomGaussian ); 00039 TSoftwareAdcModule( const TSoftwareAdcModule& right ); 00040 virtual ~TSoftwareAdcModule(); 00041 00042 public: 00043 virtual Tint Clear(); 00044 virtual Tint Update(); 00045 virtual Tint Initialize(); 00046 virtual Tvoid FillData( TDataElement& element, Tint channel ); 00047 00048 public: 00049 virtual const TSoftwareAdcModule& operator=( const TSoftwareAdcModule& right ); 00050 virtual Tbool operator==( const TSoftwareAdcModule& right ) const; 00051 virtual Tbool operator!=( const TSoftwareAdcModule& right ) const; 00052 00053 public: 00054 virtual Tint GetScale() const; 00055 virtual const TintList& GetMean() const; 00056 virtual Tint GetMean( Tint channel ) const; 00057 virtual const TintList& GetSigma() const; 00058 virtual Tint GetSigma( Tint channel ) const; 00059 virtual const TChannel& GetChannel() const; 00060 virtual Tint GetData( Tint channel ) const; 00061 virtual Trandom_t GetRandomType() const; 00062 virtual Tvoid SetScale( Tint scale ); 00063 virtual Tvoid SetMean( const TintList& meanlist ); 00064 virtual Tvoid SetMean( Tint channel, Tint mean ); 00065 virtual Tvoid SetSigma( const TintList& sigmalist ); 00066 virtual Tvoid SetSigma( Tint channel, Tint sigma ); 00067 virtual Tvoid SetChannel( const TChannel& channels ); 00068 virtual Tvoid SetData( Tint channel, Tint data ); 00069 virtual Tvoid GetRandomType( Trandom_t randomtype ); 00070 00071 public: 00072 static Tint GetSeed(); 00073 static const TRandomEngine& GetRandomEngine(); 00074 static Tvoid SetSeed( Tint seed ); 00075 static Tvoid SetRandomEngine( const TRandomEngine& engine ); 00076 00077 protected: 00078 virtual Tvoid setParameters(); 00079 virtual Tvoid fillGaussian(); 00080 00081 }; 00082 00083 inline Tint TSoftwareAdcModule::GetScale() const 00084 { 00085 return( theScale ); 00086 } 00087 00088 inline const TintList& TSoftwareAdcModule::GetMean() const 00089 { 00090 return( theMean ); 00091 } 00092 00093 inline Tint TSoftwareAdcModule::GetMean( Tint channel ) const 00094 { 00095 if ( channel < 0 || channel >= theNumberOfChannels ) { 00096 Tcerr << "TSoftwareAdcModule::GetMean: invalid ID" << Tendl; 00097 return( -EFAULT ); 00098 } else { 00099 return( theMean[ channel ] ); 00100 } 00101 } 00102 00103 inline const TintList& TSoftwareAdcModule::GetSigma() const 00104 { 00105 return( theSigma ); 00106 } 00107 00108 inline Tint TSoftwareAdcModule::GetSigma( Tint channel ) const 00109 { 00110 if ( channel < 0 || channel >= theNumberOfChannels ) { 00111 Tcerr << "TSoftwareAdcModule::GetSigma: invalid ID" << Tendl; 00112 return( -EFAULT ); 00113 } else { 00114 return( theSigma[ channel ] ); 00115 } 00116 } 00117 00118 inline const TChannel& TSoftwareAdcModule::GetChannel() const 00119 { 00120 return( theChannel ); 00121 } 00122 00123 inline Tint TSoftwareAdcModule::GetData( Tint channel ) const 00124 { 00125 if ( channel < 0 || channel >= theNumberOfChannels ) { 00126 Tcerr << "TSoftwareAdcModule::GetData: invalid ID" << Tendl; 00127 return( -EFAULT ); 00128 } else { 00129 return( theChannel[ channel ] ); 00130 } 00131 } 00132 00133 inline Trandom_t TSoftwareAdcModule::GetRandomType() const 00134 { 00135 return( theRandomType ); 00136 } 00137 00138 inline Tvoid TSoftwareAdcModule::SetScale( Tint scale ) 00139 { 00140 theScale = scale; 00141 return; 00142 } 00143 00144 inline Tvoid TSoftwareAdcModule::SetMean( const TintList& meanlist ) 00145 { 00146 theMean = meanlist; 00147 return; 00148 } 00149 00150 inline Tvoid TSoftwareAdcModule::SetMean( Tint channel, Tint mean ) 00151 { 00152 if ( channel < 0 || channel >= theNumberOfChannels ) 00153 Tcerr << "TSoftwareAdc::SetMean: invalid ID" << Tendl; 00154 else 00155 theMean[ channel ] = mean; 00156 return; 00157 } 00158 00159 inline Tvoid TSoftwareAdcModule::SetSigma( const TintList& sigmalist ) 00160 { 00161 theSigma = sigmalist; 00162 return; 00163 } 00164 00165 inline Tvoid TSoftwareAdcModule::SetSigma( Tint channel, Tint sigma ) 00166 { 00167 if ( channel < 0 || channel >= theNumberOfChannels ) 00168 Tcerr << "TSoftwareAdc::SetSigma: invalid ID" << Tendl; 00169 else 00170 theSigma[ channel ] = sigma; 00171 return; 00172 } 00173 00174 inline Tvoid TSoftwareAdcModule::SetChannel( const TChannel& channels ) 00175 { 00176 theChannel = channels; 00177 return; 00178 } 00179 00180 inline Tvoid TSoftwareAdcModule::SetData( Tint channel, Tint data ) 00181 { 00182 if ( channel < 0 || channel >= theNumberOfChannels ) 00183 Tcerr << "TSoftwareAdc::SetData: invalid ID" << Tendl; 00184 else 00185 theChannel[ channel ] = data; 00186 return; 00187 } 00188 00189 inline Tvoid TSoftwareAdcModule::GetRandomType( Trandom_t randomtype ) 00190 { 00191 theRandomType = randomtype; 00192 return; 00193 } 00194 00195 inline Tint TSoftwareAdcModule::GetSeed() 00196 { 00197 return( TSoftwareAdcModule::theSeed ); 00198 } 00199 00200 inline const TRandomEngine& TSoftwareAdcModule::GetRandomEngine() 00201 { 00202 return( TSoftwareAdcModule::theRandomEngine ); 00203 } 00204 00205 inline Tvoid TSoftwareAdcModule::SetSeed( Tint seed ) 00206 { 00207 TSoftwareAdcModule::theSeed = seed; 00208 return; 00209 } 00210 00211 inline Tvoid TSoftwareAdcModule::SetRandomEngine( const TRandomEngine& engine ) 00212 { 00213 TSoftwareAdcModule::theRandomEngine = engine; 00214 return; 00215 } 00216 00217 #endif