added some information about elapsed fitting times. Corrected some outdated online helps.

This commit is contained in:
suter_a 2013-01-07 11:54:28 +00:00
parent 55eeeeb740
commit 459a36fa79
5 changed files with 101 additions and 33 deletions

View File

@ -6,6 +6,8 @@
changes since 0.11.0
===================================
NEW 2013-01-07 print out the estimated time needed for the Minimize,Minos, etc.
both, to the stdout and to the MINUIT2.OUTPUT file.
NEW 2012-11-19 added a flag in the Fourier block (dc-corrected) which can
be used to subtract a potential DC-offset before the Fourier
transform is carried out.

View File

@ -4,19 +4,19 @@ FITPARAMETER
# No Name Value Step Pos_Error Boundaries
1 field 94.717 0 none
2 deadlayer 10.5 0 none
3 lambda 115.947 -0.91963 none
3 lambda 115.96 -0.92 0.88
# E = 22keV
4 phase22 25.4956 0 none
5 asym22 0.104724 -0.00293244 none 0 0.3
6 rate22 0.558459 -0.0323891 none
7 NormL22 753.067 -0.86835 none
8 BGL22 51.0796 -0.132894 none
9 NormR22 545.968 -0.762193 none
10 BGR22 38.5992 -0.115679 none
11 relasyR22 1.0697 -0.0377904 none 0.2 2
12 relphaR22 162.711 -1.53722 none 110 210
5 asym22 0.1047 -0.0029 0.0030 0 0.3
6 rate22 0.558 -0.032 0.033
7 NormL22 753.00 -0.87 0.87
8 BGL22 51.08 -0.13 0.13
9 NormR22 545.93 -0.77 0.76
10 BGR22 38.60 -0.12 0.12
11 relasyR22 1.068 -0.038 0.039 0.2 2
12 relphaR22 162.8 -1.5 1.5 110 210
13 energy22 22 0 none
14 one 1 0 none
@ -41,11 +41,11 @@ norm 7
backgr.fit 8
lifetimecorrection
map 4 5 6 14 15 13 0 0 0 0
forward 1
forward 1
background 65000 66500
data 3419 63000
t0 3419
fit 0.15 10.00
t0 3419.0
fit 0.15 10
packing 150
RUN data/lem09_his_0916 MUE4 PSI ROOT-NPP (name beamline institute data-file-format)
@ -54,21 +54,17 @@ norm 9
backgr.fit 10
lifetimecorrection
map 4 5 6 11 12 13 0 0 0 0
forward 3
forward 3
background 65000 66500
data 3419 63000
t0 3419
fit 0.15 10.00
t0 3419.0
fit 0.15 10
packing 150
###############################################################
COMMANDS
MINIMIZE
#HESSE
#MINOS
#SCAN 3
CONTOURS 2 3
MNPLOT
MINOS
SAVE
###############################################################
@ -78,13 +74,13 @@ fourier_power 10
apodization WEAK # NONE, WEAK, MEDIUM, STRONG
plot POWER # REAL, IMAG, REAL_AND_IMAG, POWER, PHASE
phase par4
range 0.00 200.00
range 0 200
###############################################################
PLOT 0 (single histo plot)
runs 1 2
range 0.00 4.00 -0.25 0.25
range 0 4 -0.25 0.25
###############################################################
STATISTIC --- 2010-03-12 11:22:43
*** FIT DID NOT CONVERGE ***
STATISTIC --- 2013-01-07 11:11:17
chisq = 696.9, NDF = 663, chisq/NDF = 1.051076

View File

