Changeset 4294 for trunk/MagicSoft/Mars/mtemp
- Timestamp:
- 06/16/04 09:57:59 (20 years ago)
- Location:
- trunk/MagicSoft/Mars/mtemp
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mtemp/MFindStars.cc
r4071 r4294 36 36 #include <TFile.h> 37 37 #include <TTree.h> 38 #include <TCanvas.h> 38 39 #include <TH1F.h> 39 40 #include <TF1.h> … … 57 58 58 59 #include "MParList.h" 60 #include "MTaskList.h" 59 61 60 62 ClassImp(MFindStars); … … 63 65 const Float_t sqrt2 = sqrt(2.); 64 66 const Float_t sqrt3 = sqrt(3.); 67 const UInt_t lastInnerPixel = 396; 68 65 69 66 70 //______________________________________________________________________________ … … 81 85 { 82 86 83 MFindStars* find = (MFindStars*)gMinuit->GetObjectFit(); 84 MHCamera& display = (MHCamera&)find->GetDisplay(); 85 Float_t ped = find->GetPedestalDC(); 86 Float_t rms = find->GetPedestalRMSDC(); 87 MGeomCam& geom = (MGeomCam&)display.GetGeomCam(); 88 89 UInt_t numPixels = geom.GetNumPixels(); 90 87 MParList* plist = (MParList*)gMinuit->GetObjectFit(); 88 MTaskList* tlist = (MTaskList*)plist->FindObject("MTaskList"); 89 MFindStars* find = (MFindStars*)tlist->FindObject("MFindStars"); 90 MStarLocalCam* stars = (MStarLocalCam*)plist->FindObject("MStarLocalCam"); 91 MGeomCam* geom = (MGeomCam*)plist->FindObject("MGeomCam"); 92 93 MHCamera& display = (MHCamera&)find->GetDisplay(); 94 95 Float_t innerped = stars->GetInnerPedestalDC(); 96 Float_t innerrms = stars->GetInnerPedestalRMSDC(); 97 Float_t outerped = stars->GetOuterPedestalDC(); 98 Float_t outerrms = stars->GetOuterPedestalRMSDC(); 99 100 UInt_t numPixels = geom->GetNumPixels(); 101 91 102 //calculate chisquare 92 103 Double_t chisq = 0; 93 104 Double_t delta; 94 105 Double_t x,y,z; 95 Double_t errorz = rms; //[uA]106 Double_t errorz=0; 96 107 97 108 UInt_t usedPx=0; 98 109 for (UInt_t pixid=1; pixid<numPixels; pixid++) 99 110 { 100 z = display.GetBinContent(pixid+1)-ped;101 102 111 if (display.IsUsed(pixid)) 103 112 { 104 x = geom[pixid].GetX(); 105 y = geom[pixid].GetY(); 113 x = (*geom)[pixid].GetX(); 114 y = (*geom)[pixid].GetY(); 115 z = display.GetBinContent(pixid+1)-(pixid>lastInnerPixel?outerped:innerped); 116 errorz=(pixid>lastInnerPixel?outerrms:innerrms); 106 117 107 118 if (errorz > 0.0) 108 119 { 109 120 usedPx++; 110 111 121 delta = (z-func(x,y,par))/errorz; 122 chisq += delta*delta; 112 123 } 113 124 else … … 121 132 } 122 133 123 MFindStars::MFindStars(const char *name, const char *title): fNumVar(5) 134 MFindStars::MFindStars(const char *name, const char *title): 135 fGeomCam(NULL), fCurr(NULL), fTimeCurr(NULL), fDrive(NULL), fStars(NULL), fNumVar(5) 124 136 { 125 137 fName = name ? name : "MFindStars"; … … 185 197 // fMethod = "MINIMIZE"; 186 198 fNulloutput = kFALSE; 199 200 // Set output level 201 // fLog->SetOutputLevel(3); // No dbg messages 187 202 } 188 203 … … 199 214 200 215 // Initialize camera display with the MGeomCam information 201 fDisplay.SetGeometry(*fGeomCam );216 fDisplay.SetGeometry(*fGeomCam,"FindStarsDisplay","FindStarsDisplay"); 202 217 fDisplay.SetUsed(fPixelsUsed); 203 218 204 219 fCurr = (MCameraDC*)pList->FindObject(AddSerialNumber("MCameraDC")); 205 220 … … 218 233 } 219 234 220 fDrive = (MReportDrive*)pList->FindObject(AddSerialNumber("MReportDrive"));235 // fDrive = (MReportDrive*)pList->FindObject(AddSerialNumber("MReportDrive")); 221 236 222 237 if (!fDrive) … … 226 241 else 227 242 { 228 //Initialitation MAstroCamera229 // Name of a MC file having MGeomCam and MMcConfigRunHeader230 TString fname = "../data/Gamma_zbin9_90_7_1480to1489_w0.root";231 232 // Time for which to get the picture233 // MTime time;234 // time.Set(2004, 2, 28, 01, 32, 15);235 236 // Current observatory237 MObservatory magic1;238 239 // Right Ascension [h] and declination [deg] of source240 // Currently 'perfect' pointing is assumed241 // const Double_t ra = MAstro::Hms2Rad(5, 34, 31.9);242 // const Double_t dec = MAstro::Dms2Rad(22, 0, 52.0);243 244 // --------------------------------------------------------------------------245 // Create camera display from geometry246 MMcConfigRunHeader *config=0;247 MGeomCam *geom=0;248 249 TFile file(fname);250 TTree *tree = (TTree*)file.Get("RunHeaders");251 tree->SetBranchAddress("MMcConfigRunHeader", &config);252 if (tree->GetBranch("MGeomCam"))253 tree->SetBranchAddress("MGeomCam", &geom);254 tree->GetEntry(0);255 256 fAstro.SetMirrors(*config->GetMirrors());257 fAstro.SetGeom(*geom);258 259 260 fAstro.SetLimMag(6);261 fAstro.SetRadiusFOV(3);262 fAstro.ReadBSC("../data/bsc5.dat");263 264 fAstro.SetObservatory(magic1);265 // Time for which to get the picture266 // MTime time;267 // time.Set(2004, 2, 28, 01, 32, 15);268 // fAstro.SetTime(time);269 fAstro.SetTime(*fTimeCurr);270 fAstro.SetGuiActive();271 272 fAstro.SetStarList(fStars->GetList());243 // //Initialitation MAstroCamera 244 // // Name of a MC file having MGeomCam and MMcConfigRunHeader 245 // TString fname = "../data/Gamma_zbin9_90_7_1480to1489_w0.root"; 246 247 // // Time for which to get the picture 248 // // MTime time; 249 // // time.Set(2004, 2, 28, 01, 32, 15); 250 251 // // Current observatory 252 // MObservatory magic1; 253 254 // // Right Ascension [h] and declination [deg] of source 255 // // Currently 'perfect' pointing is assumed 256 // // const Double_t ra = MAstro::Hms2Rad(5, 34, 31.9); 257 // // const Double_t dec = MAstro::Dms2Rad(22, 0, 52.0); 258 259 // // -------------------------------------------------------------------------- 260 // // Create camera display from geometry 261 // MMcConfigRunHeader *config=0; 262 // MGeomCam *geom=0; 263 264 // TFile file(fname); 265 // TTree *tree = (TTree*)file.Get("RunHeaders"); 266 // tree->SetBranchAddress("MMcConfigRunHeader", &config); 267 // if (tree->GetBranch("MGeomCam")) 268 // tree->SetBranchAddress("MGeomCam", &geom); 269 // tree->GetEntry(0); 270 271 // fAstro.SetMirrors(*config->GetMirrors()); 272 // fAstro.SetGeom(*geom); 273 274 275 // fAstro.SetLimMag(6); 276 // fAstro.SetRadiusFOV(3); 277 // fAstro.ReadBSC("../data/bsc5.dat"); 278 279 // fAstro.SetObservatory(magic1); 280 // // Time for which to get the picture 281 // // MTime time; 282 // // time.Set(2004, 2, 28, 01, 32, 15); 283 // // fAstro.SetTime(time); 284 // fAstro.SetTime(*fTimeCurr); 285 // fAstro.SetGuiActive(); 286 287 // fAstro.SetStarList(fStars->GetList()); 273 288 274 289 } … … 282 297 } 283 298 284 fMinDCForStars = 1. 5*fMaxNumIntegratedEvents; //[uA]299 fMinDCForStars = 1.*fMaxNumIntegratedEvents; //[uA] 285 300 286 301 // Initialize the TMinuit object … … 297 312 gMinuit->mnexcm("SET PRI", arglist ,1,ierflg); 298 313 299 // Set object pointer to allow mimuit to access internally300 gMinuit->SetObjectFit( this);314 // Set MParList object pointer to allow mimuit to access internally 315 gMinuit->SetObjectFit(pList); 301 316 302 317 return kTRUE; … … 305 320 Int_t MFindStars::Process() 306 321 { 322 307 323 UInt_t numPixels = fGeomCam->GetNumPixels(); 308 324 TArrayC origPixelsUsed; … … 314 330 if (fDrive) 315 331 { 316 Float_t ra = fDrive->GetRa();317 Float_t dec = fDrive->GetDec();332 // Float_t ra = fDrive->GetRa(); 333 // Float_t dec = fDrive->GetDec(); 318 334 319 fAstro.SetRaDec(ra, dec);320 fAstro.SetGuiActive();335 // fAstro.SetRaDec(ra, dec); 336 // fAstro.SetGuiActive(); 321 337 322 fAstro.FillStarList();338 // fAstro.FillStarList(); 323 339 } 324 340 else … … 336 352 } 337 353 338 DCPedestalCalc(fPedestalDC, fPedestalRMSDC); 339 fMinDCForStars = fMinDCForStars>(fPedestalDC+fDCTailCut*fPedestalRMSDC)?fMinDCForStars:(fPedestalDC+fDCTailCut*fPedestalRMSDC); 340 341 *fLog << dbg << " DC pedestal = " << fPedestalDC << " pedestal rms = " << fPedestalRMSDC << endl; 342 *fLog << dbg << " fMinDCForStars " << fMinDCForStars << endl; 343 344 // Find the star candidats searching the most brights pairs of pixels 345 Float_t maxPixelDC; 346 MGeomPix maxPixel; 347 348 while(FindPixelWithMaxDC(maxPixelDC, maxPixel)) 354 if (DCPedestalCalc()) 349 355 { 350 356 351 MStarLocalPos *starpos = new MStarLocalPos; 352 starpos->SetExpValues(maxPixelDC,maxPixel.GetX(),maxPixel.GetY()); 353 starpos->SetCalcValues(maxPixelDC,maxPixelDC,maxPixel.GetX(),maxPixel.GetY(),fRingInterest/2,fRingInterest/2); 354 starpos->SetFitValues(maxPixelDC,maxPixelDC,maxPixel.GetX(),maxPixel.GetY(),fRingInterest/2,fRingInterest/2,0.,1); 355 fStars->GetList()->Add(starpos); 356 357 ShadowStar(starpos); 357 Float_t innermin = fStars->GetInnerPedestalDC()+fDCTailCut*fStars->GetInnerPedestalRMSDC(); 358 Float_t outermin = fStars->GetOuterPedestalDC()+fDCTailCut*fStars->GetOuterPedestalRMSDC(); 359 fMinDCForStars = innermin>outermin?innermin:outermin; 360 if (fMinuitPrintOutLevel>=0) *fLog << dbg << "fMinDCForStars = " << fMinDCForStars << endl; 358 361 362 // Find the star candidats searching the most brights pairs of pixels 363 Float_t maxPixelDC; 364 MGeomPix maxPixel; 365 366 while(FindPixelWithMaxDC(maxPixelDC, maxPixel)) 367 { 368 369 MStarLocalPos *starpos = new MStarLocalPos; 370 starpos->SetExpValues(maxPixelDC,maxPixel.GetX(),maxPixel.GetY()); 371 starpos->SetCalcValues(maxPixelDC,maxPixelDC,maxPixel.GetX(),maxPixel.GetY(),fRingInterest/2,fRingInterest/2); 372 starpos->SetFitValues(maxPixelDC,maxPixelDC,maxPixel.GetX(),maxPixel.GetY(),fRingInterest/2,fRingInterest/2,0.,1); 373 fStars->GetList()->Add(starpos); 374 375 ShadowStar(starpos); 376 377 } 378 379 fDisplay.SetUsed(origPixelsUsed); 359 380 } 360 361 fDisplay.SetUsed(origPixelsUsed); 381 362 382 } 363 383 … … 366 386 { 367 387 *fLog << err << GetName() << " No stars candidates in the camera." << endl; 368 return k FALSE;388 return kCONTINUE; 369 389 } 370 390 else … … 390 410 //After finding stars reset all vairables 391 411 fDisplay.Reset(); 412 fStars->GetDisplay().Reset(); //FIXME: Put this display just in the container 392 413 fDisplay.SetUsed(origPixelsUsed); 393 414 fNumIntegratedEvents=0; … … 399 420 origPixelsUsed[pix]=(Char_t)kTRUE; 400 421 else 401 422 origPixelsUsed[pix]=(Char_t)kFALSE; 402 423 403 424 } … … 413 434 Int_t MFindStars::PostProcess() 414 435 { 415 if(fStars->GetList()->GetSize() != 0)416 fStars->Print();417 418 436 return kTRUE; 419 437 } … … 426 444 { 427 445 fPixelsUsed[blindpixels[idx]]=(Char_t)kFALSE; 428 *fLog << dbg << "MFindStars::SetBlindPixels fDisplay.IsUsed(" <<blindpixels[idx] << ") kFALSE" << endl;446 if (fMinuitPrintOutLevel>=0) *fLog << dbg << "MFindStars::SetBlindPixels fDisplay.IsUsed(" <<blindpixels[idx] << ") kFALSE" << endl; 429 447 } 430 448 … … 432 450 } 433 451 434 Bool_t MFindStars::DCPedestalCalc( Float_t &ped, Float_t &rms)452 Bool_t MFindStars::DCPedestalCalc() 435 453 { 436 454 //------------------------------------------------------------- … … 442 460 443 461 UInt_t numPixels = fGeomCam->GetNumPixels(); 444 445 TH1F dchist("dchist","",120,0.,30.*fMaxNumIntegratedEvents); 446 for (UInt_t pix=1; pix<numPixels; pix++) 447 dchist.Fill(fDisplay.GetBinContent(pix+1)); 448 449 Float_t nummaxprobdc = dchist.GetBinContent(dchist.GetMaximumBin()); 450 Float_t maxprobdc = dchist.GetBinCenter(dchist.GetMaximumBin()); 451 UInt_t bin = dchist.GetMaximumBin(); 452 do 453 { 454 bin++; 455 } 456 while(dchist.GetBinContent(bin)/nummaxprobdc > 0.5); 457 Float_t halfmaxprobdc = dchist.GetBinCenter(bin); 458 459 *fLog << dbg << " maxprobdc[high] " << maxprobdc << "[" << nummaxprobdc << "] "; 460 *fLog << dbg << " halfmaxprobdc[high] " << halfmaxprobdc << "[" << dchist.GetBinContent(bin) << "]" << endl; 461 462 Float_t rmsguess = TMath::Abs(maxprobdc-halfmaxprobdc); 463 Float_t min = maxprobdc-3*rmsguess; 464 min = (min<0.?0.:min); 465 Float_t max = maxprobdc+3*rmsguess; 466 467 *fLog << dbg << " maxprobdc " << maxprobdc << " rmsguess " << rmsguess << endl; 468 469 TF1 func("func","gaus",min,max); 470 func.SetParameters(nummaxprobdc, maxprobdc, rmsguess); 462 Float_t ped; 463 Float_t rms; 464 465 TH1F **dchist = new TH1F*[2]; 466 for (UInt_t i=0; i<2; i++) 467 dchist[i] = new TH1F("","",26,0.4*fMaxNumIntegratedEvents,3.*fMaxNumIntegratedEvents); 471 468 472 dchist.Fit("func","QR0"); 473 // Remove the comments if you want to go through the file 474 // event-by-event: 475 // HandleInput(); 476 477 UInt_t aproxnumdegrees = 6*(bin-dchist.GetMaximumBin()); 478 Float_t chiq = func.GetChisquare(); 479 ped = func.GetParameter(1); 480 rms = func.GetParameter(2); 481 482 *fLog << dbg << " ped " << ped << " rms " << rms << " chiq/ndof " << chiq << "/" << aproxnumdegrees << endl; 483 484 Int_t numsigmas = 5; 485 Axis_t minbin = ped-numsigmas*rms/dchist.GetBinWidth(1); 486 minbin=minbin<1?1:minbin; 487 Axis_t maxbin = ped+numsigmas*rms/dchist.GetBinWidth(1); 488 *fLog << dbg << " Number of pixels with dc under " << numsigmas << " sigmas = " << dchist.Integral((int)minbin,(int)maxbin) << endl; 489 490 //Check results from the fit are consistent 491 if (TMath::Abs(ped-maxprobdc) > rmsguess || rms > rmsguess) 492 { 493 *fLog << warn << GetName() << " Pedestal DC fit give non consistent results." << endl; 494 *fLog << warn << " maxprobdc " << maxprobdc << " rmsguess " << rmsguess << endl; 495 *fLog << warn << " ped " << ped << " rms " << rms << " chiq/ndof " << chiq << "/" << aproxnumdegrees << endl; 496 ped = maxprobdc; 497 rms = rmsguess/1.175; // FWHM=2.35*rms 498 } 499 500 //================================================================= 501 502 // reset gMinuit to the MINUIT object for optimizing the supercuts 503 gMinuit = savePointer; 504 //------------------------------------------- 505 469 for (UInt_t pix=1; pix<=lastInnerPixel; pix++) 470 dchist[0]->Fill(fDisplay.GetBinContent(pix+1)); 471 for (UInt_t pix=lastInnerPixel+1; pix<numPixels; pix++) 472 dchist[1]->Fill(fDisplay.GetBinContent(pix+1)); 473 474 // inner/outer pixels 475 for (UInt_t i=0; i<2; i++) 476 { 477 Float_t nummaxprobdc = dchist[i]->GetBinContent(dchist[i]->GetMaximumBin()); 478 Float_t maxprobdc = dchist[i]->GetBinCenter(dchist[i]->GetMaximumBin()); 479 UInt_t bin = dchist[i]->GetMaximumBin(); 480 do 481 { 482 bin++; 483 } 484 while(dchist[i]->GetBinContent(bin)/nummaxprobdc > 0.5); 485 Float_t halfmaxprobdc = dchist[i]->GetBinCenter(bin); 486 487 if (fMinuitPrintOutLevel>=0) *fLog << dbg << " maxprobdc[high] " << maxprobdc << "[" << nummaxprobdc << "] "; 488 if (fMinuitPrintOutLevel>=0) *fLog << dbg << " halfmaxprobdc[high] " << halfmaxprobdc << "[" << dchist[i]->GetBinContent(bin) << "]" << endl; 489 490 Float_t rmsguess = TMath::Abs(maxprobdc-halfmaxprobdc); 491 Float_t min = maxprobdc-3*rmsguess; 492 min = (min<0.?0.:min); 493 Float_t max = maxprobdc+3*rmsguess; 494 495 if (fMinuitPrintOutLevel>=0) *fLog << dbg << " maxprobdc " << maxprobdc << " rmsguess " << rmsguess << endl; 496 497 TF1 func("func","gaus",min,max); 498 func.SetParameters(nummaxprobdc, maxprobdc, rmsguess); 499 500 dchist[i]->Fit("func","QR0"); 501 502 UInt_t aproxnumdegrees = 6*(bin-dchist[i]->GetMaximumBin()); 503 Float_t chiq = func.GetChisquare(); 504 ped = func.GetParameter(1); 505 rms = func.GetParameter(2); 506 507 if (fMinuitPrintOutLevel>=0) *fLog << dbg << " ped " << ped << " rms " << rms << " chiq/ndof " << chiq << "/" << aproxnumdegrees << endl; 508 509 Int_t numsigmas = 5; 510 Axis_t minbin = ped-numsigmas*rms/dchist[i]->GetBinWidth(1); 511 minbin=minbin<1?1:minbin; 512 Axis_t maxbin = ped+numsigmas*rms/dchist[i]->GetBinWidth(1); 513 if (fMinuitPrintOutLevel>=0) *fLog << dbg << " Number of pixels with dc under " << numsigmas << " sigmas = " << dchist[i]->Integral((int)minbin,(int)maxbin) << endl; 514 515 //Check results from the fit are consistent 516 if (ped < 0. || rms < 0.) 517 { 518 *fLog << dbg << "dchist[i]->GetEntries()" << dchist[i]->GetEntries(); 519 // TCanvas *c1 = new TCanvas("c2","c2",500,800); 520 // dchist[i]->Draw(); 521 // c1->Print("dchist.ps"); 522 // delete c1; 523 // exit(1); 524 } 525 else if (TMath::Abs(ped-maxprobdc) > rmsguess || rms > rmsguess) 526 { 527 *fLog << warn << GetName() << " Pedestal DC fit give non consistent results for " << (i==0?"Inner":"Outer") << "pixels." << endl; 528 *fLog << warn << " maxprobdc " << maxprobdc << " rmsguess " << rmsguess << endl; 529 *fLog << warn << " ped " << ped << " rms " << rms << " chiq/ndof " << chiq << "/" << aproxnumdegrees << endl; 530 ped = maxprobdc; 531 rms = rmsguess/1.175; // FWHM=2.35*rms 532 } 533 534 if (i == 0) 535 { 536 fStars->SetInnerPedestalDC(ped); 537 fStars->SetInnerPedestalRMSDC(rms); 538 } 539 else 540 { 541 fStars->SetOuterPedestalDC(ped); 542 fStars->SetOuterPedestalRMSDC(rms); 543 } 544 545 546 547 } 548 549 550 for (UInt_t i=0; i<2; i++) 551 delete dchist[i]; 552 delete [] dchist; 553 554 //================================================================= 555 556 // reset gMinuit to the MINUIT object for optimizing the supercuts 557 gMinuit = savePointer; 558 //------------------------------------------- 559 560 if (fStars->GetInnerPedestalDC() < 0. || fStars->GetInnerPedestalRMSDC() < 0. || fStars->GetOuterPedestalDC() < 0. || fStars->GetOuterPedestalRMSDC() < 0.) 561 return kFALSE; 562 506 563 return kTRUE; 507 564 } … … 561 618 562 619 if (maxDC == 0) 620 { 621 *fLog << warn << " No found pixels with maximum dc" << endl; 563 622 return kFALSE; 564 623 } 624 565 625 maxPix = (*fGeomCam)[maxPixIdx[0]]; 566 626 567 *fLog << dbg << "Star candidate maxDC(" << setw(3) << maxDC << " uA) x position(" << setw(3) << maxPix.GetX() << " mm) x position(" << setw(3) << maxPix.GetY() << " mm) swnumber(" << maxPixIdx[0] << ")" << endl;627 if (fMinuitPrintOutLevel>=0) *fLog << dbg << "Star candidate maxDC(" << setw(3) << maxDC << " uA) x position(" << setw(3) << maxPix.GetX() << " mm) x position(" << setw(3) << maxPix.GetY() << " mm) swnumber(" << maxPixIdx[0] << ")" << endl; 568 628 569 629 return kTRUE; … … 574 634 575 635 UInt_t numPixels = fGeomCam->GetNumPixels(); 636 Float_t innerped = fStars->GetInnerPedestalDC(); 637 Float_t outerped = fStars->GetOuterPedestalDC(); 638 576 639 TArrayC origPixelsUsed; 577 640 origPixelsUsed.Set(numPixels); … … 589 652 590 653 Float_t max=0; 654 UInt_t pixmax=0; 591 655 Float_t meanX=0; 592 656 Float_t meanY=0; … … 594 658 Float_t meanSqY=0; 595 659 Float_t sumCharge=0; 596 UInt_t usedPx=0; 660 UInt_t usedInnerPx=0; 661 UInt_t usedOuterPx=0; 597 662 598 663 const Float_t meanPresition = 3.; //[mm] … … 620 685 621 686 // determine mean x and mean y 622 usedPx=0; 687 usedInnerPx=0; 688 usedOuterPx=0; 623 689 for(UInt_t pix=0; pix<numPixels; pix++) 624 690 { 625 691 if(fDisplay.IsUsed(pix)) 626 692 { 627 usedPx++;693 pix>lastInnerPixel?usedOuterPx++:usedInnerPx++; 628 694 629 695 Float_t charge = fDisplay.GetBinContent(pix+1); … … 631 697 Float_t pixYpos = (*fGeomCam)[pix].GetY(); 632 698 633 if (charge>max) max=charge; 699 if (charge>max) 700 { 701 max=charge; 702 pixmax=pix; 703 } 704 634 705 meanX += charge*pixXpos; 635 706 meanY += charge*pixYpos; … … 640 711 } 641 712 642 *fLog << dbg << " usedPx " << usedPx << endl;713 if (fMinuitPrintOutLevel>=0) *fLog << dbg << " usedInnerPx " << usedInnerPx << " usedOuterPx " << usedOuterPx << endl; 643 714 644 715 meanX /= sumCharge; … … 680 751 681 752 // Substrack pedestal DC 682 sumCharge-= fPedestalDC*usedPx;683 max-= fPedestalDC;753 sumCharge-= (usedInnerPx*innerped+usedOuterPx*outerped)/(usedInnerPx+usedOuterPx); 754 max-=pixmax>lastInnerPixel?outerped:innerped; 684 755 685 756 … … 695 766 for (UInt_t pix=1; pix<numPixels; pix++) 696 767 if (fDisplay.IsUsed(pix)) 697 *fLog << dbg << "[fit the star spot] fDisplay.IsUsed(" << pix << ") kTRUE" << endl; 698 768 if (fMinuitPrintOutLevel>=0) *fLog << dbg << "[fit the star spot] fDisplay.IsUsed(" << pix << ") kTRUE" << endl; 769 770 if (fMinuitPrintOutLevel>=0) *fLog << dbg << "fMinDCForStars " << fMinDCForStars << " pixmax>lastInnerPixel?outerped:innerped " << (pixmax>lastInnerPixel?outerped:innerped) << " fMaxNumIntegratedEvents " << fMaxNumIntegratedEvents << endl; 771 699 772 //Initialate variables for fit 700 773 fVinit[0] = max; 701 fLimlo[0] = fMinDCForStars- fPedestalDC;702 fLimup[0] = 30*fMaxNumIntegratedEvents- fPedestalDC;774 fLimlo[0] = fMinDCForStars-(pixmax>lastInnerPixel?outerped:innerped); 775 fLimup[0] = 30*fMaxNumIntegratedEvents-(pixmax>lastInnerPixel?outerped:innerped); 703 776 fVinit[1] = meanX; 704 777 fVinit[2] = rmsX; … … 707 780 //Init steps 708 781 for(Int_t i=0; i<fNumVar; i++) 782 { 709 783 if (fVinit[i] != 0) 710 784 fStep[i] = TMath::Abs(fVinit[i]/sqrt2); 785 if (fMinuitPrintOutLevel>=0) *fLog << dbg << " fVinit[" << i << "] " << fVinit[i]; 786 if (fMinuitPrintOutLevel>=0) *fLog << dbg << " fStep[" << i << "] " << fStep[i]; 787 if (fMinuitPrintOutLevel>=0) *fLog << dbg << " fLimlo[" << i << "] " << fLimlo[i]; 788 if (fMinuitPrintOutLevel>=0) *fLog << dbg << " fLimup[" << i << "] " << fLimup[i] << endl; 789 } 711 790 // 712 791 … … 732 811 if(fMinuitPrintOutLevel>=0) 733 812 { 734 *fLog << dbg << "Time spent for the minimization in MINUIT : " << endl;;813 if (fMinuitPrintOutLevel>=0) *fLog << dbg << "Time spent for the minimization in MINUIT : " << endl;; 735 814 clock.Print(); 736 815 } … … 807 886 } 808 887 809 *fLog << dbg << " shadowPx " << shadowPx << endl;888 if (fMinuitPrintOutLevel>=0) *fLog << dbg << " shadowPx " << shadowPx << endl; 810 889 811 890 fDisplay.SetUsed(fPixelsUsed); -
trunk/MagicSoft/Mars/mtemp/MFindStars.h
r4051 r4294 41 41 MStarLocalCam *fStars; 42 42 43 MAstroCamera fAstro;43 // MAstroCamera fAstro; 44 44 TArrayC fPixelsUsed; 45 45 MHCamera fDisplay; … … 51 51 Float_t fMinDCForStars; //[uA] 52 52 53 Float_t fPedestalDC; //[ua] 54 Float_t fPedestalRMSDC; //[ua] 53 Float_t fDCTailCut; 55 54 56 55 //Fitting(Minuit) variables … … 58 57 Float_t fTempChisquare; 59 58 Int_t fTempDegreesofFreedom; 59 Int_t fMinuitPrintOutLevel; 60 60 61 61 TString *fVname; … … 69 69 Bool_t fNulloutput; 70 70 71 Bool_t DCPedestalCalc( Float_t &ped, Float_t &rms);71 Bool_t DCPedestalCalc(); 72 72 Bool_t FindPixelWithMaxDC(Float_t &maxDC, MGeomPix &maxPix); 73 73 Bool_t FindStar(MStarLocalPos* star); … … 81 81 Int_t Process(); 82 82 Int_t PostProcess(); 83 83 84 // setters 84 85 void SetNumIntegratedEvents(UInt_t max) {fMaxNumIntegratedEvents=max;} 85 86 void SetRingInterest(Float_t ring) {fRingInterest=ring;} 86 87 void SetBlindPixels(TArrayS blindpixels); 88 void SetMinuitPrintOutLevel(Int_t level) {fMinuitPrintOutLevel=level;} 89 void SetDCTailCut(Float_t cut) {fDCTailCut=cut;} 87 90 88 91 void SetChisquare(Float_t chi) {fTempChisquare=chi;} 89 92 void SetDegreesofFreedom(Int_t free) {fTempDegreesofFreedom=free;} 90 93 91 MHCamera* GetDisplay() { return &fDisplay; } 92 Float_t GetPedestalDC() { return fPedestalDC; } 93 Float_t GetPedestalRMSDC() { return fPedestalRMSDC; } 94 //Getters 95 MHCamera& GetDisplay() { return fDisplay; } 94 96 95 97 Float_t GetChisquare() {return fTempChisquare;} 96 98 Int_t GetDegreesofFreedom() {return fTempDegreesofFreedom;} 97 99 UInt_t GetNumIntegratedEvents() {return fMaxNumIntegratedEvents;} 100 Float_t GetRingInterest() {return fRingInterest;} 98 101 99 102 ClassDef(MFindStars, 0) // Tool to find stars from DC Currents -
trunk/MagicSoft/Mars/mtemp/MStarLocalCam.cc
r4051 r4294 53 53 54 54 fStars = new TList; 55 56 fInnerPedestalDC = 0.; 57 fOuterPedestalDC = 0.; 58 fInnerPedestalRMSDC = 0.; 59 fOuterPedestalRMSDC = 0.; 60 55 61 } 56 62 … … 67 73 MStarLocalPos &MStarLocalCam::operator[] (Int_t i) 68 74 { 69 return *static_cast<MStarLocalPos*>(fStars->At(i)); 75 MStarLocalPos& star = *static_cast<MStarLocalPos*>(fStars->At(i)); 76 return star; 70 77 } 71 78 … … 89 96 void MStarLocalCam::Print(Option_t *o) const 90 97 { 91 TIter Next(fStars); 92 MStarLocalPos* star; 93 UInt_t starnum = 0; 94 while ((star=(MStarLocalPos*)Next())) 95 { 96 *fLog << inf << "Star[" << starnum << "] info:" << endl; 97 star->Print(o); 98 starnum++; 99 } 98 *fLog << inf << "DCs baseline:" << endl; 99 *fLog << inf << " Inner Pixels Mean pedestal \t" << setw(4) << fInnerPedestalDC << " uA and RMS " << setw(4) << fInnerPedestalRMSDC << " uA for DCs" << endl; 100 *fLog << inf << " Outer Pixels Mean pedestal \t" << setw(4) << fOuterPedestalDC << " uA and RMS " << setw(4) << fOuterPedestalRMSDC << " uA for DCs" << endl; 101 102 TIter Next(fStars); 103 MStarLocalPos* star; 104 UInt_t starnum = 0; 105 while ((star=(MStarLocalPos*)Next())) 106 { 107 *fLog << inf << "Star[" << starnum << "] info:" << endl; 108 star->Print(o); 109 starnum++; 110 } 100 111 } -
trunk/MagicSoft/Mars/mtemp/MStarLocalCam.h
r4051 r4294 5 5 #include "MParContainer.h" 6 6 #endif 7 #ifndef MARS_MCamEvent 8 #include "MCamEvent.h" 7 8 #ifndef MARS_MHCamera 9 #include "MHCamera.h" 9 10 #endif 10 11 … … 20 21 TList *fStars; //-> FIXME: Change TClonesArray away from a pointer? 21 22 22 public: 23 // BaseLine DCs info 24 Float_t fInnerPedestalDC; //[ua] 25 Float_t fOuterPedestalDC; //[ua] 26 27 Float_t fInnerPedestalRMSDC; //[ua] 28 Float_t fOuterPedestalRMSDC; //[ua] 29 30 MHCamera fDisplay; 31 32 public: 23 33 24 34 MStarLocalCam(const char *name=NULL, const char *title=NULL); … … 29 39 30 40 TList *GetList() const { return fStars; } 41 UInt_t GetNumStars() const { return fStars->GetSize(); } 42 43 //Getters 44 45 Float_t GetInnerPedestalDC() {return fInnerPedestalDC;} 46 Float_t GetOuterPedestalDC() {return fOuterPedestalDC;} 47 Float_t GetInnerPedestalRMSDC() { return fInnerPedestalRMSDC;} 48 Float_t GetOuterPedestalRMSDC() { return fOuterPedestalRMSDC;} 49 50 MHCamera& GetDisplay() { return fDisplay; } 51 52 //Setters 53 void SetInnerPedestalDC(Float_t ped) {fInnerPedestalDC = ped;} 54 void SetOuterPedestalDC(Float_t ped) {fOuterPedestalDC = ped;} 55 void SetInnerPedestalRMSDC(Float_t rms){fInnerPedestalRMSDC = rms;} 56 void SetOuterPedestalRMSDC(Float_t rms){fOuterPedestalRMSDC = rms;} 31 57 32 58 void Paint(Option_t *o=NULL); -
trunk/MagicSoft/Mars/mtemp/MStarLocalPos.cc
r4051 r4294 68 68 fSigmaMajorAxisFit = 0.; 69 69 fChiSquare = 0.; 70 fNdof = 0;70 fNdof = 1; 71 71 72 72 } -
trunk/MagicSoft/Mars/mtemp/MStarLocalPos.h
r4053 r4294 59 59 Float_t GetSigmaMajorAxisFit() {return fSigmaMajorAxisFit;} 60 60 Float_t GetChiSquare() {return fChiSquare;} 61 Float_t GetNdof() {return fNdof;}61 UInt_t GetNdof() {return fNdof;} 62 62 Float_t GetChiSquareNdof() {return fChiSquare/fNdof;} 63 63 -
trunk/MagicSoft/Mars/mtemp/mifae/Changelog
r4293 r4294 18 18 19 19 -*-*- END OF LINE -*-*- 20 21 2004/06/15 Javier Lopez 22 * library/MSrcPosFromStars.[h,cc] 23 - Task to compute the position of a source from 24 the positions of several stars. 25 26 * library/MHPSFFromStars.[h,cc] 27 - Histogram task that holds and fills the histograms of 28 positioning and point spread function of an star. 29 30 * macros/distancebetweenstars.C 31 - Add macros that show in an histogram the distance between 32 the stars in a field of view. 33 34 * macros/psffromstars.C 35 - Add task that show the point spread funtion and positon of 36 the most central star in the field of view. This information 37 is compute using the MFindStars tool. 20 38 21 39 2004/06/11 Ester Aliu -
trunk/MagicSoft/Mars/mtemp/mifae/library/IFAELinkDef.h
r4117 r4294 18 18 #pragma link C++ class MFHVNotNominal+; 19 19 #pragma link C++ class MCalibrateDC+; 20 #pragma link C++ class MHPSFFromStars+; 21 #pragma link C++ class MSrcPosFromStars+; 20 22 21 23 #endif -
trunk/MagicSoft/Mars/mtemp/mifae/library/MCalibrateDC.cc
r4075 r4294 51 51 using namespace std; 52 52 53 MCalibrateDC::MCalibrateDC(TString filename, const char *name, const char *title) : fMinDCAllowed(0.5) //[ua]53 MCalibrateDC::MCalibrateDC(TString filename, const char *name, const char *title) 54 54 { 55 55 fName = name ? name : "MCalibrateDC"; -
trunk/MagicSoft/Mars/mtemp/mifae/library/Makefile
r4117 r4294 44 44 -I../../../mcamera \ 45 45 -I../../../mastro \ 46 -I../../../mhist 46 -I../../../mhist \ 47 -I../../ 47 48 48 49 … … 60 61 MIslandClean.cc \ 61 62 MFHVNotNominal.cc \ 62 MCalibrateDC.cc 63 MCalibrateDC.cc \ 64 MHPSFFromStars.cc \ 65 MSrcPosFromStars.cc 63 66 64 67 ############################################################ -
trunk/MagicSoft/Mars/mtemp/mifae/macros/findstars.C
r4075 r4294 47 47 48 48 49 void findstars(const TString filename="dc_2004_03_1 9_00_36_50_20781_Mrk421.root", const TString directory="/nfs/magic/CaCodata/rootdata/Mrk421/Period015/2004_03_19/", const UInt_t numEvents = 0)49 void findstars(const TString filename="dc_2004_03_17_01_16_51_20440_Mrk421.root", const TString directory="/nfs/magic/CaCodata/rootdata/Mrk421/Period015/2004_03_17/", const UInt_t numEvents = 0) 50 50 { 51 51 … … 81 81 MGeomApply geomapl; 82 82 TString continuoslightfile = 83 "/nfs/magic/CaCodata/rootdata/Miscellaneous/Period016/2004_04_16/dc_2004_04_16_04_46_18_22368_Off3c279-2CL100.root"; 83 // "/home/Javi/mnt_magic_data/CaCo/rootdata/Miscellaneous/Period016/2004_04_16/dc_2004_04_16_04_46_18_22368_Off3c279-2CL100.root"; 84 "/nfs/magic/CaCodata/rootdata/Miscellaneous/Period016/2004_04_16/dc_2004_04_16_04_46_18_22368_Off3c279-2CL100.root"; 85 86 Float_t mindc = 0.9; //[uA] 84 87 MCalibrateDC dccal; 85 88 dccal.SetFileName(continuoslightfile); 86 89 dccal.SetMinDCAllowed(mindc); 87 90 88 const Int_t numblind = 12; 89 const Short_t x[numblind] = { 8, 27, 90 507, 508, 509, 510, 511, 91 543, 559, 560, 561, 567}; 91 const Int_t numblind = 5; 92 const Short_t x[numblind] = { 47, 124, 470, 475, 571}; 92 93 const TArrayS blindpixels(numblind,(Short_t*)x); 93 94 Float_t ringinterest = 100; //[mm] 94 Float_t tailcut = 3.5;95 UInt_t integratedevents = 1 0;95 Float_t tailcut = 2.5; 96 UInt_t integratedevents = 1; 96 97 97 98 MFindStars findstars; 98 //findstars.SetBlindPixels(blindpixels);99 findstars.SetBlindPixels(blindpixels); 99 100 findstars.SetRingInterest(ringinterest); 100 101 findstars.SetDCTailCut(tailcut); 101 102 findstars.SetNumIntegratedEvents(integratedevents); 102 findstars.SetMinuitPrintOutLevel( 0);103 findstars.SetMinuitPrintOutLevel(-1); 103 104 104 // prints105 MPrint pdc("MCameraDC");106 MPrint pstar("MStarLocalCam");107 105 108 106 tlist.AddToList(&geomapl); 109 107 tlist.AddToList(&read); 110 108 tlist.AddToList(&dccal); 111 // tlist.AddToList(&pdc, "Currents");112 109 tlist.AddToList(&findstars, "Currents"); 113 // tlist.AddToList(&pstar, "Currents");114 110 115 111 //
Note:
See TracChangeset
for help on using the changeset viewer.