Changeset 4748 for trunk/MagicSoft/Mars/mbadpixels
- Timestamp:
- 08/26/04 16:40:23 (20 years ago)
- Location:
- trunk/MagicSoft/Mars/mbadpixels
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/MagicSoft/Mars/mbadpixels/MBadPixelsTreat.cc ¶
r4698 r4748 57 57 58 58 #include <TEnv.h> 59 #include <TArrayD.h> 59 60 #include "MArrayD.h" // Used instead of TArrayD because operator[] has no range check 60 61 61 62 #include "MLog.h" … … 76 77 #include "MBadPixelsCam.h" 77 78 79 #include "MArrivalTime.h" 80 78 81 ClassImp(MBadPixelsTreat); 79 82 … … 88 91 // 89 92 MBadPixelsTreat::MBadPixelsTreat(const char *name, const char *title) 90 : fFlags(0), fNumMinNeighbors(3), fNamePedPhotC ontainer("MPedPhotCam")93 : fFlags(0), fNumMinNeighbors(3), fNamePedPhotCam("MPedPhotCam") 91 94 { 92 95 fName = name ? name : gsDefName.Data(); … … 118 121 if (!fBadPixels) 119 122 { 120 *fLog << err << "MBadPixelsCamnot found... aborting." << endl;123 *fLog << err << AddSerialNumber("MBadPixelsCam") << " not found... aborting." << endl; 121 124 return kFALSE; 122 125 } 123 126 124 fPedPhot = (MPedPhotCam*)pList->FindObject(AddSerialNumber(fNamePedPhotContainer), "MPedPhotCam");125 if (!fPedPhot)126 {127 *fLog << err << "MPedPhotCam not found... aborting." << endl;128 return kFALSE;129 }130 131 127 fEvt = (MCerPhotEvt*)pList->FindObject(AddSerialNumber("MCerPhotEvt")); 132 128 if (!fEvt) 133 129 { 134 *fLog << err << "MCerPhotEvtnot found... aborting." << endl;130 *fLog << err << AddSerialNumber("MCerPhotEvt") << " not found... aborting." << endl; 135 131 return kFALSE; 136 132 } … … 139 135 if (!fGeomCam && TESTBIT(fFlags, kUseInterpolation)) 140 136 { 141 *fLog << err << "MGeomCam not found... can't use interpolation." << endl;137 *fLog << err << AddSerialNumber("MGeomCam") << " not found - can't use interpolation... abort." << endl; 142 138 return kFALSE; 139 } 140 141 fPedPhot = 0; 142 if (IsProcessPedestal()) 143 { 144 fPedPhot = (MPedPhotCam*)pList->FindObject(AddSerialNumber(fNamePedPhotCam), "MPedPhotCam"); 145 if (!fPedPhot) 146 { 147 *fLog << err << AddSerialNumber("MPedPhotCam") << " not found... aborting." << endl; 148 return kFALSE; 149 } 150 *fLog << inf << "Processing Pedestals..." << endl; 151 } 152 153 fTimes = 0; 154 if (IsProcessTimes()) 155 { 156 fTimes = (MArrivalTime*)pList->FindObject(AddSerialNumber("MArrivalTime")); 157 if (!fTimes) 158 { 159 *fLog << err << AddSerialNumber("MArrivalTime") << " not found... aborting." << endl; 160 return kFALSE; 161 } 162 *fLog << inf << "Processing Times..." << endl; 143 163 } 144 164 … … 160 180 // Create arrays (FIXME: Check if its possible to create it only once) 161 181 // 162 TArrayD nphot(entries);163 TArrayD perr(entries);182 MArrayD nphot(entries); 183 MArrayD perr(entries); 164 184 165 185 // … … 269 289 270 290 // Create arrays (FIXME: Check if its possible to create it only once) 271 TArrayD ped(entries);272 TArrayD rms(entries);291 MArrayD ped(entries); 292 MArrayD rms(entries); 273 293 274 294 // … … 354 374 355 375 (*fPedPhot)[i].Set(ped[i], rms[i]); 376 } 377 } 378 379 // -------------------------------------------------------------------------- 380 // 381 void MBadPixelsTreat::InterpolateTimes() const 382 { 383 Int_t n = fTimes->GetSize(); 384 385 for (int i=0; i<n; i++) 386 { 387 // 388 // Check whether pixel with idx i is blind 389 // 390 if (!IsPixelBad(i)) 391 continue; 392 393 // 394 // Get the corresponding geometry and pedestal 395 // 396 const MGeomPix &gpix = (*fGeomCam)[i]; 397 398 const Int_t n0 = gpix.GetNumNeighbors(); 399 400 MArrayD time(6); 401 for (int j=0; j<n0; j++) 402 time[j] = (*fTimes)[gpix.GetNeighbor(j)]; 403 404 Int_t p0=0; 405 Int_t p1=0; 406 407 Double_t min=FLT_MAX; 408 for (int j=0; j<n0; j++) 409 for (int k=1; k<j+1; k++) 410 { 411 const Double_t diff = TMath::Abs(time[n0-k] - time[n0-k-j]); 412 413 if (diff>=min && diff<250) 414 continue; 415 416 p0 = n0-k; 417 p1 = n0-k-j; 418 min = diff; 419 } 420 421 if (TMath::Abs(time[p0] - time[p1])<250) 422 fTimes->SetTime(i, (time[p0]+time[p1])/2); 356 423 } 357 424 } … … 557 624 if (TESTBIT(fFlags, kProcessPedestal)) 558 625 InterpolatePedestals(); 626 if (TESTBIT(fFlags, kProcessTimes)) 627 InterpolateTimes(); 559 628 } 560 629 else … … 582 651 if (TESTBIT(fFlags, kProcessPedestal)) 583 652 out << " " << GetUniqueName() << ".SetProcessPedestal();" << endl; 653 if (TESTBIT(fFlags, kProcessTimes)) 654 out << " " << GetUniqueName() << ".SetProcessTimes();" << endl; 584 655 if (TESTBIT(fFlags, kHardTreatment)) 585 656 out << " " << GetUniqueName() << ".SetHardTreatment();" << endl; … … 620 691 SetProcessPedestal(GetEnvValue(env, prefix, "ProcessPedestal", IsProcessPedestal())); 621 692 } 693 if (IsEnvDefined(env, prefix, "ProcessTimes", print)) 694 { 695 rc = kTRUE; 696 SetProcessTimes(GetEnvValue(env, prefix, "ProcessTimes", IsProcessTimes())); 697 } 622 698 if (IsEnvDefined(env, prefix, "NumMinNeighbors", print)) 623 699 { -
TabularUnified trunk/MagicSoft/Mars/mbadpixels/MBadPixelsTreat.h ¶
r4698 r4748 9 9 class MCerPhotEvt; 10 10 class MPedPhotCam; 11 class MArrivalTime; 11 12 class MBadPixelsCam; 12 13 … … 17 18 MPedPhotCam *fPedPhot; //! 18 19 MCerPhotEvt *fEvt; //! 20 MArrivalTime *fTimes; //! 19 21 MBadPixelsCam *fBadPixels; //! 20 22 21 23 Byte_t fFlags; // flag for the method which is used 22 24 Byte_t fNumMinNeighbors; 23 TString fNamePedPhotContainer; // name of the 'MPedPhotCam' container 25 26 TString fNamePedPhotCam; // name of the 'MPedPhotCam' container 24 27 25 28 enum … … 28 31 kUseCentralPixel = 2, 29 32 kProcessPedestal = 3, 30 kHardTreatment = 4 33 kProcessTimes = 4, 34 kHardTreatment = 5 31 35 }; 32 36 33 37 static Double_t Pow2(Double_t x) { return x*x; } 34 38 39 void InterpolateTimes() const; 35 40 void InterpolateSignal() const; 36 41 void InterpolatePedestals() const; … … 60 65 b ? SETBIT(fFlags, kProcessPedestal) : CLRBIT(fFlags, kProcessPedestal); 61 66 } 67 void SetProcessTimes(Bool_t b=kTRUE) 68 { 69 b ? SETBIT(fFlags, kProcessTimes) : CLRBIT(fFlags, kProcessTimes); 70 } 62 71 void SetHardTreatment(Bool_t b=kTRUE) 63 72 { … … 67 76 Bool_t IsHardTreatment() const { return TESTBIT(fFlags, kHardTreatment); } 68 77 Bool_t IsProcessPedestal() const { return TESTBIT(fFlags, kProcessPedestal); } 78 Bool_t IsProcessTimes() const { return TESTBIT(fFlags, kProcessTimes); } 69 79 Bool_t IsUseCentralPixel() const { return TESTBIT(fFlags, kUseCentralPixel); } 70 80 Bool_t IsUseInterpolation() const { return TESTBIT(fFlags, kUseInterpolation); } 71 81 72 82 void SetNumMinNeighbors(Byte_t num) { fNumMinNeighbors=num; } 73 void SetNamePedPhotContainer(const char *name) { fNamePedPhotContainer = name; } 74 83 void SetNamePedPhotCam(const char *name) { fNamePedPhotCam = name; } 75 84 76 85 ClassDef(MBadPixelsTreat, 1) // Task to treat bad pixels (interpolation, unmapping)
Note:
See TracChangeset
for help on using the changeset viewer.