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