Changeset 5901
- Timestamp:
- 01/19/05 13:17:09 (20 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r5900 r5901 21 21 -*-*- END OF LINE -*-*- 22 22 23 2205/01/19 Abelardo Moralejo 23 2005/01/19 Thomas Bretz 24 25 * mbase/MMath.cc: 26 - added a comment to SignificanceLiMa, made by Daniel Mazin 27 - also check for b==0 28 29 * mhflux/MAlphaFitter.[h,cc]: 30 - fixed significance calculation in case of on-off data 31 - added fScaleFactor 32 33 * mhflux/MHAlpha.[h,cc], mhflux/MHFalseSource.cc: 34 - handle scale factor in case of on-off observations 35 36 37 38 2005/01/19 Abelardo Moralejo 24 39 25 40 * mtrigger/MFTriggerPattern.[cc,h] … … 27 42 defined by N. Galante (see below) 28 43 29 2205/01/19 Nicola Galante 44 45 46 2005/01/19 Nicola Galante 30 47 31 48 * mtrigger/MFTriggerPattern.[cc,h] … … 35 52 - fixed a bug in Process, both fMaskRequiredUnprescaled and 36 53 fMaskRequiredPrescaled are checked simultaneously. 54 37 55 38 56 -
trunk/MagicSoft/Mars/mbase/MMath.cc
r5883 r5901 70 70 // 71 71 // Returns -1 if sum<0 or alpha<0 or the argument of sqrt<0 72 // Returns 0 if s+b==0 or s==0 72 // Returns 0 if s+b==0, s==0 or b==0 73 // 74 // Here is some eMail written by Daniel Mazin about the meaning of the arguments: 75 // 76 // > Ok. Here is my understanding: 77 // > According to Li&Ma paper (correctly cited in MMath.cc) alpha is the 78 // > scaling factor. The mathematics behind the formula 17 (and/or 9) implies 79 // > exactly this. If you scale OFF to ON first (using time or using any other 80 // > method), then you cannot use formula 17 (9) anymore. You can just try 81 // > the formula before scaling (alpha!=1) and after scaling (alpha=1), you 82 // > will see the result will be different. 83 // 84 // > Here are less mathematical arguments: 85 // 86 // > 1) the better background determination you have (smaller alpha) the more 87 // > significant is your excess, thus your analysis is more sensitive. If you 88 // > normalize OFF to ON first, you loose this sensitivity. 89 // 90 // > 2) the normalization OFF to ON has an error, which naturally depends on 91 // > the OFF and ON. This error is propagating to the significance of your 92 // > excess if you use the Li&Ma formula 17 correctly. But if you normalize 93 // > first and use then alpha=1, the error gets lost completely, you loose 94 // > somehow the criteria of goodness of the normalization. 73 95 // 74 96 Double_t MMath::SignificanceLiMa(Double_t s, Double_t b, Double_t alpha) … … 76 98 const Double_t sum = s+b; 77 99 78 if (s==0 || sum==0)100 if (s==0 || b==0 || sum==0) 79 101 return 0; 80 102 -
trunk/MagicSoft/Mars/mhflux/MAlphaFitter.cc
r5776 r5901 65 65 fChiSqBg=0; 66 66 fIntegralMax=0; 67 fScaleFactor=1; 67 68 68 69 fCoefficients.Reset(); … … 210 211 } 211 212 212 Bool_t MAlphaFitter::Fit(TH1D &hon, TH1D &hof, Bool_t paint)213 Bool_t MAlphaFitter::Fit(TH1D &hon, TH1D &hof, Double_t alpha, Bool_t paint) 213 214 { 214 215 /* … … 224 225 fit.SetPolynomOrder(1); 225 226 226 if ( !fit.Fit(h, paint))227 if (alpha<=0 || !fit.Fit(h, paint)) 227 228 return kFALSE; 228 229 … … 237 238 fEventsSignal = hon.Integral(0, bin); 238 239 fEventsExcess = fEventsSignal-fEventsBackground; 239 fSignificance = MMath::SignificanceLiMaSigned(fEventsSignal, fEventsBackground); 240 fScaleFactor = alpha; 241 fSignificance = MMath::SignificanceLiMaSigned(fEventsSignal, fEventsBackground/alpha, alpha); 240 242 241 243 if (fEventsExcess<0) … … 399 401 h0->SetDirectory(0); 400 402 401 Scale(*h0, *h1); 402 403 const Bool_t rc = Fit(*h1, *h0, paint); 403 const Bool_t rc = ScaleAndFit(*h1, h0, paint); 404 404 405 405 delete h0; … … 419 419 h0->SetDirectory(0); 420 420 421 Scale(*h0, *h1); 422 423 const Bool_t rc = Fit(*h1, *h0, paint); 421 const Bool_t rc = ScaleAndFit(*h1, h0, paint); 424 422 425 423 delete h0; … … 439 437 h0->SetDirectory(0); 440 438 441 Scale(*h0, *h1); 442 443 const Bool_t rc = Fit(*h1, *h0, paint); 439 const Bool_t rc = ScaleAndFit(*h1, h0, paint); 444 440 445 441 delete h0; … … 449 445 } 450 446 451 voidMAlphaFitter::Scale(TH1D &of, const TH1D &on) const447 Double_t MAlphaFitter::Scale(TH1D &of, const TH1D &on) const 452 448 { 453 449 Float_t scaleon = 1; … … 456 452 { 457 453 case kNone: 458 return ;454 return 1; 459 455 460 456 case kEntries: … … 481 477 break; 482 478 479 // This is just to make some compiler happy 483 480 default: 484 return ;481 return 1; 485 482 } 486 483 487 484 if (scaleof!=0) 485 { 488 486 of.Scale(scaleon/scaleof); 487 return scaleon/scaleof; 488 } 489 489 else 490 { 490 491 of.Reset(); 491 } 492 return 0; 493 } 494 } -
trunk/MagicSoft/Mars/mhflux/MAlphaFitter.h
r5776 r5901 40 40 Double_t fEventsExcess; 41 41 Double_t fEventsSignal; 42 Double_t fEventsBackground; 42 Double_t fEventsBackground; // fScaleFactor already applied 43 43 44 44 Double_t fChiSqSignal; 45 45 Double_t fChiSqBg; 46 46 Double_t fIntegralMax; 47 Double_t fScaleFactor; // Scale factor for off-data 47 48 48 49 TArrayD fCoefficients; … … 62 63 gROOT->GetListOfFunctions()->Remove(fFunc); 63 64 fFunc->SetName("Dummy"); 65 66 Clear(); 64 67 } 65 68 … … 103 106 Double_t GetChiSqSignal() const { return fChiSqSignal; } 104 107 Double_t GetChiSqBg() const { return fChiSqBg; } 108 Double_t GetScaleFactor() const { return fScaleFactor; } 105 109 106 110 Double_t GetGausSigma() const { return fCoefficients[2]; } … … 113 117 114 118 Bool_t Fit(TH1D &h, Bool_t paint=kFALSE); 115 Bool_t Fit(TH1D &on, TH1D &off, Bool_t paint=kFALSE); 119 Bool_t Fit(TH1D &on, TH1D &off, Double_t alpha, Bool_t paint=kFALSE); 120 Bool_t Fit(TH1D &on, TH1D *off, Double_t alpha, Bool_t paint=kFALSE) 121 { 122 return off ? Fit(on, *off, alpha, paint) : Fit(on, paint); 123 } 116 124 Bool_t Fit(TH1D &on, TH1D *off, Bool_t paint=kFALSE) 117 125 { 118 return off ? Fit(on, *off, paint) : Fit(on, paint); 126 return off ? Fit(on, *off, 1, paint) : Fit(on, paint); 127 } 128 Bool_t ScaleAndFit(TH1D &on, TH1D *off, Bool_t paint=kFALSE) 129 { 130 const Double_t alpha = off ? Scale(*off, on) : 1; 131 return off ? Fit(on, *off, alpha, paint) : Fit(on, paint); 119 132 } 120 133 … … 140 153 } 141 154 142 voidScale(TH1D &off, const TH1D &on) const;155 Double_t Scale(TH1D &off, const TH1D &on) const; 143 156 144 157 ClassDef(MAlphaFitter, 1) -
trunk/MagicSoft/Mars/mhflux/MHAlpha.cc
r5883 r5901 392 392 393 393 TH1D *h = fOffData ? fOffData->ProjectionZ("ProjTimeTemp", -1, 9999, -1, 9999, "E") : 0; 394 const Bool_t rc = fit. Fit(fHAlphaTime, h);394 const Bool_t rc = fit.ScaleAndFit(fHAlphaTime, h); 395 395 if (h) 396 396 delete h; … … 544 544 { 545 545 TH1D *hoff = fOffData->ProjectionZ("ProjAlphaOff"); 546 fFit.Scale(*hoff, *hon);546 const Double_t alpha = fFit.Scale(*hoff, *hon); 547 547 548 548 hon->SetMaximum(); 549 549 hon->SetMaximum(TMath::Max(hon->GetMaximum(), hoff->GetMaximum())*1.05); 550 551 // BE CARFEULL: This is a really weird workaround! 552 hoff->SetMaximum(alpha); 550 553 551 554 if ((h0=(TH1D*)gPad->FindObject("ProjAlphaOnOff"))) … … 564 567 if ((h0 = (TH1D*)gPad->FindObject("ProjAlpha"))) 565 568 { 566 // Do not store the 'final' result in fFit 567 MAlphaFitter fit(fFit); 569 // Check whether we are dealing with on-off analysis 568 570 TH1D *hoff = (TH1D*)gPad->FindObject("ProjAlphaOff"); 569 fit.Fit(*h0, hoff, kTRUE); 570 fit.PaintResult(); 571 if (hoff) 572 { 573 // Do not store the 'final' result in fFit 574 MAlphaFitter fit(fFit); 575 576 // BE CARFEULL: This is a really weird workaround! 577 const Double_t alpha = hoff->GetMaximum(); 578 fit.Fit(*h0, hoff, alpha<0 ? 1: alpha, kTRUE); 579 580 fit.PaintResult(); 581 } 571 582 } 572 583 … … 757 768 758 769 TH1D *hof = 0; 770 Double_t alpha = 1; 759 771 760 772 if (fOffData) … … 772 784 hof->Draw("same"); 773 785 774 fit.Scale(*hof, *hon);786 alpha = fit.Scale(*hof, *hon); 775 787 776 788 hon->SetMaximum(); … … 796 808 } 797 809 798 if (hof ? fit.Fit(*hon, *hof ) : fit.Fit(*hon))799 810 if (hof ? fit.Fit(*hon, *hof, alpha) : fit.Fit(*hon)) 811 *fLog << dbg << "Bin " << i << ": sigma=" << fit.GetSignificance() << " omega=" << fit.GetGausSigma() << " events=" << fit.GetEventsExcess() << endl; 800 812 /* 801 813 if (fit.FitEnergy(fHAlpha, fOffData, i, kTRUE)) -
trunk/MagicSoft/Mars/mhflux/MHFalseSource.cc
r5869 r5901 954 954 955 955 TH1D *h=0, *hoff=0; 956 Double_t scale = 1; 956 957 for (int ix=1; ix<=nx; ix++) 957 958 for (int iy=1; iy<=ny; iy++) … … 969 970 { 970 971 hoff = fHistOff->ProjectionZ("AlphaFitOff", ix, ix, iy, iy); 971 hoff->Scale(entries/hoff->GetEntries()); 972 hoff->Scale(entries/h->GetEntries()); 973 scale = fit.Scale(*hoff, *h); 972 974 } 973 975 974 if (!fit.Fit(*h, hoff ))976 if (!fit.Fit(*h, hoff, scale)) 975 977 continue; 976 978
Note:
See TracChangeset
for help on using the changeset viewer.