diff --git a/ChangeLog b/ChangeLog index 7d0ab59d..d3f17096 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,9 @@ changes since 0.11.0 =================================== +NEW 2012-10-25 (i) add PRINT_LEVEL to the command block (0='nothing' to +3='everything'). This allows to tune the Minuit2 output. (ii) added the +possibilty to give the fit range in bins. For details see the docu. NEW 2012-09-24 add header information for printing. NEW 2012-05-31 added Noakes-Kalvius function (see A. Yaouanc and P. Dalmas de Reotiers, "Muon Spin Rotation, Relaxation, and Resonance" Oxford, Section 6.4.1.3). diff --git a/doc/html/user/MUSR/BmwLibs.html b/doc/html/user/MUSR/BmwLibs.html index 7e2f571d..0e82bbdc 100644 --- a/doc/html/user/MUSR/BmwLibs.html +++ b/doc/html/user/MUSR/BmwLibs.html @@ -1,6 +1,6 @@ - + @@ -8,7 +8,7 @@ - + @@ -111,9 +111,7 @@ pre {

- - - +

To be written... @@ -146,7 +144,7 @@ pre {
Topic revision: 10 Jul 2011, wojek
@@ -194,7 +192,7 @@ pre { - +

diff --git a/doc/html/user/MUSR/LibFitPofB.html b/doc/html/user/MUSR/LibFitPofB.html index 5c02d2de..dde0258d 100644 --- a/doc/html/user/MUSR/LibFitPofB.html +++ b/doc/html/user/MUSR/LibFitPofB.html @@ -1,6 +1,6 @@ - + @@ -8,7 +8,7 @@ - + @@ -111,9 +111,7 @@ pre {

- - - +

@@ -422,7 +420,7 @@ An example XML file looks as follows:
Topic revision: 10 Jul 2011, wojek
@@ -470,7 +468,7 @@ An example XML file looks as follows: - +

diff --git a/doc/html/user/MUSR/LibZFRelaxation.html b/doc/html/user/MUSR/LibZFRelaxation.html index 3ba871e5..10c7aaf7 100644 --- a/doc/html/user/MUSR/LibZFRelaxation.html +++ b/doc/html/user/MUSR/LibZFRelaxation.html @@ -1,6 +1,6 @@ - + @@ -8,7 +8,7 @@ - + @@ -111,9 +111,7 @@ pre {

- - - +

@@ -227,7 +225,7 @@ The parameters are:
Topic revision: 10 Jul 2011, wojek
@@ -275,7 +273,7 @@ The parameters are:
    - +

    diff --git a/doc/html/user/MUSR/Msr2Data.html b/doc/html/user/MUSR/Msr2Data.html index b5c56e0a..a4c71b05 100644 --- a/doc/html/user/MUSR/Msr2Data.html +++ b/doc/html/user/MUSR/Msr2Data.html @@ -1,6 +1,6 @@ - + @@ -8,7 +8,7 @@ - + @@ -111,9 +111,7 @@ pre {

    - - - +

    @@ -351,7 +349,7 @@ For reporting bugs or requesting new features and improvements please use the - @@ -421,7 +419,7 @@ For reporting bugs or requesting new features and improvements please use the
    - +

    diff --git a/doc/html/user/MUSR/MusrFit.html b/doc/html/user/MUSR/MusrFit.html index 1a8b9fb2..d91617be 100644 --- a/doc/html/user/MUSR/MusrFit.html +++ b/doc/html/user/MUSR/MusrFit.html @@ -1,6 +1,6 @@ - + @@ -8,7 +8,7 @@ - + @@ -111,9 +111,7 @@ pre {

    - - - +

    @@ -908,7 +906,9 @@ etc.
    xy-data (fit type 8)
    Specification of the data from an ASCII or DB file which should be used as x and y data (in this order). For a simple ASCII file the column numbers are used, in the case of a DB file one can either specify the variable numbers or the name of the variables as given in the DB header.

    -
    fit
    The range of data that should be considered when the fitting is done. For the μSR fit types 0, 2, and 4 here the starting and end times are given in microseconds. For the non-μSR fit type 8 the starting and end points of the fitting range are given in the units of the x data.
    In case the fit range specified here is larger than the
    data range (in any direction), eventually the data range will be used as fit range. +
    fit
    The range of data that should be considered when the fitting is done. For the μSR fit types 0, 2, and 4 here the starting and end times are given in microseconds. For the non-μSR fit type 8 the starting and end points of the fitting range are given in the units of the x data.
    In case the fit range specified here is larger than the data range (in any direction), eventually the data range will be used as fit range. An example for a μSR fit:
    +fit 0.2 8.5
    +
    Which means that the fitting window will span from 0.2 to 8.5 microseconds.
    Another possibility for the μSR fits is to give the fit range in bins, rather than time. The syntax is then:
    fit fgb+<n0> lgb-<n1>,
    where fgb and lgb are label tags which refer to the 'first good bin' and the 'last good bin' defined either in the data tag of the run block, data file, are estimated based on T0. <n0> and <n1> are offsets (given in bins) allowing to change the fit window compared to the data window. An example:
    fit fgb+150 lgb-1332

    packing
    Number of data channels to be binned together. For the non-μSR fit type 8 the binning is supposed to be 1. @@ -956,6 +956,8 @@ It is important to understand that before MINOS is called, all

    For even more complex fitting the additional command FIT_RANGE RESET | tstart tend | ts1 te1 ts2 te2 ... tsn ten is provided. It allows to change the fit range during different iterations. The command FIT_RANGE tstart tend changes the current fit range for all the runs present in the msr file. FIT_RANGE RESET will restore to the original fit ranges as provided in the RUN block. If for each run of the msr file an individual fit range should be used, the third option applies. Here n has to correspond to the number of runs in the RUN block.

    +As for the run block, there is a 2nd flavor how the FIT_RANGE can be changed, namely giving the fit range in bins, i.e. FIT_RANGE RESET | fgb+<n0> lgb-<n1> | fgb+<n00> lgb-<n01> fgb+<n10> lgb-<n11> ... fgb+<nN0> lgb-<nN1> where N is the number of available run blocks. The idea is inline with the above syntax and the syntax describe for the fit range (fit) of the RUN block. +

    A typical example could look like:
        COMMANDS
        FIT_RANGE 0.0 0.8
    @@ -964,6 +966,15 @@ A typical example could look like:
        MINIMIZE
        MINOS
        SAVE
    +
    or +
    +   COMMANDS
    +   FIT_RANGE fgb+15 lgb-1332 fgb+17 lgb-1330
    +   MINIMIZE
    +   FIT_RANGE RESET
    +   MINIMIZE
    +   MINOS
    +   SAVE
     

    @@ -1429,7 +1440,7 @@ For reporting bugs or requesting new features and improvements please use the -
    Topic revision: 25 Oct 2012, AndreasSuter
    @@ -1499,7 +1510,7 @@ For reporting bugs or requesting new features and improvements please use the
    - +

    diff --git a/doc/html/user/MUSR/MusrFitAcknowledgements.html b/doc/html/user/MUSR/MusrFitAcknowledgements.html index 214ae271..cd70d518 100644 --- a/doc/html/user/MUSR/MusrFitAcknowledgements.html +++ b/doc/html/user/MUSR/MusrFitAcknowledgements.html @@ -1,6 +1,6 @@ - + @@ -8,7 +8,7 @@ - + @@ -111,9 +111,7 @@ pre {

    - - - +

    Acknowledgements - musrfit

    @@ -144,7 +142,7 @@ pre {
    Topic revision: 10 Jul 2011, wojek
    @@ -192,7 +190,7 @@ pre { - +

    diff --git a/doc/html/user/MUSR/MusrFitSetup.html b/doc/html/user/MUSR/MusrFitSetup.html index eb1c5bf2..9ac021c7 100644 --- a/doc/html/user/MUSR/MusrFitSetup.html +++ b/doc/html/user/MUSR/MusrFitSetup.html @@ -1,6 +1,6 @@ - + @@ -8,7 +8,7 @@ - + @@ -111,9 +111,7 @@ pre {

    - - - +

    Setting up musrfit on Different Platforms

    @@ -334,7 +332,7 @@ musrview test-histo-ROOT-NPP.msr

    Notes

    - 1 : In case only a single user is working at the machine it might be considerable to change the ownership of the ROOT folder so that the user has easy write access to this directory: + 1 : In case only a single user is working at the machine it might be considerable to change the ownership of the ROOT folder so that the user has easy write access to this directory:

    2 : When using GCC ≥ 4.2 please make sure that the environment variables USE_PARALLEL_MINUIT2 and USE_OPENMP are not set! Otherwise MINUIT2 will be compiled with parallelization support and cannot be used together with musrfit afterwards since the musrfit code is not fully thread-safe! When compiled with GCC ≥ 4.2 musrfit itself will parallelize the χ2 calculation.

    @@ -823,7 +821,7 @@ musrview test-histo-ROOT-NPP.msr
    Topic revision: 03 Sep 2012, AndreasSuter
    @@ -871,7 +869,7 @@ musrview test-histo-ROOT-NPP.msr - +

    diff --git a/doc/html/user/MUSR/MusrGui.html b/doc/html/user/MUSR/MusrGui.html index 20a88d59..3db2da1b 100644 --- a/doc/html/user/MUSR/MusrGui.html +++ b/doc/html/user/MUSR/MusrGui.html @@ -1,6 +1,6 @@ - + @@ -8,7 +8,7 @@ - + @@ -111,9 +111,7 @@ pre {

    - - - +

    @@ -326,7 +324,7 @@ For reporting bugs or requesting new features and improvements please use the - @@ -396,7 +394,7 @@ For reporting bugs or requesting new features and improvements please use the
    - +

    diff --git a/doc/html/user/MUSR/QuickStart.html b/doc/html/user/MUSR/QuickStart.html index 9dc7f288..ad694250 100644 --- a/doc/html/user/MUSR/QuickStart.html +++ b/doc/html/user/MUSR/QuickStart.html @@ -1,6 +1,6 @@ - + @@ -8,7 +8,7 @@ - + @@ -111,9 +111,7 @@ pre {

    - - - +

    Quickstart for WKM users

    @@ -282,7 +280,7 @@ RUN 2008/lem08_his_8472 MUE4 PSI ROOT-NPP (name beamline institute dat
    Topic revision: 10 Jul 2011, wojek
    @@ -330,7 +328,7 @@ RUN 2008/lem08_his_8472 MUE4 PSI ROOT-NPP (name beamline institute dat - +

    diff --git a/doc/html/user/MUSR/TutorialSingleHisto.html b/doc/html/user/MUSR/TutorialSingleHisto.html index 07620687..8a825991 100644 --- a/doc/html/user/MUSR/TutorialSingleHisto.html +++ b/doc/html/user/MUSR/TutorialSingleHisto.html @@ -1,6 +1,6 @@ - + @@ -8,7 +8,7 @@ - + @@ -111,9 +111,7 @@ pre {

    - - - +

    musrfit Single-Histogram-Fit Tutorial

    @@ -283,7 +281,7 @@ This page only summarizes the very basic features and options of the programs co -
    +

    Attachments (6)

    processing
    @@ -305,7 +303,7 @@ This page only summarizes the very basic features and options of the programs co
    Topic revision: 02 Sep 2011, wojek
    @@ -353,7 +351,7 @@ This page only summarizes the very basic features and options of the programs co
    - +

    diff --git a/doc/html/user/MUSR/WebHome.html b/doc/html/user/MUSR/WebHome.html index b7c64322..862f4269 100644 --- a/doc/html/user/MUSR/WebHome.html +++ b/doc/html/user/MUSR/WebHome.html @@ -1,6 +1,6 @@ - + @@ -8,7 +8,7 @@ - + @@ -111,9 +111,7 @@ pre {

    - - - +

    Welcome to the MUSR web

    @@ -135,7 +133,7 @@ pre {
  1. Acknowledgements
  2. --- AS & BMW - last update July 4, 2012
    +-- AS & BMW - last update Oct 25, 2012
    @@ -158,9 +156,9 @@ pre {
    -
    Topic revision: 04 Jul 2012, AndreasSuter
    +
    Topic revision: 25 Oct 2012, AndreasSuter
    @@ -206,7 +204,7 @@ pre {
    - +

    diff --git a/doc/html/user/pub/System/PsiSkin/psistyle.css b/doc/html/user/pub/System/PsiSkin/psistyle.css index 6bd13c22..9837bb2c 100644 --- a/doc/html/user/pub/System/PsiSkin/psistyle.css +++ b/doc/html/user/pub/System/PsiSkin/psistyle.css @@ -128,6 +128,10 @@ blockquote.psi { padding-right: 0px; } +.patternContent a[href^="http://i.psi.ch"] { + background: transparent; + padding-right: 0px; +} /* ...but not to absolute links in this domain... diff --git a/src/any2many.cpp b/src/any2many.cpp index 4a050c24..aed8f8a2 100644 --- a/src/any2many.cpp +++ b/src/any2many.cpp @@ -502,6 +502,10 @@ int main(int argc, char *argv[]) else dataHandler = new PRunDataHandler(&info); + // read and convert all data + dataHandler->ConvertData(); + + // check if it has been successfull bool success = dataHandler->IsAllDataAvailable(); if (!success) { cout << endl << ">> any2many **ERROR** Couldn't read all data files, will quit ..." << endl; diff --git a/src/classes/PFitter.cpp b/src/classes/PFitter.cpp index 91da24f8..b5f632dc 100644 --- a/src/classes/PFitter.cpp +++ b/src/classes/PFitter.cpp @@ -51,6 +51,7 @@ using namespace std; #include "Minuit2/MnMigrad.h" #include "Minuit2/MnMinos.h" #include "Minuit2/MnPlot.h" +#include "Minuit2/MnPrint.h" #include "Minuit2/MnScan.h" #include "Minuit2/MnSimplex.h" #include "Minuit2/MnUserParameterState.h" @@ -99,6 +100,7 @@ PFitter::PFitter(PMsrHandler *runInfo, PRunListCollection *runListCollection, Bo fScanNoPoints = 41; // minuit2 default fScanLow = 0.0; // minuit2 default, i.e. 2 std deviations fScanHigh = 0.0; // minuit2 default, i.e. 2 std deviations + fPrintLevel = 1.0; // keep all the fit ranges in case RANGE command is present PMsrRunList *runs = fRunInfo->GetMsrRunList(); @@ -289,8 +291,7 @@ Bool_t PFitter::DoFit() cerr << endl; break; case PMN_PRINT: - cerr << endl << "**WARNING** from PFitter::DoFit() : the command PRINT is not yet implemented."; - cerr << endl; + status = ExecutePrintLevel(fCmdList[i].second); break; default: cerr << endl << "**PANIC ERROR**: PFitter::DoFit(): You should never have reached this point"; @@ -447,14 +448,19 @@ Bool_t PFitter::CheckCommands() cmd.second = cmdLineNo; fCmdList.push_back(cmd); } else if (it->fLine.Contains("FIT_RANGE", TString::kIgnoreCase)) { - // check the 3 options: FIT_RANGE RESET, FIT_RANGE start end, FIT_RANGE start1 end1 start2 end2 ... startN endN + // check the 5 options: + // (i) FIT_RANGE RESET, + // (ii) FIT_RANGE start end, + // (iii) FIT_RANGE start1 end1 start2 end2 ... startN endN + // (iv) FIT_RANGE fgb+n0 lgb-n1 + // (v) FIT_RANGE fgb+n00 lgb-n01 fgb+n10 lgb-n11 ... fgb+nN0 lgb-nN1 TObjArray *tokens = 0; TObjString *ostr; TString str; tokens = it->fLine.Tokenize(", \t"); - if (tokens->GetEntries() == 2) { + if (tokens->GetEntries() == 2) { // should only be RESET ostr = dynamic_cast(tokens->At(1)); str = ostr->GetString(); if (str.Contains("RESET"), TString::kIgnoreCase) { @@ -478,7 +484,8 @@ Bool_t PFitter::CheckCommands() if ((tokens->GetEntries() > 3) && ((static_cast(tokens->GetEntries())-1)) != 2*fRunInfo->GetMsrRunList()->size()) { cerr << endl << ">> PFitter::CheckCommands: **ERROR** in line " << it->fLineNo; cerr << endl << ">> " << it->fLine.Data(); - cerr << endl << ">> Syntax: FIT_RANGE RESET | FIT_RANGE start end | FIT_RANGE s1 e1 s2 e2 .. sN eN,"; + cerr << endl << ">> Syntax: FIT_RANGE RESET | FIT_RANGE | FIT_RANGE .. |"; + cerr << endl << ">> FIT_RANGE fgb+ lgb- | FIT_RANGE fgb+ lgb- fgb+ lgb- ... fgb+ lgb-,"; cerr << endl << ">> with N the number of runs in the msr-file."; cerr << endl << ">> Found N=" << (tokens->GetEntries()-1)/2 << ", # runs in msr-file=" << fRunInfo->GetMsrRunList()->size() << endl; fIsValid = false; @@ -488,21 +495,30 @@ Bool_t PFitter::CheckCommands() } break; } else { - // check that all range entries are numbers - Int_t n=1; - do { + // check that all range entries are numbers or fgb+n0 / lgb-n1 + Bool_t ok = true; + for (Int_t n=1; nGetEntries(); n++) { ostr = dynamic_cast(tokens->At(n)); str = ostr->GetString(); - } while ((++n < tokens->GetEntries()) && str.IsFloat()); + if (!str.IsFloat()) { + if ((n%2 == 1) && (!str.Contains("fgb", TString::kIgnoreCase))) + ok = false; + if ((n%2 == 0) && (!str.Contains("lgb", TString::kIgnoreCase))) + ok = false; + } + if (!ok) + break; + } - if (str.IsFloat()) { // everything is fine, last string was a floating point number + if (ok) { // everything is fine cmd.first = PMN_FIT_RANGE; cmd.second = cmdLineNo; fCmdList.push_back(cmd); } else { cerr << endl << ">> PFitter::CheckCommands: **ERROR** in line " << it->fLineNo; cerr << endl << ">> " << it->fLine.Data(); - cerr << endl << ">> Syntax: FIT_RANGE RESET | FIT_RANGE | FIT_RANGE .. ,"; + cerr << endl << ">> Syntax: FIT_RANGE RESET | FIT_RANGE | FIT_RANGE .. |"; + cerr << endl << ">> FIT_RANGE fgb+ lgb- | FIT_RANGE fgb+ lgb- fgb+ lgb- ... fgb+ lgb-,"; cerr << endl << ">> with N the number of runs in the msr-file."; cerr << endl << ">> Found token '" << str.Data() << "', which is not a floating point number." << endl; fIsValid = false; @@ -516,8 +532,9 @@ Bool_t PFitter::CheckCommands() } else { cerr << endl << ">> PFitter::CheckCommands: **ERROR** in line " << it->fLineNo; cerr << endl << ">> " << it->fLine.Data(); - cerr << endl << ">> Syntax: FIT_RANGE RESET | FIT_RANGE start end | FIT_RANGE s1 e1 s2 e2 .. sN eN,"; - cerr << endl << ">> with N the number of runs in the msr-file." << endl; + cerr << endl << ">> Syntax: FIT_RANGE RESET | FIT_RANGE | FIT_RANGE .. |"; + cerr << endl << ">> FIT_RANGE fgb+ lgb- | FIT_RANGE fgb+ lgb- fgb+ lgb- ... fgb+ lgb-,"; + cerr << endl << ">> with N the number of runs in the msr-file."; fIsValid = false; if (tokens) { delete tokens; @@ -619,6 +636,10 @@ Bool_t PFitter::CheckCommands() cmd.first = PMN_PLOT; cmd.second = cmdLineNo; fCmdList.push_back(cmd); + } else if (it->fLine.Contains("PRINT_LEVEL", TString::kIgnoreCase)) { + cmd.first = PMN_PRINT; + cmd.second = cmdLineNo; + fCmdList.push_back(cmd); } else if (it->fLine.Contains("RELEASE", TString::kIgnoreCase)) { // check if the given set of parameters (number or names) is present TObjArray *tokens = 0; @@ -849,10 +870,6 @@ Bool_t PFitter::CheckCommands() cmd.first = PMN_USER_PARAM_STATE; cmd.second = cmdLineNo; fCmdList.push_back(cmd); - } else if (it->fLine.Contains("PRINT", TString::kIgnoreCase)) { - cmd.first = PMN_PRINT; - cmd.second = cmdLineNo; - fCmdList.push_back(cmd); } else { // unkown command cerr << endl << ">> PFitter::CheckCommands(): **FATAL ERROR** in line " << it->fLineNo << " an unkown command is found:"; cerr << endl << ">> " << it->fLine.Data(); @@ -872,7 +889,7 @@ Bool_t PFitter::CheckCommands() if (it->fLine.Contains("FIX", TString::kIgnoreCase)) fixFlag = true; else if (it->fLine.Contains("RELEASE", TString::kIgnoreCase) || - it->fLine.Contains("RESTORE", TString::kIgnoreCase)) + it->fLine.Contains("RESTORE", TString::kIgnoreCase)) releaseFlag = true; else if (it->fLine.Contains("MINIMIZE", TString::kIgnoreCase) || it->fLine.Contains("MIGRAD", TString::kIgnoreCase) || @@ -991,6 +1008,11 @@ Bool_t PFitter::ExecuteFitRange(UInt_t lineNo) { cout << ">> PFitter::ExecuteFitRange(): " << fCmdLines[lineNo].fLine.Data() << endl; + if (fCmdLines[lineNo].fLine.Contains("fgb", TString::kIgnoreCase)) { // fit range given in bins + fRunListCollection->SetFitRange(fCmdLines[lineNo].fLine); + return true; + } + TObjArray *tokens = 0; TObjString *ostr; TString str; @@ -1002,7 +1024,7 @@ Bool_t PFitter::ExecuteFitRange(UInt_t lineNo) // execute command, no error checking needed since this has been already carried out in CheckCommands() if (tokens->GetEntries() == 2) { // reset command fRunListCollection->SetFitRange(fOriginalFitRange); - } else if (tokens->GetEntries() == 3) { // single fit range for all runs + } else if (tokens->GetEntries() == 3) { // single fit range for all runs Double_t start = 0.0, end = 0.0; PDoublePair fitRange; PDoublePairVector fitRangeVector; @@ -1116,6 +1138,9 @@ Bool_t PFitter::ExecuteHesse() fRunInfo->SetMsrParamPosErrorPresent(i, false); } + if (fPrintLevel >= 2) + cout << mnState << endl; + return true; } @@ -1181,6 +1206,9 @@ Bool_t PFitter::ExecuteMigrad() fConverged = true; + if (fPrintLevel >= 2) + cout << *fFcnMin << endl; + return true; } @@ -1247,6 +1275,9 @@ Bool_t PFitter::ExecuteMinimize() fConverged = true; + if (fPrintLevel >= 2) + cout << *fFcnMin << endl; + return true; } @@ -1328,6 +1359,60 @@ Bool_t PFitter::ExecutePlot() return true; } +//-------------------------------------------------------------------------- +// ExecutePrintLevel +//-------------------------------------------------------------------------- +/** + *

    Set the print level. + * + * \param lineNo the line number of the command block + * + * return: true if done, otherwise returns false. + */ +Bool_t PFitter::ExecutePrintLevel(UInt_t lineNo) +{ + cout << ">> PFitter::ExecutePrintLevel(): " << fCmdLines[lineNo].fLine.Data() << endl; + + TObjArray *tokens = 0; + TObjString *ostr; + TString str; + + tokens = fCmdLines[lineNo].fLine.Tokenize(", \t"); + + if (tokens->GetEntries() < 2) { + cerr << endl << "**ERROR** from PFitter::ExecutePrintLevel(): SYNTAX: PRINT_LEVEL , where =0-3" << endl << endl; + return false; + } + + ostr = (TObjString*)tokens->At(1); + str = ostr->GetString(); + + Int_t ival; + if (str.IsDigit()) { + ival = str.Atoi(); + if ((ival >=0) && (ival <= 3)) { + fPrintLevel = (UInt_t) ival; + } else { + cerr << endl << "**ERROR** from PFitter::ExecutePrintLevel(): SYNTAX: PRINT_LEVEL , where =0-3"; + cerr << endl << " found =" << ival << endl << endl; + return false; + } + } else { + cerr << endl << "**ERROR** from PFitter::ExecutePrintLevel(): SYNTAX: PRINT_LEVEL , where =0-3" << endl << endl; + return false; + } + + ROOT::Minuit2::MnPrint::SetLevel(fPrintLevel); + + // clean up + if (tokens) { + delete tokens; + tokens = 0; + } + + return true; +} + //-------------------------------------------------------------------------- // ExecuteRelease //-------------------------------------------------------------------------- @@ -1810,6 +1895,9 @@ Bool_t PFitter::ExecuteSimplex() fConverged = true; + if (fPrintLevel >= 2) + cout << *fFcnMin << endl; + return true; } diff --git a/src/classes/PMsrHandler.cpp b/src/classes/PMsrHandler.cpp index 9bf458ef..decc0edd 100644 --- a/src/classes/PMsrHandler.cpp +++ b/src/classes/PMsrHandler.cpp @@ -882,16 +882,30 @@ Int_t PMsrHandler::WriteMsrLogFile(const Bool_t messages) // write fit range line fout.width(16); fout << left << "fit"; - for (UInt_t j=0; j<2; j++) { - if (fRuns[runNo].GetFitRange(j) == -1) - break; - neededWidth = 7; - neededPrec = LastSignificant(fRuns[runNo].GetFitRange(j)); - fout.width(neededWidth); + if (fRuns[runNo].IsFitRangeInBin()) { // fit range given in bins + fout << "fgb"; + if (fRuns[runNo].GetFitRangeOffset(0) > 0) + fout << "+" << fRuns[runNo].GetFitRangeOffset(0); + fout << " lgb"; + if (fRuns[runNo].GetFitRangeOffset(1) > 0) + fout << "-" << fRuns[runNo].GetFitRangeOffset(1); + neededPrec = LastSignificant(fRuns[runNo].GetFitRange(0)); + if (LastSignificant(fRuns[runNo].GetFitRange(1)) > neededPrec) + neededPrec = LastSignificant(fRuns[runNo].GetFitRange(1)); fout.precision(neededPrec); - fout << left << fixed << fRuns[runNo].GetFitRange(j); - if (j==0) - fout << " "; + fout << " # in time: " << fRuns[runNo].GetFitRange(0) << ".." << fRuns[runNo].GetFitRange(1) << " in (usec)"; + } else { // fit range given in time + for (UInt_t j=0; j<2; j++) { + if (fRuns[runNo].GetFitRange(j) == -1) + break; + neededWidth = 7; + neededPrec = LastSignificant(fRuns[runNo].GetFitRange(j)); + fout.width(neededWidth); + fout.precision(neededPrec); + fout << left << fixed << fRuns[runNo].GetFitRange(j); + if (j==0) + fout << " "; + } } fout << endl; } else if (sstr.BeginsWith("packing")) { @@ -1682,14 +1696,25 @@ Int_t PMsrHandler::WriteMsrFile(const Char_t *filename, map *co // fit fout.width(16); fout << left << "fit"; - for (UInt_t j=0; j<2; j++) { - if (fRuns[i].GetFitRange(j) == -1) - break; - fout.width(8); - UInt_t neededPrec = 2; - neededPrec = LastSignificant(fRuns[i].GetFitRange(j)); - fout.precision(neededPrec); - fout << left << fixed << fRuns[i].GetFitRange(j); + if (fRuns[i].IsFitRangeInBin()) { // fit range given in bins + fout << "fgb"; + if (fRuns[i].GetFitRangeOffset(0) > 0) + fout << "+" << fRuns[i].GetFitRangeOffset(0); + fout << " lgb"; + if (fRuns[i].GetFitRangeOffset(1) > 0) + fout << "-" << fRuns[i].GetFitRangeOffset(1); + } else { // fit range given in time + for (UInt_t j=0; j<2; j++) { + if (fRuns[i].GetFitRange(j) == -1) + break; + UInt_t neededWidth = 7; + UInt_t neededPrec = LastSignificant(fRuns[i].GetFitRange(j)); + fout.width(neededWidth); + fout.precision(neededPrec); + fout << left << fixed << fRuns[i].GetFitRange(j); + if (j==0) + fout << " "; + } } fout << endl; @@ -2921,13 +2946,49 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines) if (tokens->GetEntries() < 3) { error = true; } else { - for (Int_t i=1; i<3; i++) { - ostr = dynamic_cast(tokens->At(i)); + if (iter->fLine.Contains("fgb", TString::kIgnoreCase)) { // fit given in bins, i.e. fit fgb+n0 lgb-n1 + // check 1st entry, i.e. fgb[+n0] + ostr = dynamic_cast(tokens->At(1)); str = ostr->GetString(); - if (str.IsFloat()) - param.SetFitRange(str.Atof(), i-1); - else - error = true; + Ssiz_t idx = str.First("+"); + TString numStr = str; + if (idx > -1) { // '+' present hence extract n0 + numStr.Remove(0,idx+1); + if (numStr.IsFloat()) { + param.SetFitRangeOffset(numStr.Atoi(), 0); + } else { + error = true; + } + } else { // n0 == 0 + param.SetFitRangeOffset(0, 0); + } + // check 2nd entry, i.e. lgb[-n1] + ostr = dynamic_cast(tokens->At(2)); + str = ostr->GetString(); + idx = str.First("-"); + numStr = str; + if (idx > -1) { // '-' present hence extract n1 + numStr.Remove(0,idx+1); + if (numStr.IsFloat()) { + param.SetFitRangeOffset(numStr.Atoi(), 1); + } else { + error = true; + } + } else { // n0 == 0 + param.SetFitRangeOffset(0, 0); + } + + if (!error) + param.SetFitRangeInBins(true); + } else { // fit given in time, i.e. fit , where , are given as doubles + for (Int_t i=1; i<3; i++) { + ostr = dynamic_cast(tokens->At(i)); + str = ostr->GetString(); + if (str.IsFloat()) + param.SetFitRange(str.Atof(), i-1); + else + error = true; + } } } } @@ -4570,10 +4631,12 @@ Bool_t PMsrHandler::CheckRunBlockIntegrity() } } // check fit range - if ((fRuns[i].GetFitRange(0) == PMUSR_UNDEFINED) || (fRuns[i].GetFitRange(1) == PMUSR_UNDEFINED)) { - cerr << endl << "PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1; - cerr << endl << " Fit range is not defined. Necessary for single histogram fits." << endl; - return false; + if (!fRuns[i].IsFitRangeInBin()) { // fit range given as times in usec + if ((fRuns[i].GetFitRange(0) == PMUSR_UNDEFINED) || (fRuns[i].GetFitRange(1) == PMUSR_UNDEFINED)) { + cerr << endl << "PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1; + cerr << endl << " Fit range is not defined. Necessary for single histogram fits." << endl; + return false; + } } // check packing if (fRuns[i].GetPacking() == -1) { @@ -4603,10 +4666,12 @@ Bool_t PMsrHandler::CheckRunBlockIntegrity() return false; } // check fit range - if ((fRuns[i].GetFitRange(0) == PMUSR_UNDEFINED) || (fRuns[i].GetFitRange(1) == PMUSR_UNDEFINED)) { - cerr << endl << "PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1; - cerr << endl << " Fit range is not defined. Necessary for single histogram fits." << endl; - return false; + if (!fRuns[i].IsFitRangeInBin()) { // fit range given as times in usec + if ((fRuns[i].GetFitRange(0) == PMUSR_UNDEFINED) || (fRuns[i].GetFitRange(1) == PMUSR_UNDEFINED)) { + cerr << endl << "PMsrHandler::CheckRunBlockIntegrity(): **ERROR** in RUN block number " << i+1; + cerr << endl << " Fit range is not defined. Necessary for single histogram fits." << endl; + return false; + } } // check packing if (fRuns[i].GetPacking() == -1) { diff --git a/src/classes/PMusr.cpp b/src/classes/PMusr.cpp index d57c5569..bbd3a769 100644 --- a/src/classes/PMusr.cpp +++ b/src/classes/PMusr.cpp @@ -75,7 +75,7 @@ PRunData::~PRunData() } //-------------------------------------------------------------------------- -// SetTheoryValue +// SetTheoryValue (public) //-------------------------------------------------------------------------- /** *

    Sets a value of the theory vector @@ -92,7 +92,7 @@ void PRunData::SetTheoryValue(UInt_t idx, Double_t dval) } //-------------------------------------------------------------------------- -// ReplaceTheory +// ReplaceTheory (public) //-------------------------------------------------------------------------- /** *

    Replaces the theory vector. @@ -150,7 +150,7 @@ PNonMusrRawRunData::~PNonMusrRawRunData() } //-------------------------------------------------------------------------- -// SetLabel +// SetLabel (public) //-------------------------------------------------------------------------- /** *

    Modifies a label at position idx. In case idx is larges than the number @@ -170,7 +170,7 @@ void PNonMusrRawRunData::SetLabel(const UInt_t idx, const TString str) } //-------------------------------------------------------------------------- -// AppendSubData +// AppendSubData (public) //-------------------------------------------------------------------------- /** *

    Modifies the data set at position idx. In case idx is larger than the number @@ -190,7 +190,7 @@ void PNonMusrRawRunData::AppendSubData(const UInt_t idx, const Double_t dval) } //-------------------------------------------------------------------------- -// AppendSubErrData +// AppendSubErrData (public) //-------------------------------------------------------------------------- /** *

    Modifies the error-data set at position idx. In case idx is larger than the number @@ -555,7 +555,7 @@ PRawRunData::~PRawRunData() } //-------------------------------------------------------------------------- -// GetTemperature +// GetTemperature (public) //-------------------------------------------------------------------------- /** *

    Returns the temperature of a muSR run. @@ -577,7 +577,7 @@ const Double_t PRawRunData::GetTemperature(const UInt_t idx) } //-------------------------------------------------------------------------- -// GetTempError +// GetTempError (public) //-------------------------------------------------------------------------- /** *

    Returns the error estimate of the temperature of a muSR run. @@ -599,7 +599,7 @@ const Double_t PRawRunData::GetTempError(const UInt_t idx) } //-------------------------------------------------------------------------- -// GetRingAnode +// GetRingAnode (public) //-------------------------------------------------------------------------- /** *

    Returns the value of a ring anode high voltage. (idx = 0: RAL, 1: RAR, 2: RAT, 3: RAB) @@ -621,7 +621,7 @@ const Double_t PRawRunData::GetRingAnode(const UInt_t idx) } //-------------------------------------------------------------------------- -// GetDataSet +// GetDataSet (public) //-------------------------------------------------------------------------- /** *

    Returns a raw muSR run data set. @@ -643,7 +643,7 @@ PRawRunDataSet* PRawRunData::GetDataSet(const UInt_t idx, Bool_t wantHistoNo) //-------------------------------------------------------------------------- -// SetRingAnode +// SetRingAnode (public) //-------------------------------------------------------------------------- /** *

    Store the ring anode value at index position idx. @@ -659,7 +659,7 @@ void PRawRunData::SetRingAnode(const UInt_t idx, const Double_t dval) } //-------------------------------------------------------------------------- -// SetTemperature +// SetTemperature (public) //-------------------------------------------------------------------------- /** *

    Store the temperature with its error at index position idx. @@ -678,7 +678,7 @@ void PRawRunData::SetTemperature(const UInt_t idx, const Double_t temp, const Do } //-------------------------------------------------------------------------- -// SetTempError +// SetTempError (public) //-------------------------------------------------------------------------- /** *

    Store the temperature error at index position idx. @@ -722,8 +722,11 @@ PMsrRunBlock::PMsrRunBlock() fBkgRange[i] = -1; // undefined start background range fDataRange[i] = -1; // undefined start data range } + fFitRangeInBins = false; // default is that fit range is given in time NOT bins fFitRange[0] = PMUSR_UNDEFINED; // undefined start fit range fFitRange[1] = PMUSR_UNDEFINED; // undefined end fit range + fFitRangeOffset[0] = 0; // undefined start fit range offset + fFitRangeOffset[1] = 0; // undefined end fit range offset fPacking = -1; // undefined packing fXYDataIndex[0] = -1; // undefined x data index (NonMusr) fXYDataIndex[1] = -1; // undefined y data index (NonMusr) @@ -752,7 +755,7 @@ PMsrRunBlock::~PMsrRunBlock() } //-------------------------------------------------------------------------- -// CleanUp +// CleanUp (public) //-------------------------------------------------------------------------- /** *

    Clean up data structure. @@ -772,8 +775,11 @@ void PMsrRunBlock::CleanUp() fBkgRange[i] = -1; // undefined background range fDataRange[i] = -1; // undefined data range } + fFitRangeInBins = false; // default is that fit range is given in time NOT bins fFitRange[0] = PMUSR_UNDEFINED; // undefined start fit range fFitRange[1] = PMUSR_UNDEFINED; // undefined end fit range + fFitRangeOffset[0] = 0; // undefined start fit range offset + fFitRangeOffset[1] = 0; // undefined end fit range offset fPacking = -1; // undefined packing fXYDataIndex[0] = -1; // undefined x data index (NonMusr) fXYDataIndex[1] = -1; // undefined y data index (NonMusr) @@ -797,7 +803,7 @@ void PMsrRunBlock::CleanUp() } //-------------------------------------------------------------------------- -// GetRunName +// GetRunName (public) //-------------------------------------------------------------------------- /** *

    get run name at position idx @@ -817,7 +823,7 @@ TString* PMsrRunBlock::GetRunName(UInt_t idx) } //-------------------------------------------------------------------------- -// SetRunName +// SetRunName (public) //-------------------------------------------------------------------------- /** *

    set run name at position idx @@ -839,7 +845,7 @@ void PMsrRunBlock::SetRunName(TString &str, Int_t idx) } //-------------------------------------------------------------------------- -// GetBeamline +// GetBeamline (public) //-------------------------------------------------------------------------- /** *

    get beamline name at position idx @@ -859,7 +865,7 @@ TString* PMsrRunBlock::GetBeamline(UInt_t idx) } //-------------------------------------------------------------------------- -// SetBeamline +// SetBeamline (public) //-------------------------------------------------------------------------- /** *

    set beamline name at position idx @@ -881,7 +887,7 @@ void PMsrRunBlock::SetBeamline(TString &str, Int_t idx) } //-------------------------------------------------------------------------- -// GetInstitute +// GetInstitute (public) //-------------------------------------------------------------------------- /** *

    get institute name at position idx @@ -901,7 +907,7 @@ TString* PMsrRunBlock::GetInstitute(UInt_t idx) } //-------------------------------------------------------------------------- -// SetInstitute +// SetInstitute (public) //-------------------------------------------------------------------------- /** *

    set institute name at position idx @@ -923,7 +929,7 @@ void PMsrRunBlock::SetInstitute(TString &str, Int_t idx) } //-------------------------------------------------------------------------- -// GetFileFormat +// GetFileFormat (public) //-------------------------------------------------------------------------- /** *

    get file format name at position idx @@ -943,7 +949,7 @@ TString* PMsrRunBlock::GetFileFormat(UInt_t idx) } //-------------------------------------------------------------------------- -// SetFileFormat +// SetFileFormat (public) //-------------------------------------------------------------------------- /** *

    set file format name at position idx @@ -965,7 +971,7 @@ void PMsrRunBlock::SetFileFormat(TString &str, Int_t idx) } //-------------------------------------------------------------------------- -// GetForwardHistoNo +// GetForwardHistoNo (public) //-------------------------------------------------------------------------- /** *

    get forward histogram value at position idx @@ -988,7 +994,7 @@ Int_t PMsrRunBlock::GetForwardHistoNo(UInt_t idx) } //-------------------------------------------------------------------------- -// SetForwardHistoNo +// SetForwardHistoNo (public) //-------------------------------------------------------------------------- /** *

    set forward histogram value at index idx @@ -1009,7 +1015,7 @@ void PMsrRunBlock::SetForwardHistoNo(Int_t histoNo, Int_t idx) } //-------------------------------------------------------------------------- -// GetBackwardHistoNo +// GetBackwardHistoNo (public) //-------------------------------------------------------------------------- /** *

    get backward histogram value at position idx @@ -1032,7 +1038,7 @@ Int_t PMsrRunBlock::GetBackwardHistoNo(UInt_t idx) } //-------------------------------------------------------------------------- -// SetBackwardHistoNo +// SetBackwardHistoNo (public) //-------------------------------------------------------------------------- /** *

    set backward histogram value at position pos @@ -1053,7 +1059,7 @@ void PMsrRunBlock::SetBackwardHistoNo(Int_t histoNo, Int_t idx) } //-------------------------------------------------------------------------- -// GetMap +// GetMap (public) //-------------------------------------------------------------------------- /** *

    get map value at position idx @@ -1073,7 +1079,7 @@ Int_t PMsrRunBlock::GetMap(UInt_t idx) } //-------------------------------------------------------------------------- -// SetMap +// SetMap (public) //-------------------------------------------------------------------------- /** *

    set map value at position idx @@ -1095,7 +1101,7 @@ void PMsrRunBlock::SetMap(Int_t mapVal, Int_t idx) } //-------------------------------------------------------------------------- -// GetBkgEstimated +// GetBkgEstimated (public) //-------------------------------------------------------------------------- /** *

    get estimated background value at position idx. If not present, @@ -1117,7 +1123,7 @@ Double_t PMsrRunBlock::GetBkgEstimated(UInt_t idx) //-------------------------------------------------------------------------- -// SetBkgEstimated +// SetBkgEstimated (public) //-------------------------------------------------------------------------- /** *

    set estimated background value at position idx @@ -1137,7 +1143,7 @@ void PMsrRunBlock::SetBkgEstimated(Double_t dval, Int_t idx) } //-------------------------------------------------------------------------- -// GetBkgFix +// GetBkgFix (public) //-------------------------------------------------------------------------- /** *

    get background fixed value at position idx @@ -1157,7 +1163,7 @@ Double_t PMsrRunBlock::GetBkgFix(UInt_t idx) } //-------------------------------------------------------------------------- -// SetBkgFix +// SetBkgFix (public) //-------------------------------------------------------------------------- /** *

    set background fixed value at position idx @@ -1177,7 +1183,7 @@ void PMsrRunBlock::SetBkgFix(Double_t dval, Int_t idx) } //-------------------------------------------------------------------------- -// GetBkgRange +// GetBkgRange (public) //-------------------------------------------------------------------------- /** *

    get background range at position idx @@ -1198,7 +1204,7 @@ Int_t PMsrRunBlock::GetBkgRange(UInt_t idx) } //-------------------------------------------------------------------------- -// SetBkgRange +// SetBkgRange (public) //-------------------------------------------------------------------------- /** *

    set background range element at position idx @@ -1219,7 +1225,7 @@ void PMsrRunBlock::SetBkgRange(Int_t ival, Int_t idx) //-------------------------------------------------------------------------- -// GetDataRange +// GetDataRange (public) //-------------------------------------------------------------------------- /** *

    get data range at position idx @@ -1240,7 +1246,7 @@ Int_t PMsrRunBlock::GetDataRange(UInt_t idx) } //-------------------------------------------------------------------------- -// SetDataRange +// SetDataRange (public) //-------------------------------------------------------------------------- /** *

    set data range element at position idx @@ -1260,7 +1266,7 @@ void PMsrRunBlock::SetDataRange(Int_t ival, Int_t idx) } //-------------------------------------------------------------------------- -// GetT0Bin +// GetT0Bin (public) //-------------------------------------------------------------------------- /** *

    get T0 bin at position idx @@ -1280,7 +1286,7 @@ Double_t PMsrRunBlock::GetT0Bin(UInt_t idx) } //-------------------------------------------------------------------------- -// SetT0Bin +// SetT0Bin (public) //-------------------------------------------------------------------------- /** *

    set T0 bin at position idx @@ -1302,7 +1308,7 @@ void PMsrRunBlock::SetT0Bin(Double_t dval, Int_t idx) } //-------------------------------------------------------------------------- -// GetAddT0BinSize +// GetAddT0BinSize (public) //-------------------------------------------------------------------------- /** *

    get add T0 size of the addrun at index addRunIdx @@ -1325,7 +1331,7 @@ Int_t PMsrRunBlock::GetAddT0BinSize(UInt_t addRunIdx) } //-------------------------------------------------------------------------- -// GetAddT0Bin +// GetAddT0Bin (public) //-------------------------------------------------------------------------- /** *

    get add T0 of the addrun (index addRunIdx) at index histoIdx @@ -1355,7 +1361,7 @@ Double_t PMsrRunBlock::GetAddT0Bin(UInt_t addRunIdx, UInt_t histoIdx) } //-------------------------------------------------------------------------- -// SetAddT0Bin +// SetAddT0Bin (public) //-------------------------------------------------------------------------- /** *

    set add T0 bin of the addrun at index histoNoIdx @@ -1376,7 +1382,7 @@ void PMsrRunBlock::SetAddT0Bin(Double_t dval, UInt_t addRunIdx, UInt_t histoNoId } //-------------------------------------------------------------------------- -// GetFitRange +// GetFitRange (public) //-------------------------------------------------------------------------- /** *

    get fit range value at position idx. idx: 0=fit range start, 1=fit range end. @@ -1396,7 +1402,7 @@ Double_t PMsrRunBlock::GetFitRange(UInt_t idx) } //-------------------------------------------------------------------------- -// SetFitRange +// SetFitRange (public) //-------------------------------------------------------------------------- /** *

    set fit range value at position idx @@ -1413,7 +1419,44 @@ void PMsrRunBlock::SetFitRange(Double_t dval, UInt_t idx) } //-------------------------------------------------------------------------- -// SetParGlobal +// GetFitRangeOffset (public) +//-------------------------------------------------------------------------- +/** + *

    get fit range offset value at position idx. idx: 0=fit range offset start, 1=fit range offset end. + * + * return: + * - fit range offset value, if idx is within proper boundaries + * - -1, otherwise + * + * \param idx index of the fit range value to be returned + */ +Int_t PMsrRunBlock::GetFitRangeOffset(UInt_t idx) +{ + if (idx >= 2) + return -1; + + return fFitRangeOffset[idx]; +} + +//-------------------------------------------------------------------------- +// SetFitRangeOffset (public) +//-------------------------------------------------------------------------- +/** + *

    set fit range offset value at position idx. Illegale values will be ignored. + * + * \param ival value to be set + * \param idx index of the fit range value to be set + */ +void PMsrRunBlock::SetFitRangeOffset(Int_t ival, UInt_t idx) +{ + if (idx >= 2) + return; + + fFitRangeOffset[idx] = ival; +} + +//-------------------------------------------------------------------------- +// SetParGlobal (public) //-------------------------------------------------------------------------- /** *

    store the information that a certain parameter used in the block is global @@ -1428,7 +1471,7 @@ void PMsrRunBlock::SetParGlobal(const TString &str, Int_t ival) } //-------------------------------------------------------------------------- -// SetMapGlobal +// SetMapGlobal (public) //-------------------------------------------------------------------------- /** *

    store the information that a certain mapped parameter in the block is global diff --git a/src/classes/PRunAsymmetry.cpp b/src/classes/PRunAsymmetry.cpp index 9b9babc0..58c6740e 100644 --- a/src/classes/PRunAsymmetry.cpp +++ b/src/classes/PRunAsymmetry.cpp @@ -42,6 +42,10 @@ #include using namespace std; +#include +#include +#include + #include "PMusr.h" #include "PRunAsymmetry.h" @@ -54,6 +58,11 @@ using namespace std; PRunAsymmetry::PRunAsymmetry() : PRunBase() { fNoOfFitBins = 0; + + // the 2 following variables are need in case fit range is given in bins, and since + // the fit range can be changed in the command block, these variables need to be accessible + fGoodBins[0] = -1; + fGoodBins[1] = -1; } //-------------------------------------------------------------------------- @@ -69,6 +78,11 @@ PRunAsymmetry::PRunAsymmetry() : PRunBase() */ PRunAsymmetry::PRunAsymmetry(PMsrHandler *msrInfo, PRunDataHandler *rawData, UInt_t runNo, EPMusrHandleTag tag) : PRunBase(msrInfo, rawData, runNo, tag) { + // the 2 following variables are need in case fit range is given in bins, and since + // the fit range can be changed in the command block, these variables need to be accessible + fGoodBins[0] = -1; + fGoodBins[1] = -1; + // check if alpha and/or beta is fixed -------------------- PMsrParamList *param = msrInfo->GetMsrParamList(); @@ -140,7 +154,7 @@ PRunAsymmetry::~PRunAsymmetry() } //-------------------------------------------------------------------------- -// CalcChiSquare +// CalcChiSquare (public) //-------------------------------------------------------------------------- /** *

    Calculate chi-square. @@ -236,7 +250,7 @@ Double_t PRunAsymmetry::CalcChiSquareExpected(const std::vector& par) } //-------------------------------------------------------------------------- -// CalcMaxLikelihood +// CalcMaxLikelihood (public) //-------------------------------------------------------------------------- /** *

    NOT IMPLEMENTED!! @@ -266,7 +280,97 @@ UInt_t PRunAsymmetry::GetNoOfFitBins() } //-------------------------------------------------------------------------- -// CalcNoOfFitBins (private) +// SetFitRangeBin (public) +//-------------------------------------------------------------------------- +/** + *

    Allows to change the fit range on the fly. Used in the COMMAND block. + * The syntax of the string is: FIT_RANGE fgb[+n00] lgb[-n01] [fgb[+n10] lgb[-n11] ... fgb[+nN0] lgb[-nN1]]. + * If only one pair of fgb/lgb is given, it is used for all runs in the RUN block section. + * If multiple fgb/lgb's are given, the number N has to be the number of RUN blocks in + * the msr-file. + * + *

    nXY are offsets which can be used to shift, limit the fit range. + * + * \param fitRange string containing the necessary information. + */ +void PRunAsymmetry::SetFitRangeBin(const TString fitRange) +{ + TObjArray *tok = 0; + TObjString *ostr = 0; + TString str; + Ssiz_t idx = -1; + Int_t offset = 0; + + tok = fitRange.Tokenize(" \t"); + + if (tok->GetEntries() == 3) { // structure FIT_RANGE fgb+n0 lgb-n1 + // handle fgb+n0 entry + ostr = (TObjString*) tok->At(1); + str = ostr->GetString(); + // check if there is an offset present + idx = str.First("+"); + if (idx != -1) { // offset present + str.Remove(0, idx+1); + if (str.IsFloat()) // if str is a valid number, convert is to an integer + offset = str.Atoi(); + } + fFitStartTime = (fGoodBins[0] + offset - fT0s[0]) * fTimeResolution; + + // handle lgb-n1 entry + ostr = (TObjString*) tok->At(2); + str = ostr->GetString(); + // check if there is an offset present + idx = str.First("-"); + if (idx != -1) { // offset present + str.Remove(0, idx+1); + if (str.IsFloat()) // if str is a valid number, convert is to an integer + offset = str.Atoi(); + } + fFitEndTime = (fGoodBins[1] - offset - fT0s[0]) * fTimeResolution; + } else if ((tok->GetEntries() > 3) && (tok->GetEntries() % 2 == 1)) { // structure FIT_RANGE fgb[+n00] lgb[-n01] [fgb[+n10] lgb[-n11] ... fgb[+nN0] lgb[-nN1]] + Int_t pos = 2*(fRunNo+1)-1; + + if (pos + 1 >= tok->GetEntries()) { + cerr << endl << ">> PRunSingleHisto::SetFitRangeBin(): **ERROR** invalid FIT_RANGE command found: '" << fitRange << "'"; + cerr << endl << ">> will ignore it. Sorry ..." << endl; + } else { + // handle fgb+n0 entry + ostr = (TObjString*) tok->At(pos); + str = ostr->GetString(); + // check if there is an offset present + idx = str.First("+"); + if (idx != -1) { // offset present + str.Remove(0, idx+1); + if (str.IsFloat()) // if str is a valid number, convert is to an integer + offset = str.Atoi(); + } + fFitStartTime = (fGoodBins[0] + offset - fT0s[0]) * fTimeResolution; + + // handle lgb-n1 entry + ostr = (TObjString*) tok->At(pos+1); + str = ostr->GetString(); + // check if there is an offset present + idx = str.First("-"); + if (idx != -1) { // offset present + str.Remove(0, idx+1); + if (str.IsFloat()) // if str is a valid number, convert is to an integer + offset = str.Atoi(); + } + fFitEndTime = (fGoodBins[1] - offset - fT0s[0]) * fTimeResolution; + } + } else { // error + cerr << endl << ">> PRunSingleHisto::SetFitRangeBin(): **ERROR** invalid FIT_RANGE command found: '" << fitRange << "'"; + cerr << endl << ">> will ignore it. Sorry ..." << endl; + } + + // clean up + if (tok) { + delete tok; + } +} + +//-------------------------------------------------------------------------- +// CalcNoOfFitBins (protected) //-------------------------------------------------------------------------- /** *

    Calculate the number of fitted bins for the current fit range. @@ -288,7 +392,7 @@ void PRunAsymmetry::CalcNoOfFitBins() } //-------------------------------------------------------------------------- -// CalcTheory +// CalcTheory (protected) //-------------------------------------------------------------------------- /** *

    Calculate theory for a given set of fit-parameters. @@ -344,7 +448,7 @@ void PRunAsymmetry::CalcTheory() } //-------------------------------------------------------------------------- -// PrepareData +// PrepareData (protected) //-------------------------------------------------------------------------- /** *

    Prepare data for fitting or viewing. What is already processed at this stage: @@ -682,7 +786,7 @@ Bool_t PRunAsymmetry::PrepareData() } //-------------------------------------------------------------------------- -// SubtractFixBkg +// SubtractFixBkg (private) //-------------------------------------------------------------------------- /** *

    Subtracts a fixed background from the raw data. The background is given @@ -722,7 +826,7 @@ Bool_t PRunAsymmetry::SubtractFixBkg() } //-------------------------------------------------------------------------- -// SubtractEstimatedBkg +// SubtractEstimatedBkg (private) //-------------------------------------------------------------------------- /** *

    Subtracts the background which is estimated from a given interval (typically before t0). @@ -835,7 +939,7 @@ Bool_t PRunAsymmetry::SubtractEstimatedBkg() } //-------------------------------------------------------------------------- -// PrepareFitData +// PrepareFitData (protected) //-------------------------------------------------------------------------- /** *

    Take the pre-processed data (i.e. grouping and addrun are preformed) and form the asymmetry for fitting. @@ -936,6 +1040,19 @@ Bool_t PRunAsymmetry::PrepareFitData(PRawRunData* runData, UInt_t histoNo[2]) cerr << endl; } + // if fit range is given in bins (and not time), the fit start/end time can be calculated at this point now + if (fRunInfo->IsFitRangeInBin()) { + fFitStartTime = (fRunInfo->GetDataRange(0) + fRunInfo->GetFitRangeOffset(0) - fT0s[0]) * fTimeResolution; // (fgb+n0-t0)*dt + fFitEndTime = (fRunInfo->GetDataRange(1) - fRunInfo->GetFitRangeOffset(1) - fT0s[0]) * fTimeResolution; // (lgb-n1-t0)*dt + // write these times back into the data structure. This way it is available when writting the log-file + fRunInfo->SetFitRange(fFitStartTime, 0); + fRunInfo->SetFitRange(fFitEndTime, 1); + } + + // keep good bins for potential latter use + fGoodBins[0] = start[0]; + fGoodBins[1] = end[0]; + // everything looks fine, hence fill packed forward and backward histo PRunData forwardPacked; PRunData backwardPacked; @@ -1032,7 +1149,7 @@ Bool_t PRunAsymmetry::PrepareFitData(PRawRunData* runData, UInt_t histoNo[2]) } //-------------------------------------------------------------------------- -// PrepareViewData +// PrepareViewData (protected) //-------------------------------------------------------------------------- /** *

    Take the pre-processed data (i.e. grouping and addrun are preformed) and form the asymmetry for view representation. @@ -1141,6 +1258,12 @@ Bool_t PRunAsymmetry::PrepareViewData(PRawRunData* runData, UInt_t histoNo[2]) } } + // if fit range is given in bins (and not time), the fit start/end time can be calculated at this point now + if (fRunInfo->IsFitRangeInBin()) { + fFitStartTime = (fRunInfo->GetDataRange(0) + fRunInfo->GetFitRangeOffset(0) - fT0s[0]) * fTimeResolution; // (fgb+n0-t0)*dt + fFitEndTime = (fRunInfo->GetDataRange(1) - fRunInfo->GetFitRangeOffset(1) - fT0s[0]) * fTimeResolution; // (lgb-n1-t0)*dt + } + // everything looks fine, hence fill packed forward and backward histo PRunData forwardPacked; PRunData backwardPacked; @@ -1289,7 +1412,7 @@ Bool_t PRunAsymmetry::PrepareViewData(PRawRunData* runData, UInt_t histoNo[2]) } //-------------------------------------------------------------------------- -// PrepareRRFViewData +// PrepareRRFViewData (protected) //-------------------------------------------------------------------------- /** *

    Prepares the RRF data set for visual representation. This is done the following way: diff --git a/src/classes/PRunDataHandler.cpp b/src/classes/PRunDataHandler.cpp index 792dd0d7..931645f0 100644 --- a/src/classes/PRunDataHandler.cpp +++ b/src/classes/PRunDataHandler.cpp @@ -82,22 +82,68 @@ using namespace std; #define A2M_WKM 7 #define A2M_ASCII 8 +#define PHR_INIT_ALL 0 +#define PHR_INIT_MSR 1 +#define PHR_INIT_ANY2MANY 2 + //-------------------------------------------------------------------------- // Constructor //-------------------------------------------------------------------------- /** - *

    Constructor, reading the data histogramm files. - * - * \param msrInfo pointer to the msr-file handler + *

    Empty Constructor */ -PRunDataHandler::PRunDataHandler(PAny2ManyInfo *any2ManyInfo) : fAny2ManyInfo(any2ManyInfo) +PRunDataHandler::PRunDataHandler() { - fDataPath.clear(); - // read files - if (!ReadWriteFilesList()) // couldn't read file - fAllDataAvailable = false; - else - fAllDataAvailable = true; + Init(); +} + +//-------------------------------------------------------------------------- +// Constructor +//-------------------------------------------------------------------------- +/** + *

    Constructor which just reads a single muSR data file. + * + * \param fileName + * \param fileFormat + */ +PRunDataHandler::PRunDataHandler(TString fileName, const TString fileFormat) : fFileFormat(fileFormat) +{ + Init(); + + FileExistsCheck(fileName); +} + +//-------------------------------------------------------------------------- +// Constructor +//-------------------------------------------------------------------------- +/** + *

    Constructor which just reads a single muSR data file. + * + * \param fileName + * \param fileFormat + * \param dataPath + */ +PRunDataHandler::PRunDataHandler(TString fileName, const TString fileFormat, const PStringVector dataPath) : fDataPath(dataPath), fFileFormat(fileFormat) +{ + Init(); + + FileExistsCheck(fileName); +} + +//-------------------------------------------------------------------------- +// Constructor +//-------------------------------------------------------------------------- +/** + *

    Constructor which just writes a single muSR data file. + * + * \param fileName + * \param fileFormat + * \param dataPath + * \param runData + */ +PRunDataHandler::PRunDataHandler(TString fileName, const TString fileFormat, const TString dataPath, PRawRunData &runData) +{ + Init(); } //-------------------------------------------------------------------------- @@ -108,14 +154,24 @@ PRunDataHandler::PRunDataHandler(PAny2ManyInfo *any2ManyInfo) : fAny2ManyInfo(an * * \param msrInfo pointer to the msr-file handler */ +PRunDataHandler::PRunDataHandler(PAny2ManyInfo *any2ManyInfo) : fAny2ManyInfo(any2ManyInfo) +{ + Init(PHR_INIT_ANY2MANY); +} + +//-------------------------------------------------------------------------- +// Constructor +//-------------------------------------------------------------------------- +/** + *

    Constructor, reading the data histogramm files. + * + * \param any2ManyInfo pointer to the PAny2ManyInfo structure needed to convert data + * \param dataPath contains all data search paths. + */ PRunDataHandler::PRunDataHandler(PAny2ManyInfo *any2ManyInfo, const PStringVector dataPath) : fAny2ManyInfo(any2ManyInfo), fDataPath(dataPath) { - // read files - if (!ReadWriteFilesList()) // couldn't read file - fAllDataAvailable = false; - else - fAllDataAvailable = true; + Init(PHR_INIT_ANY2MANY); } //-------------------------------------------------------------------------- @@ -128,11 +184,7 @@ PRunDataHandler::PRunDataHandler(PAny2ManyInfo *any2ManyInfo, const PStringVecto */ PRunDataHandler::PRunDataHandler(PMsrHandler *msrInfo) : fMsrInfo(msrInfo) { - // read files - if (!ReadFilesMsr()) // couldn't read file - fAllDataAvailable = false; - else - fAllDataAvailable = true; + Init(PHR_INIT_MSR); } //-------------------------------------------------------------------------- @@ -148,11 +200,7 @@ PRunDataHandler::PRunDataHandler(PMsrHandler *msrInfo) : fMsrInfo(msrInfo) PRunDataHandler::PRunDataHandler(PMsrHandler *msrInfo, const PStringVector dataPath) : fMsrInfo(msrInfo), fDataPath(dataPath) { - // read files - if (!ReadFilesMsr()) // couldn't read file - fAllDataAvailable = false; - else - fAllDataAvailable = true; + Init(PHR_INIT_MSR); } //-------------------------------------------------------------------------- @@ -163,6 +211,7 @@ PRunDataHandler::PRunDataHandler(PMsrHandler *msrInfo, const PStringVector dataP */ PRunDataHandler::~PRunDataHandler() { + fDataPath.clear(); fData.clear(); } @@ -170,7 +219,7 @@ PRunDataHandler::~PRunDataHandler() // GetRunData //-------------------------------------------------------------------------- /** - *

    Checks if runName is found. + *

    Checks if runName is found, and if so return these data. * * return: * - if data are found: pointer to the data. @@ -194,7 +243,87 @@ PRawRunData* PRunDataHandler::GetRunData(const TString &runName) } //-------------------------------------------------------------------------- -// ReadFilesMsr +// ReadData +//-------------------------------------------------------------------------- +/** + *

    Read data. Used to read data, either msr-file triggered, or a single + * explicit data file should be read. + */ +void PRunDataHandler::ReadData() +{ + if (fMsrInfo) { // i.e. msr-file triggered + if (!ReadFilesMsr()) // couldn't read file + fAllDataAvailable = false; + else + fAllDataAvailable = true; + } else if (!fRunPathName.IsWhitespace()) { // i.e. file name triggered + cerr << endl << "debug>> fFileFormat=\"" << fFileFormat << "\"" << endl; + if ((fFileFormat == "MusrRoot") || (fFileFormat == "musrroot")) { + fAllDataAvailable = ReadRootFile(); + } else if ((fFileFormat == "NeXus") || (fFileFormat == "nexus")) { + fAllDataAvailable = ReadNexusFile(); + } else if ((fFileFormat == "PsiBin") || (fFileFormat == "psibin")) { + fAllDataAvailable = ReadPsiBinFile(); + } else if ((fFileFormat == "Mud") || (fFileFormat == "mud")) { + fAllDataAvailable = ReadMudFile(); + } else if ((fFileFormat == "Wkm") || (fFileFormat == "wkm")) { + fAllDataAvailable = ReadWkmFile(); + } else { + cerr << endl << ">> PRunDataHandler::ReadData(): **ERROR** unkown file format \"" << fFileFormat << "\" found." << endl; + fAllDataAvailable = false; + } + } else { + cerr << endl << ">> PRunDataHandler::ReadData(): **ERROR** Couldn't read files." << endl; + fAllDataAvailable = false; + } +} + +//-------------------------------------------------------------------------- +// ConvertData +//-------------------------------------------------------------------------- +/** + *

    Read data and convert it. This routine is used by any2many. + */ +void PRunDataHandler::ConvertData() +{ + if (!ReadWriteFilesList()) // couldn't read file + fAllDataAvailable = false; + else + fAllDataAvailable = true; +} + +//-------------------------------------------------------------------------- +// WriteData +//-------------------------------------------------------------------------- +/** + *

    Write data. This routine is used to write a single file. + */ +void PRunDataHandler::WriteData() +{ + +} + +//-------------------------------------------------------------------------- +// Init (private) +//-------------------------------------------------------------------------- +/** + *

    Common initializer. + */ +void PRunDataHandler::Init(const Int_t tag) +{ + if ((tag==PHR_INIT_ALL) || (tag==PHR_INIT_ANY2MANY)) + fMsrInfo = 0; + if ((tag==PHR_INIT_ALL) || (tag==PHR_INIT_MSR)) + fAny2ManyInfo = 0; + fAllDataAvailable = false; + if (tag!=PHR_INIT_ALL) + fFileFormat = TString(""); + fRunName = TString(""); + fRunPathName = TString(""); +} + +//-------------------------------------------------------------------------- +// ReadFilesMsr (private) //-------------------------------------------------------------------------- /** *

    The main read file routine which is filtering what read sub-routine @@ -283,7 +412,7 @@ Bool_t PRunDataHandler::ReadFilesMsr() } //-------------------------------------------------------------------------- -// ReadWriteFilesList +// ReadWriteFilesList (private) //-------------------------------------------------------------------------- /** *

    The main read file routine which is filtering what read sub-routine @@ -762,7 +891,7 @@ void PRunDataHandler::TestFileName(TString &runName, const TString &ext) } //-------------------------------------------------------------------------- -// FileExistsCheck +// FileExistsCheck (private) //-------------------------------------------------------------------------- /** *

    Checks if a given data file exists. @@ -972,7 +1101,7 @@ Bool_t PRunDataHandler::FileExistsCheck(PMsrRunBlock &runInfo, const UInt_t idx) } //-------------------------------------------------------------------------- -// FileExistsCheck +// FileExistsCheck (private) //-------------------------------------------------------------------------- /** *

    Checks if a given data file exists. Used for the any2many program. @@ -1069,7 +1198,76 @@ Bool_t PRunDataHandler::FileExistsCheck(const Bool_t fileName, const Int_t idx) } //-------------------------------------------------------------------------- -// ReadRootFile +// FileExistsCheck (private) +//-------------------------------------------------------------------------- +/** + *

    Checks if a given data file exists. Used for the any2many program. + * + * return: + * - true if data file exists, + * - otherwise false. + * + * \param fileName file name + */ +Bool_t PRunDataHandler::FileExistsCheck(const TString fileName) +{ + TString pathName("???"); + TString str(""); + + // check if the file is in the local directory + if (gSystem->AccessPathName(fileName) != true) { // found in the local dir + pathName = fileName; + } + // check if the file is found in the directory given in the startup file + if (pathName.CompareTo("???") == 0) { // not found in local directory search + for (UInt_t i=0; iAccessPathName(str.Data())!=true) { // found + pathName = str; + break; + } + } + } + // check if the file is found in the directories given by MUSRFULLDATAPATH + const Char_t *musrpath = gSystem->Getenv("MUSRFULLDATAPATH"); + if (pathName.CompareTo("???") == 0) { // not found in local directory and xml path + str = TString(musrpath); + // MUSRFULLDATAPATH has the structure: path_1:path_2:...:path_n + TObjArray *tokens = str.Tokenize(":"); + TObjString *ostr; + for (Int_t i=0; iGetEntries(); i++) { + ostr = dynamic_cast(tokens->At(i)); + str = ostr->GetString() + TString("/") + fileName; + if (gSystem->AccessPathName(str.Data())!=true) { // found + pathName = str; + break; + } + } + // cleanup + if (tokens) { + delete tokens; + tokens = 0; + } + } + // no proper path name found + if (pathName.CompareTo("???") == 0) { + cerr << endl << ">> PRunDataHandler::FileExistsCheck(): **ERROR** Couldn't find '" << fileName.Data() << "' in any standard path."; + cerr << endl << ">> standard search pathes are:"; + cerr << endl << ">> 1. the local directory"; + cerr << endl << ">> 2. the data directory given in the startup XML file"; + cerr << endl << ">> 3. the directories listed in MUSRFULLDATAPATH"; + return false; + } + + fRunPathName = pathName; + + cerr << endl << "debug-> fRunPathName=" << fRunPathName << endl; + + return true; +} + +//-------------------------------------------------------------------------- +// ReadRootFile (private) //-------------------------------------------------------------------------- /** *

    Reads both, the "old" LEM-data ROOT-files with TLemRunHeader, and the more general @@ -1738,7 +1936,7 @@ Bool_t PRunDataHandler::ReadRootFile() } //-------------------------------------------------------------------------- -// ReadNexusFile +// ReadNexusFile (private) //-------------------------------------------------------------------------- /** *

    Will read the NeXuS File Format as soon as PSI will have an implementation. @@ -2105,7 +2303,7 @@ Bool_t PRunDataHandler::ReadNexusFile() } //-------------------------------------------------------------------------- -// ReadWkmFile +// ReadWkmFile (private) //-------------------------------------------------------------------------- /** *

    Reads, for backwards compatibility, the ascii-wkm-file data format. @@ -2411,7 +2609,7 @@ Bool_t PRunDataHandler::ReadWkmFile() } //-------------------------------------------------------------------------- -// ReadPsiBinFile +// ReadPsiBinFile (private) //-------------------------------------------------------------------------- /** *

    Reads the old-fashioned PSI-BIN data-files. The MuSR_td_PSI_bin class @@ -2659,7 +2857,7 @@ Bool_t PRunDataHandler::ReadPsiBinFile() } //-------------------------------------------------------------------------- -// ReadMudFile +// ReadMudFile (private) //-------------------------------------------------------------------------- /** *

    Reads the triumf mud-file format. @@ -2977,7 +3175,7 @@ Bool_t PRunDataHandler::ReadMudFile() } //-------------------------------------------------------------------------- -// ReadMduAsciiFile +// ReadMduAsciiFile (private) //-------------------------------------------------------------------------- /** *

    Reads the mdu ascii files (PSI). Needed to work around PSI-BIN limitations. @@ -3280,7 +3478,7 @@ Bool_t PRunDataHandler::ReadMduAsciiFile() } //-------------------------------------------------------------------------- -// ReadAsciiFile +// ReadAsciiFile (private) //-------------------------------------------------------------------------- /** *

    Reads ascii files. Intended for the nonMuSR data. @@ -3517,7 +3715,7 @@ Bool_t PRunDataHandler::ReadAsciiFile() } //-------------------------------------------------------------------------- -// ReadDBFile +// ReadDBFile (private) //-------------------------------------------------------------------------- /** *

    Reads triumf db-files. Intended for the nonMuSR data. @@ -3966,7 +4164,7 @@ Bool_t PRunDataHandler::ReadDBFile() } //-------------------------------------------------------------------------- -// WriteMusrRootFile +// WriteMusrRootFile (private) //-------------------------------------------------------------------------- /** *

    Write the MusrRoot file format. Only the required entries will be handled. @@ -4208,7 +4406,7 @@ Bool_t PRunDataHandler::WriteMusrRootFile(TString fln) } //-------------------------------------------------------------------------- -// WriteRootFile +// WriteRootFile (private) //-------------------------------------------------------------------------- /** *

    Write the PSI LEM root-file format. @@ -4392,7 +4590,7 @@ Bool_t PRunDataHandler::WriteRootFile(TString fln) } //-------------------------------------------------------------------------- -// WriteNexusFile +// WriteNexusFile (private) //-------------------------------------------------------------------------- /** *

    Write the nexus-file format. @@ -4737,7 +4935,7 @@ Bool_t PRunDataHandler::WriteNexusFile(TString fln) } //-------------------------------------------------------------------------- -// WriteWkmFile +// WriteWkmFile (private) //-------------------------------------------------------------------------- /** *

    Write the wkm-file format. @@ -4878,7 +5076,7 @@ Bool_t PRunDataHandler::WriteWkmFile(TString fln) } //-------------------------------------------------------------------------- -// WritePsiBinFile +// WritePsiBinFile (private) //-------------------------------------------------------------------------- /** *

    Write the psi-bin-file format. @@ -5099,7 +5297,7 @@ Bool_t PRunDataHandler::WritePsiBinFile(TString fln) } //-------------------------------------------------------------------------- -// WriteMudFile +// WriteMudFile (private) //-------------------------------------------------------------------------- /** *

    Write the mud-file format. @@ -5259,7 +5457,7 @@ Bool_t PRunDataHandler::WriteMudFile(TString fln) } //-------------------------------------------------------------------------- -// WriteAsciiFile +// WriteAsciiFile (private) //-------------------------------------------------------------------------- /** *

    Write the ascii-file format. diff --git a/src/classes/PRunListCollection.cpp b/src/classes/PRunListCollection.cpp index 80b2acf3..bed6bd1e 100644 --- a/src/classes/PRunListCollection.cpp +++ b/src/classes/PRunListCollection.cpp @@ -131,8 +131,34 @@ Bool_t PRunListCollection::Add(Int_t runNo, EPMusrHandleTag tag) // SetFitRange (public) //-------------------------------------------------------------------------- /** - *

    Set the current fit range. If fitRange.size()==1 the given fit range will be used for all the runs, - * otherwise fitRange.size()==the number of runs in the msr-file, and for each run there will be an induvidual + *

    Set the current fit range in bins. The string has the structure: + * 'fit_range fgb0+n00 lgb0-n01 [fgb1+n10 lgb-n11 fgb2+n20 lgb2-n21 .. fgbN+nN0 lgbN-nN1]' + * where fgb is the first good bin, lgb is the last good bin. nXY are offsets in bins. + * N is the number of runs in the msr-file. + * + *

    This means there are 2 options: (i) a globle fit range in bins for all runs in the + * msr-file, or (ii) each run block in the msr-file needs its individual range. + * + * \param fitRange string holding the fit range(s). + */ +void PRunListCollection::SetFitRange(const TString fitRange) +{ + for (UInt_t i=0; iSetFitRangeBin(fitRange); + for (UInt_t i=0; iSetFitRangeBin(fitRange); + for (UInt_t i=0; iSetFitRangeBin(fitRange); + for (UInt_t i=0; iSetFitRangeBin(fitRange); +} + +//-------------------------------------------------------------------------- +// SetFitRange (public) +//-------------------------------------------------------------------------- +/** + *

    Set the current fit range in time. If fitRange.size()==1 the given fit range will be used for all the runs, + * otherwise fitRange.size()==the number of runs in the msr-file, and for each run there will be an individual * fit range. * * \param fitRange vector holding the fit range(s). diff --git a/src/classes/PRunMuMinus.cpp b/src/classes/PRunMuMinus.cpp index 19d91db0..5ceb342a 100644 --- a/src/classes/PRunMuMinus.cpp +++ b/src/classes/PRunMuMinus.cpp @@ -30,6 +30,11 @@ ***************************************************************************/ #include +using namespace std; + +#include +#include +#include #include "PRunMuMinus.h" @@ -43,6 +48,11 @@ PRunMuMinus::PRunMuMinus() : PRunBase() { fNoOfFitBins = 0; + // the 2 following variables are need in case fit range is given in bins, and since + // the fit range can be changed in the command block, these variables need to be accessible + fGoodBins[0] = -1; + fGoodBins[1] = -1; + fHandleTag = kEmpty; } @@ -61,6 +71,11 @@ PRunMuMinus::PRunMuMinus(PMsrHandler *msrInfo, PRunDataHandler *rawData, UInt_t { fNoOfFitBins = 0; + // the 2 following variables are need in case fit range is given in bins, and since + // the fit range can be changed in the command block, these variables need to be accessible + fGoodBins[0] = -1; + fGoodBins[1] = -1; + if (!PrepareData()) { cerr << endl << ">> PRunMuMinus::PRunMuMinus: **SEVERE ERROR**: Couldn't prepare data for fitting!"; cerr << endl << ">> This is very bad :-(, will quit ..."; @@ -270,6 +285,96 @@ UInt_t PRunMuMinus::GetNoOfFitBins() return fNoOfFitBins; } +//-------------------------------------------------------------------------- +// SetFitRangeBin (public) +//-------------------------------------------------------------------------- +/** + *

    Allows to change the fit range on the fly. Used in the COMMAND block. + * The syntax of the string is: FIT_RANGE fgb[+n00] lgb[-n01] [fgb[+n10] lgb[-n11] ... fgb[+nN0] lgb[-nN1]]. + * If only one pair of fgb/lgb is given, it is used for all runs in the RUN block section. + * If multiple fgb/lgb's are given, the number N has to be the number of RUN blocks in + * the msr-file. + * + *

    nXY are offsets which can be used to shift, limit the fit range. + * + * \param fitRange string containing the necessary information. + */ +void PRunMuMinus::SetFitRangeBin(const TString fitRange) +{ + TObjArray *tok = 0; + TObjString *ostr = 0; + TString str; + Ssiz_t idx = -1; + Int_t offset = 0; + + tok = fitRange.Tokenize(" \t"); + + if (tok->GetEntries() == 3) { // structure FIT_RANGE fgb+n0 lgb-n1 + // handle fgb+n0 entry + ostr = (TObjString*) tok->At(1); + str = ostr->GetString(); + // check if there is an offset present + idx = str.First("+"); + if (idx != -1) { // offset present + str.Remove(0, idx+1); + if (str.IsFloat()) // if str is a valid number, convert is to an integer + offset = str.Atoi(); + } + fFitStartTime = (fGoodBins[0] + offset - fT0s[0]) * fTimeResolution; + + // handle lgb-n1 entry + ostr = (TObjString*) tok->At(2); + str = ostr->GetString(); + // check if there is an offset present + idx = str.First("-"); + if (idx != -1) { // offset present + str.Remove(0, idx+1); + if (str.IsFloat()) // if str is a valid number, convert is to an integer + offset = str.Atoi(); + } + fFitEndTime = (fGoodBins[1] - offset - fT0s[0]) * fTimeResolution; + } else if ((tok->GetEntries() > 3) && (tok->GetEntries() % 2 == 1)) { // structure FIT_RANGE fgb[+n00] lgb[-n01] [fgb[+n10] lgb[-n11] ... fgb[+nN0] lgb[-nN1]] + Int_t pos = 2*(fRunNo+1)-1; + + if (pos + 1 >= tok->GetEntries()) { + cerr << endl << ">> PRunSingleHisto::SetFitRangeBin(): **ERROR** invalid FIT_RANGE command found: '" << fitRange << "'"; + cerr << endl << ">> will ignore it. Sorry ..." << endl; + } else { + // handle fgb+n0 entry + ostr = (TObjString*) tok->At(pos); + str = ostr->GetString(); + // check if there is an offset present + idx = str.First("+"); + if (idx != -1) { // offset present + str.Remove(0, idx+1); + if (str.IsFloat()) // if str is a valid number, convert is to an integer + offset = str.Atoi(); + } + fFitStartTime = (fGoodBins[0] + offset - fT0s[0]) * fTimeResolution; + + // handle lgb-n1 entry + ostr = (TObjString*) tok->At(pos+1); + str = ostr->GetString(); + // check if there is an offset present + idx = str.First("-"); + if (idx != -1) { // offset present + str.Remove(0, idx+1); + if (str.IsFloat()) // if str is a valid number, convert is to an integer + offset = str.Atoi(); + } + fFitEndTime = (fGoodBins[1] - offset - fT0s[0]) * fTimeResolution; + } + } else { // error + cerr << endl << ">> PRunSingleHisto::SetFitRangeBin(): **ERROR** invalid FIT_RANGE command found: '" << fitRange << "'"; + cerr << endl << ">> will ignore it. Sorry ..." << endl; + } + + // clean up + if (tok) { + delete tok; + } +} + //-------------------------------------------------------------------------- // CalcNoOfFitBins (private) //-------------------------------------------------------------------------- @@ -594,6 +699,19 @@ Bool_t PRunMuMinus::PrepareFitData(PRawRunData* runData, const UInt_t histoNo) return false; } + // if fit range is given in bins (and not time), the fit start/end time can be calculated at this point now + if (fRunInfo->IsFitRangeInBin()) { + fFitStartTime = (fRunInfo->GetDataRange(0) + fRunInfo->GetFitRangeOffset(0) - fT0s[0]) * fTimeResolution; // (fgb+n0-t0)*dt + fFitEndTime = (fRunInfo->GetDataRange(1) - fRunInfo->GetFitRangeOffset(1) - fT0s[0]) * fTimeResolution; // (lgb-n1-t0)*dt + // write these times back into the data structure. This way it is available when writting the log-file + fRunInfo->SetFitRange(fFitStartTime, 0); + fRunInfo->SetFitRange(fFitEndTime, 1); + } + + // keep good bins for potential latter use + fGoodBins[0] = start; + fGoodBins[1] = end; + // everything looks fine, hence fill data set Int_t t0 = (Int_t)fT0s[0]; Double_t value = 0.0; @@ -695,6 +813,12 @@ Bool_t PRunMuMinus::PrepareRawViewData(PRawRunData* runData, const UInt_t histoN return false; } + // if fit range is given in bins (and not time), the fit start/end time can be calculated at this point now + if (fRunInfo->IsFitRangeInBin()) { + fFitStartTime = (fRunInfo->GetDataRange(0) + fRunInfo->GetFitRangeOffset(0) - fT0s[0]) * fTimeResolution; // (fgb+n0-t0)*dt + fFitEndTime = (fRunInfo->GetDataRange(1) - fRunInfo->GetFitRangeOffset(1) - fT0s[0]) * fTimeResolution; // (lgb-n1-t0)*dt + } + // everything looks fine, hence fill data set Int_t t0 = (Int_t)fT0s[0]; Double_t value = 0.0; diff --git a/src/classes/PRunSingleHisto.cpp b/src/classes/PRunSingleHisto.cpp index d8a20ae1..8eedde23 100644 --- a/src/classes/PRunSingleHisto.cpp +++ b/src/classes/PRunSingleHisto.cpp @@ -58,6 +58,12 @@ PRunSingleHisto::PRunSingleHisto() : PRunBase() { fScaleN0AndBkg = true; fNoOfFitBins = 0; + fBackground = 0; + + // the 2 following variables are need in case fit range is given in bins, and since + // the fit range can be changed in the command block, these variables need to be accessible + fGoodBins[0] = -1; + fGoodBins[1] = -1; } //-------------------------------------------------------------------------- @@ -76,6 +82,11 @@ PRunSingleHisto::PRunSingleHisto(PMsrHandler *msrInfo, PRunDataHandler *rawData, fScaleN0AndBkg = IsScaleN0AndBkg(); fNoOfFitBins = 0; + // the 2 following variables are need in case fit range is given in bins, and since + // the fit range can be changed in the command block, these variables need to be accessible + fGoodBins[0] = -1; + fGoodBins[1] = -1; + if (!PrepareData()) { cerr << endl << ">> PRunSingleHisto::PRunSingleHisto: **SEVERE ERROR**: Couldn't prepare data for fitting!"; cerr << endl << ">> This is very bad :-(, will quit ..."; @@ -461,7 +472,97 @@ UInt_t PRunSingleHisto::GetNoOfFitBins() } //-------------------------------------------------------------------------- -// CalcNoOfFitBins (private) +// SetFitRangeBin (public) +//-------------------------------------------------------------------------- +/** + *

    Allows to change the fit range on the fly. Used in the COMMAND block. + * The syntax of the string is: FIT_RANGE fgb[+n00] lgb[-n01] [fgb[+n10] lgb[-n11] ... fgb[+nN0] lgb[-nN1]]. + * If only one pair of fgb/lgb is given, it is used for all runs in the RUN block section. + * If multiple fgb/lgb's are given, the number N has to be the number of RUN blocks in + * the msr-file. + * + *

    nXY are offsets which can be used to shift, limit the fit range. + * + * \param fitRange string containing the necessary information. + */ +void PRunSingleHisto::SetFitRangeBin(const TString fitRange) +{ + TObjArray *tok = 0; + TObjString *ostr = 0; + TString str; + Ssiz_t idx = -1; + Int_t offset = 0; + + tok = fitRange.Tokenize(" \t"); + + if (tok->GetEntries() == 3) { // structure FIT_RANGE fgb+n0 lgb-n1 + // handle fgb+n0 entry + ostr = (TObjString*) tok->At(1); + str = ostr->GetString(); + // check if there is an offset present + idx = str.First("+"); + if (idx != -1) { // offset present + str.Remove(0, idx+1); + if (str.IsFloat()) // if str is a valid number, convert is to an integer + offset = str.Atoi(); + } + fFitStartTime = (fGoodBins[0] + offset - fT0s[0]) * fTimeResolution; + + // handle lgb-n1 entry + ostr = (TObjString*) tok->At(2); + str = ostr->GetString(); + // check if there is an offset present + idx = str.First("-"); + if (idx != -1) { // offset present + str.Remove(0, idx+1); + if (str.IsFloat()) // if str is a valid number, convert is to an integer + offset = str.Atoi(); + } + fFitEndTime = (fGoodBins[1] - offset - fT0s[0]) * fTimeResolution; + } else if ((tok->GetEntries() > 3) && (tok->GetEntries() % 2 == 1)) { // structure FIT_RANGE fgb[+n00] lgb[-n01] [fgb[+n10] lgb[-n11] ... fgb[+nN0] lgb[-nN1]] + Int_t pos = 2*(fRunNo+1)-1; + + if (pos + 1 >= tok->GetEntries()) { + cerr << endl << ">> PRunSingleHisto::SetFitRangeBin(): **ERROR** invalid FIT_RANGE command found: '" << fitRange << "'"; + cerr << endl << ">> will ignore it. Sorry ..." << endl; + } else { + // handle fgb+n0 entry + ostr = (TObjString*) tok->At(pos); + str = ostr->GetString(); + // check if there is an offset present + idx = str.First("+"); + if (idx != -1) { // offset present + str.Remove(0, idx+1); + if (str.IsFloat()) // if str is a valid number, convert is to an integer + offset = str.Atoi(); + } + fFitStartTime = (fGoodBins[0] + offset - fT0s[0]) * fTimeResolution; + + // handle lgb-n1 entry + ostr = (TObjString*) tok->At(pos+1); + str = ostr->GetString(); + // check if there is an offset present + idx = str.First("-"); + if (idx != -1) { // offset present + str.Remove(0, idx+1); + if (str.IsFloat()) // if str is a valid number, convert is to an integer + offset = str.Atoi(); + } + fFitEndTime = (fGoodBins[1] - offset - fT0s[0]) * fTimeResolution; + } + } else { // error + cerr << endl << ">> PRunSingleHisto::SetFitRangeBin(): **ERROR** invalid FIT_RANGE command found: '" << fitRange << "'"; + cerr << endl << ">> will ignore it. Sorry ..." << endl; + } + + // clean up + if (tok) { + delete tok; + } +} + +//-------------------------------------------------------------------------- +// CalcNoOfFitBins (protected) //-------------------------------------------------------------------------- /** *

    Calculate the number of fitted bins for the current fit range. @@ -483,7 +584,7 @@ void PRunSingleHisto::CalcNoOfFitBins() } //-------------------------------------------------------------------------- -// PrepareData (private) +// PrepareData (protected) //-------------------------------------------------------------------------- /** *

    Prepare data for fitting or viewing. What is already processed at this stage: @@ -653,7 +754,7 @@ Bool_t PRunSingleHisto::PrepareData() } } - // set forward/backward histo data of the first group + // set forward histo data of the first group fForward.resize(forward[0].size()); for (UInt_t i=0; iTake the pre-processed data (i.e. grouping and addrun are preformed) and form the histogram for fitting. @@ -754,6 +855,20 @@ Bool_t PRunSingleHisto::PrepareFitData(PRawRunData* runData, const UInt_t histoN return false; } + // keep good bins for potential latter use + fGoodBins[0] = start; + fGoodBins[1] = end; + + // if fit range is given in bins (and not time), the fit start/end time can be calculated at this point now + if (fRunInfo->IsFitRangeInBin()) { + fFitStartTime = (fRunInfo->GetDataRange(0) + fRunInfo->GetFitRangeOffset(0) - fT0s[0]) * fTimeResolution; // (fgb+n0-t0)*dt + fFitEndTime = (fRunInfo->GetDataRange(1) - fRunInfo->GetFitRangeOffset(1) - fT0s[0]) * fTimeResolution; // (lgb-n1-t0)*dt + // write these times back into the data structure. This way it is available when writting the log-file + fRunInfo->SetFitRange(fFitStartTime, 0); + fRunInfo->SetFitRange(fFitEndTime, 1); + cout << "debug> fit: " << fRunInfo->GetFitRange(0) << ", " << fRunInfo->GetFitRange(1) << end; + } + // check how the background shall be handled if (fRunInfo->GetBkgFitParamNo() == -1) { // bkg shall **NOT** be fitted // subtract background from histogramms ------------------------------------------ @@ -820,7 +935,7 @@ Bool_t PRunSingleHisto::PrepareFitData(PRawRunData* runData, const UInt_t histoN } //-------------------------------------------------------------------------- -// PrepareRawViewData (private) +// PrepareRawViewData (protected) //-------------------------------------------------------------------------- /** *

    Take the pre-processed data (i.e. grouping and addrun are preformed) and form the histogram for viewing @@ -888,6 +1003,12 @@ Bool_t PRunSingleHisto::PrepareRawViewData(PRawRunData* runData, const UInt_t hi return false; } + // if fit range is given in bins (and not time), the fit start/end time can be calculated at this point now + if (fRunInfo->IsFitRangeInBin()) { + fFitStartTime = (fRunInfo->GetDataRange(0) + fRunInfo->GetFitRangeOffset(0) - fT0s[0]) * fTimeResolution; // (fgb+n0-t0)*dt + fFitEndTime = (fRunInfo->GetDataRange(1) - fRunInfo->GetFitRangeOffset(1) - fT0s[0]) * fTimeResolution; // (lgb-n1-t0)*dt + } + // everything looks fine, hence fill data set Int_t t0 = (Int_t)fT0s[0]; Double_t value = 0.0; @@ -997,7 +1118,7 @@ Bool_t PRunSingleHisto::PrepareRawViewData(PRawRunData* runData, const UInt_t hi } //-------------------------------------------------------------------------- -// PrepareViewData (private) +// PrepareViewData (protected) //-------------------------------------------------------------------------- /** *

    Take the pre-processed data (i.e. grouping and addrun are preformed) and form the histogram for viewing @@ -1085,6 +1206,12 @@ Bool_t PRunSingleHisto::PrepareViewData(PRawRunData* runData, const UInt_t histo return false; } + // if fit range is given in bins (and not time), the fit start/end time can be calculated at this point now + if (fRunInfo->IsFitRangeInBin()) { + fFitStartTime = (fRunInfo->GetDataRange(0) + fRunInfo->GetFitRangeOffset(0) - fT0s[0]) * fTimeResolution; // (fgb+n0-t0)*dt + fFitEndTime = (fRunInfo->GetDataRange(1) - fRunInfo->GetFitRangeOffset(1) - fT0s[0]) * fTimeResolution; // (lgb-n1-t0)*dt + } + // everything looks fine, hence fill data set // feed the parameter vector diff --git a/src/include/PFitter.h b/src/include/PFitter.h index e1c79089..1979e9d1 100644 --- a/src/include/PFitter.h +++ b/src/include/PFitter.h @@ -81,6 +81,7 @@ class PFitter Bool_t fConverged; ///< flag. true: the fit has converged. Bool_t fChisqOnly; ///< flag. true: calculate chi^2 only (no fitting). Bool_t fUseChi2; ///< flag. true: chi^2 fit. false: log-max-likelihood + UInt_t fPrintLevel; ///< tag, showing the level of messages whished. 0=minimum, 1=standard, 2=maximum UInt_t fStrategy; ///< fitting strategy (see minuit2 manual). @@ -119,6 +120,7 @@ class PFitter Bool_t ExecuteMinimize(); Bool_t ExecuteMinos(); Bool_t ExecutePlot(); + Bool_t ExecutePrintLevel(UInt_t lineNo); Bool_t ExecuteRelease(UInt_t lineNo); Bool_t ExecuteRestore(); Bool_t ExecuteScan(); diff --git a/src/include/PMusr.h b/src/include/PMusr.h index e2e01cf4..ea3e2f4c 100644 --- a/src/include/PMusr.h +++ b/src/include/PMusr.h @@ -559,7 +559,9 @@ class PMsrRunBlock { virtual UInt_t GetAddT0BinEntries() { return fAddT0.size(); } virtual Int_t GetAddT0BinSize(UInt_t addRunIdx); virtual Double_t GetAddT0Bin(UInt_t addRunIdx, UInt_t histoIdx); + virtual Bool_t IsFitRangeInBin() { return fFitRangeInBins; } virtual Double_t GetFitRange(UInt_t idx); + virtual Int_t GetFitRangeOffset(UInt_t idx); virtual Int_t GetPacking() { return fPacking; } virtual Int_t GetXDataIndex() { return fXYDataIndex[0]; } virtual Int_t GetYDataIndex() { return fXYDataIndex[1]; } @@ -588,7 +590,9 @@ class PMsrRunBlock { virtual void SetDataRange(Int_t ival, Int_t idx); virtual void SetT0Bin(Double_t dval, Int_t idx=-1); virtual void SetAddT0Bin(Double_t dval, UInt_t addRunIdx, UInt_t histoNoIdx); + virtual void SetFitRangeInBins(Bool_t bval) { fFitRangeInBins = bval; } virtual void SetFitRange(Double_t dval, UInt_t idx); + virtual void SetFitRangeOffset(Int_t ival, UInt_t idx); virtual void SetPacking(Int_t ival) { fPacking = ival; } virtual void SetXDataIndex(Int_t ival) { fXYDataIndex[0] = ival; } virtual void SetYDataIndex(Int_t ival) { fXYDataIndex[1] = ival; } @@ -618,7 +622,9 @@ class PMsrRunBlock { Int_t fDataRange[4]; ///< data bin range (fit type 0, 2, 4) PDoubleVector fT0; ///< t0 bins (fit type 0, 2, 4). if fit type 0 -> f0, f1, f2, ...; if fit type 2, 4 -> f0, b0, f1, b1, ... vector fAddT0; ///< t0 bins for addrun's + Bool_t fFitRangeInBins; ///< flag telling if fit range is given in time or in bins Double_t fFitRange[2]; ///< fit range in (us) + Int_t fFitRangeOffset[2]; ///< if fit range is given in bins it can have the form fit fgb+n0 lgb-n1. This variable holds the n0 and n1. Int_t fPacking; ///< packing/rebinning Int_t fXYDataIndex[2]; ///< used to get the data indices when using db-files (fit type 8) TString fXYDataLabel[2]; ///< used to get the indices via labels when using db-files (fit type 8) diff --git a/src/include/PRunAsymmetry.h b/src/include/PRunAsymmetry.h index 6e193582..c633f3cc 100644 --- a/src/include/PRunAsymmetry.h +++ b/src/include/PRunAsymmetry.h @@ -52,6 +52,8 @@ class PRunAsymmetry : public PRunBase virtual UInt_t GetNoOfFitBins(); + virtual void SetFitRangeBin(const TString fitRange); + protected: virtual void CalcNoOfFitBins(); virtual Bool_t PrepareData(); @@ -69,6 +71,8 @@ class PRunAsymmetry : public PRunBase PDoubleVector fBackward; ///< backward histo data PDoubleVector fBackwardErr; ///< backward histo errors + Int_t fGoodBins[2]; ///< keep first/last good bins. 0=fgb, 1=lgb + Bool_t SubtractFixBkg(); Bool_t SubtractEstimatedBkg(); }; diff --git a/src/include/PRunBase.h b/src/include/PRunBase.h index 17a1a534..170b0274 100644 --- a/src/include/PRunBase.h +++ b/src/include/PRunBase.h @@ -78,8 +78,8 @@ class PRunBase Double_t fTimeResolution; ///< time resolution in (us) PDoubleVector fT0s; ///< all t0 bins of a run! The derived classes will handle it - Double_t fFitStartTime; ///< fit start time - Double_t fFitEndTime; ///< fit end time + Double_t fFitStartTime; ///< fit start time + Double_t fFitEndTime; ///< fit end time PDoubleVector fFuncValues; ///< is keeping the values of the functions from the FUNCTIONS block PTheory *fTheory; ///< theory needed to calculate chi-square diff --git a/src/include/PRunDataHandler.h b/src/include/PRunDataHandler.h index 724162d9..20174246 100644 --- a/src/include/PRunDataHandler.h +++ b/src/include/PRunDataHandler.h @@ -46,14 +46,23 @@ using namespace std; class PRunDataHandler { public: + PRunDataHandler(); + PRunDataHandler(TString fileName, const TString fileFormat); + PRunDataHandler(TString fileName, const TString fileFormat, const PStringVector dataPath); + PRunDataHandler(TString fileName, const TString fileFormat, const TString dataPath, PRawRunData &runData); PRunDataHandler(PAny2ManyInfo *any2ManyInfo); PRunDataHandler(PAny2ManyInfo *any2ManyInfo, const PStringVector dataPath); PRunDataHandler(PMsrHandler *msrInfo); PRunDataHandler(PMsrHandler *msrInfo, const PStringVector dataPath); virtual ~PRunDataHandler(); + virtual void ReadData(); + virtual void ConvertData(); + virtual void WriteData(); + virtual Bool_t IsAllDataAvailable() const { return fAllDataAvailable; } virtual PRawRunData* GetRunData(const TString &runName); + virtual TString GetRunPathName() {return fRunPathName; } private: PMsrHandler *fMsrInfo; ///< pointer to the msr-file handler @@ -61,16 +70,19 @@ class PRunDataHandler PStringVector fDataPath; ///< vector containing all the search paths where to look for data files Bool_t fAllDataAvailable; ///< flag indicating if all data sets could be read + TString fFileFormat; ///< keeps the file format if explicitly given TString fRunName; ///< current run name TString fRunPathName; ///< current path file name - PRawRunDataList fData; ///< keeping all the raw data + PRawRunDataList fData; ///< keeping all the raw data + virtual void Init(const Int_t tag=0); virtual Bool_t ReadFilesMsr(); virtual Bool_t ReadWriteFilesList(); virtual Bool_t FileAlreadyRead(TString runName); virtual void TestFileName(TString &runName, const TString &ext); virtual Bool_t FileExistsCheck(PMsrRunBlock &runInfo, const UInt_t idx); virtual Bool_t FileExistsCheck(const Bool_t fileName, const Int_t idx); + virtual Bool_t FileExistsCheck(const TString fileName); virtual Bool_t ReadRootFile(); virtual Bool_t ReadNexusFile(); virtual Bool_t ReadWkmFile(); diff --git a/src/include/PRunListCollection.h b/src/include/PRunListCollection.h index f890946c..a67d324e 100644 --- a/src/include/PRunListCollection.h +++ b/src/include/PRunListCollection.h @@ -57,6 +57,7 @@ class PRunListCollection virtual Bool_t Add(Int_t runNo, EPMusrHandleTag tag); virtual void SetFitRange(const PDoublePairVector fitRange); + virtual void SetFitRange(const TString fitRange); virtual Double_t GetSingleHistoChisq(const std::vector& par) const; virtual Double_t GetAsymmetryChisq(const std::vector& par) const; diff --git a/src/include/PRunMuMinus.h b/src/include/PRunMuMinus.h index 04a97fea..78b2d2c5 100644 --- a/src/include/PRunMuMinus.h +++ b/src/include/PRunMuMinus.h @@ -51,6 +51,8 @@ class PRunMuMinus : public PRunBase virtual UInt_t GetNoOfFitBins(); + virtual void SetFitRangeBin(const TString fitRange); + protected: virtual void CalcNoOfFitBins(); virtual Bool_t PrepareData(); @@ -60,6 +62,8 @@ class PRunMuMinus : public PRunBase private: UInt_t fNoOfFitBins; ///< number of bins to be fitted + Int_t fGoodBins[2]; ///< keep first/last good bins. 0=fgb, 1=lgb + PDoubleVector fForward; ///< forward histo data }; diff --git a/src/include/PRunNonMusr.h b/src/include/PRunNonMusr.h index bd2c40af..138df1f5 100644 --- a/src/include/PRunNonMusr.h +++ b/src/include/PRunNonMusr.h @@ -52,6 +52,8 @@ class PRunNonMusr : public PRunBase virtual UInt_t GetNoOfFitBins(); + virtual void SetFitRangeBin(const TString fitRange) {} + virtual UInt_t GetXIndex(); virtual UInt_t GetYIndex(); diff --git a/src/include/PRunSingleHisto.h b/src/include/PRunSingleHisto.h index 6474f22a..72ea1385 100644 --- a/src/include/PRunSingleHisto.h +++ b/src/include/PRunSingleHisto.h @@ -51,6 +51,8 @@ class PRunSingleHisto : public PRunBase virtual UInt_t GetNoOfFitBins(); + virtual void SetFitRangeBin(const TString fitRange); + protected: virtual void CalcNoOfFitBins(); virtual Bool_t PrepareData(); @@ -63,7 +65,9 @@ class PRunSingleHisto : public PRunBase UInt_t fNoOfFitBins; ///< number of bins to be fitted Double_t fBackground; ///< needed if background range is given (units: 1/bin) - PDoubleVector fForward; ///< forward histo data + Int_t fGoodBins[2]; ///< keep first/last good bins. 0=fgb, 1=lgb + + PDoubleVector fForward; ///< forward histo data virtual Bool_t EstimateBkg(UInt_t histoNo); virtual Bool_t IsScaleN0AndBkg(); diff --git a/src/musrfit.cpp b/src/musrfit.cpp index 8bfcf353..7b335fac 100644 --- a/src/musrfit.cpp +++ b/src/musrfit.cpp @@ -543,6 +543,8 @@ int main(int argc, char *argv[]) else dataHandler = new PRunDataHandler(msrHandler); + dataHandler->ReadData(); + bool success = dataHandler->IsAllDataAvailable(); if (!success) { cout << endl << ">> musrfit **ERROR** Couldn't read all data files, will quit ..." << endl; diff --git a/src/musrt0.cpp b/src/musrt0.cpp index c1b3cca6..2f2bb91d 100644 --- a/src/musrt0.cpp +++ b/src/musrt0.cpp @@ -366,6 +366,8 @@ Int_t main(Int_t argc, Char_t *argv[]) else dataHandler = new PRunDataHandler(msrHandler); + dataHandler->ReadData(); + success = dataHandler->IsAllDataAvailable(); if (!success) { cout << endl << ">> musrt0 **ERROR** Couldn't read all data files, will quit ..." << endl; diff --git a/src/musrview.cpp b/src/musrview.cpp index 1c091ee8..bcffb38b 100644 --- a/src/musrview.cpp +++ b/src/musrview.cpp @@ -247,6 +247,8 @@ int main(int argc, char *argv[]) else dataHandler = new PRunDataHandler(msrHandler); + dataHandler->ReadData(); + success = dataHandler->IsAllDataAvailable(); if (!success) { cerr << endl << ">> musrview **ERROR** Couldn't read all data files, will quit ..." << endl;