Changeset 2502
- Timestamp:
- 11/10/03 16:20:53 (21 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 2 added
- 2 deleted
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r2499 r2502 116 116 * mmain/MCameraDisplay.cc: 117 117 - minor changes 118 118 119 * manalysis/MBlindPixelCalc.[h,cc]: 120 - corrected interpolation of all values (thanks to Nadia) 121 - fixed algorithm for pixels not existing yet 122 123 * manalysis/MCerPhotEvt.h: 124 - added return value to AddPixel 119 125 120 126 -
trunk/MagicSoft/Mars/manalysis/MBlindPixelCalc.cc
r2470 r2502 165 165 // -------------------------------------------------------------------------- 166 166 // 167 // Replaces each pixel by the average of its surrounding pixels. 167 // Replaces each pixel (signal, signal error, pedestal, pedestal rms) 168 // by the average of its surrounding pixels. 168 169 // If TESTBIT(fFlags, kUseCentralPixel) is set the central pixel is also 169 170 // included. 170 171 // 172 // NT: Informations about the interpolated pedestals are added. 173 // When the option Interpolated is called, the blind pixel with the new 174 // values of signal and fluttuation is included in the calculation of 175 // the Image Parameters. 176 // 171 177 void MBlindPixelCalc::Interpolate() const 172 178 { 173 const UShort_t entries = fEvt->GetNumPixels(); 174 175 Double_t *nphot = new Double_t[entries]; 176 Double_t *perr = new Double_t[entries]; 177 Double_t *ped = new Double_t[entries]; 178 179 // 180 // remove the pixels in fPixelsIdx if they are set to be used, 181 // (set them to 'unused' state) 179 const UShort_t entries = fGeomCam->GetNumPixels(); 180 181 // 182 // Create arrays 183 // 184 Double_t *nphot = new Double_t[entries]; 185 Double_t *perr = new Double_t[entries]; 186 Double_t *ped = new Double_t[entries]; 187 Double_t *pedrms = new Double_t[entries]; 188 189 // 190 // Loop over all pixels 182 191 // 183 192 for (UShort_t i=0; i<entries; i++) 184 193 { 185 // FIXME: Loop over blinds instead of all pixels!!! 186 MCerPhotPix &pix = (*fEvt)[i]; 187 188 const Int_t idx = pix.GetPixId(); 189 190 if (!fPixels->IsBlind(idx)) 194 // 195 // Check whether pixel with idx i is blind 196 // 197 if (!fPixels->IsBlind(i)) 191 198 continue; 192 199 193 const MGeomPix &gpix = (*fGeomCam)[idx]; 194 195 Int_t num = TESTBIT(fFlags, kUseCentralPixel) ? 1 : 0; 196 197 nphot[i] = TESTBIT(fFlags, kUseCentralPixel) ? pix.GetNumPhotons() : 0; 198 perr[i] = TESTBIT(fFlags, kUseCentralPixel) ? (*fPed)[idx].GetPedestalRms() : 0; 199 ped[i] = TESTBIT(fFlags, kUseCentralPixel) ? (*fPed)[idx].GetPedestal() : 0; 200 201 nphot[i] *= fGeomCam->GetPixRatio(idx); 202 // FIXME? perr 203 // FIXME? ped 204 200 // 201 // Get a pointer to this pixel. If it is not yet existing 202 // create a new entry for this pixel in MCerPhotEvt 203 // 204 const MCerPhotPix *pix = fEvt->GetPixById(i); 205 if (!pix) 206 pix = fEvt->AddPixel(i, 0, 0); 207 208 // 209 // Get the corresponding geometry and pedestal 210 // 211 const MGeomPix &gpix = (*fGeomCam)[i]; 212 const MPedestalPix &ppix = (*fPed)[i]; 213 214 // Do Not-Use-Central-Pixel 215 const Bool_t nucp = !TESTBIT(fFlags, kUseCentralPixel); 216 217 Int_t num = nucp ? 0 : 1; 218 219 nphot[i] = nucp ? 0 : pix->GetNumPhotons(); 220 ped[i] = nucp ? 0 : ppix.GetPedestal(); 221 perr[i] = nucp ? 0 : Sqr(pix->GetErrorPhot()); 222 pedrms[i] = nucp ? 0 : Sqr(ppix.GetPedestalRms()); 223 224 // 225 // The values are rescaled to the small pixels area for the right comparison 226 // 227 const Double_t ratio = fGeomCam->GetPixRatio(i); 228 229 nphot[i] *= ratio; 230 ped[i] *= ratio; 231 perr[i] *= Sqr(ratio); 232 pedrms[i] *= Sqr(pedrms[i]); 233 234 // 235 // Loop over all its neighbors 236 // 205 237 const Int_t n = gpix.GetNumNeighbors(); 206 238 for (int j=0; j<n; j++) … … 208 240 const UShort_t nidx = gpix.GetNeighbor(j); 209 241 242 // 243 // Do not use blind neighbors 244 // 210 245 if (fPixels->IsBlind(nidx)) 211 246 continue; 212 247 248 // 249 // Check whether the neighbor has a signal stored 250 // 213 251 const MCerPhotPix *evtpix = fEvt->GetPixById(nidx); 214 252 if (!evtpix) 215 253 continue; 216 254 217 nphot[i] += evtpix->GetNumPhotons()*fGeomCam->GetPixRatio(nidx); 218 perr[i] += (*fPed)[nidx].GetPedestalRms(); 219 ped[i] += (*fPed)[nidx].GetPedestal(); 220 // FIXME? perr 221 // FIXME? ped 255 // 256 // Get the geometry for the neighbor 257 // 258 const Double_t nratio = fGeomCam->GetPixRatio(nidx); 259 MPedestalPix &nppix = (*fPed)[nidx]; 260 261 // 262 //The error is calculated as the quadratic sum of the errors 263 // 264 ped[i] += nratio*nppix.GetPedestal(); 265 nphot[i] += nratio*evtpix->GetNumPhotons(); 266 perr[i] += Sqr(nratio*evtpix->GetErrorPhot()); 267 pedrms[i] += Sqr(nratio*nppix.GetPedestalRms()); 222 268 223 269 num++; 224 270 } 225 271 226 nphot[i] /= num*fGeomCam->GetPixRatio(idx); 227 perr[i] /= num/*FIXME:???*/; 228 ped[i] /= num/*FIXME:???*/; 229 } 230 231 if (TESTBIT(fFlags, kUseInterpolation) && fGeomCam) 232 for (UShort_t i=0; i<entries; i++) 233 { 234 MCerPhotPix &pix = (*fEvt)[i]; 235 236 if (fPixels->IsBlind(pix.GetPixId())) 237 { 238 pix.Set(nphot[i], -1); 239 (*fPed)[pix.GetPixId()].Set(ped[i], perr[i]); 240 } 241 } 242 272 // 273 // Now the mean is calculated and the values rescaled back to the pixel area 274 // 275 nphot[i] /= num*ratio; 276 ped[i] /= num*ratio; 277 perr[i] = TMath::Sqrt(perr[i]/num)*ratio; 278 pedrms[i] = TMath::Sqrt(pedrms[i]/num)*ratio; 279 280 } 281 282 // 283 // Now the new pixel values are calculated and can be replaced in 284 // the corresponding containers 285 // 286 for (UShort_t i=0; i<entries; i++) 287 { 288 // 289 // Do not use blind neighbors 290 // 291 if (!fPixels->IsBlind(i)) 292 continue; 293 294 // 295 // It must exist, we have created it in the loop before. 296 // 297 fEvt->GetPixById(i)->Set(nphot[i], perr[i]); 298 (*fPed)[i].Set(ped[i], pedrms[i]); 299 } 300 301 // 302 // Delete the intermediat arrays 303 // 243 304 delete nphot; 244 305 delete perr; 245 306 delete ped; 307 delete pedrms; 246 308 } 247 309 -
trunk/MagicSoft/Mars/manalysis/MBlindPixelCalc.h
r2408 r2502 35 35 }; 36 36 37 static Double_t Sqr(Double_t x) { return x*x; } 38 37 39 void Interpolate() const; 38 40 void Unmap() const; -
trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.h
r2445 r2502 32 32 //void InitSize(UInt_t num) { fPixels->Expand(num); } 33 33 34 void AddPixel(Int_t idx, Float_t nph, Float_t er)34 MCerPhotPix *AddPixel(Int_t idx, Float_t nph=0, Float_t er=0) 35 35 { 36 36 // … … 47 47 48 48 fLut[idx] = fNumPixels; 49 new ((*fPixels)[fNumPixels++]) MCerPhotPix(idx, nph, er);49 return new ((*fPixels)[fNumPixels++]) MCerPhotPix(idx, nph, er); 50 50 } 51 51
Note:
See TracChangeset
for help on using the changeset viewer.