@ -78,10 +78,12 @@ void any2many_syntax()
cout << endl << " year, i.e. [yyyy] will result in something like 1999.";
cout << endl << " -c <convert-options> : <inFormat> <outFormat>";
cout << endl << " <inFormat> : input data file format. Supported formats are:";
cout << endl << " MusrRoot, PSI-BIN, ROOT (LEM), MUD, NeXus1, NeXus2, PSI-MDU, WKM";
cout << endl << " MusrRoot, PSI-BIN, ROOT (LEM), MUD, NeXus, PSI-MDU, WKM";
cout << endl << " <outFormat> : ouput data file format. Supported formats are:";
cout << endl << " PSI-BIN, MusrRoot, MUD, NeXus1-HDF4, NeXus1-HDF5, NeXus1-XML,";
cout << endl << " PSI-BIN, MusrRoot, ROOT, MUD, NeXus1-HDF4, NeXus1-HDF5, NeXus1-XML,";
cout << endl << " NeXus2-HDF4, NeXus2-HDF5, NeXus2-XML, WKM, ASCII";
cout << endl << " Comment: ROOT is superseeded by MusrRoot. If there is not a very good";
cout << endl << " reason, avoid it!";
cout << endl << " -p <output-path> : where <output-path> is the output path for the";
cout << endl << " converted files. If nothing is given, the current directory";
cout << endl << " will be used, unless the option '-s' is used.";

View File

