Changeset 4037
- Timestamp:
- 05/10/04 16:53:41 (21 years ago)
- Location:
- trunk/MagicSoft/Mars/mtemp
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mtemp/MFindStars.cc
r4011 r4037 30 30 #include "MFindStars.h" 31 31 32 #include <TTimer.h> 33 #include <TString.h> 32 34 #include <TFile.h> 33 35 #include <TTree.h> 36 #include <TH1F.h> 37 #include <TF1.h> 34 38 35 39 #include "MObservatory.h" … … 60 64 fTitle = title ? title : "Tool to find stars from DC Currents"; 61 65 66 fNumIntegratedEvents=0; 62 67 fMaxNumIntegratedEvents = 10; 63 fRingInterest = 1 00.; //[mm] ~ 0.3deg64 fMinDCForStars = 3.*fMaxNumIntegratedEvents; //[uA]68 fRingInterest = 125.; //[mm] ~ 0.4 deg 69 fMinDCForStars = 2.*fMaxNumIntegratedEvents; //[uA] 65 70 66 71 fPixelsUsed.Set(577); … … 166 171 Int_t MFindStars::Process() 167 172 { 168 if (fNumIntegratedEvents < fMaxNumIntegratedEvents) 169 { 170 fDisplay.AddCamContent(*fCurr); 171 fNumIntegratedEvents++; 172 } 173 else 173 if (fNumIntegratedEvents >= fMaxNumIntegratedEvents) 174 174 { 175 175 if (fDrive) … … 185 185 else 186 186 { 187 UInt_t numPixels = fGeomCam->GetNumPixels(); 188 TArrayC origPixelsUsed; 189 origPixelsUsed.Set(numPixels); 190 191 for (UInt_t pix=1; pix<numPixels; pix++) 192 { 193 if (fDisplay.IsUsed(pix)) 194 origPixelsUsed[pix]=(Char_t)kTRUE; 195 else 196 origPixelsUsed[pix]=(Char_t)kFALSE; 197 } 198 199 Float_t ped; 200 Float_t rms; 201 DCPedestalCalc(ped, rms); 202 fMinDCForStars = fMinDCForStars>(ped+5*rms)?fMinDCForStars:(ped+5*rms); 203 204 *fLog << dbg << " DC pedestal = " << ped << " pedestal rms = " << rms << endl; 205 *fLog << dbg << " fMinDCForStars " << fMinDCForStars << endl; 206 207 // Find the star candidats searching the most brights pairs of pixels 187 208 Float_t maxPixelDC; 188 209 MGeomPix maxPixel; 189 210 190 MHCamera cam = fDisplay; 191 cam.PrintInfo(); 192 193 // Find the star candidats searching the most brights pairs of pixels 194 while(1) 211 while(FindPixelWithMaxDC(maxPixelDC, maxPixel)) 195 212 { 196 FindPixelWithMaxDC(maxPixelDC, maxPixel);197 213 *fLog << dbg << "Star candidate maxDC(" << setw(3) << maxPixelDC << " uA) x position(" << setw(3) << maxPixel.GetX() << " mm) x position(" << setw(3) << maxPixel.GetY() << " mm)" << endl; 198 199 if (maxPixelDC<fMinDCForStars)200 break;201 214 202 215 MStarLocalPos *starpos = new MStarLocalPos; 203 216 starpos->SetExpValues(maxPixelDC,maxPixel.GetX(),maxPixel.GetY()); 204 217 starpos->SetCalcValues(maxPixelDC,maxPixel.GetX(),maxPixel.GetY(),fRingInterest/2,fRingInterest/2); 218 starpos->SetFitValues(maxPixelDC,maxPixel.GetX(),maxPixel.GetY(),fRingInterest/2,fRingInterest/2); 205 219 fStars->GetList()->Add(starpos); 206 220 … … 208 222 209 223 } 210 fDisplay = cam; 211 *fLog << dbg << GetName() << " Found " << fStars->GetList()->GetSize() << " stars candidates in the camera." << endl;224 225 fDisplay.SetUsed(origPixelsUsed); 212 226 } 213 227 … … 218 232 return kFALSE; 219 233 } 234 else 235 *fLog << inf << GetName() << " Found " << fStars->GetList()->GetSize() << " stars candidates in the camera." << endl; 220 236 221 237 TIter Next(fStars->GetList()); 222 238 MStarLocalPos* star; 223 239 while ((star=(MStarLocalPos*)Next())) 224 { 225 FindStar(star); 226 ShadowStar(star); 227 } 228 240 { 241 FindStar(star); 242 ShadowStar(star); 243 } 229 244 230 245 //After finding stars reset all vairables … … 233 248 } 234 249 250 fDisplay.AddCamContent(*fCurr); 251 fNumIntegratedEvents++; 252 235 253 return kTRUE; 236 254 } … … 254 272 } 255 273 274 Bool_t MFindStars::DCPedestalCalc(Float_t &ped, Float_t &rms) 275 { 276 UInt_t numPixels = fGeomCam->GetNumPixels(); 277 278 TH1F dchist("dchist","",120,0.,30.*fMaxNumIntegratedEvents); 279 for (UInt_t pix=1; pix<numPixels; pix++) 280 dchist.Fill(fDisplay.GetBinContent(pix+1)); 281 282 Float_t nummaxprobdc = dchist.GetBinContent(dchist.GetMaximumBin()); 283 Float_t maxprobdc = dchist.GetBinCenter(dchist.GetMaximumBin()); 284 UInt_t bin = dchist.GetMaximumBin(); 285 do 286 { 287 bin++; 288 } 289 while(dchist.GetBinContent(bin)/nummaxprobdc > 0.5); 290 Float_t halfmaxprobdc = dchist.GetBinCenter(bin); 291 292 *fLog << dbg << " maxprobdc[high] " << maxprobdc << "[" << nummaxprobdc << "] "; 293 *fLog << dbg << " halfmaxprobdc[high] " << halfmaxprobdc << "[" << dchist.GetBinContent(bin) << "]" << endl; 294 295 Float_t rmsguess = TMath::Abs(maxprobdc-halfmaxprobdc); 296 Float_t min = maxprobdc-3*rmsguess; 297 min = (min<0.?0.:min); 298 Float_t max = maxprobdc+3*rmsguess; 299 300 *fLog << dbg << " maxprobdc " << maxprobdc << " rmsguess " << rmsguess << endl; 301 302 TF1 func("func","gaus",min,max); 303 func.SetParameters(nummaxprobdc, maxprobdc, rmsguess); 304 305 dchist.Fit("func","QR0"); 306 307 UInt_t aproxnumdegrees = 6*(bin-dchist.GetMaximumBin()); 308 Float_t chiq = func.GetChisquare(); 309 ped = func.GetParameter(1); 310 rms = func.GetParameter(2); 311 312 *fLog << dbg << " ped " << ped << " rms " << rms << " chiq/ndof " << chiq << "/" << aproxnumdegrees << endl; 313 314 Int_t numsigmas = 5; 315 Axis_t minbin = ped-numsigmas*rms/dchist.GetBinWidth(1); 316 minbin=minbin<1?1:minbin; 317 Axis_t maxbin = ped+numsigmas*rms/dchist.GetBinWidth(1); 318 *fLog << dbg << " Number of pixels with dc under " << numsigmas << " sigmas = " << dchist.Integral((int)minbin,(int)maxbin) << endl; 319 return kTRUE; 320 } 321 256 322 Bool_t MFindStars::FindPixelWithMaxDC(Float_t &maxDC, MGeomPix &maxPix) 257 323 { … … 269 335 Float_t dc[2]; 270 336 dc[0] = fDisplay.GetBinContent(pix+1); 271 337 if (dc[0] < fMinDCForStars) 338 continue; 339 272 340 MGeomPix &g = (*fGeomCam)[pix]; 273 341 Int_t numNextNeighbors = g.GetNumNeighbors(); … … 280 348 UInt_t swneighbor = g.GetNeighbor(nextNeighbor); 281 349 dc[1] = fDisplay.GetBinContent(swneighbor+1); 282 350 if (dc[1] < fMinDCForStars) 351 continue; 283 352 284 353 dcsum = dc[0] + dc[1]; … … 304 373 } 305 374 375 if (maxDC == 0) 376 return kFALSE; 377 306 378 maxPix = (*fGeomCam)[maxPixIdx[0]]; 307 379 return kTRUE; … … 311 383 { 312 384 313 MHCamera cam = fDisplay; 385 UInt_t numPixels = fGeomCam->GetNumPixels(); 386 TArrayC origPixelsUsed; 387 origPixelsUsed.Set(numPixels); 314 388 315 Float_t expX = star->GetXExp(); 316 Float_t expY = star->GetYExp(); 317 318 UInt_t numPixels = fGeomCam->GetNumPixels(); 319 320 // First define a area of interest around the expected position of the star 321 for (UInt_t pix=1; pix<numPixels; pix++) 322 { 323 324 Float_t pixXpos=(*fGeomCam)[pix].GetX(); 325 Float_t pixYpos=(*fGeomCam)[pix].GetY(); 326 Float_t dist = sqrt((pixXpos-expX)*(pixXpos-expX)+ 327 (pixYpos-expY)*(pixYpos-expY)); 328 329 if (dist < fRingInterest && cam.IsUsed(pix)) 330 fPixelsUsed[pix]=(Char_t)kTRUE; 331 } 332 333 cam.SetUsed(fPixelsUsed); 334 335 389 for (UInt_t pix=1; pix<numPixels; pix++) 390 { 391 if (fDisplay.IsUsed(pix)) 392 origPixelsUsed[pix]=(Char_t)kTRUE; 393 else 394 origPixelsUsed[pix]=(Char_t)kFALSE; 395 } 396 397 Float_t expX = star->GetXExp(); 398 Float_t expY = star->GetYExp(); 399 400 // First define a area of interest around the expected position of the star 401 for (UInt_t pix=1; pix<numPixels; pix++) 402 { 403 404 Float_t pixXpos=(*fGeomCam)[pix].GetX(); 405 Float_t pixYpos=(*fGeomCam)[pix].GetY(); 406 Float_t dist = sqrt((pixXpos-expX)*(pixXpos-expX)+ 407 (pixYpos-expY)*(pixYpos-expY)); 408 409 if ((dist < fRingInterest) && fDisplay.IsUsed(pix)) 410 fPixelsUsed[pix]=(Char_t)kTRUE; 411 else 412 fPixelsUsed[pix]=(Char_t)kFALSE; 413 } 414 415 fDisplay.SetUsed(fPixelsUsed); 416 336 417 // determine mean x and mean y of the selected px 337 418 Float_t meanX=0; … … 343 424 for(UInt_t pix=0; pix<numPixels; pix++) 344 425 { 345 if( cam.IsUsed(pix))426 if(fDisplay.IsUsed(pix)) 346 427 { 347 428 usedPx++; 348 429 349 Float_t charge=cam.GetBinContent(pix+1); 350 Float_t pixXpos=(*fGeomCam)[pix].GetX(); 351 Float_t pixYpos=(*fGeomCam)[pix].GetY(); 352 353 meanX+=charge*pixXpos; 354 meanY+=charge*pixYpos; 355 meanSqX+=charge*pixXpos*pixXpos; 356 meanSqY+=charge*pixYpos*pixYpos; 357 sumCharge+=charge; 358 // cam.ResetUsed(i); // this px must not be used again! 359 } //for... use 360 } 361 362 star->SetCalcValues(sumCharge,meanX,meanY,meanSqX,meanSqY); 430 Float_t charge = fDisplay.GetBinContent(pix+1); 431 Float_t pixXpos = (*fGeomCam)[pix].GetX(); 432 Float_t pixYpos = (*fGeomCam)[pix].GetY(); 433 434 meanX += charge*pixXpos; 435 meanY += charge*pixYpos; 436 meanSqX += charge*pixXpos*pixXpos; 437 meanSqY += charge*pixYpos*pixYpos; 438 sumCharge += charge; 439 } 440 } 441 442 *fLog << dbg << " usedPx " << usedPx << endl; 443 444 meanX /= sumCharge; 445 meanY /= sumCharge; 446 meanSqX /= sumCharge; 447 meanSqY /= sumCharge; 448 449 Float_t rmsX = TMath::Sqrt(meanSqX - meanX*meanX); 450 Float_t rmsY = TMath::Sqrt(meanSqY - meanY*meanY); 363 451 452 star->SetCalcValues(sumCharge,meanX,meanY,rmsX,rmsY); 453 454 fDisplay.SetUsed(origPixelsUsed); 455 364 456 return kTRUE; 365 457 } … … 370 462 371 463 // Define an area around the star which will be set unused. 464 UInt_t shadowPx=0; 372 465 for (UInt_t pix=1; pix<numPixels; pix++) 373 466 { 374 375 467 Float_t pixXpos = (*fGeomCam)[pix].GetX(); 376 468 Float_t pixYpos = (*fGeomCam)[pix].GetY(); … … 378 470 Float_t starYpos = star->GetMeanYCalc(); 379 471 380 Float_t starSize = 2*star->GetSigmaMajorAxisCalc();472 Float_t starSize = 3*star->GetSigmaMajorAxisCalc(); 381 473 382 474 Float_t dist = sqrt((pixXpos-starXpos)*(pixXpos-starXpos)+ … … 386 478 fPixelsUsed[pix]=(Char_t)kTRUE; 387 479 else 480 { 388 481 fPixelsUsed[pix]=(Char_t)kFALSE; 389 } 482 shadowPx++; 483 } 484 } 485 486 *fLog << dbg << " shadowPx " << shadowPx << endl; 390 487 391 488 fDisplay.SetUsed(fPixelsUsed); -
trunk/MagicSoft/Mars/mtemp/MFindStars.h
r4002 r4037 1 #ifndef MARS_M JFindStars2 #define MARS_M JFindStars1 #ifndef MARS_MFindStars 2 #define MARS_MFindStars 3 3 4 4 #ifndef ROOT_TArrayS … … 49 49 50 50 Float_t fRingInterest; //[mm] 51 Float_t fMinDCForStars; 51 Float_t fMinDCForStars; //[uA] 52 52 53 Bool_t DCPedestalCalc(Float_t &ped, Float_t &rms); 53 54 Bool_t FindPixelWithMaxDC(Float_t &maxDC, MGeomPix &maxPix); 54 55 Bool_t FindStar(MStarLocalPos* star); … … 56 57 57 58 public: 59 58 60 MFindStars(const char *name=NULL, const char *title=NULL); 59 61 -
trunk/MagicSoft/Mars/mtemp/MStarLocalCam.cc
r3808 r4037 33 33 34 34 #include "MStarLocalCam.h" 35 #include "MStarLocalPos.h"36 35 37 36 #include <TList.h> 38 37 38 #include "MLog.h" 39 #include "MLogManip.h" 40 41 #include "MStarLocalPos.h" 42 43 using namespace std; 39 44 40 45 // -------------------------------------------------------------------------- … … 52 57 MStarLocalCam::~MStarLocalCam() 53 58 { 54 delete fStars; 59 fStars->SetOwner(); 60 fStars->Delete(); 55 61 } 56 62 … … 78 84 TIter Next(fStars); 79 85 MStarLocalPos* star; 86 UInt_t starnum = 0; 80 87 while ((star=(MStarLocalPos*)Next())) 88 { 89 *fLog << inf << "Star[" << starnum << "] info:" << endl; 81 90 star->Print(); 91 starnum++; 92 } 82 93 } -
trunk/MagicSoft/Mars/mtemp/MStarLocalPos.cc
r3808 r4037 99 99 void MStarLocalPos::Print(Option_t *opt) const 100 100 { 101 *fLog << inf << "Star expected position:" << endl; 102 *fLog << inf << " X " << fXExp << " mm \tY " << fYExp << " mm" << endl; 103 *fLog << inf << "Star calculated position:" << endl; 104 *fLog << inf << " X " << fMeanXCalc << " mm \tY " << fMeanYCalc << " mm" << endl; 105 *fLog << inf << "Star fitted position:" << endl; 106 *fLog << inf << " X " << fXExp << " mm \tY " << fYExp << " mm" << endl; 101 *fLog << inf << "Star position:" << endl; 102 *fLog << inf << " Expected \t X " << setw(4) << fXExp << " mm \tY " << setw(4) << fYExp << " mm" << endl; 103 *fLog << inf << " Calcultated \t X " << setw(4) << fMeanXCalc << " mm \tY " << setw(4) << fMeanYCalc << " mm" << endl; 104 *fLog << inf << " Fitted \t X " << setw(4) << fMeanXFit << " mm \tY " << setw(4) << fMeanYFit << " mm" << endl; 105 *fLog << inf << "Star size:" << endl; 106 *fLog << inf << " Calcultated \t X " << setw(4) << fSigmaMinorAxisCalc << " mm \tY " << setw(4) << fSigmaMajorAxisCalc << " mm" << endl; 107 *fLog << inf << " Fitted \t X " << setw(4) << fSigmaMinorAxisFit << " mm \tY " << setw(4) << fSigmaMajorAxisFit << " mm" << endl; 107 108 }
Note:
See TracChangeset
for help on using the changeset viewer.