Changeset 3476 for trunk/MagicSoft/Mars/mbadpixels
- Timestamp:
- 03/11/04 16:32:11 (21 years ago)
- Location:
- trunk/MagicSoft/Mars/mbadpixels
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mbadpixels/MBadPixelsCalc.cc
r3465 r3476 56 56 #include "MBadPixelsCalc.h" 57 57 58 #include <TArrayD.h> 59 58 60 #include "MLog.h" 59 61 #include "MLogManip.h" … … 62 64 63 65 #include "MGeomCam.h" 66 #include "MGeomPix.h" 67 64 68 #include "MSigmabar.h" 65 69 … … 150 154 151 155 if (pixPedRms*nratio > fPedestalLevel * meanPedRMS || pixPedRms == 0) 152 (*fBadPixels)[i].SetUnsuitableEvt(); 153 } 154 } 156 (*fBadPixels)[i].SetUnsuitable(MBadPixelsPix::kUnsuitableEvt); 157 } 158 } 159 160 // -------------------------------------------------------------------------- 161 // Check the pedestal Rms of the pixels: compute with 2 iterations the mean 162 // for inner and outer pixels. Set as blind the pixels with too small or 163 // too high pedestal Rms with respect to the mean. 164 // 165 Bool_t MBadPixelsCalc::CheckPedestalRms() const 166 { 167 const Int_t entries = fPedPhotCam->GetSize(); 168 169 const Int_t na = fGeomCam->GetNumAreas(); 170 171 TArrayD meanrms(na); 172 TArrayI npix(na); 173 174 for (Int_t i=0; i<entries; i++) 175 { 176 const Double_t rms = (*fPedPhotCam)[i].GetRms(); 177 178 if (rms<=0 || rms>=200*fGeomCam->GetPixRatioSqrt(i)) 179 continue; 180 181 const Byte_t aidx = (*fGeomCam)[i].GetAidx(); 182 183 meanrms[aidx] += rms; 184 npix[aidx]++; 185 } 186 187 //if no pixel has a minimum signal, return 188 for (int i=0; i<na; i++) 189 { 190 if (npix[i]==0 || meanrms[i]==0) 191 { 192 //fErrors[1]++; //no valid Pedestals Rms 193 return kFALSE; 194 } 195 196 meanrms[i] /= npix[i]; 197 npix[i]=0; 198 } 199 200 TArrayD meanrms2(na); 201 for (Int_t i=0; i<entries; i++) 202 { 203 const Double_t rms = (*fPedPhotCam)[i].GetRms(); 204 const Byte_t aidx = (*fGeomCam)[i].GetAidx(); 205 206 //Calculate the corrected means: 207 208 if (rms<=0.5*meanrms[aidx] || rms>=1.5*meanrms[aidx]) 209 continue; 210 211 meanrms2[aidx] += rms; 212 npix[aidx]++; 213 } 214 215 //if no pixel has a minimum signal, return 216 for (int i=0; i<na; i++) 217 { 218 if (npix[i]==0 || meanrms2[i]==0) 219 { 220 //fErrors[1]++; //no valid Pedestals Rms 221 return kFALSE; 222 } 223 224 meanrms2[i] /= npix[i]; 225 } 226 227 Int_t bads = 0; 228 229 //Blind the Bad Pixels 230 for (Int_t i=0; i<entries; i++) 231 { 232 const Double_t rms = (*fPedPhotCam)[i].GetRms(); 233 const Byte_t aidx = (*fGeomCam)[i].GetAidx(); 234 235 if (rms>meanrms2[aidx]/3 && rms<=meanrms2[aidx]*3) 236 continue; 237 238 (*fBadPixels)[i].SetUnsuitable(MBadPixelsPix::kUnsuitableEvt); 239 bads++; 240 } 241 242 // Check if the number of pixels to blind is > 60% of total number of pixels 243 // 244 if (bads>0.6*entries) 245 { 246 //fErrors[2]++; 247 return kFALSE; 248 } 249 250 return kTRUE; 251 } 252 253 155 254 // -------------------------------------------------------------------------- 156 255 // … … 159 258 { 160 259 if (fPedestalLevel>0) 161 CheckPedestalR MS();260 CheckPedestalRms(); 162 261 163 262 return kTRUE; -
trunk/MagicSoft/Mars/mbadpixels/MBadPixelsCalc.h
r3068 r3476 23 23 24 24 void CheckPedestalRMS() const; 25 Bool_t CheckPedestalRms() const; 25 26 26 27 Int_t PreProcess(MParList *pList); -
trunk/MagicSoft/Mars/mbadpixels/MBadPixelsCam.cc
r3473 r3476 280 280 InitSize(idx+1); 281 281 282 (*this)[idx].SetUnsuitable Run();282 (*this)[idx].SetUnsuitable(MBadPixelsPix::kUnsuitableRun); 283 283 } 284 284 } … … 295 295 296 296 for (int i=0; i<GetSize(); i++) 297 if ((*this)[i].IsUnsuitable Run())297 if ((*this)[i].IsUnsuitable(MBadPixelsPix::kUnsuitableRun)) 298 298 fout << " " << i; 299 299 -
trunk/MagicSoft/Mars/mbadpixels/MBadPixelsPix.h
r3475 r3476 52 52 53 53 // Setter 54 void SetUnsuitableRun() { fInfo[0] |= kUnsuitableRun; } 55 void SetSuitableRun() { fInfo[0] &= ~kUnsuitableRun; } 56 57 void SetUnsuitableEvt() { fInfo[0] |= kUnsuitableEvt; } 58 void SetSuitableEvt() { fInfo[0] &= ~kUnsuitableEvt; } 59 60 void SetUnreliableRun() { fInfo[0] |= kUnreliableRun; } 61 void SetReliableRun() { fInfo[0] &= ~kUnreliableRun; } 54 void SetUnsuitable(UnsuitableType_t typ) { fInfo[0] |= typ; } 62 55 63 56 // Calibration … … 78 71 79 72 // Getter 80 Bool_t IsUnsuitableRun() const { return fInfo[0]&kUnsuitableRun; } 81 Bool_t IsSuitableRun() const { return !(fInfo[0]&kUnsuitableRun); } 82 83 Bool_t IsUnsuitableEvt() const { return fInfo[0]&kUnsuitableEvt; } 84 Bool_t IsSuitableEvt() const { return !(fInfo[0]&kUnsuitableEvt); } 85 86 Bool_t IsUnreliableRun() const { return fInfo[0]&kUnreliableRun; } 87 Bool_t IsReliableRun() const { return !(fInfo[0]&kUnreliableRun); } 73 Bool_t IsUnsuitable(UnsuitableType_t typ) const { return fInfo[0]&typ; } 88 74 89 75 Bool_t IsOK() const { return fInfo[0]==0; } -
trunk/MagicSoft/Mars/mbadpixels/MBadPixelsTreat.cc
r3126 r3476 36 36 // Input Containers: 37 37 // MCerPhotEvt 38 // MPedPhotCam 38 39 // MBadPixelsCam 40 // [MGeomCam] 39 41 // 40 42 // Output Containers: … … 45 47 46 48 #include <fstream> 49 50 #include <TArrayD.h> 47 51 48 52 #include "MLog.h" … … 114 118 if (!fGeomCam && TESTBIT(fFlags, kUseInterpolation)) 115 119 { 116 *fLog << err << " No camera geometry available... can't use interpolation." << endl;120 *fLog << err << "MGeomCam not found... can't use interpolation." << endl; 117 121 return kFALSE; 118 122 } 119 123 120 124 return kTRUE; 125 } 126 127 // -------------------------------------------------------------------------- 128 // 129 // Replaces each pixel (signal, signal error, pedestal, pedestal rms) 130 // by the average of its surrounding pixels. 131 // If TESTBIT(fFlags, kUseCentralPixel) is set the central pixel is also 132 // included. 133 // 134 void MBadPixelsTreat::InterpolateSignal() const 135 { 136 const UShort_t entries = fGeomCam->GetNumPixels(); 137 138 // 139 // Create arrays 140 // 141 TArrayD nphot(entries); 142 TArrayD perr(entries); 143 144 // 145 // Loop over all pixels 146 // 147 for (UShort_t i=0; i<entries; i++) 148 { 149 // 150 // Check whether pixel with idx i is blind 151 // 152 if (!(*fBadPixels)[i].IsBad()) 153 continue; 154 155 // 156 // Get a pointer to this pixel. If it is not yet existing 157 // create a new entry for this pixel in MCerPhotEvt 158 // 159 MCerPhotPix *pix = fEvt->GetPixById(i); 160 if (!pix) 161 pix = fEvt->AddPixel(i, 0, 0); 162 163 // 164 // Get the corresponding geometry and pedestal 165 // 166 const MGeomPix &gpix = (*fGeomCam)[i]; 167 168 // Do Not-Use-Central-Pixel 169 const Bool_t nucp = !TESTBIT(fFlags, kUseCentralPixel); 170 171 Int_t num = nucp ? 0 : 1; 172 173 nphot[i] = nucp ? 0 : pix->GetNumPhotons(); 174 perr[i] = nucp ? 0 : Pow2(pix->GetErrorPhot()); 175 176 // 177 // The values are rescaled to the small pixels area for the right comparison 178 // 179 const Double_t ratio = fGeomCam->GetPixRatio(i); 180 181 nphot[i] *= ratio; 182 perr[i] *= ratio; 183 184 // 185 // Loop over all its neighbors 186 // 187 const Int_t n = gpix.GetNumNeighbors(); 188 for (int j=0; j<n; j++) 189 { 190 const UShort_t nidx = gpix.GetNeighbor(j); 191 192 // 193 // Do not use blind neighbors 194 // 195 if (!(*fBadPixels)[i].IsBad()) 196 continue; 197 198 // 199 // Check whether the neighbor has a signal stored 200 // 201 const MCerPhotPix *evtpix = fEvt->GetPixById(nidx); 202 if (!evtpix) 203 continue; 204 205 // 206 // Get the geometry for the neighbor 207 // 208 const Double_t nratio = fGeomCam->GetPixRatio(nidx); 209 210 // 211 //The error is calculated as the quadratic sum of the errors 212 // 213 nphot[i] += nratio*evtpix->GetNumPhotons(); 214 perr[i] += nratio* Pow2(evtpix->GetErrorPhot()); 215 216 num++; 217 } 218 219 // 220 // Now the mean is calculated and the values rescaled back 221 // to the pixel area 222 // 223 nphot[i] /= (num*ratio); 224 perr[i] = TMath::Sqrt(perr[i]/(num*ratio)); 225 226 // Check if there are enough neighbors to calculate the mean 227 // If not, unmap the pixel. The maximum number of blind neighbors 228 // should be 2 229 if (num<3) 230 { 231 pix->SetPixelUnmapped(); 232 continue; 233 } 234 235 pix->Set(nphot[i], perr[i]); 236 } 237 } 238 239 // -------------------------------------------------------------------------- 240 // 241 void MBadPixelsTreat::InterpolatePedestals() const 242 { 243 const Int_t entries = fPedPhot->GetSize(); 244 245 TArrayD ped(entries); 246 TArrayD rms(entries); 247 248 // 249 // Loop over all pixels 250 // 251 for (UShort_t i=0; i<entries; i++) 252 { 253 // 254 // Check whether pixel with idx i is blind 255 // 256 if (!(*fBadPixels)[i].IsBad()) 257 continue; 258 259 // 260 // Get the corresponding geometry and pedestal 261 // 262 const MGeomPix &gpix = (*fGeomCam)[i]; 263 const MPedPhotPix &ppix = (*fPedPhot)[i]; 264 265 // Do Not-Use-Central-Pixel 266 const Bool_t nucp = !TESTBIT(fFlags, kUseCentralPixel); 267 268 Int_t num = nucp ? 0 : 1; 269 270 ped[i] = nucp ? 0 : ppix.GetMean(); 271 rms[i] = nucp ? 0 : Pow2(ppix.GetRms()); 272 273 // 274 // The values are rescaled to the small pixels area for the right comparison 275 // 276 const Double_t ratio = fGeomCam->GetPixRatio(i); 277 278 ped[i] *= ratio; 279 rms[i] *= ratio; 280 281 // 282 // Loop over all its neighbors 283 // 284 const Int_t n = gpix.GetNumNeighbors(); 285 for (int j=0; j<n; j++) 286 { 287 const UShort_t nidx = gpix.GetNeighbor(j); 288 289 // 290 // Do not use blind neighbors 291 // 292 if (!(*fBadPixels)[i].IsBad()) 293 continue; 294 295 // 296 // Get the geometry for the neighbor 297 // 298 const Double_t nratio = fGeomCam->GetPixRatio(nidx); 299 const MPedPhotPix &nppix = (*fPedPhot)[nidx]; 300 301 // 302 //The error is calculated as the quadratic sum of the errors 303 // 304 ped[i] += (nratio*nppix.GetMean()); 305 rms[i] += nratio*Pow2(nppix.GetRms()); 306 307 num++; 308 } 309 310 // Check if there are enough neighbors to calculate the mean 311 // If not, unmap the pixel. The minimum number of good neighbors 312 // should be 3 313 if (num < 3) 314 { 315 MCerPhotPix *pix =fEvt->GetPixById(i); 316 if (!pix) 317 pix = fEvt->AddPixel(i, 0, 0); 318 pix->SetPixelUnmapped(); 319 continue; 320 } 321 322 // 323 // Now the mean is calculated and the values rescaled back 324 // to the pixel area 325 // 326 ped[i] /= (num*ratio); 327 rms[i] = TMath::Sqrt(rms[i]/(num*ratio)); 328 329 (*fPedPhot)[i].Set(ped[i], rms[i]); 330 } 121 331 } 122 332 … … 177 387 nphot[i] = nucp ? 0 : pix->GetNumPhotons(); 178 388 ped[i] = nucp ? 0 : ppix.GetMean(); 179 perr[i] = nucp ? 0 : Sqr(pix->GetErrorPhot());180 pedrms[i] = nucp ? 0 : Sqr(ppix.GetRms());389 perr[i] = nucp ? 0 : Pow2(pix->GetErrorPhot()); 390 pedrms[i] = nucp ? 0 : Pow2(ppix.GetRms()); 181 391 182 392 // … … 187 397 nphot[i] *= ratio; 188 398 ped[i] *= ratio; 189 perr[i] *= Sqr(ratio);190 pedrms[i] *= Sqr(pedrms[i]);399 perr[i] *= Pow2(ratio); 400 pedrms[i] *= Pow2(pedrms[i]); 191 401 192 402 // … … 222 432 ped[i] += nratio*nppix.GetMean(); 223 433 nphot[i] += nratio*evtpix->GetNumPhotons(); 224 perr[i] += Sqr(nratio*evtpix->GetErrorPhot());225 pedrms[i] += Sqr(nratio*nppix.GetRms());434 perr[i] += Pow2(nratio*evtpix->GetErrorPhot()); 435 pedrms[i] += Pow2(nratio*nppix.GetRms()); 226 436 227 437 num++; … … 294 504 Int_t MBadPixelsTreat::Process() 295 505 { 506 /* 507 if (TESTBIT(fFlags, kCheckPedestalRms)) 508 { 509 // if the number of blind pixels is too high, do not interpolate 510 if (CheckPedestalRms()==kFALSE) 511 return kTRUE; 512 513 if (TESTBIT(fFlags, kUseInterpolation)) 514 InterpolatePedestals(); 515 } 516 */ 517 296 518 if (TESTBIT(fFlags, kUseInterpolation) && fGeomCam) 297 519 Interpolate(); … … 299 521 Unmap(); 300 522 523 524 //fErrors[0]++; 525 301 526 return kTRUE; 302 527 } -
trunk/MagicSoft/Mars/mbadpixels/MBadPixelsTreat.h
r3126 r3476 27 27 }; 28 28 29 static Double_t Sqr(Double_t x) { return x*x; } 29 static Double_t Pow2(Double_t x) { return x*x; } 30 31 void InterpolateSignal() const; 32 void InterpolatePedestals() const; 30 33 31 34 void Interpolate() const; -
trunk/MagicSoft/Mars/mbadpixels/MMcBadPixelsSet.cc
r3420 r3476 131 131 // Case for Crab Nebula FOV 132 132 // 133 (*fBadPixels)[400].SetUnsuitable Run();134 (*fBadPixels)[401].SetUnsuitable Run();135 (*fBadPixels)[402].SetUnsuitable Run();136 (*fBadPixels)[437].SetUnsuitable Run();137 (*fBadPixels)[438].SetUnsuitable Run();138 (*fBadPixels)[439].SetUnsuitable Run();133 (*fBadPixels)[400].SetUnsuitable(MBadPixelsPix::kUnsuitableRun); 134 (*fBadPixels)[401].SetUnsuitable(MBadPixelsPix::kUnsuitableRun); 135 (*fBadPixels)[402].SetUnsuitable(MBadPixelsPix::kUnsuitableRun); 136 (*fBadPixels)[437].SetUnsuitable(MBadPixelsPix::kUnsuitableRun); 137 (*fBadPixels)[438].SetUnsuitable(MBadPixelsPix::kUnsuitableRun); 138 (*fBadPixels)[439].SetUnsuitable(MBadPixelsPix::kUnsuitableRun); 139 139 140 140 *fLog << inf;
Note:
See TracChangeset
for help on using the changeset viewer.