Changeset 6107 for trunk/MagicSoft/Mars/msignal
- Timestamp:
- 01/29/05 11:35:42 (20 years ago)
- Location:
- trunk/MagicSoft/Mars/msignal
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/msignal/MExtractFixedWindowSpline.cc
r5697 r6107 72 72 // 73 73 MExtractFixedWindowSpline::MExtractFixedWindowSpline(const char *name, const char *title) 74 : fHiGainFirstDeriv(NULL), fLoGainFirstDeriv(NULL),75 fHiGainSecondDeriv(NULL), fLoGainSecondDeriv(NULL)76 74 { 77 75 … … 80 78 81 79 SetRange(fgHiGainFirst, fgHiGainLast, fgLoGainFirst, fgLoGainLast); 82 }83 84 MExtractFixedWindowSpline::~MExtractFixedWindowSpline()85 {86 87 if (fHiGainFirstDeriv)88 delete [] fHiGainFirstDeriv;89 if (fLoGainFirstDeriv)90 delete [] fLoGainFirstDeriv;91 if (fHiGainSecondDeriv)92 delete [] fHiGainSecondDeriv;93 if (fLoGainSecondDeriv)94 delete [] fLoGainSecondDeriv;95 96 80 } 97 81 … … 124 108 { 125 109 *fLog << warn << GetDescriptor() 126 << Form("%s%2i%s%2i",": Hi Gain window size has to be even, set last slice from "110 << Form("%s%2i%s%2i",": Hi Gain window size has to be uneven, set last slice from " 127 111 ,(int)hilast," to ",(int)(hilast-1)) << endl; 128 112 hilast -= 1; … … 133 117 *fLog << warn << GetDescriptor() 134 118 << Form("%s%2i%s%2i",": Hi Gain window is smaller than 2 FADC sampes, set last slice from" 135 ,(int)hilast," to ",(int)(hifirst+ 1)) << endl;136 hilast = hifirst+ 1;119 ,(int)hilast," to ",(int)(hifirst+2)) << endl; 120 hilast = hifirst+2; 137 121 } 138 122 … … 145 129 { 146 130 *fLog << warn << GetDescriptor() 147 << Form("%s%2i%s%2i",": Lo Gain window size has to be even, set last slice from "131 << Form("%s%2i%s%2i",": Lo Gain window size has to be uneven, set last slice from " 148 132 ,(int)lolast," to ",(int)(lolast-1)) << endl; 149 133 lolast -= 1; … … 155 139 *fLog << warn << GetDescriptor() 156 140 << Form("%s%2i%s%2i",": Lo Gain window is smaller than 2 FADC sampes, set last slice from" 157 ,(int)lolast," to ",(int)(lofirst+ 1)) << endl;158 lolast = lofirst+ 1;141 ,(int)lolast," to ",(int)(lofirst+2)) << endl; 142 lolast = lofirst+2; 159 143 } 160 144 } … … 164 148 165 149 // 166 // Very important: Because the spline interpolates between the slice ,150 // Very important: Because the spline interpolates between the slices, 167 151 // the number of samples for the pedestal subtraction 168 152 // is now 1 less than with e.g. MExtractFixedWindow … … 200 184 fLoGainFirst, fLoGainLast, fNumLoGainSamples); 201 185 202 if (fHiGainFirstDeriv)203 delete [] fHiGainFirstDeriv;204 if (fLoGainFirstDeriv)205 delete [] fLoGainFirstDeriv;206 if (fHiGainSecondDeriv)207 delete [] fHiGainSecondDeriv;208 if (fLoGainSecondDeriv)209 delete [] fLoGainSecondDeriv;210 211 186 Int_t range = fHiGainLast - fHiGainFirst + 1 + fHiLoLast; 212 187 213 fHiGainFirstDeriv = new Float_t[range]; 214 memset(fHiGainFirstDeriv,0,range*sizeof(Float_t)); 215 fHiGainSecondDeriv = new Float_t[range]; 216 memset(fHiGainSecondDeriv,0,range*sizeof(Float_t)); 188 fHiGainFirstDeriv.Set(range); 189 fHiGainSecondDeriv.Set(range); 217 190 218 191 range = fLoGainLast - fLoGainFirst + 1; 219 192 220 fLoGainFirstDeriv = new Float_t[range]; 221 memset(fLoGainFirstDeriv,0,range*sizeof(Float_t)); 222 fLoGainSecondDeriv = new Float_t[range]; 223 memset(fLoGainSecondDeriv,0,range*sizeof(Float_t)); 193 fLoGainFirstDeriv.Set(range); 194 fLoGainSecondDeriv.Set(range); 224 195 225 196 return kTRUE; … … 243 214 244 215 const Byte_t *end = ptr + fHiGainLast - fHiGainFirst; 245 246 216 Int_t range = fHiGainLast - fHiGainFirst + fHiLoLast + 1; 247 217 248 218 Float_t pp; 249 Int_t i = 0;219 // Int_t i = 0; 250 220 251 221 Int_t summ = 0; 252 sum = (Float_t)*ptr++/2.; 253 // 222 // 223 // Take half of the first slice content 224 // 225 Float_t *firstderiv = fHiGainFirstDeriv.GetArray(); 226 Float_t *secondderiv = fHiGainSecondDeriv.GetArray(); 227 sum = (Float_t)*ptr/2.; 228 // 229 // The first slice has already been treated now! 230 // 231 ptr++; // i++; 232 secondderiv++; 233 firstderiv++; 234 // 254 235 // Check for saturation in all other slices 255 236 // … … 258 239 259 240 summ += *ptr; 260 i++; 261 262 pp = fHiGainSecondDeriv[i-1] + 4.; 263 fHiGainSecondDeriv[i] = -1.0/pp; 264 fHiGainFirstDeriv [i] = *(ptr+1) - 2.* *(ptr) + *(ptr-1); 265 fHiGainFirstDeriv [i] = (6.0*fHiGainFirstDeriv[i]-fHiGainFirstDeriv[i-1])/pp; 241 242 // pp = fHiGainSecondDeriv[i-1] + 4.; 243 // fHiGainSecondDeriv[i] = -1.0/pp; 244 // fHiGainFirstDeriv [i] = *(ptr+1) - 2.* *(ptr) + *(ptr-1); 245 // fHiGainFirstDeriv [i] = (6.0*fHiGainFirstDeriv[i]-fHiGainFirstDeriv[i-1])/pp; 246 247 pp = *(secondderiv-1) + 4.; 248 *secondderiv = -1.0/pp; 249 *firstderiv = *(ptr+1) - 2.* *(ptr) + *(ptr-1); 250 *firstderiv = (6.0* *(firstderiv) - *(firstderiv-1))/pp; 266 251 267 252 if (*ptr++ >= fSaturationLimit) 268 253 sat++; 269 } 270 271 if (*ptr++ >= fSaturationLimit) 272 sat++; 273 274 if (fHiLoLast == 0) 275 { 254 255 secondderiv++; 256 firstderiv++; 257 258 // i++; 259 } 260 261 switch (fHiLoLast) 262 { 263 case 0: 264 // Treat the last slice of the high-gain as half slice: 276 265 sum += (Float_t)*ptr/2.; 277 fHiGainSecondDeriv[++i] = 0.; 278 } 279 else 280 { 281 282 // 283 // There are two overlap slices which we have to treat sepatately 284 // 285 // First, the last high-gain slice as center 286 // 266 break; 267 case 1: 268 // Treat the last slice of the high-gain as full slice: 287 269 summ += *ptr; 288 i++; 289 270 pp = *(secondderiv-1) + 4.; 271 *secondderiv = -1.0/pp; 272 *firstderiv = *(logain) - 2.* *(ptr) + *(ptr-1); 273 *firstderiv = (6.0* *(firstderiv) - *(firstderiv-1))/pp; 274 secondderiv++; 275 firstderiv++; 290 276 if (*logain >= fSaturationLimit) 291 277 sat++; 292 293 if (fHiLoLast == 1) 294 sum += (Float_t)*logain/2; 295 else 296 { 297 pp = fHiGainSecondDeriv[i-1] + 4.; 298 fHiGainSecondDeriv[i] = -1.0/pp; 299 fHiGainFirstDeriv [i] = *(logain) - 2.* *(ptr) + *(ptr-1); 300 fHiGainFirstDeriv [i] = (6.0*fHiGainFirstDeriv[i]-fHiGainFirstDeriv[i-1])/pp; 301 302 // 303 // Second, the first low-gain slice as center 304 // 305 summ += *logain; 306 i++; 307 308 pp = fHiGainSecondDeriv[i-1] + 4.; 309 fHiGainSecondDeriv[i] = -1.0/pp; 310 fHiGainFirstDeriv [i] = *(logain+1) - 2.* *(logain) + *(ptr); 311 fHiGainFirstDeriv [i] = (6.0*fHiGainFirstDeriv[i]-fHiGainFirstDeriv[i-1])/pp; 312 313 if (*logain++ >= fSaturationLimit) 314 sat++; 315 316 end = logain + fHiLoLast - 2; 317 318 while (logain<end) 319 { 320 321 summ += *logain; 322 i++; 323 324 pp = fHiGainSecondDeriv[i-1] + 4.; 325 fHiGainSecondDeriv[i] = -1.0/pp; 326 fHiGainFirstDeriv [i] = *(logain+1) - 2.* *(logain) + *(logain-1); 327 fHiGainFirstDeriv [i] = (6.0*fHiGainFirstDeriv[i]-fHiGainFirstDeriv[i-1])/pp; 328 329 if (*logain++ >= fSaturationLimit) 330 sat++; 331 332 } 333 } 334 } 335 336 fHiGainSecondDeriv[range-1] = 0.; 278 // Treat the first slice of the low-gain as half slice: 279 sum += (Float_t)*logain/2; 280 break; 281 case 2: 282 // Treat the last slice of the high-gain as full slice: 283 summ += *ptr; 284 pp = *(secondderiv-1) + 4.; 285 *secondderiv = -1.0/pp; 286 *firstderiv = *(logain) - 2.* *(ptr) + *(ptr-1); 287 *firstderiv = (6.0* *(firstderiv) - *(firstderiv-1))/pp; 288 secondderiv++; 289 firstderiv++; 290 // Treat the last first slice of the low-gain as full slice: 291 summ += *logain; 292 pp = *(secondderiv-1) + 4.; 293 *secondderiv = -1.0/pp; 294 *firstderiv = *(logain+1) - 2.* *(logain) + *(ptr); 295 *firstderiv = (6.0* *(firstderiv) - *(firstderiv-1))/pp; 296 secondderiv++; 297 firstderiv++; 298 if (*logain++ >= fSaturationLimit) 299 sat++; 300 // Treat the second slice of the low-gain as half slice: 301 sum += (Float_t)*logain/2; 302 if (*logain >= fSaturationLimit) 303 sat++; 304 break; 305 default: 306 // Treat the last slice of the high-gain as full slice: 307 summ += *ptr; 308 pp = *(secondderiv-1) + 4.; 309 *secondderiv = -1.0/pp; 310 *firstderiv = *(logain) - 2.* *(ptr) + *(ptr-1); 311 *firstderiv = (6.0* *(firstderiv) - *(firstderiv-1))/pp; 312 secondderiv++; 313 firstderiv++; 314 // Treat the last first slice of the low-gain as full slice: 315 summ += *logain; 316 pp = *(secondderiv-1) + 4.; 317 *secondderiv = -1.0/pp; 318 *firstderiv = *(logain+1) - 2.* *(logain) + *(ptr); 319 *firstderiv = (6.0* *(firstderiv) - *(firstderiv-1))/pp; 320 secondderiv++; 321 firstderiv++; 322 if (*logain++ >= fSaturationLimit) 323 sat++; 324 // Treat the rest of the slices: 325 const Byte_t *end = logain+fHiLoLast; 326 while (logain<end) 327 { 328 summ += *logain; 329 pp = *(secondderiv-1) + 4.; 330 *secondderiv = -1.0/pp; 331 *firstderiv = *(logain+1) - 2.* *(logain) + *(logain-1); 332 *firstderiv = (6.0* *(firstderiv) - *(firstderiv-1))/pp; 333 // pp = fHiGainSecondDeriv[i-1] + 4.; 334 // fHiGainSecondDeriv[i] = -1.0/pp; 335 // fHiGainFirstDeriv [i] = *(logain+1) - 2.* *(logain) + *(logain-1); 336 // fHiGainFirstDeriv [i] = (6.0*fHiGainFirstDeriv[i]-fHiGainFirstDeriv[i-1])/pp; 337 secondderiv++; 338 firstderiv++; 339 if (*logain++ >= fSaturationLimit) 340 sat++; 341 } 342 break; 343 } 344 345 // 346 // Go back to last but one element: 347 // 348 secondderiv--; 349 firstderiv--; 337 350 338 351 for (Int_t k=range-2;k>0;k--) 339 352 { 340 fHiGainSecondDeriv[k] = fHiGainSecondDeriv[k]*fHiGainSecondDeriv[k+1] + fHiGainFirstDeriv[k]; 341 sum += 0.25*fHiGainSecondDeriv[k]; 342 } 343 353 *secondderiv = *secondderiv * *(secondderiv+1) + *firstderiv; 354 sum += 0.25* *secondderiv; 355 secondderiv--; 356 // fHiGainSecondDeriv[k] = fHiGainSecondDeriv[k]*fHiGainSecondDeriv[k+1] + fHiGainFirstDeriv[k]; 357 // sum += 0.25*fHiGainSecondDeriv[k]; 358 } 359 344 360 sum += (Float_t)summ; 345 361 } … … 360 376 361 377 Float_t pp; 362 Int_t i = 0; 363 364 fLoGainSecondDeriv[0] = 0.; 365 fLoGainFirstDeriv[0] = 0.; 378 // Int_t i = 0; 366 379 367 380 Int_t summ = 0; 368 sum = (Float_t)*ptr++/2.; 381 // 382 // Take half of the first slice content 383 // 384 Float_t *firstderiv = fLoGainFirstDeriv.GetArray(); 385 Float_t *secondderiv = fLoGainSecondDeriv.GetArray(); 386 sum = (Float_t)*ptr/2.; 387 // 388 // The first slice has already been treated now! 389 // 390 ptr++; // i++; 391 secondderiv++; 392 firstderiv++; 369 393 // 370 394 // Check for saturation in all other slices … … 374 398 375 399 summ += *ptr; 376 i++; 377 378 pp = fLoGainSecondDeriv[i-1] + 4.; 379 fLoGainSecondDeriv[i] = -1.0/pp; 380 fLoGainFirstDeriv [i] = *(ptr+1) - 2.* *(ptr) + *(ptr-1); 381 fLoGainFirstDeriv [i] = (6.0*fLoGainFirstDeriv[i]-fLoGainFirstDeriv[i-1])/pp; 400 // i++; 401 402 // pp = fLoGainSecondDeriv[i-1] + 4.; 403 // fLoGainSecondDeriv[i] = -1.0/pp; 404 // fLoGainFirstDeriv [i] = *(ptr+1) - 2.* *(ptr) + *(ptr-1); 405 // fLoGainFirstDeriv [i] = (6.0*fLoGainFirstDeriv[i]-fLoGainFirstDeriv[i-1])/pp; 406 407 pp = *(secondderiv-1) + 4.; 408 *secondderiv = -1.0/pp; 409 *firstderiv = *(ptr+1) - 2.* *(ptr) + *(ptr-1); 410 *firstderiv = (6.0* *(firstderiv) - *(firstderiv-1))/pp; 382 411 383 412 if (*ptr++ >= fSaturationLimit) 384 413 sat++; 385 } 386 387 if (*ptr++ >= fSaturationLimit)388 sat++;389 414 415 secondderiv++; 416 firstderiv++; 417 } 418 390 419 sum += (Float_t)*ptr/2.; 391 fLoGainSecondDeriv[++i] = 0.; 392 420 421 // 422 // Go back to last but one element: 423 // 424 secondderiv--; 425 firstderiv--; 426 393 427 for (Int_t k=range-2;k>0;k--) 394 428 { 395 fLoGainSecondDeriv[k] = fLoGainSecondDeriv[k]*fLoGainSecondDeriv[k+1] + fLoGainFirstDeriv[k]; 396 sum += 0.25*fLoGainSecondDeriv[k]; 429 *secondderiv = *secondderiv * *(secondderiv+1) + *firstderiv; 430 sum += 0.25* *secondderiv; 431 secondderiv--; 432 // fLoGainSecondDeriv[k] = fLoGainSecondDeriv[k]*fLoGainSecondDeriv[k+1] + fLoGainFirstDeriv[k]; 433 // sum += 0.25*fLoGainSecondDeriv[k]; 397 434 } 398 435 -
trunk/MagicSoft/Mars/msignal/MExtractFixedWindowSpline.h
r4340 r6107 4 4 #ifndef MARS_MExtractor 5 5 #include "MExtractor.h" 6 #endif 7 8 #ifndef MARS_MArrayF 9 #include "MArrayF.h" 6 10 #endif 7 11 … … 16 20 static const Byte_t fgLoGainLast; // Default for fLoGainLast (now set to: 14) 17 21 18 Float_t *fHiGainFirstDeriv;19 Float_t *fLoGainFirstDeriv;20 Float_t *fHiGainSecondDeriv;21 Float_t *fLoGainSecondDeriv;22 MArrayF fHiGainFirstDeriv; //! Temporary storage 23 MArrayF fLoGainFirstDeriv; //! Temporary storage 24 MArrayF fHiGainSecondDeriv; //! Temporary storage 25 MArrayF fLoGainSecondDeriv; //! Temporary storage 22 26 23 27 Bool_t ReInit (MParList *pList); … … 29 33 30 34 MExtractFixedWindowSpline(const char *name=NULL, const char *title=NULL); 31 ~MExtractFixedWindowSpline() ;35 ~MExtractFixedWindowSpline() {} 32 36 33 37 void SetRange(Byte_t hifirst=0, Byte_t hilast=0, Byte_t lofirst=0, Byte_t lolast=0);
Note:
See TracChangeset
for help on using the changeset viewer.