Changeset 7353 for trunk/MagicSoft/Mars/mbadpixels
- Timestamp:
- 09/16/05 11:58:09 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mbadpixels/MBadPixelsTreat.cc
r7349 r7353 69 69 #include <TObjString.h> 70 70 71 #include "MArrayD.h" // Used instead of TArrayD because operator[] has no range check71 //#include "MArrayD.h" // Used instead of TArrayD because operator[] has no range check 72 72 73 73 #include "MLog.h" … … 218 218 219 219 // 220 // Create arrays (FIXME: Check if its possible to create it only once)220 // Loop over all pixels 221 221 // 222 MArrayD nphot(entries); 223 MArrayD perr(entries); 222 for (UShort_t i=0; i<entries; i++) 223 { 224 // 225 // Check whether pixel with idx i is blind 226 // 227 if (!IsPixelBad(i)) 228 continue; 229 230 // 231 // Get the corresponding geometry and pedestal 232 // 233 MSignalPix &pix = (*fEvt)[i]; 234 const MGeomPix &gpix = (*fGeomCam)[i]; 235 236 // Do Not-Use-Central-Pixel 237 const Bool_t nucp = !TESTBIT(fFlags, kUseCentralPixel); 238 239 Int_t num = nucp ? 0 : 1; 240 241 Double_t nphot = nucp ? 0 : pix.GetNumPhotons(); 242 Double_t perr = nucp ? 0 : Pow2(pix.GetErrorPhot()); 243 244 // 245 // The values are rescaled to the small pixels area for the right comparison 246 // 247 const Double_t ratio = fGeomCam->GetPixRatio(i); 248 249 nphot *= ratio; 250 perr *= ratio; 251 252 // 253 // Loop over all its neighbors 254 // 255 const Int_t n = gpix.GetNumNeighbors(); 256 for (int j=0; j<n; j++) 257 { 258 const UShort_t nidx = gpix.GetNeighbor(j); 259 260 // 261 // Do not use blind neighbors 262 // 263 if (IsPixelBad(nidx)) 264 continue; 265 266 // 267 // Get the geometry for the neighbor 268 // 269 const Double_t nratio = fGeomCam->GetPixRatio(nidx); 270 271 // 272 //The error is calculated as the quadratic sum of the errors 273 // 274 const MSignalPix &evtpix = (*fEvt)[nidx]; 275 276 nphot += nratio*evtpix.GetNumPhotons(); 277 perr += nratio*Pow2(evtpix.GetErrorPhot()); 278 279 num++; 280 } 281 282 // Check if there are enough neighbors to calculate the mean 283 // If not, unmap the pixel. The maximum number of blind neighbors 284 // should be 2 285 if (num<fNumMinNeighbors) 286 { 287 pix.SetPixelUnmapped(); 288 continue; 289 } 290 291 // 292 // Now the mean is calculated and the values rescaled back 293 // to the pixel area 294 // 295 nphot /= num*ratio; 296 perr = TMath::Sqrt(perr/(num*ratio)); 224 297 298 pix.Set(nphot, perr); 299 } 300 } 301 302 // -------------------------------------------------------------------------- 303 // 304 void MBadPixelsTreat::InterpolatePedestals(MPedPhotCam &pedphot) const 305 { 306 const Int_t entries = pedphot.GetSize(); 307 225 308 // 226 309 // Loop over all pixels … … 237 320 // Get the corresponding geometry and pedestal 238 321 // 239 MSignalPix &pix = (*fEvt)[i];240 const M GeomPix &gpix = (*fGeomCam)[i];322 const MGeomPix &gpix = (*fGeomCam)[i]; 323 const MPedPhotPix &ppix = pedphot[i]; 241 324 242 325 // Do Not-Use-Central-Pixel … … 245 328 Int_t num = nucp ? 0 : 1; 246 329 247 nphot[i] = nucp ? 0 : pix.GetNumPhotons();248 perr[i] = nucp ? 0 : Pow2(pix.GetErrorPhot());249 250 // 251 330 Double_t ped = nucp ? 0 : ppix.GetMean(); 331 Double_t rms = nucp ? 0 : Pow2(ppix.GetRms()); 332 333 // 334 // The values are rescaled to the small pixels area for the right comparison 252 335 // 253 336 const Double_t ratio = fGeomCam->GetPixRatio(i); 254 337 255 nphot[i]*= ratio;256 perr[i]*= ratio;338 ped *= ratio; 339 rms *= ratio; 257 340 258 341 // … … 273 356 // Get the geometry for the neighbor 274 357 // 275 const Double_t nratio = fGeomCam->GetPixRatio(nidx);276 277 //278 //The error is calculated as the quadratic sum of the errors279 //280 const MSignalPix &evtpix = (*fEvt)[nidx];281 282 nphot[i] += nratio*evtpix.GetNumPhotons();283 perr[i] += nratio*Pow2(evtpix.GetErrorPhot());284 285 num++;286 }287 288 // Check if there are enough neighbors to calculate the mean289 // If not, unmap the pixel. The maximum number of blind neighbors290 // should be 2291 if (num<fNumMinNeighbors)292 {293 pix.SetPixelUnmapped();294 continue;295 }296 297 //298 // Now the mean is calculated and the values rescaled back299 // to the pixel area300 //301 nphot[i] /= (num*ratio);302 perr[i] = TMath::Sqrt(perr[i]/(num*ratio));303 304 pix.Set(nphot[i], perr[i]);305 }306 }307 308 // --------------------------------------------------------------------------309 //310 void MBadPixelsTreat::InterpolatePedestals(MPedPhotCam &pedphot) const311 {312 const Int_t entries = pedphot.GetSize();313 314 // Create arrays (FIXME: Check if its possible to create it only once)315 MArrayD ped(entries);316 MArrayD rms(entries);317 318 //319 // Loop over all pixels320 //321 for (UShort_t i=0; i<entries; i++)322 {323 //324 // Check whether pixel with idx i is blind325 //326 if (!IsPixelBad(i))327 continue;328 329 //330 // Get the corresponding geometry and pedestal331 //332 const MGeomPix &gpix = (*fGeomCam)[i];333 const MPedPhotPix &ppix = pedphot[i];334 335 // Do Not-Use-Central-Pixel336 const Bool_t nucp = !TESTBIT(fFlags, kUseCentralPixel);337 338 Int_t num = nucp ? 0 : 1;339 340 ped[i] = nucp ? 0 : ppix.GetMean();341 rms[i] = nucp ? 0 : Pow2(ppix.GetRms());342 343 //344 // The values are rescaled to the small pixels area for the right comparison345 //346 const Double_t ratio = fGeomCam->GetPixRatio(i);347 348 ped[i] *= ratio;349 rms[i] *= ratio;350 351 //352 // Loop over all its neighbors353 //354 const Int_t n = gpix.GetNumNeighbors();355 for (int j=0; j<n; j++)356 {357 const UShort_t nidx = gpix.GetNeighbor(j);358 359 //360 // Do not use blind neighbors361 //362 if (IsPixelBad(nidx))363 continue;364 365 //366 // Get the geometry for the neighbor367 //368 358 const Double_t nratio = fGeomCam->GetPixRatio(nidx); 369 359 const MPedPhotPix &nppix = pedphot[nidx]; … … 372 362 //The error is calculated as the quadratic sum of the errors 373 363 // 374 ped [i]+= nratio*nppix.GetMean();375 rms [i]+= nratio*Pow2(nppix.GetRms());364 ped += nratio*nppix.GetMean(); 365 rms += nratio*Pow2(nppix.GetRms()); 376 366 377 367 num++; … … 381 371 // If not, unmap the pixel. The minimum number of good neighbors 382 372 // should be fNumMinNeighbors 383 if (num < fNumMinNeighbors) 384 { 385 MSignalPix *pix =fEvt->GetPixById(i); 386 if (!pix) 387 pix = fEvt->AddPixel(i, 0, 0); 388 pix->SetPixelUnmapped(); 373 if (num<fNumMinNeighbors) 374 { 375 (*fEvt)[i].SetPixelUnmapped(); 389 376 continue; 390 377 } … … 394 381 // to the pixel area 395 382 // 396 ped [i] /= (num*ratio);397 rms [i] = TMath::Sqrt(rms[i]/(num*ratio));398 399 pedphot[i].Set(ped [i], rms[i]);383 ped /= num*ratio; 384 rms = TMath::Sqrt(rms/(num*ratio)); 385 386 pedphot[i].Set(ped, rms); 400 387 } 401 388 pedphot.SetReadyToSave(); … … 436 423 const MGeomPix &gpix = (*fGeomCam)[i]; 437 424 438 MArrayD time(gpix.GetNumNeighbors()); 425 const UInt_t n2 = gpix.GetNumNeighbors(); 426 427 Double_t time[n2]; 439 428 440 429 Int_t n0 = 0; 441 for (unsigned int j=0; j<time.GetSize(); j++) 442 { 443 const Int_t nn = gpix.GetNeighbor(j); 444 445 const Double_t t = (*fEvt)[nn].GetArrivalTime(); 446 if (t>=0 && !IsPixelBad(nn)) 430 for (unsigned int j=0; j<n2; j++) 431 { 432 const Double_t t = (*fEvt)[j].GetArrivalTime(); 433 if (t>=0) 447 434 time[n0++] = t; 448 435 }
Note:
See TracChangeset
for help on using the changeset viewer.