Changeset 2311
- Timestamp:
- 08/21/03 11:55:13 (21 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r2308 r2311 4 4 5 5 * manalysis/MCT1FindSupercuts.[h,cc], manalysis/MCT1Supercuts.[h,cc], 6 manalysis/MCT1SupercutsCalc.[h,cc], manalysis/MMinuitInterface.[h,cc]: 6 manalysis/MCT1SupercutsCalc.[h,cc], manalysis/MMinuitInterface.[h,cc], 7 mhist/MHFindSignificance.[h,cc]: 7 8 - changed some variables and member functions with respect to an upcoming 8 9 Minimization Class … … 11 12 - added some sanity checks 12 13 - simplified some variable usage 14 15 * mhist/MHCT1Supercuts.[h,cc]: 16 - removed obsolete SetupFill 13 17 14 18 -
trunk/MagicSoft/Mars/manalysis/MCT1Supercuts.h
r2308 r2311 31 31 32 32 Bool_t SetParameters(const TArrayD &d); 33 const TArrayD &GetParameters() const ;33 const TArrayD &GetParameters() const { return fParameters; } 34 34 35 35 const Double_t *GetLengthUp() const { return fLengthUp; } -
trunk/MagicSoft/Mars/mhist/MHFindSignificance.cc
r2305 r2311 61 61 62 62 #include <TArrayD.h> 63 #include <TArrayI.h> 63 64 #include <TH1.h> 64 65 #include <TF1.h> … … 849 850 while (1) 850 851 { 851 852 //-------------------------------------------------- 853 // prepare fit of a polynomial : (a0 + a1*x + a2*x**2 + a3*x**3 + ...) 854 855 TString funcname = "Poly"; 856 Double_t xmin = 0.0; 857 Double_t xmax = 90.0; 858 859 TString formula = "[0]"; 860 TString bra1 = "+["; 861 TString bra2 = "]"; 862 TString xpower = "*x"; 863 TString newpower = "*x"; 864 for (Int_t i=1; i<=fDegree; i++) 865 { 866 formula += bra1; 867 formula += i; 868 formula += bra2; 869 formula += xpower; 870 871 xpower += newpower; 872 } 873 874 //*fLog << "FitPolynomial : formula = " << formula << endl; 875 876 fPoly = new TF1(funcname, formula, xmin, xmax); 877 TList *funclist = fHist->GetListOfFunctions(); 878 funclist->Add(fPoly); 879 880 //------------------------ 881 // attention : the dimensions must agree with those in CallMinuit() 882 883 char parname[80][100]; 884 Double_t vinit[80]; 885 Double_t step[80]; 886 Double_t limlo[80]; 887 Double_t limup[80]; 888 Int_t fix[80]; 889 890 UInt_t npar = fDegree+1; 891 892 for (UInt_t j=0; j<npar; j++) 893 { 894 vinit[j] = 0.0; 895 } 896 vinit[0] = mean; 897 vinit[2] = a2init; 898 899 900 for (UInt_t j=0; j<npar; j++) 901 { 902 sprintf(&parname[j][0], "p%d", j+1); 903 904 if (vinit[j] != 0.0) 905 step[j] = fabs(vinit[j]) / 10.0; 906 else 907 step[j] = 0.000001; 908 909 limlo[j] = 0.0; 910 limup[j] = 0.0; 911 912 fix[j] = 0; 913 } 914 915 // limit the first coefficient of the polynomial to positive values 916 // because the background must not be negative 917 limlo[0] = 0.0; 918 limup[0] = fHist->GetEntries(); 919 920 921 // use the subsequernt loop if you want to apply the 922 // constraint : uneven derivatives (at alpha=0) = zero 923 for (UInt_t j=1; j<npar; j += 2) 924 { 925 vinit[j] = 0.0; 926 step[j] = 0.0; 927 fix[j] = 1; 928 } 929 930 TString method = "Migrad"; 931 TObject *objectfit = fHist; 932 Bool_t nulloutput = kFALSE; 933 934 *fLog << "FitPolynomial : before CallMinuit()" << endl; 935 936 MMinuitInterface inter; 937 Bool_t rc = inter.CallMinuit( fcnpoly, npar, parname, vinit, step, 938 limlo, limup, fix, objectfit, method, 939 nulloutput); 940 941 if (rc != 0) 942 { 943 // *fLog << "MHFindSignificance::FitPolynomial; polynomial fit failed" 944 // << endl; 945 // return kFALSE; 946 } 947 948 949 //------------------- 950 // get status of minimization 951 Double_t fmin = 0.0; 952 Double_t fedm = 0.0; 953 Double_t errdef = 0.0; 954 Int_t npari = 0; 955 Int_t nparx = 0; 956 957 if (gMinuit) 958 gMinuit->mnstat(fmin, fedm, errdef, npari, nparx, fIstat); 959 960 //*fLog << "MHFindSignificance::FitPolynomial; fmin, fedm, errdef, npari, nparx, fIstat = " 961 // << fmin << ", " << fedm << ", " << errdef << ", " << npari 962 // << ", " << nparx << ", " << fIstat << endl; 963 964 965 //------------------- 966 // store the results 967 968 Int_t nparfree = gMinuit!=NULL ? gMinuit->GetNumFreePars() : 0; 969 fChisq = fmin; 970 fNdf = fMbins - nparfree; 971 fProb = TMath::Prob(fChisq, fNdf); 972 973 974 // get fitted parameter values and errors 975 fValues.Set(fDegree+1); 976 fErrors.Set(fDegree+1); 977 978 for (Int_t j=0; j<=fDegree; j++) 979 { 980 Double_t val, err; 981 if (gMinuit) 982 gMinuit->GetParameter(j, val, err); 983 984 fPoly->SetParameter(j, val); 985 fPoly->SetParError(j, err); 986 987 fValues[j] = val; 988 fErrors[j] = err; 989 } 990 991 //-------------------------------------------------- 992 // if the highest coefficient (j0) of the polynomial 993 // is consistent with zero reduce the degree of the polynomial 994 995 Int_t j0 = 0; 996 for (Int_t j=fDegree; j>1; j--) 997 { 998 // ignore fixed parameters 999 if (fErrors[j] == 0.0) 1000 continue; 1001 1002 // this is the highest coefficient 1003 j0 = j; 1004 break; 1005 } 1006 1007 if ( !fReduceDegree || j0 == 0 || fabs(fValues[j0]) > fErrors[j0] ) 1008 break; 1009 1010 // reduce the degree of the polynomial 1011 *fLog << "MHFindSignificance::FitPolynomial; reduce the degree of the polynomial from " 1012 << fDegree << " to " << (j0-2) << endl; 1013 fDegree = j0 - 2; 1014 1015 funclist->Remove(fPoly); 1016 //if (fPoly) 1017 delete fPoly; 1018 fPoly = NULL; 1019 1020 // delete the Minuit object in order to have independent starting 1021 // conditions for the next minimization 1022 //if (gMinuit) 1023 delete gMinuit; 1024 gMinuit = NULL; 852 //-------------------------------------------------- 853 // prepare fit of a polynomial : (a0 + a1*x + a2*x**2 + a3*x**3 + ...) 854 855 TString funcname = "Poly"; 856 Double_t xmin = 0.0; 857 Double_t xmax = 90.0; 858 859 TString formula = "[0]"; 860 TString bra1 = "+["; 861 TString bra2 = "]"; 862 TString xpower = "*x"; 863 TString newpower = "*x"; 864 for (Int_t i=1; i<=fDegree; i++) 865 { 866 formula += bra1; 867 formula += i; 868 formula += bra2; 869 formula += xpower; 870 871 xpower += newpower; 872 } 873 874 //*fLog << "FitPolynomial : formula = " << formula << endl; 875 876 fPoly = new TF1(funcname, formula, xmin, xmax); 877 TList *funclist = fHist->GetListOfFunctions(); 878 funclist->Add(fPoly); 879 880 //------------------------ 881 // attention : the dimensions must agree with those in CallMinuit() 882 const UInt_t npar = fDegree+1; 883 884 TString parname[npar]; 885 TArrayD vinit(npar); 886 TArrayD step(npar); 887 TArrayD limlo(npar); 888 TArrayD limup(npar); 889 TArrayI fix(npar); 890 891 vinit[0] = mean; 892 vinit[2] = a2init; 893 894 for (UInt_t j=0; j<npar; j++) 895 { 896 parname[j] = "p"; 897 parname[j] += j+1; 898 899 step[j] = vinit[j] != 0.0 ? TMath::Abs(vinit[j]) / 10.0 : 0.000001; 900 } 901 902 // limit the first coefficient of the polynomial to positive values 903 // because the background must not be negative 904 limup[0] = fHist->GetEntries(); 905 906 // use the subsequernt loop if you want to apply the 907 // constraint : uneven derivatives (at alpha=0) = zero 908 for (UInt_t j=1; j<npar; j+=2) 909 { 910 vinit[j] = 0; 911 step[j] = 0; 912 fix[j] = 1; 913 } 914 915 *fLog << "FitPolynomial : before CallMinuit()" << endl; 916 917 MMinuitInterface inter; 918 const Bool_t rc = inter.CallMinuit(fcnpoly, parname, vinit, step, 919 limlo, limup, fix, fHist, "Migrad", 920 kFALSE); 921 922 if (rc != 0) 923 { 924 // *fLog << "MHFindSignificance::FitPolynomial; polynomial fit failed" 925 // << endl; 926 // return kFALSE; 927 } 928 929 930 //------------------- 931 // get status of minimization 932 Double_t fmin = 0; 933 Double_t fedm = 0; 934 Double_t errdef = 0; 935 Int_t npari = 0; 936 Int_t nparx = 0; 937 938 if (gMinuit) 939 gMinuit->mnstat(fmin, fedm, errdef, npari, nparx, fIstat); 940 941 //*fLog << "MHFindSignificance::FitPolynomial; fmin, fedm, errdef, npari, nparx, fIstat = " 942 // << fmin << ", " << fedm << ", " << errdef << ", " << npari 943 // << ", " << nparx << ", " << fIstat << endl; 944 945 946 //------------------- 947 // store the results 948 949 Int_t nparfree = gMinuit!=NULL ? gMinuit->GetNumFreePars() : 0; 950 fChisq = fmin; 951 fNdf = fMbins - nparfree; 952 fProb = TMath::Prob(fChisq, fNdf); 953 954 955 // get fitted parameter values and errors 956 fValues.Set(npar); 957 fErrors.Set(npar); 958 959 for (Int_t j=0; j<=fDegree; j++) 960 { 961 Double_t val, err; 962 if (gMinuit) 963 gMinuit->GetParameter(j, val, err); 964 965 fPoly->SetParameter(j, val); 966 fPoly->SetParError(j, err); 967 968 fValues[j] = val; 969 fErrors[j] = err; 970 } 971 972 //-------------------------------------------------- 973 // if the highest coefficient (j0) of the polynomial 974 // is consistent with zero reduce the degree of the polynomial 975 976 Int_t j0 = 0; 977 for (Int_t j=fDegree; j>1; j--) 978 { 979 // ignore fixed parameters 980 if (fErrors[j] == 0) 981 continue; 982 983 // this is the highest coefficient 984 j0 = j; 985 break; 986 } 987 988 if (!fReduceDegree || j0==0 || TMath::Abs(fValues[j0]) > fErrors[j0]) 989 break; 990 991 // reduce the degree of the polynomial 992 *fLog << "MHFindSignificance::FitPolynomial; reduce the degree of the polynomial from " 993 << fDegree << " to " << (j0-2) << endl; 994 fDegree = j0 - 2; 995 996 funclist->Remove(fPoly); 997 //if (fPoly) 998 delete fPoly; 999 fPoly = NULL; 1000 1001 // delete the Minuit object in order to have independent starting 1002 // conditions for the next minimization 1003 //if (gMinuit) 1004 delete gMinuit; 1005 gMinuit = NULL; 1025 1006 } 1026 1007 //=========== end of loop for reducing the degree ================== 1027 1008 // of the polynomial 1028 1009 1029 1010 1030 1011 //-------------------------------------------------- … … 1034 1015 if (fIstat >= 1) 1035 1016 { 1036 // error matrix was calculated 1037 if (gMinuit) 1038 gMinuit->mnemat(&fEmat[0][0], fNdim); 1039 1040 // copy covariance matrix into a matrix which includes also the fixed 1041 // parameters 1042 TString name; 1043 Double_t bnd1, bnd2, val, err; 1044 Int_t jvarbl; 1045 Int_t kvarbl; 1046 for (Int_t j=0; j<=fDegree; j++) 1047 { 1017 // error matrix was calculated 1048 1018 if (gMinuit) 1049 gMinuit->mnpout(j, name, val, err, bnd1, bnd2, jvarbl); 1050 for (Int_t k=0; k<=fDegree; k++) 1051 { 1052 if (gMinuit) 1053 gMinuit->mnpout(k, name, val, err, bnd1, bnd2, kvarbl); 1054 if (jvarbl == 0 || kvarbl == 0) 1055 fEma[j][k] = 0.0; 1056 else 1057 fEma[j][k] = fEmat[jvarbl-1][kvarbl-1]; 1019 gMinuit->mnemat(&fEmat[0][0], fNdim); 1020 1021 // copy covariance matrix into a matrix which includes also the fixed 1022 // parameters 1023 TString name; 1024 Double_t bnd1, bnd2, val, err; 1025 Int_t jvarbl; 1026 Int_t kvarbl; 1027 for (Int_t j=0; j<=fDegree; j++) 1028 { 1029 if (gMinuit) 1030 gMinuit->mnpout(j, name, val, err, bnd1, bnd2, jvarbl); 1031 1032 for (Int_t k=0; k<=fDegree; k++) 1033 { 1034 if (gMinuit) 1035 gMinuit->mnpout(k, name, val, err, bnd1, bnd2, kvarbl); 1036 1037 fEma[j][k] = jvarbl==0 || kvarbl==0 ? 0 : fEmat[jvarbl-1][kvarbl-1]; 1038 } 1058 1039 } 1059 }1060 1040 } 1061 1041 else 1062 1042 { 1063 // error matrix was not calculated, construct it1064 *fLog << "MHFindSignificance::FitPolynomial; error matrix not defined"1043 // error matrix was not calculated, construct it 1044 *fLog << "MHFindSignificance::FitPolynomial; error matrix not defined" 1065 1045 << endl; 1066 for (Int_t j=0; j<=fDegree; j++) 1067 { 1068 for (Int_t k=0; k<=fDegree; k++) 1069 { 1070 fEma[j][k] = 0.0; 1046 for (Int_t j=0; j<=fDegree; j++) 1047 { 1048 for (Int_t k=0; k<=fDegree; k++) 1049 fEma[j][k] = 0; 1050 1051 fEma[j][j] = fErrors[j]*fErrors[j]; 1071 1052 } 1072 fEma[j][j] = fErrors[j]*fErrors[j];1073 }1074 1053 } 1075 1054 … … 1078 1057 // calculate correlation matrix 1079 1058 for (Int_t j=0; j<=fDegree; j++) 1080 { 1081 for (Int_t k=0; k<=fDegree; k++) 1082 { 1083 if (fEma[j][j]*fEma[k][k] != 0.0) 1084 fCorr[j][k] = fEma[j][k] / sqrt( fEma[j][j]*fEma[k][k] ); 1085 else 1086 fCorr[j][k] = 0.0; 1087 } 1088 } 1059 for (Int_t k=0; k<=fDegree; k++) 1060 { 1061 const Double_t sq = fEma[j][j]*fEma[k][k]; 1062 fCorr[j][k] = sq==0 ? 0 : fEma[j][k] / TMath::Sqrt(fEma[j][j]*fEma[k][k]); 1063 } 1089 1064 1090 1065 … … 1092 1067 // reset the errors of the points in the histogram 1093 1068 for (Int_t i=1; i<=nbins; i++) 1094 { 1095 fHist->SetBinError(i, saveError[i-1]); 1096 } 1097 1069 fHist->SetBinError(i, saveError[i-1]); 1098 1070 1099 1071 return kTRUE; … … 1114 1086 // search bin i0 which has x0 as lower edge 1115 1087 1116 Int_t 1117 Int_t 1088 Int_t i0 = -1; 1089 Int_t nbold = fHistOrig->GetNbinsX(); 1118 1090 for (Int_t i=1; i<=nbold; i++) 1119 1091 { 1120 if ( fabs(fHistOrig->GetBinLowEdge(i) - x0) < 1.e-4 )1121 {1122 i0 = i;1123 break;1124 }1092 if (TMath::Abs(fHistOrig->GetBinLowEdge(i) - x0) < 1.e-4 ) 1093 { 1094 i0 = i; 1095 break; 1096 } 1125 1097 } 1126 1098 … … 1137 1109 // get new bin edges 1138 1110 1139 Int_t nbnew = (nbold-istart+1) / nrebin; 1140 Double_t xmin = fHistOrig->GetBinLowEdge(istart); 1141 Double_t xmax = xmin + 1142 ((Double_t)nbnew) * ((Double_t)nrebin) * fHistOrig->GetBinWidth(1); 1111 const Int_t nbnew = (nbold-istart+1) / nrebin; 1112 const Double_t xmin = fHistOrig->GetBinLowEdge(istart); 1113 const Double_t xmax = xmin + (Double_t)nbnew * nrebin * fHistOrig->GetBinWidth(1); 1143 1114 fHist->SetBins(nbnew, xmin, xmax); 1144 1115 … … 1152 1123 for (Int_t i=1; i<=nbnew; i++) 1153 1124 { 1154 Int_t j = nrebin*(i-1) + istart;1155 1156 Double_t content = 0.0;1157 Double_t error2 = 0.0;1158 for (Int_t k=0; k<nrebin; k++)1159 {1160 content += fHistOrig->GetBinContent(j+k);1161 error2 += fHistOrig->GetBinError(j+k) * fHistOrig->GetBinError(j+k);1162 }1163 fHist->SetBinContent(i, content);1164 fHist->SetBinError (i, sqrt(error2));1165 } 1166 fHist->SetEntries( fHistOrig->GetEntries() ); 1125 Int_t j = nrebin*(i-1) + istart; 1126 1127 Double_t content = 0; 1128 Double_t error2 = 0; 1129 for (Int_t k=0; k<nrebin; k++) 1130 { 1131 content += fHistOrig->GetBinContent(j+k); 1132 error2 += fHistOrig->GetBinError(j+k) * fHistOrig->GetBinError(j+k); 1133 } 1134 fHist->SetBinContent(i, content); 1135 fHist->SetBinError (i, sqrt(error2)); 1136 } 1137 fHist->SetEntries( fHistOrig->GetEntries() ); 1167 1138 1168 1139 return kTRUE; … … 1286 1257 Double_t xmax = 90.0; 1287 1258 1288 TString bra1 = "[";1289 TString bra2 = "]";1290 1259 TString xpower = "*x"; 1291 1260 TString newpower = "*x"; … … 1293 1262 TString formulaBackg = "[0]"; 1294 1263 for (Int_t i=1; i<=fDegree; i++) 1295 { 1296 formulaBackg += "+"; 1297 formulaBackg += bra1; 1298 formulaBackg += i; 1299 formulaBackg += bra2; 1300 formulaBackg += xpower; 1301 1302 xpower += newpower; 1303 } 1304 1305 TString formulaGauss = bra1; 1306 formulaGauss += fDegree+1; 1307 formulaGauss += bra2; 1308 formulaGauss += "/"; 1309 formulaGauss += bra1; 1310 formulaGauss += fDegree+3; 1311 formulaGauss += bra2; 1312 formulaGauss += "*exp(-0.5*((x-"; 1313 formulaGauss += bra1; 1314 formulaGauss += fDegree+2; 1315 formulaGauss += bra2; 1316 formulaGauss += ")/"; 1317 formulaGauss += bra1; 1318 formulaGauss += fDegree+3; 1319 formulaGauss += bra2; 1320 formulaGauss += ")^2)"; 1264 formulaBackg += Form("+[%d]^%d", i, i); 1265 1266 const TString formulaGauss = Form("[%d]/[%d]*exp(-0.5*((x-[%d])/[%d])^2)", 1267 fDegree+1, fDegree+3, fDegree+2, fDegree+3); 1321 1268 1322 1269 TString formula = formulaBackg; … … 1337 1284 //------------------------ 1338 1285 // attention : the dimensions must agree with those in CallMinuit() 1339 1340 char parname[80][100];1341 Double_t vinit[80];1342 Double_t step[80];1343 Double_t limlo[80];1344 Double_t limup[80];1345 Int_t fix[80];1346 1347 1286 Int_t npar = fDegree+1 + 3; 1287 1288 TString parname[npar]; 1289 TArrayD vinit(npar); 1290 TArrayD step(npar); 1291 TArrayD limlo(npar); 1292 TArrayD limup(npar); 1293 TArrayI fix(npar); 1294 1348 1295 1349 1296 // take as initial values for the polynomial 1350 1297 // the result from the polynomial fit 1351 1298 for (Int_t j=0; j<=fDegree; j++) 1352 {1353 1299 vinit[j] = fPoly->GetParameter(j); 1354 } 1355 1356 1357 1358 Double_t sigma = 8.0; 1359 vinit[fDegree+1] = 2.0 * fNex * fHist->GetBinWidth(1) / 1360 sqrt( 2.0*TMath::Pi() ); 1361 vinit[fDegree+2] = 0.0; 1300 1301 Double_t sigma = 8; 1302 vinit[fDegree+1] = 2.0 * fNex * fHist->GetBinWidth(1) / TMath::Sqrt(TMath::Pi()*2); 1303 vinit[fDegree+2] = 0; 1362 1304 vinit[fDegree+3] = sigma; 1363 1305 … … 1367 1309 for (Int_t j=0; j<npar; j++) 1368 1310 { 1369 sprintf(&parname[j][0], "p%d", j+1); 1370 1371 if (vinit[j] != 0.0) 1372 step[j] = fabs(vinit[j]) / 10.0; 1373 else 1374 step[j] = 0.000001; 1375 1376 limlo[j] = 0.0; 1377 limup[j] = 0.0; 1378 1379 fix[j] = 0; 1311 parname[j] = "p"; 1312 parname[j] += j+1; 1313 1314 step[j] = vinit[j]!=0 ? TMath::Abs(vinit[j]) / 10.0 : 0.000001; 1380 1315 } 1381 1316 1382 1317 // limit the first coefficient of the polynomial to positive values 1383 1318 // because the background must not be negative 1384 limlo[0] = 0.0; 1385 limup[0] = 10.0 * fHist->GetEntries(); 1319 limup[0] = fHist->GetEntries()*10; 1386 1320 1387 1321 // limit the sigma of the Gauss function 1388 limlo[fDegree+3] = 0.0; 1389 limup[fDegree+3] = 20.0; 1322 limup[fDegree+3] = 20; 1390 1323 1391 1324 1392 1325 // use the subsequernt loop if you want to apply the 1393 1326 // constraint : uneven derivatives (at alpha=0) = zero 1394 for (Int_t j=1; j<=fDegree; j +=2)1395 { 1396 vinit[j] = 0.0;1397 step[j] = 0.0;1398 fix[j] =1;1327 for (Int_t j=1; j<=fDegree; j+=2) 1328 { 1329 vinit[j] = 0; 1330 step[j] = 0; 1331 fix[j] = 1; 1399 1332 } 1400 1333 1401 1334 // fix position of Gauss function 1402 vinit[fDegree+2] = 0 .0;1403 step[fDegree+2] = 0 .0;1404 fix[fDegree+2] = 1335 vinit[fDegree+2] = 0; 1336 step[fDegree+2] = 0; 1337 fix[fDegree+2] = 1; 1405 1338 1406 1339 // if a constant background has been assumed (due to low statistics) … … 1408 1341 if (fConstantBackg) 1409 1342 { 1410 step[0] = 0.0; 1411 fix[0] = 1; 1412 } 1413 1414 TString method = "Migrad"; 1415 TObject *objectfit = fHist; 1416 Bool_t nulloutput = kFALSE; 1343 step[0] = 0; 1344 fix[0] = 1; 1345 } 1417 1346 1418 1347 MMinuitInterface inter; 1419 Bool_t rc = inter.CallMinuit( fcnpolygauss, npar, parname,vinit, step,1420 limlo, limup, fix, objectfit, method,1421 nulloutput);1348 const Bool_t rc = inter.CallMinuit(fcnpolygauss, parname, vinit, step, 1349 limlo, limup, fix, fHist, "Migrad", 1350 kFALSE); 1422 1351 1423 1352 if (rc != 0) … … 1480 1409 fdSigmaGauss = fGErrors[fDegree+3]; 1481 1410 // fitted total number of excess events 1482 fNexGauss = fGValues[fDegree+1] * sqrt(2.0*TMath::Pi()) /1483 ( 2.0 * fHist->GetBinWidth(1));1411 fNexGauss = fGValues[fDegree+1] * TMath::Sqrt(TMath::Pi()*2) / 1412 (fHist->GetBinWidth(1)*2 ); 1484 1413 fdNexGauss = fNexGauss * fGErrors[fDegree+1]/fGValues[fDegree+1]; 1485 1414 … … 1502 1431 for (Int_t j=0; j<npar; j++) 1503 1432 { 1504 if (gMinuit)1505 gMinuit->mnpout(j, name, val, err, bnd1, bnd2, jvarbl);1506 for (Int_t k=0; k<npar; k++)1507 {1508 1433 if (gMinuit) 1509 gMinuit->mnpout(k, name, val, err, bnd1, bnd2, kvarbl); 1510 if (jvarbl == 0 || kvarbl == 0) 1511 fGEma[j][k] = 0.0; 1512 else 1513 fGEma[j][k] = fGEmat[jvarbl-1][kvarbl-1]; 1514 } 1434 gMinuit->mnpout(j, name, val, err, bnd1, bnd2, jvarbl); 1435 1436 for (Int_t k=0; k<npar; k++) 1437 { 1438 if (gMinuit) 1439 gMinuit->mnpout(k, name, val, err, bnd1, bnd2, kvarbl); 1440 1441 fGEma[j][k] = jvarbl==0 || kvarbl==0 ? 0 : fGEmat[jvarbl-1][kvarbl-1]; 1442 } 1515 1443 } 1516 1444 } … … 1522 1450 for (Int_t j=0; j<npar; j++) 1523 1451 { 1524 for (Int_t k=0; k<npar; k++) 1525 { 1526 fGEma[j][k] = 0.0; 1527 } 1528 fGEma[j][j] = fGErrors[j]*fGErrors[j]; 1452 for (Int_t k=0; k<npar; k++) 1453 fGEma[j][k] = 0; 1454 1455 fGEma[j][j] = fGErrors[j]*fGErrors[j]; 1529 1456 } 1530 1457 } … … 1537 1464 for (Int_t k=0; k<npar; k++) 1538 1465 { 1539 if (fGEma[j][j]*fGEma[k][k] != 0.0) 1540 fGCorr[j][k] = fGEma[j][k] / sqrt( fGEma[j][j]*fGEma[k][k] ); 1541 else 1542 fGCorr[j][k] = 0.0; 1466 const Double_t sq = fGEma[j][j]*fGEma[k][k]; 1467 fGCorr[j][k] = sq==0 ? 0 : fGEma[j][k] / sqrt( fGEma[j][j]*fGEma[k][k] ); 1543 1468 } 1544 1469 } … … 1548 1473 // reset the errors of the points in the histogram 1549 1474 for (Int_t i=1; i<=nbins; i++) 1550 {1551 1475 fHist->SetBinError(i, saveError[i-1]); 1552 }1553 1476 1554 1477 return kTRUE; -
trunk/MagicSoft/Mars/mhist/MHFindSignificance.h
r2300 r2311 1 1 #ifndef MARS_MHFindSignificance 2 2 #define MARS_MHFindSignificance 3 4 #ifdef MARS_MLogManip5 #error Please make ensure that MLogManip.h are included _after_ MHFindSignificance.h6 #endif7 8 3 9 4 #ifndef MARS_MH … … 11 6 #endif 12 7 8 #ifndef ROOT_TArrayD 13 9 #include <TArrayD.h> 14 #include <TH1.h> 15 #include <TCanvas.h> 10 #endif 16 11 17 class TArrayD;18 12 class TF1; 19 13 class TH1; 14 class TCanvas; 20 15 21 16 class MHFindSignificance : public MH
Note:
See TracChangeset
for help on using the changeset viewer.