Changeset 3183 for trunk/MagicSoft/Mars/mimage
- Timestamp:
- 02/16/04 11:18:25 (21 years ago)
- Location:
- trunk/MagicSoft/Mars/mimage
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mimage/MHillas.cc
r2624 r3183 188 188 Int_t MHillas::Calc(const MGeomCam &geom, const MCerPhotEvt &evt) 189 189 { 190 const UInt_t npixevt = evt.GetNumPixels(); 191 192 // 193 // sanity check 194 // 195 if (npixevt < 3) 190 // 191 // sanity check 1 192 // 193 if (evt.GetNumPixels()<3) 196 194 return 1; 197 195 … … 209 207 fSize = 0; 210 208 211 Int_t numused = 0; 212 213 for (UInt_t i=0; i<npixevt; i++) 209 MCerPhotPix *pix = 0; 210 211 TIter Next(evt); 212 UInt_t numused = 0; 213 while ((pix=(MCerPhotPix*)Next())) 214 214 { 215 const MCerPhotPix &pix = evt[i]; 216 217 if (!pix.IsPixelUsed()) 218 continue; 219 220 const MGeomPix &gpix = geom[pix.GetPixId()]; 221 222 const Float_t nphot = pix.GetNumPhotons(); 215 const MGeomPix &gpix = geom[pix->GetPixId()]; 216 217 const Float_t nphot = pix->GetNumPhotons(); 223 218 224 219 fSize += nphot; // [counter] … … 230 225 231 226 // 232 // sanity check s227 // sanity check 2 233 228 // 234 229 if (fSize==0) … … 238 233 fMeanY /= fSize; // [mm] 239 234 235 // 236 // sanity check 3 237 // 240 238 if (numused<3) 241 239 return 3; … … 254 252 Double_t corryy=0; // [m^2] 255 253 256 for (UInt_t i=0; i<npixevt; i++) 254 Next.Reset(); 255 while ((pix=(MCerPhotPix*)Next())) 257 256 { 258 const MCerPhotPix &pix = evt[i]; 259 260 if (!pix.IsPixelUsed()) 261 continue; 262 263 const MGeomPix &gpix = geom[pix.GetPixId()]; 257 const MGeomPix &gpix = geom[pix->GetPixId()]; 264 258 265 259 const Float_t dx = gpix.GetX() - fMeanX; // [mm] 266 260 const Float_t dy = gpix.GetY() - fMeanY; // [mm] 267 261 268 const Float_t nphot = pix .GetNumPhotons();// [#phot]262 const Float_t nphot = pix->GetNumPhotons(); // [#phot] 269 263 270 264 corrxx += nphot * dx*dx; // [mm^2] … … 297 291 const Double_t d0 = corryy - corrxx; 298 292 const Double_t d1 = corrxy*2; 299 const Double_t d2 = d0 + sqrt(d0*d0 + d1*d1);293 const Double_t d2 = d0 + TMath::Sqrt(d0*d0 + d1*d1); 300 294 const Double_t tand = d2 / d1; 301 295 const Double_t tand2 = tand*tand; 302 296 303 fDelta = atan(tand);297 fDelta = TMath::ATan(tand); 304 298 305 299 const Double_t s2 = tand2+1; 306 const Double_t s = sqrt(s2);300 const Double_t s = TMath::Sqrt(s2); 307 301 308 302 fCosDelta = 1.0/s; // need these in derived classes 309 303 fSinDelta = tand/s; // like MHillasExt 310 304 311 Double_t axis1 = (tand2*corryy + d2 + corrxx)/s2/fSize;312 Double_t axis2 = (tand2*corrxx - d2 + corryy)/s2/fSize;305 const Double_t axis1 = (tand2*corryy + d2 + corrxx)/s2/fSize; 306 const Double_t axis2 = (tand2*corrxx - d2 + corryy)/s2/fSize; 313 307 314 308 // … … 320 314 // very small numbers can get negative by rounding 321 315 // 322 fLength = axis1<0 ? 0 : sqrt(axis1); // [mm]323 fWidth = axis2<0 ? 0 : sqrt(axis2); // [mm]316 fLength = axis1<0 ? 0 : TMath::Sqrt(axis1); // [mm] 317 fWidth = axis2<0 ? 0 : TMath::Sqrt(axis2); // [mm] 324 318 325 319 SetReadyToSave(); -
trunk/MagicSoft/Mars/mimage/MImgCleanStd.cc
r2781 r3183 329 329 void MImgCleanStd::CleanStep1() 330 330 { 331 const Int_t entries = fEvt->GetNumPixels();332 331 const TArrayD &data = fData->GetData(); 333 332 … … 335 334 // check the number of all pixels against the noise level and 336 335 // set them to 'unused' state if necessary 337 // 338 for (Int_t i=0; i<entries; i++ )339 { 340 MCerPhotPix &pix = (*fEvt)[i];341 342 if (data[pix.GetPixId()] <= fCleanLvl1)343 pix.SetPixelUnused();344 }336 // 337 MCerPhotPix *pix; 338 339 // Loop over all pixels 340 MCerPhotEvtIter Next(fEvt, kFALSE); 341 while ((pix=static_cast<MCerPhotPix*>(Next()))) 342 if (data[pix->GetPixId()] <= fCleanLvl1) 343 pix->SetPixelUnused(); 345 344 } 346 345 … … 351 350 // neighbors). 352 351 // 353 // Takes the maximum pixel id from CleanStep1 as an argument354 //355 352 void MImgCleanStd::CleanStep2() 356 353 { 357 const Int_t entries = fEvt->GetNumPixels(); 358 359 // 360 // In the worst case we have to loop 6 times 577 times, to 361 // catch the behaviour of all next neighbors. Here we can gain 362 // much by using an array instead of checking through all pixels 363 // (MCerPhotEvt::IsPixelUsed) all the time. 364 // 365 // We allocate the array ourself because the TArrays always do 366 // range check which slows down the access to the array 367 // by 25-50% 368 // 369 Byte_t *ispixused = new Byte_t[fCam->GetNumPixels()]; 370 memset(ispixused, 0, sizeof(Byte_t)*fCam->GetNumPixels()); 371 372 for (Int_t i=0; i<entries; i++) 373 { 374 const MCerPhotPix &pix = (*fEvt)[i]; 375 ispixused[pix.GetPixId()] = pix.IsPixelUsed() ? 1 : 0 ; 376 } 377 378 for (Int_t i=0; i<entries; i++) 379 { 380 // get entry i from list 381 MCerPhotPix &pix = (*fEvt)[i]; 382 383 // get pixel id of this entry 384 const Int_t idx = pix.GetPixId(); 385 386 // check if pixel is in use, if not goto next pixel in list 387 if (ispixused[idx] == 0) 388 continue; 354 MCerPhotPix *pix; 355 356 // Loop over used pixels only 357 TIter Next(*fEvt); 358 while ((pix=static_cast<MCerPhotPix*>(Next()))) 359 { 360 // get pixel id of this entry 361 const Int_t idx = pix->GetPixId(); 389 362 390 363 // check for 'used' neighbors of this pixel … … 400 373 401 374 // when you find an used neighbor, break the loop 402 if ( ispixused[idx2] == 1)375 if (fEvt->IsPixelUsed(idx2)) 403 376 { 404 377 hasNeighbor = kTRUE; … … 408 381 409 382 if (hasNeighbor == kFALSE) 410 pix.SetPixelUnused(); 411 } 412 413 delete ispixused; 383 pix->SetPixelUnused(); 384 } 414 385 415 386 // 416 387 // now we declare all pixels that survive as CorePixels 417 388 // 418 for (Int_t i=0; i<entries; i++) 419 { 420 MCerPhotPix &pix = (*fEvt)[i]; 421 422 if (pix.IsPixelUsed()) 423 pix.SetPixelCore(); 424 } 389 Next.Reset(); 390 while ((pix=static_cast<MCerPhotPix*>(Next()))) 391 pix->SetPixelCore(); 425 392 } 426 393 … … 440 407 const Int_t idx2 = gpix.GetNeighbor(j); 441 408 442 if (!fEvt-> GetPixById(idx2) || !fEvt->IsPixelCore(idx2))409 if (!fEvt->IsPixelCore(idx2)) 443 410 continue; 444 411 … … 459 426 void MImgCleanStd::CleanStep4(UShort_t r, MCerPhotPix &pix) 460 427 { 461 // Skip events that have already a defined status; 462 if( pix.GetRing()!= 0) 463 return; 428 // 429 // Skip events that have already a defined status; 430 // 431 if (pix.GetRing() != 0) 432 return; 433 464 434 // 465 435 // check if the pixel's next neighbor is a used pixel. … … 478 448 479 449 MCerPhotPix *npix = fEvt->GetPixById(idx2); 480 481 450 if (!npix || !npix->IsPixelUsed() || npix->GetRing()>r-1 ) 482 451 continue; 483 452 484 453 pix.SetRing(r); … … 495 464 void MImgCleanStd::CleanStep3() 496 465 { 497 const Int_t entries = fEvt->GetNumPixels();498 466 const TArrayD &data = fData->GetData(); 499 467 500 468 for (UShort_t r=1; r<fCleanRings+1; r++) 501 469 { 502 for (Int_t i=0; i<entries; i++) 470 MCerPhotPix *pix; 471 472 // Loop over all pixels 473 MCerPhotEvtIter NextAll(fEvt, kFALSE); 474 while ((pix=static_cast<MCerPhotPix*>(NextAll()))) 503 475 { 504 //505 // get pixel as entry il from list506 //507 MCerPhotPix &pix = (*fEvt)[i];508 509 476 // 510 477 // if pixel is a core pixel go to the next pixel 511 478 // 512 if (pix .IsPixelCore())479 if (pix->IsPixelCore()) 513 480 continue; 514 481 515 if (data[pix .GetPixId()] <= fCleanLvl2)482 if (data[pix->GetPixId()] <= fCleanLvl2) 516 483 continue; 517 484 518 485 if (r==1) 519 CleanStep3b( pix);486 CleanStep3b(*pix); 520 487 else 521 CleanStep4(r, pix);488 CleanStep4(r, *pix); 522 489 } 523 490 } -
trunk/MagicSoft/Mars/mimage/MNewImagePar.cc
r2849 r3183 18 18 ! Author(s): Wolfgang Wittek 03/2003 <mailto:wittek@mppmu.mpg.de> 19 19 ! 20 ! Copyright: MAGIC Software Development, 2000-200 320 ! Copyright: MAGIC Software Development, 2000-2004 21 21 ! 22 22 ! … … 31 31 // fLeakage1 ratio: (photons in most outer ring of pixels) over fSize 32 32 // fLeakage2 ratio: (photons in the 2 outer rings of pixels) over fSize 33 // fNumSaturatedPixels: number of pixels in which at least one slice 34 // of the low gain FADC was saturated. 33 35 // 34 36 // Version 2: 35 // Added fNumSaturatedPixels: number of pixels in which at least one slice36 // of the low gain FADC was saturated.37 // ---------- 38 // - added fNumSaturatedPixels 37 39 // 38 40 ///////////////////////////////////////////////////////////////////////////// … … 106 108 const MCerPhotPix &pix = evt[i]; 107 109 110 // count saturated pixels 108 111 if (pix.IsPixelSaturated()) 109 112 fNumSaturatedPixels++; 110 113 114 // skip unused pixels 111 115 if (!pix.IsPixelUsed()) 112 116 continue; 117 118 // count used and core pixels 119 if (pix.IsPixelCore()) 120 fNumCorePixels++; 121 122 // count used pixels 123 fNumUsedPixels++; 113 124 114 125 const Int_t pixid = pix.GetPixId(); … … 125 136 if (gpix.IsInOuterRing()) 126 137 edgepix2 += nphot; 127 128 //129 // count used and core pixels130 //131 if (pix.IsPixelCore())132 fNumCorePixels++;133 134 fNumUsedPixels++;135 138 136 139 // … … 172 175 *fLog << " - Used Pixels [#] = " << fNumUsedPixels << " Pixels" << endl; 173 176 *fLog << " - Core Pixels [#] = " << fNumCorePixels << " Pixels" << endl; 177 *fLog << " - Sat. Pixels [#] = " << fNumSaturatedPixels << " Pixels" << endl; 174 178 } -
trunk/MagicSoft/Mars/mimage/MNewImagePar.h
r2849 r3183 13 13 { 14 14 private: 15 Float_t fLeakage1; // (photons in most outer ring of pixels) over fSize16 Float_t fLeakage2; // (photons in the 2 outer rings of pixels) over fSize15 Float_t fLeakage1; // (photons in most outer ring of pixels) over fSize 16 Float_t fLeakage2; // (photons in the 2 outer rings of pixels) over fSize 17 17 18 Float_t fConc; // [ratio] concentration ratio: sum of the two highest pixels / fSize19 Float_t fConc1; // [ratio] concentration ratio: sum of the highest pixel / fSize18 Float_t fConc; // [ratio] concentration ratio: sum of the two highest pixels / fSize 19 Float_t fConc1; // [ratio] concentration ratio: sum of the highest pixel / fSize 20 20 21 Short_t fNumUsedPixels; // Number of pixels which survived the image cleaning 22 Short_t fNumCorePixels; // number of core pixels 23 24 Short_t fNumSaturatedPixels; // number of saturated pixels 21 Short_t fNumUsedPixels; // Number of pixels which survived the image cleaning 22 Short_t fNumCorePixels; // number of core pixels 23 Short_t fNumSaturatedPixels; // number of pixels with saturating lo-gains 25 24 26 25 public: … … 29 28 void Reset(); 30 29 31 Float_t GetLeakage1() const 32 Float_t GetLeakage2() const 30 Float_t GetLeakage1() const { return fLeakage1; } 31 Float_t GetLeakage2() const { return fLeakage2; } 33 32 34 Float_t GetConc() const { return fConc;}35 Float_t GetConc1() const 33 Float_t GetConc() const { return fConc; } 34 Float_t GetConc1() const { return fConc1; } 36 35 37 Int_t GetNumUsedPixels() const { return fNumUsedPixels; }38 Int_t GetNumCorePixels() const { return fNumCorePixels; }36 Short_t GetNumUsedPixels() const { return fNumUsedPixels; } 37 Short_t GetNumCorePixels() const { return fNumCorePixels; } 39 38 40 39 Short_t GetNumSaturatedPixels() const { return fNumSaturatedPixels; } … … 49 48 50 49 #endif 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
Note:
See TracChangeset
for help on using the changeset viewer.