Changeset 3682 for trunk/MagicSoft/Mars/mhist
- Timestamp:
- 04/08/04 19:52:13 (21 years ago)
- Location:
- trunk/MagicSoft/Mars/mhist
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mhist/MHFalseSource.cc
r3666 r3682 46 46 // pads) you can change the AlphaCut 'online' 47 47 // 48 // Each Z-Projection (Alpha-histogram) is scaled such, that the number 49 // of entries fits the maximum number of entries in all Z-Projections. 50 // This should correct for the different acceptance in the center 51 // and at the vorder of the camera. This, however, produces more noise 52 // at the border. 53 // 48 54 // Here is a slightly simplified version of the algorithm: 49 55 // ------------------------------------------------------ … … 139 145 // 140 146 MHFalseSource::MHFalseSource(const char *name, const char *title) 141 : fTime(0), fPointPos(0), fObservatory(0), fMm2Deg(-1), 142 fAlphaCut(12.5), fBgMean(55), fDistMin(-1), fDistMax(-1)147 : fTime(0), fPointPos(0), fObservatory(0), fMm2Deg(-1), fAlphaCut(12.5), 148 fBgMean(55), fMinDist(-1), fMaxDist(-1), fMinLD(-1), fMaxLD(-1) 143 149 { 144 150 // … … 155 161 fHist.SetYTitle("y [\\circ]"); 156 162 fHist.SetZTitle("\\alpha [\\circ]"); 163 } 164 165 void MHFalseSource::MakeSymmetric(TH1 *h) 166 { 167 const Float_t min = TMath::Abs(h->GetMinimum()); 168 const Float_t max = TMath::Abs(h->GetMaximum()); 169 170 const Float_t absmax = TMath::Max(min, max)*1.002; 171 172 h->SetMaximum( absmax); 173 h->SetMinimum(-absmax); 157 174 } 158 175 … … 337 354 // and/or MTaskList 338 355 // Source dependant distance cut 339 if (f DistMin>0 && hsrc.GetDist()*fMm2Deg<fDistMin)356 if (fMinDist>0 && hsrc.GetDist()*fMm2Deg<fMinDist) 340 357 continue; 341 342 if (fDistMax>0 && hil->GetLength()>fDistMax*hsrc.GetDist()) 358 if (fMaxDist>0 && hsrc.GetDist()*fMm2Deg>fMaxDist) 359 continue; 360 361 if (fMaxLD>0 && hil->GetLength()>fMaxLD*hsrc.GetDist()) 362 continue; 363 if (fMinLD>0 && hil->GetLength()<fMinLD*hsrc.GetDist()) 343 364 continue; 344 365 … … 358 379 // the same number of bins than for on-data 359 380 // 360 void MHFalseSource::ProjectOff(TH2D *h2 )381 void MHFalseSource::ProjectOff(TH2D *h2, TH2D *all) 361 382 { 362 383 TAxis &axe = *fHist.GetZaxis(); … … 379 400 // Move contents from projection to h2 380 401 h2->Reset(); 381 h2->Add(p); 402 h2->Add(p, all->GetMaximum()); 403 h2->Divide(all); 382 404 383 405 // Delete p … … 393 415 // range (0, fAlphaCut) 394 416 // 395 void MHFalseSource::ProjectOn(TH2D *h3 )417 void MHFalseSource::ProjectOn(TH2D *h3, TH2D *all) 396 418 { 397 419 TAxis &axe = *fHist.GetZaxis(); … … 410 432 // Move contents from projection to h3 411 433 h3->Reset(); 412 h3->Add(p); 434 h3->Add(p, all->GetMaximum()); 435 h3->Divide(all); 436 437 // Delete p 413 438 delete p; 414 439 … … 454 479 TH2D* h3; 455 480 TH2D* h4; 481 TH2D* h5; 456 482 457 483 // Update projection of all-events 458 padsave->GetPad( 1)->cd(3);484 padsave->GetPad(2)->cd(3); 459 485 if ((h0 = (TH2D*)gPad->FindObject("Alpha_yx_all"))) 460 486 ProjectAll(h0); 461 487 488 // Update projection of on-events 489 padsave->GetPad(1)->cd(1); 490 if ((h3 = (TH2D*)gPad->FindObject("Alpha_yx_on"))) 491 ProjectOn(h3, h0); 492 462 493 // Update projection of off-events 463 padsave->GetPad( 2)->cd(1);494 padsave->GetPad(1)->cd(3); 464 495 if ((h2 = (TH2D*)gPad->FindObject("Alpha_yx_off"))) 465 ProjectOff(h2); 466 467 // Update projection of on-events 496 ProjectOff(h2, h0); 497 468 498 padsave->GetPad(2)->cd(2); 469 if ((h3 = (TH2D*)gPad->FindObject("Alpha_yx_on"))) 470 ProjectOn(h3); 499 if ((h5 = (TH2D*)gPad->FindObject("Alpha_yx_diff"))) 500 { 501 h5->Add(h3, h2, -1); 502 MakeSymmetric(h5); 503 } 471 504 472 505 // Update projection of significance 473 padsave->GetPad( 2)->cd(3);506 padsave->GetPad(1)->cd(2); 474 507 if (h2 && h3 && (h4 = (TH2D*)gPad->FindObject("Alpha_yx_sig"))) 475 508 { … … 483 516 Int_t max = h4->GetBin(nx, ny); 484 517 485 for (int ix= 0; ix<nx; ix++)486 for (int iy= 0; iy<ny; iy++)518 for (int ix=1; ix<=nx; ix++) 519 for (int iy=1; iy<=ny; iy++) 487 520 { 488 const Int_t n = h4->GetBin(ix +1, iy+1);521 const Int_t n = h4->GetBin(ix, iy); 489 522 490 523 const Double_t s = h3->GetBinContent(n); … … 503 536 } 504 537 538 MakeSymmetric(h4); 539 505 540 // Update projection of 'the best alpha-plot' 506 padsave->GetPad( 1)->cd(1);541 padsave->GetPad(2)->cd(1); 507 542 if ((h1 = (TH1D*)gPad->FindObject("Alpha")) && max>0) 508 543 { … … 560 595 TObject *catalog = GetCatalog(); 561 596 562 // draw the 2D histogram Sigmabar versus Theta597 // Initialize upper part 563 598 pad->cd(1); 564 599 gPad->SetBorderMode(0); 565 600 gPad->Divide(3, 1); 566 delete pad->GetPad(1)->GetPad(2); 567 568 pad->GetPad(1)->cd(3); 569 gPad->SetBorderMode(0); 570 TH1 *h0 = fHist.Project3D("yx_all"); 571 h0->SetDirectory(NULL); 572 h0->SetXTitle(fHist.GetXaxis()->GetTitle()); 573 h0->SetYTitle(fHist.GetYaxis()->GetTitle()); 574 h0->Draw("colz"); 575 h0->SetBit(kCanDelete); 576 catalog->Draw("mirror same"); 577 601 602 // PAD #1 578 603 pad->GetPad(1)->cd(1); 579 gPad->SetBorderMode(0);580 581 TH1 *h1 = fHist.ProjectionZ("Alpha");582 h1->SetDirectory(NULL);583 h1->SetTitle("Distribution of \\alpha");584 h1->SetXTitle(fHist.GetZaxis()->GetTitle());585 h1->SetYTitle("Counts");586 h1->Draw(opt);587 h1->SetBit(kCanDelete);588 589 pad->cd(2);590 gPad->SetBorderMode(0);591 gPad->Divide(3, 1);592 593 pad = gPad;594 595 pad->cd(1);596 gPad->SetBorderMode(0);597 fHist.GetZaxis()->SetRangeUser(fBgMean-fAlphaCut/2, fBgMean+fAlphaCut/2);598 TH1 *h2 = fHist.Project3D("yx_off");599 h2->SetDirectory(NULL);600 h2->SetXTitle(fHist.GetXaxis()->GetTitle());601 h2->SetYTitle(fHist.GetYaxis()->GetTitle());602 h2->Draw("colz");603 h2->SetBit(kCanDelete);604 catalog->Draw("mirror same");605 606 pad->cd(2);607 604 gPad->SetBorderMode(0); 608 605 fHist.GetZaxis()->SetRangeUser(0,fAlphaCut); … … 616 613 catalog->Draw("mirror same"); 617 614 618 pad->cd(3); 615 // PAD #2 616 pad->GetPad(1)->cd(2); 619 617 gPad->SetBorderMode(0); 620 618 fHist.GetZaxis()->SetRange(0,0); … … 627 625 h4->Draw("colz"); 628 626 h4->SetBit(kCanDelete); 627 catalog->Draw("mirror same"); 628 629 // PAD #3 630 pad->GetPad(1)->cd(3); 631 gPad->SetBorderMode(0); 632 fHist.GetZaxis()->SetRangeUser(fBgMean-fAlphaCut/2, fBgMean+fAlphaCut/2); 633 TH1 *h2 = fHist.Project3D("yx_off"); 634 h2->SetDirectory(NULL); 635 h2->SetXTitle(fHist.GetXaxis()->GetTitle()); 636 h2->SetYTitle(fHist.GetYaxis()->GetTitle()); 637 h2->Draw("colz"); 638 h2->SetBit(kCanDelete); 639 catalog->Draw("mirror same"); 640 641 // Initialize lower part 642 pad->cd(2); 643 gPad->SetBorderMode(0); 644 gPad->Divide(3, 1); 645 646 // PAD #4 647 pad->GetPad(2)->cd(1); 648 gPad->SetBorderMode(0); 649 TH1 *h1 = fHist.ProjectionZ("Alpha"); 650 h1->SetDirectory(NULL); 651 h1->SetTitle("Distribution of \\alpha"); 652 h1->SetXTitle(fHist.GetZaxis()->GetTitle()); 653 h1->SetYTitle("Counts"); 654 h1->Draw(opt); 655 h1->SetBit(kCanDelete); 656 657 // PAD #5 658 pad->GetPad(2)->cd(2); 659 gPad->SetBorderMode(0); 660 TH1 *h5 = (TH1*)h3->Clone("Alpha_yx_diff"); 661 h5->Add(h2, -1); 662 h5->SetTitle("Difference of on- and off-distribution"); 663 h5->SetDirectory(NULL); 664 h5->Draw("colz"); 665 h5->SetBit(kCanDelete); 666 catalog->Draw("mirror same"); 667 668 // PAD #6 669 pad->GetPad(2)->cd(3); 670 gPad->SetBorderMode(0); 671 TH1 *h0 = fHist.Project3D("yx_all"); 672 h0->SetDirectory(NULL); 673 h0->SetXTitle(fHist.GetXaxis()->GetTitle()); 674 h0->SetYTitle(fHist.GetYaxis()->GetTitle()); 675 h0->Draw("colz"); 676 h0->SetBit(kCanDelete); 629 677 catalog->Draw("mirror same"); 630 678 } … … 729 777 Form("Fit Region: Signal<%.1f\\circ, %.1f\\circ<Bg<%.1f\\circ", 730 778 sigmax, bgmin, bgmax)); 731 hists->SetName Title("Excess", Form("Number of excess events for \\alpha<%.0f\\circ", sigint));732 histb->SetName Title("Background", Form("Number of background events for \\alpha<%.0f\\circ", sigint));779 hists->SetName("Excess"); 780 histb->SetName("Background"); 733 781 hist->SetXTitle(fHist.GetXaxis()->GetTitle()); 734 782 hists->SetXTitle(fHist.GetXaxis()->GetTitle()); … … 776 824 *fLog << "Polynom order: " << (int)polynom << endl; 777 825 *fLog << "Fitting False Source Plot..." << flush; 826 827 TH1 *h0 = fHist.Project3D("yx_entries"); 828 Float_t entries = h0->GetMaximum(); 829 delete h0; 778 830 779 831 TH1 *h=0; … … 790 842 if (alpha0==0) 791 843 continue; 844 845 h->Scale(entries/h->GetEntries()); 792 846 793 847 if (alpha0>maxalpha0) … … 887 941 h0b.GetXaxis()->SetRangeUser(0, maxalpha0*1.5); 888 942 943 hists->SetTitle(Form("Excess events for \\alpha<%.0f\\circ (N_{max}=%d)", sigint, (int)hists->GetMaximum())); 944 histb->SetTitle(Form("Background events for \\alpha<%.0f\\circ", sigint)); 945 889 946 //hists->SetMinimum(GetMinimumGT(*hists)); 890 947 histb->SetMinimum(GetMinimumGT(*histb)); 948 949 MakeSymmetric(hists); 950 MakeSymmetric(hist); 891 951 892 952 clk.Stop(); … … 950 1010 951 1011 TH1 *result = fHist.ProjectionZ("AlphaFit", maxx, maxx, maxy, maxy); 1012 result->Scale(entries/h->GetEntries()); 1013 952 1014 result->SetDirectory(NULL); 953 1015 result->SetNameTitle("Result \\alpha", title); -
trunk/MagicSoft/Mars/mhist/MHFalseSource.h
r3666 r3682 29 29 Float_t fBgMean; // Background mean 30 30 31 Float_t fDistMin; // Min dist 32 Float_t fDistMax; // Maximum distance in percent of dist 31 Float_t fMinDist; // Min dist 32 Float_t fMaxDist; // Max dist 33 34 Float_t fMinLD; // Minimum distance in percent of dist 35 Float_t fMaxLD; // Maximum distance in percent of dist 33 36 34 37 TH3D fHist; // Alpha vs. x and y … … 40 43 void Modified(); 41 44 42 void ProjectOff(TH2D *h);43 void ProjectOn(TH2D *h);44 45 void ProjectAll(TH2D *h); 46 void ProjectOff(TH2D *h, TH2D *all); 47 void ProjectOn(TH2D *h, TH2D *all); 45 48 46 49 TObject *GetCatalog(); 50 51 void MakeSymmetric(TH1 *h); 47 52 48 53 public: … … 57 62 void FitSignificanceStd() { FitSignificance(); } //*MENU* 58 63 59 void SetDistMin(Float_t dist) { fDistMin = dist; } // Absolute minimum distance 60 void SetDistMax(Float_t ratio) { fDistMax = ratio; } // Maximum ratio between length/dist 64 void SetMinDist(Float_t dist) { fMinDist = dist; } // Absolute minimum distance 65 void SetMaxDist(Float_t dist) { fMaxDist = dist; } // Absolute maximum distance 66 void SetMinLD(Float_t ratio) { fMinLD = ratio; } // Minimum ratio between length/dist 67 void SetMaxLD(Float_t ratio) { fMaxLD = ratio; } // Maximum ratio between length/dist 61 68 62 69 void SetAlphaCut(Float_t alpha); //*MENU*
Note:
See TracChangeset
for help on using the changeset viewer.