@ -38,11 +38,14 @@
#endif
#include <iostream>
#include <iomanip>
#include <fstream>
#include <limits>
#include <cmath>
using namespace std;
#include <math.h>
#include <sys/time.h>
#include "Minuit2/FunctionMinimum.h"
#include "Minuit2/MnContours.h"
@ -136,6 +139,8 @@ PFitter::~PFitter()
fScanData.clear();
fElapsedTime.clear();
if (fFcnMin) {
delete fFcnMin;
fFcnMin = 0;
@ -1127,10 +1132,15 @@ Bool_t PFitter::ExecuteHesse()
UInt_t maxfcn = numeric_limits<UInt_t>::max();
// call hesse
Double_t start=0.0, end=0.0;
start=MilliTime();
ROOT::Minuit2::MnUserParameterState mnState = hesse((*fFitterFcn), fMnUserParams, maxfcn);
end=MilliTime();
cout << ">> PFitter::ExecuteMinimize(): execution time for Hesse = " << setprecision(3) << (end-start)/1.0e3 << " sec." << endl;
TString str = TString::Format("Hesse: %.3f sec", (end-start)/1.0e3);
fElapsedTime.push_back(str);
if (!mnState.IsValid()) {
cerr << endl << "**WARNING** PFitter::ExecuteHesse(): Hesse encountered some problems!";
cerr << endl << ">> PFitter::ExecuteHesse(): **WARNING** Hesse encountered some problems!";
cerr << endl;
return false;
}
@ -1168,9 +1178,16 @@ Bool_t PFitter::ExecuteMigrad()
UInt_t maxfcn = numeric_limits<UInt_t>::max();
// tolerance = MINUIT2 Default tolerance
Double_t tolerance = 0.1;
// keep track of elapsed time
Double_t start=0.0, end=0.0;
start=MilliTime();
ROOT::Minuit2::FunctionMinimum min = migrad(maxfcn, tolerance);
end=MilliTime();
cout << ">> PFitter::ExecuteMinimize(): execution time for Migrad = " << setprecision(3) << (end-start)/1.0e3 << " sec." << endl;
TString str = TString::Format("Migrad: %.3f sec", (end-start)/1.0e3);
fElapsedTime.push_back(str);
if (!min.IsValid()) {
cerr << endl << "**WARNING**: PFitter::ExecuteMigrad(): Fit did not converge, sorry ...";
cerr << endl << ">> PFitter::ExecuteMigrad(): **WARNING**: Fit did not converge, sorry ...";
cerr << endl;
fIsValid = false;
return false;
@ -1237,9 +1254,16 @@ Bool_t PFitter::ExecuteMinimize()
// tolerance = MINUIT2 Default tolerance
Double_t tolerance = 0.1;
// keep track of elapsed time
Double_t start=0.0, end=0.0;
start = MilliTime();
ROOT::Minuit2::FunctionMinimum min = minimize(maxfcn, tolerance);
end = MilliTime();
cout << ">> PFitter::ExecuteMinimize(): execution time for Minimize = " << setprecision(3) << (end-start)/1.0e3 << " sec." << endl;
TString str = TString::Format("Minimize: %.3f sec", (end-start)/1.0e3);
fElapsedTime.push_back(str);
if (!min.IsValid()) {
cerr << endl << "**WARNING**: PFitter::ExecuteMinimize(): Fit did not converge, sorry ...";
cerr << endl << ">> PFitter::ExecuteMinimize(): **WARNING**: Fit did not converge, sorry ...";
cerr << endl;
fIsValid = false;
return false;
@ -1311,7 +1335,13 @@ Bool_t PFitter::ExecuteMinos()
}
// make minos analysis
Double_t start=0.0, end=0.0;
start=MilliTime();
ROOT::Minuit2::MnMinos minos((*fFitterFcn), (*fFcnMin));
end=MilliTime();
cout << ">> PFitter::ExecuteMinimize(): execution time for Minos = " << setprecision(3) << (end-start)/1.0e3 << " sec." << endl;
TString str = TString::Format("Minos: %.3f sec", (end-start)/1.0e3);
fElapsedTime.push_back(str);
for (UInt_t i=0; i<fParams.size(); i++) {
// only try to call minos if the parameter is not fixed!!
@ -1529,7 +1559,7 @@ Bool_t PFitter::ExecuteSave(Bool_t firstSave)
// check if the user parameter state is valid
if (!mnState.IsValid()) {
cerr << endl << "**WARNING** Minuit2 User Parameter State is not valid, i.e. nothing to be saved";
cerr << endl << ">> PFitter::ExecuteSave: **WARNING** Minuit2 User Parameter State is not valid, i.e. nothing to be saved";
cerr << endl;
return false;
}
@ -1616,10 +1646,21 @@ Bool_t PFitter::ExecuteSave(Bool_t firstSave)
fout << endl << "*************************************************************************";
fout << endl;
// write elapsed times
fout << endl << " elapsed times:";
for (UInt_t i=0; i<fElapsedTime.size(); i++) {
fout << endl << " " << fElapsedTime[i];
}
fout << endl;
fout << endl << "*************************************************************************";
fout << endl;
fElapsedTime.clear();
// write global informations
fout << endl << " Fval() = " << mnState.Fval() << ", Edm() = " << mnState.Edm() << ", NFcn() = " << mnState.NFcn();
fout << endl;
fout << endl << "*************************************************************************";
fout << endl;
// identifiy the longest variable name for proper formating reasons
Int_t maxLength = 10;
@ -1868,9 +1909,16 @@ Bool_t PFitter::ExecuteSimplex()
UInt_t maxfcn = numeric_limits<UInt_t>::max();
// tolerance = MINUIT2 Default tolerance
Double_t tolerance = 0.1;
// keep track of elapsed time
Double_t start=0.0, end=0.0;
start=MilliTime();
ROOT::Minuit2::FunctionMinimum min = simplex(maxfcn, tolerance);
end=MilliTime();
cout << ">> PFitter::ExecuteMinimize(): execution time for Simplex = " << setprecision(3) << (end-start)/1.0e3 << " sec." << endl;
TString str = TString::Format("Simplex: %.3f sec", (end-start)/1.0e3);
fElapsedTime.push_back(str);
if (!min.IsValid()) {
cerr << endl << "**WARNING**: PFitter::ExecuteSimplex(): Fit did not converge, sorry ...";
cerr << endl << ">> PFitter::ExecuteSimplex(): **WARNING**: Fit did not converge, sorry ...";
cerr << endl;
fIsValid = false;
return false;
@ -1915,6 +1963,22 @@ Bool_t PFitter::ExecuteSimplex()
return true;
}
//--------------------------------------------------------------------------
// MilliTime
//--------------------------------------------------------------------------
/**
* <p>
*
* <b>return:</b>
*/
Double_t PFitter::MilliTime()
{
struct timeval now;
gettimeofday(&now, 0);
return ((Double_t)now.tv_sec * 1.0e6 + (Double_t)now.tv_usec)/1.0e3;
}
//-------------------------------------------------------------------------------------------------
// end
//-------------------------------------------------------------------------------------------------

View File

@ -108,6 +108,8 @@ class PFitter
PDoublePairVector fOriginalFitRange; ///< keeps the original fit range in case there is a range command in the COMMAND block
PStringVector fElapsedTime;
// commands
Bool_t CheckCommands();
Bool_t SetParameters();
@ -126,6 +128,8 @@ class PFitter
Bool_t ExecuteScan();
Bool_t ExecuteSave(Bool_t first);
Bool_t ExecuteSimplex();
Double_t MilliTime();
};
#endif // _PFITTER_H_