Changeset 7602 for trunk/MagicSoft/Mars/mhflux
- Timestamp:
- 03/14/06 16:07:39 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mhflux/MHEffectiveOnTime.cc
r7534 r7602 474 474 475 475 // FIXME: Do fit only if contents of bin has changed 476 if (Nm<=0 )476 if (Nm<=0 || h->GetBinContent(1)<=0) 477 477 return kFALSE; 478 478 … … 483 483 // within the range (yq[0], yq[1]) there must be no empty bin; 484 484 // choose pedestrian approach as long as GetQuantiles is not available 485 Double_t xq[2] = { 0.6, 0.9 9 };485 Double_t xq[2] = { 0.6, 0.95 }; // previously 0.99 486 486 Double_t yq[2]; 487 487 h->GetQuantiles(2, yq, xq); 488 488 489 // Nmdel = Nm * binwidth, with Nm = number of observed events 490 const Double_t Nmdel = h->Integral("width"); 491 492 // 493 // Setup Poisson function for the fit: 494 // lambda [Hz], N0 = ideal no of evts, del = bin width of dt 495 // 496 // parameter 0 = lambda 497 // parameter 1 = N0*del 498 // 499 TF1 func("Poisson", " [1]*[2] * [0] * exp(-[0] *x)"); 500 //func.SetParNames("lambda", "N0", "del"); 489 // 490 // Setup exponential function for the fit: 491 // 492 // parameter 0 = rate [Hz] 493 // parameter 1 = normalization 494 // 495 TF1 func("Exp", " exp([1]-[0]*x)"); 501 496 502 497 func.SetParameter(0, 200); // Hz 503 func.SetParameter(1, Nm); 504 func.FixParameter(2, Nmdel/Nm); 498 func.SetParameter(1, log(h->GetBinContent(1))); // Hz 505 499 506 500 // options : N do not store the function, do not draw … … 508 502 // R use the range specified in the function range 509 503 // Q quiet mode 510 h->Fit(&func, "NIQE", "", yq[0], yq[1]); 504 // L Use log-likelihood (better for low statistics) 505 h->Fit(&func, "NIQEL", "", h->GetBinLowEdge(3)/*yq[0]*/, yq[1]); 511 506 512 507 const Double_t chi2 = func.GetChisquare(); 508 const Double_t prob = func.GetProb(); 513 509 const Int_t NDF = func.GetNDF(); 514 510 515 511 // was fit successful ? 516 const Bool_t ok = NDF>0 && chi2<3*NDF;512 const Bool_t ok = prob>0.001; //NDF>0 && chi2<3*NDF; 517 513 518 514 if (paint) … … 523 519 } 524 520 521 // The effective on time is the "real rate" (slope of the exponential) 522 // divided by the total number of events (histogram integral including 523 // under- and overflows) 525 524 const Double_t lambda = func.GetParameter(0); 526 //const Double_t N0 = func.GetParameter(1); 527 const Double_t prob = func.GetProb(); 528 529 /* 530 *fLog << all << "Nm/lambda=" << Nm/lambda << " chi2/NDF="; 531 *fLog << (NDF ? chi2/NDF : 0.0) << " lambda="; 532 *fLog << lambda << " N0=" << N0 << endl; 533 */ 534 535 Double_t emat[2][2]; 536 gMinuit->mnemat((Double_t*)emat, 2); 537 538 const Double_t dldl = emat[0][0]; 539 //const Double_t dN0dN0 = emat[1][1]; 540 541 const Double_t teff = Nm/lambda; 542 const Double_t dteff = teff * TMath::Sqrt(dldl/(lambda*lambda) + 1.0/Nm); 543 const Double_t dl = TMath::Sqrt(dldl); 544 545 //const Double_t kappa = Nm/N0; 546 //const Double_t Rdead = 1.0 - kappa; 547 //const Double_t dRdead = kappa * TMath::Sqrt(dN0dN0/(N0*N0) + 1.0/Nm); 525 const Double_t dldl = func.GetParError(0)*func.GetParError(0); 526 const Double_t teff = Nm / lambda; 527 const Double_t dteff = teff * TMath::Sqrt(dldl/(lambda*lambda) + 1.0/Nm); 528 const Double_t dl = TMath::Sqrt(dldl); 548 529 549 530 // the effective on time is Nm/lambda … … 563 544 // Chi2 564 545 res[6] = chi2; 565 566 // Rdead (from fit) is the fraction from real time lost by the dead time567 //fHRdead.SetBinContent(i, Rdead);568 //fHRdead.SetBinError (i,dRdead);569 546 570 547 return ok; … … 583 560 fHThetaNDF.Reset(); 584 561 562 // Use a random name to make sure the object is unique 585 563 const TString name = Form("CalcTheta%d", (UInt_t)gRandom->Uniform(999999999)); 586 564 … … 594 572 h = fH2DeltaT.ProjectionX(name, i, i, "E"); 595 573 596 Double_t res[7]; 597 if (!FitH(h, res)) 574 Double_t res[7] = {0, 0, 0, 0, 0, 0, 0}; 575 //if (!FitH(h, res)) 576 // continue; 577 FitH(h, res); 578 579 if (res[0]==0) 598 580 continue; 599 581
Note:
See TracChangeset
for help on using the changeset viewer.