- Timestamp:
- 10/30/03 17:09:40 (21 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r2442 r2445 1 1 -*-*- END OF LINE -*-*- 2 3 2003/10/30: Thomas Bretz 4 5 * manalysis/MCerPhotEvt.[h,cc]: 6 - fixed a bug in the new Lut-stuff. Sometimes pixels where 7 considered existing, because there where no mark for 8 empty entries in the Lut. 9 - all loops ignored pixel with index 0 and used it as reference 10 pixel - this is wrong, because pixel 0 must not exist at all. 11 Now all loops are starting with pixel 0. 12 13 * mimage/MImgCleanStd.[h,cc]: 14 - renamed various local variables from 'id' to 'idx' 15 - in clean step 4 we assumed that a pixel with idx2 is existing 16 - this is a dangerous assumption. It is checked now. 17 18 2 19 3 20 2003/10/29: Thomas Bretz -
trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.cc
r2416 r2445 124 124 Bool_t MCerPhotEvt::IsPixelExisting(Int_t id) const 125 125 { 126 const MCerPhotPix *pix = GetPixById(id); 127 return pix ? kTRUE : kFALSE; 126 return GetPixById(id) ? kTRUE : kFALSE; 128 127 } 129 128 … … 163 162 Float_t minval = FLT_MAX; 164 163 165 for (UInt_t i= 1; i<fNumPixels; i++)164 for (UInt_t i=0; i<fNumPixels; i++) 166 165 { 167 166 const MCerPhotPix &pix = (*this)[i]; … … 170 169 171 170 const UInt_t id = pix.GetPixId(); 172 if (id >=n)171 if (id<0 || id>=n) 173 172 continue; 174 173 … … 200 199 Float_t maxval = -FLT_MAX; 201 200 202 for (UInt_t i= 1; i<fNumPixels; i++)201 for (UInt_t i=0; i<fNumPixels; i++) 203 202 { 204 203 const MCerPhotPix &pix = (*this)[i]; … … 207 206 208 207 const UInt_t id = pix.GetPixId(); 209 if (id >=n)208 if (id<0 || id>=n) 210 209 continue; 211 210 … … 229 228 return -5.; 230 229 231 Float_t minval = (*this)[0].GetNumPhotons()/(*this)[0].GetErrorPhot();232 233 for (UInt_t i= 1; i<fNumPixels; i++)230 Float_t minval = FLT_MAX; 231 232 for (UInt_t i=0; i<fNumPixels; i++) 234 233 { 235 234 const MCerPhotPix &pix = (*this)[i]; … … 259 258 Float_t maxval = -FLT_MAX; 260 259 261 for (UInt_t i= 1; i<fNumPixels; i++)260 for (UInt_t i=0; i<fNumPixels; i++) 262 261 { 263 262 const MCerPhotPix &pix = (*this)[i]; … … 289 288 Float_t minval = FLT_MAX; 290 289 291 for (UInt_t i= 1; i<fNumPixels; i++)290 for (UInt_t i=0; i<fNumPixels; i++) 292 291 { 293 292 const MCerPhotPix &pix = (*this)[i]; … … 319 318 Float_t maxval = -FLT_MAX; 320 319 321 for (UInt_t i= 1; i<fNumPixels; i++)320 for (UInt_t i=0; i<fNumPixels; i++) 322 321 { 323 322 const MCerPhotPix &pix = (*this)[i]; … … 356 355 // try to search in the array. 357 356 // 358 MCerPhotPix *MCerPhotEvt::GetPixById(int idx) const 359 { 357 MCerPhotPix *MCerPhotEvt::GetPixById(Int_t idx) const 358 { 359 if (idx<0) 360 return 0; 361 360 362 if (fLut.GetSize()>0) 361 return idx>=0 && idx<fLut.GetSize() ? (MCerPhotPix*)(fPixels->UncheckedAt(fLut[idx])) : 0; 363 { 364 if (idx>=fLut.GetSize()) 365 return 0; 366 367 return fLut[idx]<0 ? 0 : (MCerPhotPix*)(fPixels->UncheckedAt(fLut[idx])); 368 } 362 369 363 370 TIter Next(fPixels); -
trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.h
r2416 r2445 39 39 // 40 40 if (idx>=fLut.GetSize()) 41 { 42 const Int_t n = fLut.GetSize(); 41 43 fLut.Set(idx+1); 44 for (int i=n; i<idx; i++) 45 fLut[i] = -1; 46 } 42 47 43 48 fLut[idx] = fNumPixels; … … 66 71 void RemoveUnusedPixels(); 67 72 68 MCerPhotPix *GetPixById( int idx) const;// { return idx>=0 && idx<fLut.GetSize() ? (MCerPhotPix*)(fPixels->UncheckedAt(fLut[idx])) : 0; } // Return a pointer to the pixel with the requested id. NULL if it doesn't exist.73 MCerPhotPix *GetPixById(Int_t idx) const; 69 74 70 75 void Reset(); -
trunk/MagicSoft/Mars/mimage/MImgCleanStd.cc
r2239 r2445 329 329 // set them to 'unused' state if necessary 330 330 // 331 331 332 for (Int_t i=0; i<entries; i++ ) 332 333 { … … 373 374 MCerPhotPix &pix = (*fEvt)[i]; 374 375 375 const Int_t id = pix.GetPixId();376 const Int_t idx = pix.GetPixId(); 376 377 377 378 const Float_t entry = pix.GetNumPhotons(); 378 const Double_t ratio = fCam->GetPixRatio(id );379 const Double_t ratio = fCam->GetPixRatio(idx); 379 380 380 381 // COBB: '<=' to skip entry=noise=0 … … 422 423 // (MCerPhotEvt::IsPixelUsed) all the time. 423 424 // 425 // We allocate the array ourself because the TArrays always do 426 // range check which slows down the access to the array 427 // by 25-50% 428 // 424 429 Byte_t *ispixused = new Byte_t[fCam->GetNumPixels()]; 430 memset(ispixused, 0, sizeof(Byte_t)*fCam->GetNumPixels()); 425 431 426 432 for (Int_t i=0; i<entries; i++) … … 428 434 const MCerPhotPix &pix = (*fEvt)[i]; 429 435 ispixused[pix.GetPixId()] = pix.IsPixelUsed() ? 1 : 0 ; 430 436 } 431 437 432 438 for (Int_t i=0; i<entries; i++) … … 436 442 437 443 // get pixel id of this entry 438 const Int_t id = pix.GetPixId();444 const Int_t idx = pix.GetPixId(); 439 445 440 446 // check if pixel is in use, if not goto next pixel in list 441 if (ispixused[id ] == 0)447 if (ispixused[idx] == 0) 442 448 continue; 443 449 444 450 // check for 'used' neighbors of this pixel 445 const MGeomPix &gpix = (*fCam)[id ];451 const MGeomPix &gpix = (*fCam)[idx]; 446 452 const Int_t nnmax = gpix.GetNumNeighbors(); 447 453 … … 451 457 for (Int_t j=0; j<nnmax; j++) 452 458 { 453 const Int_t id 2 = gpix.GetNeighbor(j);459 const Int_t idx2 = gpix.GetNeighbor(j); 454 460 455 461 // when you find an used neighbor, break the loop 456 if (ispixused[id 2] == 1)462 if (ispixused[idx2] == 1) 457 463 { 458 459 464 hasNeighbor = kTRUE; 465 break; 460 466 } 461 467 } … … 478 484 } 479 485 } 486 480 487 481 488 // -------------------------------------------------------------------------- … … 518 525 // get pixel id of this entry 519 526 // 520 const Int_t id = pix.GetPixId();527 const Int_t idx = pix.GetPixId(); 521 528 522 529 // … … 524 531 // 525 532 const Float_t entry = pix.GetNumPhotons(); 526 const Double_t ratio = fCam->GetPixRatio(id );533 const Double_t ratio = fCam->GetPixRatio(idx); 527 534 528 535 return (entry * ratio <= fCleanLvl2 * fInnerNoise); … … 531 538 void MImgCleanStd::CleanStep3b(MCerPhotPix &pix) 532 539 { 533 const Int_t id = pix.GetPixId();540 const Int_t idx = pix.GetPixId(); 534 541 535 542 // … … 537 544 // if it is a core pixel set pixel state to: used. 538 545 // 539 MGeomPix &gpix = (*fCam)[id ];546 MGeomPix &gpix = (*fCam)[idx]; 540 547 const Int_t nnmax = gpix.GetNumNeighbors(); 541 548 542 549 for (Int_t j=0; j<nnmax; j++) 543 550 { 544 const Int_t id 2 = gpix.GetNeighbor(j);545 546 if (!fEvt->GetPixById(id 2) || !fEvt->IsPixelCore(id2))547 551 const Int_t idx2 = gpix.GetNeighbor(j); 552 553 if (!fEvt->GetPixById(idx2) || !fEvt->IsPixelCore(idx2)) 554 continue; 548 555 549 556 pix.SetPixelUsed(); 550 557 break; 551 558 } 552 559 } … … 568 575 // and tell to which ring it belongs to. 569 576 // 570 const Int_t id = pix.GetPixId();571 MGeomPix &gpix = (*fCam)[id ];577 const Int_t idx = pix.GetPixId(); 578 MGeomPix &gpix = (*fCam)[idx]; 572 579 573 580 const Int_t nnmax = gpix.GetNumNeighbors(); … … 575 582 for (Int_t j=0; j<nnmax; j++) 576 583 { 577 const Int_t id2 = gpix.GetNeighbor(j); 578 579 MCerPhotPix &npix = *fEvt->GetPixById(id2); 580 581 // FIXME! 582 // Needed check to read CT1 data without having a Segmentation fault 583 if (!fEvt->GetPixById(id2)) 584 continue; 585 586 if (!npix.IsPixelUsed() || npix.GetRing()>r-1 ) 584 const Int_t idx2 = gpix.GetNeighbor(j); 585 586 MCerPhotPix *npix = fEvt->GetPixById(idx2); 587 588 if (!npix || !npix->IsPixelUsed() || npix->GetRing()>r-1 ) 587 589 continue; 588 590
Note:
See TracChangeset
for help on using the changeset viewer.