- Timestamp:
- 06/18/08 21:39:50 (16 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r8977 r8978 24 24 - small improvement to output 25 25 - handle underflow bin of effective on-time more accurate 26 - reddid the formattig of the spectral fit 27 28 * mbase/MMath.[h,cc]: 29 - added Format member function 26 30 27 31 -
trunk/MagicSoft/Mars/mbase/MMath.cc
r8957 r8978 1 1 /* ======================================================================== *\ 2 ! $Name: not supported by cvs2svn $:$Id: MMath.cc,v 1.3 8 2008-06-14 15:55:50tbretz Exp $2 ! $Name: not supported by cvs2svn $:$Id: MMath.cc,v 1.39 2008-06-18 20:39:48 tbretz Exp $ 3 3 ! -------------------------------------------------------------------------- 4 4 ! … … 811 811 return 3; 812 812 } 813 814 // -------------------------------------------------------------------------- 815 // 816 // Format a value and its error corresponding to the rules (note 817 // this won't work if the error is more then eight orders smaller than 818 // the value) 819 // 820 void MMath::Format(Double_t &v, Double_t &e) 821 { 822 // Valid digits 823 Int_t i = TMath::FloorNint(TMath::Log10(v))-TMath::FloorNint(TMath::Log10(e)); 824 825 // Check if error starts with 1 or 2. In this case use one 826 // more valid digit 827 TString error = Form("%.0e", e); 828 if (error[0]=='1' || error[0]=='2') 829 { 830 i++; 831 error = Form("%.1e", e); 832 } 833 834 const char *fmt = Form("%%.%de", i); 835 836 v = atof(Form(fmt, v)); 837 e = error.Atof(); 838 } -
trunk/MagicSoft/Mars/mbase/MMath.h
r8585 r8978 1 1 #ifndef MARS_MMath 2 2 #define MARS_MMath 3 4 #ifndef _MATH_H 5 #include <math.h> // Needed for darwin 6 #endif 3 7 4 8 #ifndef ROOT_TMath … … 69 73 TArrayD LeastSqFitPowerLaw(Int_t n, Double_t *x, Double_t *y); 70 74 71 inline Int_t ModF(Double_t dbl, Double_t &frac) { Double_t rc; frac = modf(dbl, &rc); return TMath::Nint(rc); }75 inline Int_t ModF(Double_t dbl, Double_t &frac) { Double_t rc; frac = ::modf(dbl, &rc); return TMath::Nint(rc); } 72 76 73 inline Double_t Sqrt3(Double_t x) { return cbrt(x); }77 inline Double_t Sqrt3(Double_t x) { return ::cbrt(x); } 74 78 75 79 inline Double_t Sgn(Double_t d) { return d<0 ? -1 : 1; } 80 81 void Format(Double_t &v, Double_t &e); 76 82 } 77 83 -
trunk/MagicSoft/Mars/mjobs/MJSpectrum.cc
r8977 r8978 48 48 #include "MLogManip.h" 49 49 50 #include "MMath.h" 50 51 #include "MDirIter.h" 51 52 … … 292 293 293 294 const Double_t ufl = vstime->GetBinContent(0); 295 const Double_t ofl = vstime->GetBinContent(vstime->GetNbinsX()+1); 296 const Double_t eff = vstime->Integral()+ufl+ofl; 294 297 if (ufl>0) 295 298 { … … 301 304 *fLog << warn << "WARNING - " << Form("%.1f%% (%.0fs)", 100*ufl/eff, ufl) << " of the eff. observation time is in the underflow bin." << endl; 302 305 } 303 304 const Double_t ofl = vstime->GetBinContent(vstime->GetNbinsX()+1);305 const Double_t eff = vstime->Integral()+ufl+ofl;306 306 if (ofl>0) 307 307 *fLog << warn << "WARNING - " << Form("%.1f%% (%.0fs)", 100*ofl/eff, ofl) << " of the eff. observation time is in the overflow bin." << endl; … … 872 872 TString MJSpectrum::FormString(const TF1 &f, Byte_t type) 873 873 { 874 const Double_t p0 = f.GetParameter(0); 875 const Double_t p1 = f.GetParameter(1); 876 877 const Double_t e0 = f.GetParError(0); 878 const Double_t e1 = f.GetParError(1); 879 880 const Int_t np = TMath::Nint(TMath::Floor(TMath::Log10(p1))); 881 const Double_t exp = TMath::Power(10, np); 882 883 const Float_t fe0 = TMath::Log10(e0); 884 const Float_t fe1 = TMath::Log10(e1); 885 886 // calc number of (gueltige ziffern) digits to be displayed 887 const char *f0 = fe0-TMath::Floor(fe0)>0.3 ? "3.1" : "1.0"; 888 const char *f1 = fe1-TMath::Floor(fe1)>0.3 ? "3.1" : "1.0"; 874 Double_t p0 = f.GetParameter(0); 875 Double_t p1 = f.GetParameter(1); 876 877 Double_t e0 = f.GetParError(0); 878 Double_t e1 = f.GetParError(1); 879 880 MMath::Format(p0, e0); 881 MMath::Format(p1, e1); 889 882 890 883 TString str; … … 893 886 case 0: 894 887 { 895 const TString fmt0 = Form("(%%%sf#pm%%%sf)\\bullet10^{%%d}", f1, f1);896 const TString fmt1 = Form("(\\frac{E}{500GeV})^{%%%sf#pm%%%sf}", f0, f0);897 898 str = Form( fmt0.Data(), p1/exp, e1/exp, np);899 str += Form( fmt1.Data(), p0, e0);888 const Int_t i = TMath::FloorNint(TMath::Log10(p1)); 889 const Double_t exp = TMath::Power(10, i); 890 891 str = Form("(%f#pm%f)\\bullet10^{%d}", p1/exp, e1/exp, i); 892 str += Form("(\\frac{E}{500GeV})^{%f#pm%f}", p0, e0); 900 893 str += "\\frac{ph}{TeVm^{2}s}"; 901 894 }
Note:
See TracChangeset
for help on using the changeset viewer.