diff --git a/ChangeLog b/ChangeLog index 92fd9cd8..1863b388 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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. diff --git a/doc/examples/BMWlibs/test-libFitPofB_Meissner-ROOT-NPP.msr b/doc/examples/BMWlibs/test-libFitPofB_Meissner-ROOT-NPP.msr index 8c158feb..36bd8c4d 100644 --- a/doc/examples/BMWlibs/test-libFitPofB_Meissner-ROOT-NPP.msr +++ b/doc/examples/BMWlibs/test-libFitPofB_Meissner-ROOT-NPP.msr @@ -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 diff --git a/src/any2many.cpp b/src/any2many.cpp index aed8f8a2..8b922cd2 100644 --- a/src/any2many.cpp +++ b/src/any2many.cpp @@ -78,10 +78,12 @@ void any2many_syntax() cout << endl << " year, i.e. [yyyy] will result in something like 1999."; cout << endl << " -c : "; cout << endl << " : 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 << " : 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 : where 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."; diff --git a/src/classes/PFitter.cpp b/src/classes/PFitter.cpp index 99aa70c7..f7b9b3b7 100644 --- a/src/classes/PFitter.cpp +++ b/src/classes/PFitter.cpp @@ -38,11 +38,14 @@ #endif #include +#include #include #include + +#include using namespace std; -#include +#include #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::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::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> 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::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 +//-------------------------------------------------------------------------- +/** + *

+ * + * return: + */ +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 //------------------------------------------------------------------------------------------------- diff --git a/src/include/PFitter.h b/src/include/PFitter.h index d968d7f4..aba1ddfa 100644 --- a/src/include/PFitter.h +++ b/src/include/PFitter.h @@ -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_