Changeset 7353
- Timestamp:
- 09/16/05 11:58:09 (19 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r7352 r7353 18 18 19 19 -*-*- END OF LINE -*-*- 20 2005/09/16 Thomas Bretz 21 22 * mbadpixels/MBadPixelsTreat.cc: 23 - removed obsolete artificial add of missing (zero supressed) 24 pixels 25 - removed obsolete MArrayD which stored the result of the 26 interpolation but was never used 27 28 * mcalib/MCalibrateData.cc: 29 - removed an obsolete calibConv=-1 in case the pixel is unsuitable 30 (UpdateConversionFactors) 31 - improved warning output in case the conv factor is out-of-range 32 33 * mcalib/MCalibrateRelTimes.cc: 34 - reordered the algorithm for the time calibration to make it faster 35 - replaced if(IsLoGainUsed()) by the new function GetArrivalTime in 36 MArrivalTimePix 37 38 * msignal/MArrivalTimePix.h: 39 - new getter function GetArrivalTime returning the arrival time 40 depending on the flag IsLoGainUsed() 41 42 43 20 44 2005/09/16 Daniela Dorner 21 45 -
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 } -
trunk/MagicSoft/Mars/mcalib/MCalibrateData.cc
r7189 r7353 542 542 { 543 543 skip++; 544 calibConv = -1.; 545 continue; 544 continue; // calibConv will remain 0 546 545 } 547 546 … … 679 678 calibConv = -1.; 680 679 calibFFactor = -1.; 681 *fLog << warn << "Conversion factor of Pixel " << pixidx << " out of range " << endl; 680 *fLog << warn << GetDescriptor() 681 << ": WARNING - Conversion factor of Pixel " << pixidx << " out of range... set to 0. " << endl; 682 682 } 683 683 cpix.SetCalibConst(calibConv); -
trunk/MagicSoft/Mars/mcalib/MCalibrateRelTimes.cc
r7134 r7353 86 86 Int_t MCalibrateRelTimes::PreProcess(MParList *pList) 87 87 { 88 89 88 fSignals = (MArrivalTimeCam*)pList->FindObject(AddSerialNumber("MArrivalTimeCam")); 90 89 91 90 if (!fSignals) 92 91 { 93 *fLog << err << AddSerialNumber("MArrivalTimeCam") << " not found ... aborting" << endl;92 *fLog << err << AddSerialNumber("MArrivalTimeCam") << " not found ... aborting" << endl; 94 93 return kFALSE; 95 94 } … … 97 96 fBadPixels = (MBadPixelsCam*)pList->FindObject(AddSerialNumber("MBadPixelsCam")); 98 97 if (!fBadPixels) 99 *fLog << warn << AddSerialNumber("MBadPixelsCam") << " not found ... no action" << endl; 100 98 *fLog << warn << AddSerialNumber("MBadPixelsCam") << " not found ... ignoring." << endl; 101 99 102 100 fCalibrations = (MCalibrationRelTimeCam*)pList->FindObject(AddSerialNumber("MCalibrationRelTimeCam")); … … 106 104 return kFALSE; 107 105 } 108 109 106 110 107 fArrivalTime = (MSignalCam*)pList->FindCreateObj(AddSerialNumber("MSignalCam")); … … 124 121 const UInt_t npix = fSignals->GetSize(); 125 122 126 for (UInt_t pixidx=0; pixidx<npix; pixidx++)123 for (UInt_t idx=0; idx<npix; idx++) 127 124 { 128 MCalibrationRelTimePix &pix = (MCalibrationRelTimePix&)(*fCalibrations)[pixidx]; 129 130 if (fBadPixels && (*fBadPixels)[pixidx].IsUnsuitable(MBadPixelsPix::kUnsuitableRun)) 125 if (fBadPixels && (*fBadPixels)[idx].IsUnsuitable(MBadPixelsPix::kUnsuitableRun)) 131 126 continue; 132 127 133 const Float_t offset = pix.GetTimeOffset(); 128 const MCalibrationRelTimePix &pix = (MCalibrationRelTimePix&)(*fCalibrations)[idx]; 129 const MArrivalTimePix &sig = (*fSignals)[idx]; 134 130 135 MArrivalTimePix &sig = (*fSignals)[pixidx]; 131 const Float_t signal = sig.GetArrivalTime(); 132 const Float_t offset = pix.GetTimeOffset(); 136 133 137 Float_t signal; 138 139 if (sig.IsLoGainUsed()) 140 signal = sig.GetArrivalTimeLoGain(); 141 else 142 signal = sig.GetArrivalTimeHiGain(); 143 144 const Float_t time = signal - offset; 145 146 (*fArrivalTime)[pixidx].SetArrivalTime(time); 147 148 } /* for (UInt_t pixidx=0; pixidx<npix; pixidx++) */ 134 (*fArrivalTime)[idx].SetArrivalTime(signal - offset); 135 } 149 136 150 137 fArrivalTime->SetReadyToSave(); -
trunk/MagicSoft/Mars/msignal/MArrivalTimePix.h
r4899 r7353 35 35 Float_t GetArrivalTimeLoGainError() const { return fArrivalTimeLoGainError; } 36 36 37 Float_t GetArrivalTime() const { return IsLoGainUsed() ? fArrivalTimeLoGain : fArrivalTimeHiGain; } 38 37 39 Byte_t GetNumHiGainSaturated() const { return fNumHiGainSaturated; } 38 40 Byte_t GetNumLoGainSaturated() const { return fNumLoGainSaturated; }
Note:
See TracChangeset
for help on using the changeset viewer.