Changeset 7360 for trunk/MagicSoft/Mars/mbadpixels
- Timestamp:
- 09/22/05 12:06:41 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mbadpixels/MBadPixelsTreat.cc
r7353 r7360 67 67 68 68 #include <TEnv.h> 69 #include <TRandom.h> 69 70 #include <TObjString.h> 70 71 … … 408 409 void MBadPixelsTreat::InterpolateTimes() const 409 410 { 410 Int_t n = fEvt->GetNumPixels(); 411 411 const Double_t tdiffshoweredge = 0.5; 412 413 const Int_t n = fEvt->GetNumPixels(); 412 414 for (int i=0; i<n; i++) 413 415 { 414 // 415 // Check whether pixel with idx i is blind 416 // 416 // Check whether pixel with idx i is bad 417 417 if (!IsPixelBad(i)) 418 418 continue; 419 419 420 // 421 // Get the corresponding geometry and pedestal 422 // 420 // Geometry of bad pixel 423 421 const MGeomPix &gpix = (*fGeomCam)[i]; 424 422 425 const UInt_t n2 = gpix.GetNumNeighbors(); 426 427 Double_t time[n2]; 428 429 Int_t n0 = 0; 430 for (unsigned int j=0; j<n2; j++) 431 { 432 const Double_t t = (*fEvt)[j].GetArrivalTime(); 433 if (t>=0) 434 time[n0++] = t; 435 } 436 437 Int_t p0=-1; 438 Int_t p1=-1; 439 440 Double_t min=FLT_MAX; 441 for (int j=0; j<n0; j++) 442 for (int k=0; k<j; k++) 423 // Number of neighbor pixels 424 const Int_t n2 = gpix.GetNumNeighbors(); 425 426 // Copy the arrival time of all neighboring bad pixels 427 // to a new array for simplicity 428 Double_t time[6]; 429 Int_t cnt = 0; 430 for (Int_t j=0; j<n2; j++) 431 { 432 const Int_t idx = gpix.GetNeighbor(j); 433 if (!IsPixelBad(idx)) 434 time[cnt++] = (*fEvt)[idx].GetArrivalTime(); 435 } 436 437 // if there are too few neighbours, don't interpolate the pixel 438 //if ((cnt < 3 && n2 > 3) || (cnt < 2 && n2 == 3)) 439 if (cnt<fNumMinNeighbors) 440 { 441 (*fEvt)[i].SetPixelUnmapped(); 442 continue; 443 } 444 445 Double_t min = FLT_MAX; // Find minimum arrival time 446 Double_t max = -FLT_MAX; // Find maximum arrival time 447 448 Double_t sum2 = 0; // Sum of arrival times of the pixels 449 Int_t cnt2 = 0; // Number of pixels summed in sum2 450 451 for (Int_t j=0; j<cnt; j++) 452 { 453 const Double_t tm1 = time[j]; // time of one neighbor pixel 454 const Double_t tm2 = time[(j+1)%cnt]; // time of its neighbor pixel 455 456 // Calculate mean arrival time of pixel probably inside the shower 457 if (TMath::Abs(tm1 - tm2)<tdiffshoweredge) 443 458 { 444 const Double_t diff = TMath::Abs(time[j] - time[k]); 445 446 if (diff>=min && diff<250) 447 continue; 448 449 p0 = j; 450 p1 = k; 451 min = diff; 459 sum2 += tm1+tm2; 460 cnt2++; 452 461 } 453 462 454 // FIXME: Request a minimum number of neighbors to take action? 455 if (p0>=0 && p1>=0 && TMath::Abs(time[p0] - time[p1])<250) 456 (*fEvt)[i].SetArrivalTime((time[p0]+time[p1])/2); 463 // Find minimum arrival time 464 if (tm1<min) 465 min = tm1; 466 467 // Find maximum arrival time 468 if (tm1>max) 469 max = tm1; 470 } 471 472 // If less than two nbeighbors belong to a shower the pixel doesn't 473 // belong to the shower, too. Set the arrival time to a uniform 474 // random value, otherwise use the mean value of the pixels belonging 475 // to the shower. 476 if (cnt2<=2) 477 sum2 = gRandom->Uniform(max-min)+min; // FIXME? Set Seed value? 478 else 479 sum2 /= cnt2*2; 480 481 (*fEvt)[i].SetArrivalTime(sum2); 457 482 } 458 483 }
Note:
See TracChangeset
for help on using the changeset viewer.