Changeset 12326 for trunk/Mars
- Timestamp:
- 10/30/11 03:41:29 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Mars/mcore/DrsCalib.h
r12285 r12326 1 #ifndef MARS_CalibData 2 #define MARS_CalibData 3 1 4 class CalibData 2 5 { … … 167 170 } 168 171 169 static void Apply(int16_t *val, const int16_t *start, uint32_t roi, 170 const int32_t *offset, const uint32_t scaleabs, 171 const int64_t *gain, const uint32_t scalegain, 172 const int64_t *trgoff, const uint32_t scalerel) 173 { 174 return ;// "FIXME: scalegain exceeds valid range..." 175 for (size_t ch=0; ch<1440; ch++) 176 { 177 const int16_t spos = start[ch]; 178 if (spos<0) 179 continue; 180 181 const size_t pos = ch*roi; 182 183 for (size_t i=0; i<roi; i++) 184 { 185 // Value is relative to trigger 186 // Offset is relative to DRS pipeline 187 // Abs is corresponding index relative to DRS pipeline 188 const size_t rel = pos + i; 189 const size_t abs = pos + (spos+i)%1024; 190 191 const int64_t v = 192 + int64_t(val[rel]) *scaleabs*scalerel 193 - int64_t(trgoff[rel])*scaleabs 194 - int64_t(offset[abs])*scalerel 195 ; 196 197 // The gain value is multiplied by fNumOffset and fNumGain 198 const int64_t div = int64_t(gain[abs])*scaleabs*scalerel; 199 val[rel] = (v*scalegain)/div; 200 } 172 static void ApplyCh(float *vec, const int16_t *val, int16_t start, uint32_t roi, 173 const int32_t *offset, const uint32_t scaleabs, 174 const int64_t *gain, const uint64_t scalegain, 175 const int64_t *trgoff, const uint64_t scalerel) 176 { 177 if (start<0) 178 { 179 memset(vec, 0, roi); 180 return; 181 } 182 183 for (size_t i=0; i<roi; i++) 184 { 185 // Value is relative to trigger 186 // Offset is relative to DRS pipeline 187 // Abs is corresponding index relative to DRS pipeline 188 const size_t rel = i; 189 const size_t abs = (start+i)%1024; 190 191 const int64_t v = 192 + (int64_t(val[rel])*scaleabs-offset[abs])*scalerel 193 - trgoff[rel] 194 ; 195 196 const int64_t div = gain[abs]*scalerel; 197 vec[rel] = double(v)*scalegain/div; 201 198 } 202 199 } … … 204 201 static void Apply(float *vec, const int16_t *val, const int16_t *start, uint32_t roi, 205 202 const int32_t *offset, const uint32_t scaleabs, 206 const int64_t *gain, /*const*/ uint64_t scalegain, 207 const int64_t *trgoff, /*const*/ uint64_t scalerel) 208 { 209 /* 210 scalegain *= scaleabs; 211 scalerel *= scaleabs; 212 203 const int64_t *gain, const uint64_t scalegain, 204 const int64_t *trgoff, const uint64_t scalerel) 205 { 213 206 for (size_t ch=0; ch<1440; ch++) 214 207 { 215 208 const size_t pos = ch*roi; 216 const int16_t spos = start[ch]; 217 if (spos<0) 218 { 219 memset(vec+pos, 0, roi); 220 continue; 221 } 222 223 for (size_t i=0; i<roi; i++) 224 { 225 // Value is relative to trigger 226 // Offset is relative to DRS pipeline 227 // Abs is corresponding index relative to DRS pipeline 228 const size_t rel = pos + i; 229 const size_t abs = pos + (spos+i)%1024; 230 231 const int64_t v = 232 + int64_t(val[rel]) *scaleabs*scalerel 233 - int64_t(trgoff[rel])*scaleabs 234 - int64_t(offset[abs])*scalerel 235 ; 236 237 const int64_t div = int64_t(gain[abs])*scaleabs*scalerel; 238 239 vec[rel] = double(v)*scalegain/div; 240 } 241 }*/ 242 243 for (size_t ch=0; ch<1440; ch++) 244 { 245 const size_t pos = ch*roi; 246 247 const int16_t spos = start[ch]; 248 if (spos<0) 249 { 250 memset(vec+pos, 0, roi); 251 continue; 252 } 253 254 for (size_t i=0; i<roi; i++) 255 { 256 // Value is relative to trigger 257 // Offset is relative to DRS pipeline 258 // Abs is corresponding index relative to DRS pipeline 259 const size_t rel = pos + i; 260 const size_t abs = pos + (spos+i)%1024; 261 262 const int64_t v = 263 + (int64_t(val[rel])*scaleabs-offset[abs])*scalerel 264 - trgoff[rel] 265 ; 266 267 const int64_t div = gain[abs]*scalerel; 268 vec[rel] = double(v)*scalegain/div; 269 } 209 const size_t drs = ch*1024; 210 ApplyCh(vec+pos, val+pos, start[ch], roi, 211 offset+drs, scaleabs, 212 gain +drs, scalegain, 213 trgoff+drs, scalerel); 270 214 } 271 215 } … … 409 353 }; 410 354 355 #endif
Note:
See TracChangeset
for help on using the changeset viewer.