Changeset 7147 for trunk/MagicSoft/Mars/mjobs
- Timestamp:
- 06/13/05 09:41:57 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mjobs/MJSpectrum.cc
r7099 r7147 38 38 #include <TFile.h> 39 39 #include <TChain.h> 40 #include <TLatex.h> 40 41 #include <TCanvas.h> 41 42 #include <TObjArray.h> … … 84 85 MJSpectrum::MJSpectrum(const char *name, const char *title) 85 86 : fCut0(0),fCut1(0), fCut2(0), fCut3(0), fEstimateEnergy(0), 86 fRefill(kFALSE), fSimpleMode(kTRUE), fRawMc(kFALSE) 87 fRefill(kFALSE), fSimpleMode(kTRUE), fRawMc(kFALSE), 88 fNoThetaWeights(kFALSE) 87 89 { 88 90 fName = name ? name : "MJSpectrum"; … … 336 338 // Calculate the Probability 337 339 temp1.Divide(&temp2); 338 temp1.Scale( 1./temp1.GetMaximum());340 temp1.Scale(fNoThetaWeights ? 1./temp1.GetMaximum() : 1./temp1.Integral()); 339 341 340 342 // Some cosmetics: Name, Axis, etc. … … 348 350 } 349 351 352 // -------------------------------------------------------------------------- 353 // 354 // Display the final theta distribution. 355 // 350 356 void MJSpectrum::DisplayResult(const TH2D &h2) const 351 357 { … … 376 382 } 377 383 384 // -------------------------------------------------------------------------- 385 // 386 // Fills the excess histogram (vs E-est) from the events stored in the 387 // ganymed result file and therefor estimates the energy. 388 // 389 // The resulting histogram excess-vs-energy ist copied into h2. 390 // 378 391 Bool_t MJSpectrum::Refill(MParList &plist, TH1D &h2) const 379 392 { … … 531 544 } 532 545 546 // -------------------------------------------------------------------------- 547 // 548 // Calculate the final spectrum from: 549 // - collection area 550 // - excess 551 // - correction coefficients 552 // - ontime 553 // and display it 554 // 533 555 TArrayD MJSpectrum::DisplaySpectrum(MHCollectionArea &area, TH1D &excess, MHEnergyEst &hest, Double_t ontime) const 534 556 { … … 573 595 weights.DrawCopy(); 574 596 575 //spectrum. Divide(&weights);576 spectrum. Multiply(&weights);577 spectrum.Set NameTitle("Flux", "N/TeVsm^{2} versus Energy (after unfolding)");597 //spectrum.Multiply(&weights); 598 spectrum.SetNameTitle("Flux", "Spectrum (after unfolding)"); 599 spectrum.SetBit(TH1::kNoStats); 578 600 579 601 for (int i=0; i<excess.GetNbinsX(); i++) 580 602 { 603 spectrum.SetBinContent(i+1, spectrum.GetBinContent(i+1)*weights.GetBinContent(i+1)); 604 spectrum.SetBinError(i+1, spectrum.GetBinError(i+1) *weights.GetBinContent(i+1)); 605 581 606 spectrum.SetBinContent(i+1, spectrum.GetBinContent(i+1)/spectrum.GetBinWidth(i+1)*1000); 582 607 spectrum.SetBinError(i+1, spectrum.GetBinError(i+1)/ spectrum.GetBinWidth(i+1)*1000); … … 589 614 gPad->SetGridx(); 590 615 gPad->SetGridy(); 616 spectrum.SetMinimum(1e-12); 591 617 spectrum.SetXTitle("E [GeV]"); 592 618 spectrum.SetYTitle("N/TeVsm^{2}"); 593 619 spectrum.DrawCopy(); 594 620 595 TF1 f("f", "[1]*(x/1e3)^[0]", 50, 3e4);621 TF1 f("f", "[1]*(x/1e3)^[0]", 10, 3e4); 596 622 f.SetParameter(0, -2.87); 597 623 f.SetParameter(1, 1.9e-6); 598 624 f.SetLineColor(kGreen); 599 spectrum.Fit(&f, "NIM", "", 55, 2e4);625 spectrum.Fit(&f, "NIM", "", 100, 4000); 600 626 f.DrawCopy("same"); 601 627 602 /* 603 TString str; 604 str += "(1.68#pm0.15)10^{-7}"; 605 str += "(\\frac{E}{TeV})^{-2.59#pm0.06}"; 606 str += "\\frac{ph}{TeVm^{2}s}"; 607 608 TLatex tex; 609 tex.DrawLatex(2e2, 7e-5, str); 610 */ 628 const Double_t p0 = f.GetParameter(0); 629 const Double_t p1 = f.GetParameter(1); 630 631 const Double_t e0 = f.GetParError(0); 632 const Double_t e1 = f.GetParError(1); 633 634 const Int_t np = TMath::Nint(TMath::Floor(TMath::Log10(p1))); 635 const Double_t exp = TMath::Power(10, np); 636 637 TString str; 638 str += Form("(%.2f#pm%.2f)10^{%d}", p1/exp, e1/exp, np); 639 str += Form("(\\frac{E}{TeV})^{-%.2f#pm%.2f}", p0, e0); 640 str += "\\frac{ph}{TeVm^{2}s}"; 641 642 TLatex tex; 643 tex.SetTextSize(0.045); 644 tex.SetBit(TLatex::kTextNDC); 645 tex.DrawLatex(0.45, 0.935, str); 646 647 str = Form("\\chi^{2}/NDF=%.2f", f.GetChisquare()/f.GetNDF()); 648 tex.DrawLatex(0.70, 0.83, str); 611 649 612 650 TArrayD res(2); 613 651 res[0] = f.GetParameter(0); 614 652 res[1] = f.GetParameter(1); 653 654 655 // Plot other spectra from Whipple 656 f.SetParameter(0, -2.45); 657 f.SetParameter(1, 3.3e-7); 658 f.SetRange(300, 8000); 659 f.SetLineColor(kBlack); 660 f.SetLineStyle(kDashed); 661 f.DrawCopy("same"); 662 663 // Plot other spectra from Cangaroo 664 f.SetParameter(0, -2.53); 665 f.SetParameter(1, 2.0e-7); 666 f.SetRange(7000, 50000); 667 f.SetLineColor(kBlack); 668 f.SetLineStyle(kDashed); 669 f.DrawCopy("same"); 670 671 // Plot other spectra from Robert 672 f.SetParameter(0, -2.59); 673 f.SetParameter(1, 2.58e-7); 674 f.SetRange(150, 1500); 675 f.SetLineColor(kBlack); 676 f.SetLineStyle(kDashed); 677 f.DrawCopy("same"); 678 679 // Plot other spectra from HEGRA 680 f.SetParameter(0, -2.61); 681 f.SetParameter(1, 2.7e-7); 682 f.SetRange(1000, 20000); 683 f.SetLineColor(kBlack); 684 f.SetLineStyle(kDashed); 685 f.DrawCopy("same"); 686 615 687 return res; 616 688 } 617 689 690 // -------------------------------------------------------------------------- 691 // 692 // Scale some image parameter plots using the scale factor and plot them 693 // together with the corresponding MC histograms. 694 // Called from DisplaySize 695 // 618 696 Bool_t MJSpectrum::PlotSame(MStatusArray &arr, MParList &plist, const char *name, const char *tab, const char *plot, Double_t scale) const 619 697 { … … 664 742 } 665 743 744 // -------------------------------------------------------------------------- 745 // 746 // Take a lot of histograms and plot them together in one plot. 747 // Calls PlotSame 748 // 666 749 Bool_t MJSpectrum::DisplaySize(MParList &plist, Double_t scale) const 667 750 { … … 698 781 gPad->SetGridy(); 699 782 700 excess->SetTitle(" Number of excess events vs Size (data, mc/blue)");783 excess->SetTitle("Excess events vs Size (data/black, mc/blue)"); 701 784 excess = excess->DrawCopy("E2"); 702 785 // Don't do this on the original object! … … 727 810 histsel->KolmogorovTest(excess, "DX"); 728 811 fLog->Separator("Chi^2 Test"); 729 histsel->Chi2Test(excess, "P"); 812 const Double_t p = histsel->Chi2Test(excess, "P"); 813 814 TLatex tex; 815 tex.SetBit(TLatex::kTextNDC); 816 tex.DrawLatex(0.7, 0.93, Form("P(\\chi^{2})=%.0f", p*100)); 730 817 } 731 818 } … … 814 901 if (!GetThetaDistribution(temp1, temp2)) 815 902 return kFALSE; 903 904 if (!fNoThetaWeights) 905 weight.SetZdWeights(&temp1); 816 906 817 907 TH1D excess; … … 930 1020 931 1021 tlist2.AddToList(&read); 932 if (!fRawMc )1022 if (!fRawMc && fNoThetaWeights) 933 1023 tlist2.AddToList(&contsel); 934 1024 tlist2.AddToList(&calc);
Note:
See TracChangeset
for help on using the changeset viewer.