Changeset 7817 for trunk/MagicSoft/Mars/mhflux
- Timestamp:
- 07/29/06 11:20:14 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mhflux/MHEffectiveOnTime.cc
r7602 r7817 76 76 // 77 77 // 78 // Class version 2: 79 // ---------------- 80 // + UInt_t fFirstBin; 81 // + UInt_t fNumEvents; 82 // - Int_t fNumEvents; 83 // 84 // 78 85 // ========================================================================== 79 86 // Dear Colleagues, … … 286 293 MHEffectiveOnTime::MHEffectiveOnTime(const char *name, const char *title) 287 294 : fPointPos(0), fTime(0), fParam(0), fIsFinalized(kFALSE), 288 fNumEvents(200*60) /*, fNameProjDeltaT(Form("DeltaT_%p", this)),289 fNameProjTheta(Form("Theta_%p", this))*/295 fNumEvents(200*60), fFirstBin(3) 296 //fNumEvents(2*60), fFirstBin(1) 290 297 { 291 298 // … … 488 495 489 496 // 497 // Determine a good starting value for the slope 498 // 499 const TAxis &axe = *h->GetXaxis(); 500 const UInt_t ibin = axe.FindFixBin(yq[1]); 501 const Double_t x1 = axe.GetBinCenter(ibin<=fFirstBin?fFirstBin+1:ibin); 502 const Double_t x0 = axe.GetBinCenter(fFirstBin); 503 const Double_t y1 = h->GetBinContent(ibin)>1 ? TMath::Log(h->GetBinContent(ibin)) : 0; 504 const Double_t y0 = TMath::Log(h->GetBinContent(fFirstBin)); 505 506 // Estimated slope 507 const Float_t m = -(y1-y0)/(x1-x0); 508 509 // 490 510 // Setup exponential function for the fit: 491 511 // … … 495 515 TF1 func("Exp", " exp([1]-[0]*x)"); 496 516 497 func.SetParameter(0, 200); // Hz517 func.SetParameter(0, m); // Hz 498 518 func.SetParameter(1, log(h->GetBinContent(1))); // Hz 519 520 // We set a limit to make sure that almost empty histograms which 521 // are fitted dont't produce hang ups or crashes 522 func.SetParLimits(0, 0, 15000); // Hz 499 523 500 524 // options : N do not store the function, do not draw … … 503 527 // Q quiet mode 504 528 // L Use log-likelihood (better for low statistics) 505 h->Fit(&func, "NIQEL", "", h->GetBinLowEdge( 3)/*yq[0]*/, yq[1]);529 h->Fit(&func, "NIQEL", "", h->GetBinLowEdge(fFirstBin)/*yq[0]*/, yq[1]); 506 530 507 531 const Double_t chi2 = func.GetChisquare(); … … 524 548 const Double_t lambda = func.GetParameter(0); 525 549 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);550 const Double_t teff = lambda==0 ? 0 : Nm / lambda; 551 const Double_t dteff = lambda==0 ? 0 : teff * TMath::Sqrt(dldl/(lambda*lambda) + 1.0/Nm); 528 552 const Double_t dl = TMath::Sqrt(dldl); 529 553 … … 715 739 // histogram - if it fails try again when 1.6% more events available 716 740 // 717 const Int_t n = (Int_t)fH1DeltaT.GetEntries();741 const UInt_t n = (UInt_t)fH1DeltaT.GetEntries(); 718 742 if (n>=fNumEvents && n%(fNumEvents/60)==0) 719 743 FitTimeBin(); … … 993 1017 DrawRightAxis("\\lambda [s^{-1}]"); 994 1018 } 1019 1020 // -------------------------------------------------------------------------- 1021 // 1022 // The following resources are available: 1023 // 1024 // MHEffectiveOnTime.FistBin: 3 1025 // MHEffectiveOnTime.NuMEvents: 12000 1026 // 1027 Int_t MHEffectiveOnTime::ReadEnv(const TEnv &env, TString prefix, Bool_t print) 1028 { 1029 Bool_t rc = kFALSE; 1030 if (IsEnvDefined(env, prefix, "FirstBin", print)) 1031 { 1032 rc = kTRUE; 1033 SetFirstBin(GetEnvValue(env, prefix, "FirstBin", (Int_t)fFirstBin)); 1034 } 1035 if (IsEnvDefined(env, prefix, "NumEvents", print)) 1036 { 1037 rc = kTRUE; 1038 SetNumEvents(GetEnvValue(env, prefix, "NumEvents", (Int_t)fNumEvents)); 1039 } 1040 return rc; 1041 }
Note:
See TracChangeset
for help on using the changeset viewer.