added a feature which brings up a error message box, if there was any issue with the msr-file when starting musrview from musredit.

This commit is contained in:
2025-06-29 09:04:45 +02:00
parent 4da145d674
commit b692b78cac
9 changed files with 451 additions and 138 deletions

View File

@@ -17,6 +17,15 @@ root_generate_dictionary(
LINKDEF ${MUSRFIT_INC}/PFourierCanvasLinkDef.h LINKDEF ${MUSRFIT_INC}/PFourierCanvasLinkDef.h
MODULE PFourierCanvas MODULE PFourierCanvas
) )
root_generate_dictionary(
PMsgBoxDict
PMsgBox.h
LINKDEF ${MUSRFIT_INC}/PMsgBoxLinkDef.h
OPTIONS
-I${Boost_INCLUDE_DIR} -I${FFTW3_INCLUDE} -I${MUSRFIT_INC}
-inlineInputHeader
MODULE PMsgBox
)
root_generate_dictionary( root_generate_dictionary(
PMusrCanvasDict PMusrCanvasDict
PMusrCanvas.h PMusrCanvas.h
@@ -72,7 +81,7 @@ set(prefix "${CMAKE_INSTALL_PREFIX}")
set(exec_prefix "\$\{prefix\}") set(exec_prefix "\$\{prefix\}")
set(libdir "\$\{exec_prefix\}/lib") set(libdir "\$\{exec_prefix\}/lib")
set(includedir "\$\{prefix\}/include") set(includedir "\$\{prefix\}/include")
set(MUSR_VERSION "1.5.0") set(MUSR_VERSION "1.6.0")
set(MUSR_LIBRARY_NAME "PMusr") set(MUSR_LIBRARY_NAME "PMusr")
configure_file("PMusr.pc.in" "PMusr.pc" @ONLY) configure_file("PMusr.pc.in" "PMusr.pc" @ONLY)
set(USERFCN_LIBRARY_NAME "PUserFcnBase") set(USERFCN_LIBRARY_NAME "PUserFcnBase")
@@ -93,6 +102,8 @@ add_library(PMusr SHARED
PMusrCanvasDict.cxx PMusrCanvasDict.cxx
PFunction.cpp PFunction.cpp
PFunctionHandler.cpp PFunctionHandler.cpp
PMsgBox.cpp
PMsgBoxDict.cxx
PMsr2Data.cpp PMsr2Data.cpp
PMsrHandler.cpp PMsrHandler.cpp
PMusrCanvas.cpp PMusrCanvas.cpp
@@ -220,6 +231,8 @@ install(TARGETS PMusr DESTINATION lib)
install( install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/libPFourierCanvas_rdict.pcm FILES ${CMAKE_CURRENT_BINARY_DIR}/libPFourierCanvas_rdict.pcm
${CMAKE_CURRENT_BINARY_DIR}/libPFourierCanvas.rootmap ${CMAKE_CURRENT_BINARY_DIR}/libPFourierCanvas.rootmap
${CMAKE_CURRENT_BINARY_DIR}/libPMsgBox_rdict.pcm
${CMAKE_CURRENT_BINARY_DIR}/libPMsgBox.rootmap
${CMAKE_CURRENT_BINARY_DIR}/libPMusrCanvas_rdict.pcm ${CMAKE_CURRENT_BINARY_DIR}/libPMusrCanvas_rdict.pcm
${CMAKE_CURRENT_BINARY_DIR}/libPMusrCanvas.rootmap ${CMAKE_CURRENT_BINARY_DIR}/libPMusrCanvas.rootmap
${CMAKE_CURRENT_BINARY_DIR}/libPMusrT0_rdict.pcm ${CMAKE_CURRENT_BINARY_DIR}/libPMusrT0_rdict.pcm

78
src/classes/PMsgBox.cpp Normal file
View File

@@ -0,0 +1,78 @@
/***************************************************************************
PMsgBox.cpp
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2025 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "PMsgBox.h"
PMsgBox::PMsgBox(const std::string errMsg, const TGWindow *p, UInt_t w, UInt_t h) : TGMainFrame(p, w, h)
{
fListBox = new TGListBox(this, 89);
// feed list box with errMsg
size_t start = 0;
size_t end = errMsg.find("\n");
unsigned int i=1;
std::string tok{""};
fListBox->AddEntry(tok.c_str(), i++);
while (end != std::string::npos) {
tok = errMsg.substr(start, end - start);
start = end + 1;
end = errMsg.find("\n", start);
fListBox->AddEntry(tok.c_str(), i++);
}
fListBox->Resize(600, 200);
AddFrame(fListBox, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 5));
// Create a horizontal frame containing button(s)
TGHorizontalFrame *hframe = new TGHorizontalFrame(this, 150, 20, kFixedWidth);
TGTextButton *exit = new TGTextButton(hframe, "&Exit ");
exit->Connect("Pressed()", "PMsgBox", this, "DoExit()");
hframe->AddFrame(exit, new TGLayoutHints(kLHintsExpandX, 5, 5, 3, 4));
AddFrame(hframe, new TGLayoutHints(kLHintsExpandX, 2, 2, 5, 1));
// Set a name to the main frame
SetWindowName("Error Message");
MapSubwindows();
// Initialize the layout algorithm via Resize()
Resize(GetDefaultSize());
// Map main frame
MapWindow();
}
PMsgBox::~PMsgBox()
{
// nothing to be done here?
}
void PMsgBox::DoExit()
{
gApplication->Terminate(0);
}

View File

@@ -276,9 +276,11 @@ Int_t PMsrHandler::ReadMsrFile()
if ((result == PMUSR_SUCCESS) && !fFourierOnly) { if ((result == PMUSR_SUCCESS) && !fFourierOnly) {
UInt_t parX, parY; UInt_t parX, parY;
if (!CheckUniquenessOfParamNames(parX, parY)) { if (!CheckUniquenessOfParamNames(parX, parY)) {
std::cerr << std::endl << ">> PMsrHandler::ReadMsrFile: **SEVERE ERROR** parameter name " << fParam[parX].fName.Data() << " is identical for parameter no " << fParam[parX].fNo << " and " << fParam[parY].fNo << "!"; fLastErrorMsg.str("");
std::cerr << std::endl << ">> Needs to be fixed first!"; fLastErrorMsg.clear();
std::cerr << std::endl; fLastErrorMsg << ">> PMsrHandler::ReadMsrFile: **SEVERE ERROR** parameter name " << fParam[parX].fName.Data() << " is identical for parameter no " << fParam[parX].fNo << " and " << fParam[parY].fNo << "!\n";
fLastErrorMsg << ">> Needs to be fixed first!\n";
std::cerr << std::endl << fLastErrorMsg.str();
result = PMUSR_MSR_SYNTAX_ERROR; result = PMUSR_MSR_SYNTAX_ERROR;
} }
} }
@@ -2443,8 +2445,10 @@ Int_t PMsrHandler::WriteMsrFile(const Char_t *filename, std::map<UInt_t, TString
Bool_t PMsrHandler::SetMsrParamValue(UInt_t idx, Double_t value) Bool_t PMsrHandler::SetMsrParamValue(UInt_t idx, Double_t value)
{ {
if (idx >= fParam.size()) { if (idx >= fParam.size()) {
std::cerr << std::endl << ">> PMsrHandler::SetMsrParamValue(): **ERROR** idx = " << idx << " is >= than the number of fit parameters " << fParam.size(); fLastErrorMsg.str("");
std::cerr << std::endl; fLastErrorMsg.clear();
fLastErrorMsg << ">> PMsrHandler::SetMsrParamValue(): **ERROR** idx = " << idx << " is >= than the number of fit parameters " << fParam.size() << "\n";
std::cerr << fLastErrorMsg.str();
return false; return false;
} }
@@ -2470,8 +2474,10 @@ Bool_t PMsrHandler::SetMsrParamValue(UInt_t idx, Double_t value)
Bool_t PMsrHandler::SetMsrParamStep(UInt_t idx, Double_t value) Bool_t PMsrHandler::SetMsrParamStep(UInt_t idx, Double_t value)
{ {
if (idx >= fParam.size()) { if (idx >= fParam.size()) {
std::cerr << std::endl << ">> PMsrHandler::SetMsrParamValue(): **ERROR** idx = " << idx << " is larger than the number of parameters " << fParam.size(); fLastErrorMsg.str("");
std::cerr << std::endl; fLastErrorMsg.clear();
fLastErrorMsg << ">> PMsrHandler::SetMsrParamValue(): **ERROR** idx = " << idx << " is larger than the number of parameters " << fParam.size() << "\n";
std::cerr << fLastErrorMsg.str();
return false; return false;
} }
@@ -2496,8 +2502,10 @@ Bool_t PMsrHandler::SetMsrParamStep(UInt_t idx, Double_t value)
Bool_t PMsrHandler::SetMsrParamPosErrorPresent(UInt_t idx, Bool_t value) Bool_t PMsrHandler::SetMsrParamPosErrorPresent(UInt_t idx, Bool_t value)
{ {
if (idx >= fParam.size()) { if (idx >= fParam.size()) {
std::cerr << std::endl << ">> PMsrHandler::SetMsrParamPosErrorPresent(): **ERROR** idx = " << idx << " is larger than the number of parameters " << fParam.size(); fLastErrorMsg.str("");
std::cerr << std::endl; fLastErrorMsg.clear();
fLastErrorMsg << ">> PMsrHandler::SetMsrParamPosErrorPresent(): **ERROR** idx = " << idx << " is larger than the number of parameters " << fParam.size() << "\n";
std::cerr << fLastErrorMsg.str();
return false; return false;
} }
@@ -2522,8 +2530,10 @@ Bool_t PMsrHandler::SetMsrParamPosErrorPresent(UInt_t idx, Bool_t value)
Bool_t PMsrHandler::SetMsrParamPosError(UInt_t idx, Double_t value) Bool_t PMsrHandler::SetMsrParamPosError(UInt_t idx, Double_t value)
{ {
if (idx >= fParam.size()) { if (idx >= fParam.size()) {
std::cerr << std::endl << ">> PMsrHandler::SetMsrParamPosError(): **ERROR** idx = " << idx << " is larger than the number of parameters " << fParam.size(); fLastErrorMsg.str("");
std::cerr << std::endl; fLastErrorMsg.clear();
fLastErrorMsg << ">> PMsrHandler::SetMsrParamPosError(): **ERROR** idx = " << idx << " is larger than the number of parameters " << fParam.size() << "\n";
std::cerr << fLastErrorMsg.str();
return false; return false;
} }
@@ -2546,8 +2556,10 @@ Bool_t PMsrHandler::SetMsrParamPosError(UInt_t idx, Double_t value)
void PMsrHandler::SetMsrT0Entry(UInt_t runNo, UInt_t idx, Double_t bin) void PMsrHandler::SetMsrT0Entry(UInt_t runNo, UInt_t idx, Double_t bin)
{ {
if (runNo >= fRuns.size()) { // error if (runNo >= fRuns.size()) { // error
std::cerr << std::endl << ">> PMsrHandler::SetMsrT0Entry: **ERROR** runNo = " << runNo << ", is out of valid range 0.." << fRuns.size(); fLastErrorMsg.str("");
std::cerr << std::endl; fLastErrorMsg.clear();
fLastErrorMsg << ">> PMsrHandler::SetMsrT0Entry: **ERROR** runNo = " << runNo << ", is out of valid range 0.." << fRuns.size() << "\n";
std::cerr << fLastErrorMsg.str();
return; return;
} }
@@ -2574,8 +2586,10 @@ void PMsrHandler::SetMsrT0Entry(UInt_t runNo, UInt_t idx, Double_t bin)
void PMsrHandler::SetMsrAddT0Entry(UInt_t runNo, UInt_t addRunIdx, UInt_t histoIdx, Double_t bin) void PMsrHandler::SetMsrAddT0Entry(UInt_t runNo, UInt_t addRunIdx, UInt_t histoIdx, Double_t bin)
{ {
if (runNo >= fRuns.size()) { // error if (runNo >= fRuns.size()) { // error
std::cerr << std::endl << ">> PMsrHandler::SetMsrAddT0Entry: **ERROR** runNo = " << runNo << ", is out of valid range 0.." << fRuns.size(); fLastErrorMsg.str("");
std::cerr << std::endl; fLastErrorMsg.clear();
fLastErrorMsg << ">> PMsrHandler::SetMsrAddT0Entry: **ERROR** runNo = " << runNo << ", is out of valid range 0.." << fRuns.size() << "\n";
std::cerr << fLastErrorMsg.str();
return; return;
} }
@@ -2607,8 +2621,10 @@ void PMsrHandler::SetMsrAddT0Entry(UInt_t runNo, UInt_t addRunIdx, UInt_t histoI
void PMsrHandler::SetMsrDataRangeEntry(UInt_t runNo, UInt_t idx, Int_t bin) void PMsrHandler::SetMsrDataRangeEntry(UInt_t runNo, UInt_t idx, Int_t bin)
{ {
if (runNo >= fRuns.size()) { // error if (runNo >= fRuns.size()) { // error
std::cerr << std::endl << ">> PMsrHandler::SetMsrDataRangeEntry: **ERROR** runNo = " << runNo << ", is out of valid range 0.." << fRuns.size(); fLastErrorMsg.str("");
std::cerr << std::endl; fLastErrorMsg.clear();
fLastErrorMsg << ">> PMsrHandler::SetMsrDataRangeEntry: **ERROR** runNo = " << runNo << ", is out of valid range 0.." << fRuns.size() << "\n";
std::cerr << fLastErrorMsg.str();
return; return;
} }
@@ -2628,8 +2644,10 @@ void PMsrHandler::SetMsrDataRangeEntry(UInt_t runNo, UInt_t idx, Int_t bin)
void PMsrHandler::SetMsrBkgRangeEntry(UInt_t runNo, UInt_t idx, Int_t bin) void PMsrHandler::SetMsrBkgRangeEntry(UInt_t runNo, UInt_t idx, Int_t bin)
{ {
if (runNo >= fRuns.size()) { // error if (runNo >= fRuns.size()) { // error
std::cerr << std::endl << ">> PMsrHandler::SetMsrBkgRangeEntry: **ERROR** runNo = " << runNo << ", is out of valid range 0.." << fRuns.size(); fLastErrorMsg.str("");
std::cerr << std::endl; fLastErrorMsg.clear();
fLastErrorMsg << ">> PMsrHandler::SetMsrBkgRangeEntry: **ERROR** runNo = " << runNo << ", is out of valid range 0.." << fRuns.size() << "\n";
std::cerr << fLastErrorMsg.str();
return; return;
} }
@@ -2714,8 +2732,10 @@ Bool_t PMsrHandler::HandleFitParameterEntry(PMsrLines &lines)
tokens = iter->fLine.Tokenize(" \t"); tokens = iter->fLine.Tokenize(" \t");
if (!tokens) { if (!tokens) {
std::cerr << std::endl << ">> PMsrHandler::HandleFitParameterEntry: **SEVERE ERROR** Couldn't tokenize Parameters in line " << iter->fLineNo; fLastErrorMsg.str("");
std::cerr << std::endl << std::endl; fLastErrorMsg.clear();
fLastErrorMsg << ">> PMsrHandler::HandleFitParameterEntry: **SEVERE ERROR** Couldn't tokenize Parameters in line " << iter->fLineNo << "\n";
std::cerr << fLastErrorMsg.str();
return false; return false;
} }
@@ -2832,28 +2852,27 @@ Bool_t PMsrHandler::HandleFitParameterEntry(PMsrLines &lines)
// check if enough elements found // check if enough elements found
if (error) { if (error) {
std::cerr << std::endl; fLastErrorMsg.str("");
std::cerr << std::endl << ">> PMsrHandler::HandleFitParameterEntry: **ERROR** in line " << iter->fLineNo << ":"; fLastErrorMsg.clear();
std::cerr << std::endl << ">> " << iter->fLine.Data(); fLastErrorMsg << "\n";
std::cerr << std::endl << ">> A Fit Parameter line needs to have the following form: "; fLastErrorMsg << ">> PMsrHandler::HandleFitParameterEntry: **ERROR** in line " << iter->fLineNo << ":\n";
std::cerr << std::endl; fLastErrorMsg << ">> " << iter->fLine.Data() << "\n";
std::cerr << std::endl << ">> No Name Value Step/Error [Lower_Boundary Upper_Boundary]"; fLastErrorMsg << ">> A Fit Parameter line needs to have the following form:\n";
std::cerr << std::endl; fLastErrorMsg << "\n";
std::cerr << std::endl << ">> or"; fLastErrorMsg << ">> No Name Value Step/Error [Lower_Boundary Upper_Boundary]\n\n";
std::cerr << std::endl; fLastErrorMsg << ">> or\n\n";
std::cerr << std::endl << ">> No Name Value Step/Neg_Error Pos_Error [Lower_Boundary Upper_Boundary]"; fLastErrorMsg << ">> No Name Value Step/Neg_Error Pos_Error [Lower_Boundary Upper_Boundary]\n\n";
std::cerr << std::endl; fLastErrorMsg << ">> No: the parameter number (an Int_t)\n";
std::cerr << std::endl << ">> No: the parameter number (an Int_t)"; fLastErrorMsg << ">> Name: the name of the parameter (less than 256 character)\n";
std::cerr << std::endl << ">> Name: the name of the parameter (less than 256 character)"; fLastErrorMsg << ">> Value: the starting value of the parameter (a Double_t)\n";
std::cerr << std::endl << ">> Value: the starting value of the parameter (a Double_t)"; fLastErrorMsg << ">> Step/Error,\n";
std::cerr << std::endl << ">> Step/Error,"; fLastErrorMsg << ">> Step/Neg_Error: the starting step value in a fit (a Double_t), or\n";
std::cerr << std::endl << ">> Step/Neg_Error: the starting step value in a fit (a Double_t), or"; fLastErrorMsg << ">> the symmetric error (MIGRAD, SIMPLEX), or\n";
std::cerr << std::endl << ">> the symmetric error (MIGRAD, SIMPLEX), or"; fLastErrorMsg << ">> the negative error (MINOS)\n";
std::cerr << std::endl << ">> the negative error (MINOS)"; fLastErrorMsg << ">> Pos_Error: the positive error (MINOS), (a Double_t or \"none\")\n";
std::cerr << std::endl << ">> Pos_Error: the positive error (MINOS), (a Double_t or \"none\")"; fLastErrorMsg << ">> Lower_Boundary: the lower boundary allowed for the fit parameter (a Double_t or \"none\")\n";
std::cerr << std::endl << ">> Lower_Boundary: the lower boundary allowed for the fit parameter (a Double_t or \"none\")"; fLastErrorMsg << ">> Upper_Boundary: the upper boundary allowed for the fit parameter (a Double_t or \"none\")\n";
std::cerr << std::endl << ">> Upper_Boundary: the upper boundary allowed for the fit parameter (a Double_t or \"none\")"; std::cerr << fLastErrorMsg.str();
std::cerr << std::endl;
} else { // everything is OK, therefore add the parameter to the parameter list } else { // everything is OK, therefore add the parameter to the parameter list
fParam.push_back(param); fParam.push_back(param);
} }
@@ -2871,13 +2890,15 @@ Bool_t PMsrHandler::HandleFitParameterEntry(PMsrLines &lines)
for (UInt_t i=0; i<fParam.size(); i++) { for (UInt_t i=0; i<fParam.size(); i++) {
if (fParam[i].fNo != static_cast<Int_t>(i)+1) { if (fParam[i].fNo != static_cast<Int_t>(i)+1) {
error = true; error = true;
std::cerr << std::endl << ">> PMsrHandler::HandleFitParameterEntry: **ERROR**"; fLastErrorMsg.str("");
std::cerr << std::endl << ">> Sorry, you are assuming to much from this program, it cannot"; fLastErrorMsg.clear();
std::cerr << std::endl << ">> handle none subsequent numbered parameters yet or in the near future."; fLastErrorMsg << ">> PMsrHandler::HandleFitParameterEntry: **ERROR**\n";
std::cerr << std::endl << ">> Found parameter " << fParam[i].fName.Data() << ", with"; fLastErrorMsg << ">> Sorry, you are assuming to much from this program, it cannot\n";
std::cerr << std::endl << ">> parameter number " << fParam[i].fNo << ", at paramter position " << i+1 << "."; fLastErrorMsg << ">> handle none subsequent numbered parameters yet or in the near future.\n";
std::cerr << std::endl << ">> This needs to be fixed first."; fLastErrorMsg << ">> Found parameter " << fParam[i].fName.Data() << ", with\n";
std::cerr << std::endl; fLastErrorMsg << ">> parameter number " << fParam[i].fNo << ", at paramter position " << i+1 << ".\n";
fLastErrorMsg << ">> This needs to be fixed first.\n";
std::cerr << fLastErrorMsg.str();
break; break;
} }
} }
@@ -2986,8 +3007,10 @@ Bool_t PMsrHandler::HandleGlobalEntry(PMsrLines &lines)
// tokenize line // tokenize line
tokens = str.Tokenize(" \t"); tokens = str.Tokenize(" \t");
if (!tokens) { if (!tokens) {
std::cerr << std::endl << ">> PMsrHandler::HandleGlobalEntry: **SEVERE ERROR** Couldn't tokenize line " << iter->fLineNo; fLastErrorMsg.str("");
std::cerr << std::endl << std::endl; fLastErrorMsg.clear();
fLastErrorMsg << ">> PMsrHandler::HandleGlobalEntry: **SEVERE ERROR** Couldn't tokenize line " << iter->fLineNo << "\n\n";
std::cerr << fLastErrorMsg.str();
return false; return false;
} }
@@ -3197,9 +3220,12 @@ Bool_t PMsrHandler::HandleGlobalEntry(PMsrLines &lines)
if (error) { if (error) {
--iter; --iter;
std::cerr << std::endl << ">> PMsrHandler::HandleGlobalEntry: **ERROR** in line " << iter->fLineNo << ":"; fLastErrorMsg.str("");
std::cerr << std::endl << ">> '" << iter->fLine.Data() << "'"; fLastErrorMsg.clear();
std::cerr << std::endl << ">> GLOBAL block syntax is too complex to print it here. Please check the manual."; fLastErrorMsg << ">> PMsrHandler::HandleGlobalEntry: **ERROR** in line " << iter->fLineNo << ":\n";
fLastErrorMsg << ">> '" << iter->fLine.Data() << "'\n";
fLastErrorMsg << ">> GLOBAL block syntax is too complex to print it here. Please check the manual.\n";
std::cerr << fLastErrorMsg.str();
} else { // save global } else { // save global
fGlobal = global; fGlobal = global;
} }
@@ -3250,8 +3276,10 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines)
// tokenize line // tokenize line
tokens = str.Tokenize(" \t"); tokens = str.Tokenize(" \t");
if (!tokens) { if (!tokens) {
std::cerr << std::endl << ">> PMsrHandler::HandleRunEntry: **SEVERE ERROR** Couldn't tokenize Parameters in line " << iter->fLineNo; fLastErrorMsg.str("");
std::cerr << std::endl << std::endl; fLastErrorMsg.clear();
fLastErrorMsg << ">> PMsrHandler::HandleRunEntry: **SEVERE ERROR** Couldn't tokenize Parameters in line " << iter->fLineNo << "\n\n";
std::cerr << fLastErrorMsg.str();
return false; return false;
} }
@@ -3307,10 +3335,12 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines)
if (line.BeginsWith("addrun", TString::kIgnoreCase)) { if (line.BeginsWith("addrun", TString::kIgnoreCase)) {
if (!runLinePresent) { if (!runLinePresent) {
std::cerr << std::endl << ">> PMsrHandler::HandleRunEntry: **ERROR** Found ADDRUN without prior RUN, or"; fLastErrorMsg.str("");
std::cerr << std::endl << ">> ADDRUN lines intercepted by other stuff. All this is not allowed!"; fLastErrorMsg.clear();
std::cerr << std::endl << ">> error in line " << iter->fLineNo; fLastErrorMsg << ">> PMsrHandler::HandleRunEntry: **ERROR** Found ADDRUN without prior RUN, or\n";
std::cerr << std::endl; fLastErrorMsg << ">> ADDRUN lines intercepted by other stuff. All this is not allowed!\n";
fLastErrorMsg << ">> error in line " << iter->fLineNo << "\n";
std::cerr << fLastErrorMsg.str();
error = true; error = true;
continue; continue;
} }
@@ -3521,7 +3551,10 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines)
if (!fFourierOnly) { if (!fFourierOnly) {
for (UInt_t i=0; i<param.GetMap()->size(); i++) { for (UInt_t i=0; i<param.GetMap()->size(); i++) {
if ((param.GetMap(i) < 0) || (param.GetMap(i) > static_cast<Int_t>(fParam.size()))) { if ((param.GetMap(i) < 0) || (param.GetMap(i) > static_cast<Int_t>(fParam.size()))) {
std::cerr << std::endl << ">> PMsrHandler::HandleRunEntry: **SEVERE ERROR** map value " << param.GetMap(i) << " in line " << iter->fLineNo << " is out of range!"; fLastErrorMsg.str("");
fLastErrorMsg.clear();
fLastErrorMsg << ">> PMsrHandler::HandleRunEntry: **SEVERE ERROR** map value " << param.GetMap(i) << " in line " << iter->fLineNo << " is out of range!\n";
std::cerr << fLastErrorMsg.str();
error = true; error = true;
break; break;
} }
@@ -3814,9 +3847,12 @@ Bool_t PMsrHandler::HandleRunEntry(PMsrLines &lines)
if (error) { if (error) {
--iter; --iter;
std::cerr << std::endl << ">> PMsrHandler::HandleRunEntry: **ERROR** in line " << iter->fLineNo << ":"; fLastErrorMsg.str("");
std::cerr << std::endl << ">> " << iter->fLine.Data(); fLastErrorMsg.clear();
std::cerr << std::endl << ">> RUN block syntax is too complex to print it here. Please check the manual."; fLastErrorMsg << ">> PMsrHandler::HandleRunEntry: **ERROR** in line " << iter->fLineNo << ":\n";
fLastErrorMsg << ">> " << iter->fLine.Data() << "\n";
fLastErrorMsg << ">> RUN block syntax is too complex to print it here. Please check the manual.\n";
std::cerr << fLastErrorMsg.str();
} else { // save last run found } else { // save last run found
fRuns.push_back(param); fRuns.push_back(param);
param.CleanUp(); param.CleanUp();
@@ -3969,7 +4005,10 @@ Bool_t PMsrHandler::ParseFourierPhaseValueVector(PMsrFourierStructure &fourier,
TObjArray *tok = str.Tokenize(" ,;\t"); TObjArray *tok = str.Tokenize(" ,;\t");
if (tok == nullptr) { if (tok == nullptr) {
std::cerr << std::endl << ">> PMsrHandler::ParseFourierPhaseValueVector: **ERROR** couldn't tokenize Fourier phase line." << std::endl << std::endl; fLastErrorMsg.str("");
fLastErrorMsg.clear();
fLastErrorMsg << ">> PMsrHandler::ParseFourierPhaseValueVector: **ERROR** couldn't tokenize Fourier phase line.\n\n";
std::cerr << fLastErrorMsg.str();
return false; return false;
} }
@@ -3990,8 +4029,11 @@ Bool_t PMsrHandler::ParseFourierPhaseValueVector(PMsrFourierStructure &fourier,
} else { } else {
result = false; result = false;
if (i>1) { // make sure that no 'phase val, parX' mixture is present if (i>1) { // make sure that no 'phase val, parX' mixture is present
std::cerr << std::endl << ">> PMsrHandler::ParseFourierPhaseValueVector: **ERROR** in Fourier phase line."; fLastErrorMsg.str("");
std::cerr << std::endl << ">> Attempt to mix val, parX? This is currently not supported." << std::endl << std::endl; fLastErrorMsg.clear();
fLastErrorMsg << ">> PMsrHandler::ParseFourierPhaseValueVector: **ERROR** in Fourier phase line.\n";
fLastErrorMsg << ">> Attempt to mix val, parX? This is currently not supported.\n\n";
std::cerr << fLastErrorMsg.str();
error = true; error = true;
} }
break; break;
@@ -4029,7 +4071,10 @@ Bool_t PMsrHandler::ParseFourierPhaseParVector(PMsrFourierStructure &fourier, co
TObjArray *tok = str.Tokenize(" ,;\t"); TObjArray *tok = str.Tokenize(" ,;\t");
if (tok == nullptr) { if (tok == nullptr) {
std::cerr << std::endl << ">> PMsrHandler::ParseFourierPhaseParVector: **ERROR** couldn't tokenize Fourier phase line." << std::endl << std::endl; fLastErrorMsg.str("");
fLastErrorMsg.clear();
fLastErrorMsg << ">> PMsrHandler::ParseFourierPhaseParVector: **ERROR** couldn't tokenize Fourier phase line.\n\n";
std::cerr << fLastErrorMsg.str();
return false; return false;
} }
@@ -4045,7 +4090,10 @@ Bool_t PMsrHandler::ParseFourierPhaseParVector(PMsrFourierStructure &fourier, co
TObjString *ostr = dynamic_cast<TObjString*>(tok->At(i)); TObjString *ostr = dynamic_cast<TObjString*>(tok->At(i));
sstr = ostr->GetString(); sstr = ostr->GetString();
if (!sstr.BeginsWith("par")) { if (!sstr.BeginsWith("par")) {
std::cerr << ">> PMsrHandler::ParseFourierPhaseParVector: **ERROR** found unhandable token '" << sstr << "'" << std::endl; fLastErrorMsg.str("");
fLastErrorMsg.clear();
fLastErrorMsg << ">> PMsrHandler::ParseFourierPhaseParVector: **ERROR** found unhandable token '" << sstr << "'\n";
std::cerr << fLastErrorMsg.str();
error = true; error = true;
result = false; result = false;
break; break;
@@ -4063,7 +4111,10 @@ Bool_t PMsrHandler::ParseFourierPhaseParVector(PMsrFourierStructure &fourier, co
} }
if (refCount > 1) { if (refCount > 1) {
std::cerr << ">> PMsrHandler::ParseFourierPhaseParVector: **ERROR** found multiple parR's! Only one reference phase is accepted." << std::endl; fLastErrorMsg.str("");
fLastErrorMsg.clear();
fLastErrorMsg << ">> PMsrHandler::ParseFourierPhaseParVector: **ERROR** found multiple parR's! Only one reference phase is accepted.\n";
std::cerr << fLastErrorMsg.str();
result = false; result = false;
} }
@@ -4083,7 +4134,10 @@ Bool_t PMsrHandler::ParseFourierPhaseParVector(PMsrFourierStructure &fourier, co
fourier.fPhaseRef = sstr.Atoi(); fourier.fPhaseRef = sstr.Atoi();
fourier.fPhaseParamNo.push_back(sstr.Atoi()); fourier.fPhaseParamNo.push_back(sstr.Atoi());
} else { } else {
std::cerr << ">> PMsrHandler::ParseFourierPhaseParVector: **ERROR** found token '" << ostr->GetString() << "' which is not parX with X an integer." << std::endl; fLastErrorMsg.str("");
fLastErrorMsg.clear();
fLastErrorMsg << ">> PMsrHandler::ParseFourierPhaseParVector: **ERROR** found token '" << ostr->GetString() << "' which is not parX with X an integer.\n";
std::cerr << fLastErrorMsg.str();
fourier.fPhaseParamNo.clear(); fourier.fPhaseParamNo.clear();
error = true; error = true;
break; break;
@@ -4129,7 +4183,10 @@ Bool_t PMsrHandler::ParseFourierPhaseParIterVector(PMsrFourierStructure &fourier
// remove 'par(' from string if present, otherwise and error is issued // remove 'par(' from string if present, otherwise and error is issued
if (!wstr.BeginsWith("par(") && !wstr.BeginsWith("parR(")) { if (!wstr.BeginsWith("par(") && !wstr.BeginsWith("parR(")) {
std::cout << ">> PMsrHandler::ParseFourierPhaseParIterVector: **ERROR** token should start with 'par(' or 'parR(', found: '" << wstr << "' -> ERROR" << std::endl; fLastErrorMsg.str("");
fLastErrorMsg.clear();
fLastErrorMsg << ">> PMsrHandler::ParseFourierPhaseParIterVector: **ERROR** token should start with 'par(' or 'parR(', found: '" << wstr << "' -> ERROR\n";
std::cerr << fLastErrorMsg.str();
error = true; error = true;
return false; return false;
} }
@@ -4151,14 +4208,20 @@ Bool_t PMsrHandler::ParseFourierPhaseParIterVector(PMsrFourierStructure &fourier
// tokenize rest which should have the form 'X0, offset, #Param' // tokenize rest which should have the form 'X0, offset, #Param'
TObjArray *tok = wstr.Tokenize(",;"); TObjArray *tok = wstr.Tokenize(",;");
if (tok == nullptr) { if (tok == nullptr) {
std::cerr << ">> PMsrHandler::ParseFourierPhaseParIterVector: **ERROR** tokenize failed." << std::endl; fLastErrorMsg.str("");
fLastErrorMsg.clear();
fLastErrorMsg << ">> PMsrHandler::ParseFourierPhaseParIterVector: **ERROR** tokenize failed.\n";
std::cerr << fLastErrorMsg.str();
error = true; error = true;
return false; return false;
} }
// check for proper number of expected elements // check for proper number of expected elements
if (tok->GetEntries() != 3) { if (tok->GetEntries() != 3) {
std::cerr << ">> PMsrHandler::ParseFourierPhaseParIterVector: **ERROR** wrong syntax for the expected par(X0, offset, #param)." << std::endl; fLastErrorMsg.str("");
fLastErrorMsg.clear();
fLastErrorMsg << ">> PMsrHandler::ParseFourierPhaseParIterVector: **ERROR** wrong syntax for the expected par(X0, offset, #param).\n";
std::cerr << fLastErrorMsg.str();
error = true; error = true;
delete tok; delete tok;
return false; return false;
@@ -4172,7 +4235,10 @@ Bool_t PMsrHandler::ParseFourierPhaseParIterVector(PMsrFourierStructure &fourier
if (wstr.IsDigit()) { if (wstr.IsDigit()) {
x0 = wstr.Atoi(); x0 = wstr.Atoi();
} else { } else {
std::cerr << ">> PMsrHandler::ParseFourierPhaseParIterVector: **ERROR** X0='" << wstr << "' is not an integer." << std::endl; fLastErrorMsg.str("");
fLastErrorMsg.clear();
fLastErrorMsg << ">> PMsrHandler::ParseFourierPhaseParIterVector: **ERROR** X0='" << wstr << "' is not an integer.\n";
std::cerr << fLastErrorMsg.str();
error = true; error = true;
delete tok; delete tok;
return false; return false;
@@ -4184,7 +4250,10 @@ Bool_t PMsrHandler::ParseFourierPhaseParIterVector(PMsrFourierStructure &fourier
if (wstr.IsDigit()) { if (wstr.IsDigit()) {
offset = wstr.Atoi(); offset = wstr.Atoi();
} else { } else {
std::cerr << ">> PMsrHandler::ParseFourierPhaseParIterVector: **ERROR** offset='" << wstr << "' is not an integer." << std::endl; fLastErrorMsg.str("");
fLastErrorMsg.clear();
fLastErrorMsg << ">> PMsrHandler::ParseFourierPhaseParIterVector: **ERROR** offset='" << wstr << "' is not an integer.\n";
std::cerr << fLastErrorMsg.str();
error = true; error = true;
delete tok; delete tok;
return false; return false;
@@ -4196,7 +4265,10 @@ Bool_t PMsrHandler::ParseFourierPhaseParIterVector(PMsrFourierStructure &fourier
if (wstr.IsDigit()) { if (wstr.IsDigit()) {
noParam = wstr.Atoi(); noParam = wstr.Atoi();
} else { } else {
std::cerr << ">> PMsrHandler::ParseFourierPhaseParIterVector: **ERROR** #Param='" << wstr << "' is not an integer." << std::endl; fLastErrorMsg.str("");
fLastErrorMsg.clear();
fLastErrorMsg << ">> PMsrHandler::ParseFourierPhaseParIterVector: **ERROR** #Param='" << wstr << "' is not an integer.\n";
std::cerr << fLastErrorMsg.str();
error = true; error = true;
delete tok; delete tok;
return false; return false;
@@ -4257,8 +4329,10 @@ Bool_t PMsrHandler::HandleFourierEntry(PMsrLines &lines)
// tokenize line // tokenize line
tokens = iter->fLine.Tokenize(" \t"); tokens = iter->fLine.Tokenize(" \t");
if (!tokens) { if (!tokens) {
std::cerr << std::endl << ">> PMsrHandler::HandleFourierEntry: **SEVERE ERROR** Couldn't tokenize Parameters in line " << iter->fLineNo; fLastErrorMsg.str("");
std::cerr << std::endl << std::endl; fLastErrorMsg.clear();
fLastErrorMsg << ">> PMsrHandler::HandleFourierEntry: **SEVERE ERROR** Couldn't tokenize Parameters in line " << iter->fLineNo << "\n\n";
std::cerr << fLastErrorMsg.str();
return false; return false;
} }
@@ -4401,7 +4475,10 @@ Bool_t PMsrHandler::HandleFourierEntry(PMsrLines &lines)
if (fourier.fPhaseParamNo.size() > 0) { if (fourier.fPhaseParamNo.size() > 0) {
for (UInt_t i=0; i<fourier.fPhaseParamNo.size(); i++) { for (UInt_t i=0; i<fourier.fPhaseParamNo.size(); i++) {
if (fourier.fPhaseParamNo[i] > fParam.size()) { if (fourier.fPhaseParamNo[i] > fParam.size()) {
std::cerr << ">> PMsrHandler::HandleFourierEntry: found Fourier parameter entry par" << fourier.fPhaseParamNo[i] << " > #Param = " << fParam.size() << std::endl; fLastErrorMsg.str("");
fLastErrorMsg.clear();
fLastErrorMsg << ">> PMsrHandler::HandleFourierEntry: found Fourier parameter entry par" << fourier.fPhaseParamNo[i] << " > #Param = " << fParam.size() << "\n";
std::cerr << fLastErrorMsg.str();
error = true; error = true;
--iter; --iter;
continue; continue;
@@ -4507,28 +4584,28 @@ Bool_t PMsrHandler::HandleFourierEntry(PMsrLines &lines)
} }
if (error) { if (error) {
std::cerr << std::endl << ">> PMsrHandler::HandleFourierEntry: **ERROR** in line " << iter->fLineNo << ":"; fLastErrorMsg.str("");
std::cerr << std::endl; fLastErrorMsg.clear();
std::cerr << std::endl << ">> " << iter->fLine.Data(); fLastErrorMsg << ">> PMsrHandler::HandleFourierEntry: **ERROR** in line " << iter->fLineNo << ":\n\n";
std::cerr << std::endl; fLastErrorMsg << ">> " << iter->fLine.Data() << "\n\n";
std::cerr << std::endl << ">> FOURIER block syntax, parameters in [] are optinal:"; fLastErrorMsg << ">> FOURIER block syntax, parameters in [] are optinal:\n\n";
std::cerr << std::endl; fLastErrorMsg << ">> FOURIER\n";
std::cerr << std::endl << ">> FOURIER"; fLastErrorMsg << ">> [units Gauss | MHz | Mc/s]\n";
std::cerr << std::endl << ">> [units Gauss | MHz | Mc/s]"; fLastErrorMsg << ">> [fourier_power n # n is a number such that zero padding up to 2^n will be used]\n";
std::cerr << std::endl << ">> [fourier_power n # n is a number such that zero padding up to 2^n will be used]"; fLastErrorMsg << ">> n=0 means no zero padding\n";
std::cerr << std::endl << ">> n=0 means no zero padding"; fLastErrorMsg << ">> 0 <= n <= 20 are allowed values\n";
std::cerr << std::endl << ">> 0 <= n <= 20 are allowed values"; fLastErrorMsg << ">> [dc-corrected true | false]\n";
std::cerr << std::endl << ">> [dc-corrected true | false]"; fLastErrorMsg << ">> [apodization none | weak | medium | strong]\n";
std::cerr << std::endl << ">> [apodization none | weak | medium | strong]"; fLastErrorMsg << ">> [plot real | imag | real_and_imag | power | phase | phase_opt_real]\n";
std::cerr << std::endl << ">> [plot real | imag | real_and_imag | power | phase | phase_opt_real]"; fLastErrorMsg << ">> [phase valList | parList | parIterList [# comment]]\n";
std::cerr << std::endl << ">> [phase valList | parList | parIterList [# comment]]"; fLastErrorMsg << ">> valList : val [sep val ... sep val]. sep=' ,;\\t'\n";
std::cerr << std::endl << ">> valList : val [sep val ... sep val]. sep=' ,;\\t'"; fLastErrorMsg << ">> parList : parX0 [sep parX1 ... sep parXn], Xi is the parameter number\n";
std::cerr << std::endl << ">> parList : parX0 [sep parX1 ... sep parX1]"; fLastErrorMsg << ">> parList : parRX0 sep parX1 ... sep parXn, parRX0 is the reference phase, e.g. parR3\n";
std::cerr << std::endl << ">> parIterList : par(X0,offset,#param), with X0=first parameter number"; fLastErrorMsg << ">> parIterList : par(X0,offset,#param), with X0=first parameter number\n";
std::cerr << std::endl << ">> offset=parameter offset, #param=number of phase parameters."; fLastErrorMsg << ">> offset=parameter offset, #param=number of phase parameters.\n";
std::cerr << std::endl << ">> [range_for_phase_correction min max | all]"; fLastErrorMsg << ">> [range_for_phase_correction min max | all]\n";
std::cerr << std::endl << ">> [range min max]"; fLastErrorMsg << ">> [range min max]\n";
std::cerr << std::endl; std::cerr << fLastErrorMsg.str();
} else { // save last run found } else { // save last run found
fFourier = fourier; fFourier = fourier;
} }
@@ -4603,8 +4680,10 @@ Bool_t PMsrHandler::HandlePlotEntry(PMsrLines &lines)
if (line.Contains("PLOT")) { // handle plot header if (line.Contains("PLOT")) { // handle plot header
tokens = line.Tokenize(" \t"); tokens = line.Tokenize(" \t");
if (!tokens) { if (!tokens) {
std::cerr << std::endl << ">> PMsrHandler::HandlePlotEntry: **SEVERE ERROR** Couldn't tokenize PLOT in line " << iter1->fLineNo; fLastErrorMsg.str("");
std::cerr << std::endl << std::endl; fLastErrorMsg.clear();
fLastErrorMsg << ">> PMsrHandler::HandlePlotEntry: **SEVERE ERROR** Couldn't tokenize PLOT in line " << iter1->fLineNo << "\n\n";
std::cerr << fLastErrorMsg.str();
return false; return false;
} }
if (tokens->GetEntries() < 2) { // plot type missing if (tokens->GetEntries() < 2) { // plot type missing
@@ -4642,9 +4721,11 @@ Bool_t PMsrHandler::HandlePlotEntry(PMsrLines &lines)
case MSR_PLOT_MU_MINUS: case MSR_PLOT_MU_MINUS:
rl = std::make_unique<PStringNumberList>(line.Data()); rl = std::make_unique<PStringNumberList>(line.Data());
if (!rl->Parse(errorMsg, true)) { if (!rl->Parse(errorMsg, true)) {
std::cerr << std::endl << ">> PMsrHandler::HandlePlotEntry: **SEVERE ERROR** Couldn't tokenize PLOT in line " << iter1->fLineNo; fLastErrorMsg.str("");
std::cerr << std::endl << ">> Error Message: " << errorMsg; fLastErrorMsg.clear();
std::cerr << std::endl << std::endl; fLastErrorMsg << ">> PMsrHandler::HandlePlotEntry: **SEVERE ERROR** Couldn't tokenize PLOT in line " << iter1->fLineNo << "\n";
fLastErrorMsg << ">> Error Message: " << errorMsg;
std::cerr << fLastErrorMsg.str();
return false; return false;
} }
runList = rl->GetList(); runList = rl->GetList();
@@ -6379,9 +6460,11 @@ Bool_t PMsrHandler::CheckAddRunParameters()
// check concerning the addt0 tags // check concerning the addt0 tags
if (fRuns[i].GetAddT0BinEntries() != 0) { if (fRuns[i].GetAddT0BinEntries() != 0) {
if (fRuns[i].GetAddT0BinEntries() != fRuns[i].GetRunNameSize()-1) { if (fRuns[i].GetAddT0BinEntries() != fRuns[i].GetRunNameSize()-1) {
std::cerr << std::endl << ">> PMsrHandler::CheckAddRunParameters: **ERROR** # of addt0 != # of addruns."; fLastErrorMsg.str("");
std::cerr << std::endl << ">> Run #" << i+1; fLastErrorMsg.clear();
std::cerr << std::endl; fLastErrorMsg << ">> PMsrHandler::CheckAddRunParameters: **ERROR** # of addt0 != # of addruns.\n";
fLastErrorMsg << ">> Run #" << i+1 << "\n";
std::cerr << std::endl << fLastErrorMsg.str();
result = false; result = false;
break; break;
} }
@@ -6406,8 +6489,10 @@ void PMsrHandler::CheckMaxLikelihood()
for (UInt_t i=0; i<fRuns.size(); i++) { for (UInt_t i=0; i<fRuns.size(); i++) {
if ((fRuns[i].GetFitType() != MSR_FITTYPE_SINGLE_HISTO) && (fGlobal.GetFitType() != MSR_FITTYPE_SINGLE_HISTO) && if ((fRuns[i].GetFitType() != MSR_FITTYPE_SINGLE_HISTO) && (fGlobal.GetFitType() != MSR_FITTYPE_SINGLE_HISTO) &&
(fRuns[i].GetFitType() != MSR_FITTYPE_MU_MINUS) && (fGlobal.GetFitType() != MSR_FITTYPE_MU_MINUS)) { (fRuns[i].GetFitType() != MSR_FITTYPE_MU_MINUS) && (fGlobal.GetFitType() != MSR_FITTYPE_MU_MINUS)) {
std::cerr << std::endl << ">> PMsrHandler::CheckMaxLikelihood: **WARNING**: Maximum Log Likelihood Fit is only implemented"; fLastErrorMsg.str("");
std::cerr << std::endl << ">> for Single Histogram and Mu Minus Fits. Will fall back to Chi Square Fit."; fLastErrorMsg.clear();
fLastErrorMsg << ">> PMsrHandler::CheckMaxLikelihood: **WARNING**: Maximum Log Likelihood Fit is only implemented\n";
fLastErrorMsg << ">> for Single Histogram and Mu Minus Fits. Will fall back to Chi Square Fit.\n";
std::cerr << std::endl << std::endl; std::cerr << std::endl << std::endl;
fStatistic.fChisq = true; fStatistic.fChisq = true;
break; break;
@@ -6530,24 +6615,30 @@ Bool_t PMsrHandler::CheckRealFFT()
// check if the given phases in the Fourier block are in agreement with the Plot block settings // check if the given phases in the Fourier block are in agreement with the Plot block settings
if ((fFourier.fPhase.size() > 1) && (fPlots.size() > 0)) { if ((fFourier.fPhase.size() > 1) && (fPlots.size() > 0)) {
if (fFourier.fPhase.size() != fPlots[0].fRuns.size()) { if (fFourier.fPhase.size() != fPlots[0].fRuns.size()) {
std::cerr << std::endl << ">> PMsrHandler::ReadMsrFile: **ERROR** if more than one phase is given in the Fourier block,"; fLastErrorMsg.str("");
std::cerr << std::endl << ">> it needs to correspond to the number of runs in the Plot block!" << std::endl; fLastErrorMsg.clear();
std::cerr << std::endl << ">> currently:"; fLastErrorMsg << ">> PMsrHandler::ReadMsrFile: **ERROR** if more than one phase is given in the Fourier block,\n";
std::cerr << std::endl << ">> number of runs in the PLOT block: " << fPlots[0].fRuns.size(); fLastErrorMsg << ">> it needs to correspond to the number of runs in the Plot block!\n";
std::cerr << std::endl << ">> number of phases in the FOURIER block: " << fFourier.fPhase.size(); fLastErrorMsg << ">> currently:\n";
fLastErrorMsg << ">> number of runs in the PLOT block: " << fPlots[0].fRuns.size() << "\n";
fLastErrorMsg << ">> number of phases in the FOURIER block: " << fFourier.fPhase.size() << "\n";
std::cerr << std::endl << fLastErrorMsg.str();
return false; return false;
} }
} }
// make sure that FOURIER phases are defined // make sure that FOURIER phases are defined
if ((fFourier.fPhase.size() == 0) && (fFourier.fPhaseParamNo.size() == 0)) { if ((fFourier.fPhase.size() == 0) && (fFourier.fPhaseParamNo.size() == 0)) {
std::cerr << std::endl << ">> PMsrHandler::ReadMsrFile: **ERROR** for FOURIER plot != POWER,"; fLastErrorMsg.str("");
std::cerr << std::endl << ">> phases need to be defined in the FOURIER block!"; fLastErrorMsg.clear();
std::cerr << std::endl << ">> Examples:"; fLastErrorMsg << ">> PMsrHandler::ReadMsrFile: **ERROR** for FOURIER plot != POWER,\n";
std::cerr << std::endl << ">> phase parR7 par9 par13 par16"; fLastErrorMsg << ">> phases need to be defined in the FOURIER block!\n";
std::cerr << std::endl << ">> where parR7 is the reference phase, and the others the relative phases."; fLastErrorMsg << ">> Examples:\n";
std::cerr << std::endl << ">> I.e. phase of run 2: parR7 + par9, etc."; fLastErrorMsg << ">> phase parR7 par9 par13 par16\n";
std::cerr << std::endl << ">> For further details see the docu."; fLastErrorMsg << ">> where parR7 is the reference phase, and the others the relative phases.\n";
fLastErrorMsg << ">> I.e. phase of run 2: parR7 + par9, etc.\n";
fLastErrorMsg << ">> For further details see the docu.\n";
std::cerr << std::endl << fLastErrorMsg.str();
return false; return false;
} }

54
src/include/PMsgBox.h Normal file
View File

@@ -0,0 +1,54 @@
/***************************************************************************
PMsgBox.h
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2025 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef _PMSGBOX_H_
#define _PMSGBOX_H_
#include <string>
#include <TApplication.h>
#include <TGClient.h>
#include <TGButton.h>
#include <TGListBox.h>
#include <TList.h>
class PMsgBox : public TGMainFrame {
private:
TGListBox *fListBox;
public:
PMsgBox(const std::string errMsg, const TGWindow *p, UInt_t w, UInt_t h);
~PMsgBox() override;
void DoExit();
ClassDefOverride(PMsgBox, 0)
};
#endif // _PMSGBOX_H_

View File

@@ -0,0 +1,39 @@
/***************************************************************************
PMsgBoxLinkDef.h
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2025 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifdef __CINT__
#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;
#pragma link C++ class PMsgBox+;
#endif

View File

@@ -32,6 +32,8 @@
#include <string> #include <string>
#include <memory> #include <memory>
#include <sstream>
#include <string>
#include <TString.h> #include <TString.h>
#include <TComplex.h> #include <TComplex.h>
@@ -104,6 +106,8 @@ class PMsrHandler
virtual void GetGroupingString(Int_t runNo, TString detector, TString &groupingStr); virtual void GetGroupingString(Int_t runNo, TString detector, TString &groupingStr);
virtual Bool_t EstimateN0(); virtual Bool_t EstimateN0();
virtual std::string GetLastErrorMsg() { return fLastErrorMsg.str(); }
virtual std::string GetDKSTheoryString(); virtual std::string GetDKSTheoryString();
virtual UInt_t GetDKSTag(); virtual UInt_t GetDKSTag();
virtual Int_t GetNoOfMaps() { return fNoOfMaps; } virtual Int_t GetNoOfMaps() { return fNoOfMaps; }
@@ -135,6 +139,8 @@ class PMsrHandler
Int_t fNoOfMaps; Int_t fNoOfMaps;
std::stringstream fLastErrorMsg;
virtual Bool_t HandleFitParameterEntry(PMsrLines &line); virtual Bool_t HandleFitParameterEntry(PMsrLines &line);
virtual Bool_t HandleTheoryEntry(PMsrLines &line); virtual Bool_t HandleTheoryEntry(PMsrLines &line);
virtual Bool_t HandleFunctionsEntry(PMsrLines &line); virtual Bool_t HandleFunctionsEntry(PMsrLines &line);

View File

@@ -2620,6 +2620,9 @@ void PTextEdit::musrView()
if (fAdmin->getMusrviewShowOneToOneFlag()) if (fAdmin->getMusrviewShowOneToOneFlag())
arg << "-1"; arg << "-1";
// add error message box option
arg << "-s";
QProcess proc; QProcess proc;
// make sure that the system environment variables are properly set // make sure that the system environment variables are properly set
QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); QProcessEnvironment env = QProcessEnvironment::systemEnvironment();

View File

@@ -2612,6 +2612,9 @@ void PTextEdit::musrView()
if (fAdmin->getMusrviewShowOneToOneFlag()) if (fAdmin->getMusrviewShowOneToOneFlag())
arg << "-1"; arg << "-1";
// add error message box option
arg << "-s";
QProcess proc; QProcess proc;
// make sure that the system environment variables are properly set // make sure that the system environment variables are properly set
QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); QProcessEnvironment env = QProcessEnvironment::systemEnvironment();

View File

@@ -38,6 +38,8 @@
#include <iostream> #include <iostream>
#include <memory> #include <memory>
#include <vector> #include <vector>
#include <sstream>
#include <TApplication.h> #include <TApplication.h>
#include <TSAXParser.h> #include <TSAXParser.h>
@@ -53,6 +55,7 @@
#include "PRunDataHandler.h" #include "PRunDataHandler.h"
#include "PRunListCollection.h" #include "PRunListCollection.h"
#include "PMusrCanvas.h" #include "PMusrCanvas.h"
#include "PMsgBox.h"
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
@@ -81,9 +84,21 @@ void musrview_syntax()
std::cout << std::endl << " will produce an ascii dump of the data and fit as plotted."; std::cout << std::endl << " will produce an ascii dump of the data and fit as plotted.";
std::cout << std::endl << " --timeout <timeout>: <timeout> given in seconds after which musrview terminates."; std::cout << std::endl << " --timeout <timeout>: <timeout> given in seconds after which musrview terminates.";
std::cout << std::endl << " If <timeout> <= 0, no timeout will take place. Default <timeout> is 0."; std::cout << std::endl << " If <timeout> <= 0, no timeout will take place. Default <timeout> is 0.";
std::cout << std::endl << " -s, --show-errMsgBox: if this tag is defined, error message boxes are shown,";
std::cout << std::endl << " rather than only stderr output.";
std::cout << std::endl << std::endl; std::cout << std::endl << std::endl;
} }
//--------------------------------------------------------------------------
void musrview_error_msg(std::string errMsg)
{
int argc=0;
char **argv;
TApplication app("musrviewErrorMsg", &argc, argv);
new PMsgBox(errMsg, gClient->GetRoot(), 600, 200);
app.Run();
}
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
/** /**
* <p>The musrview program is used to show muSR fit results in graphical form. * <p>The musrview program is used to show muSR fit results in graphical form.
@@ -104,18 +119,20 @@ void musrview_syntax()
*/ */
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int result = PMUSR_SUCCESS; int result{PMUSR_SUCCESS};
bool show_syntax = false; bool show_syntax{false};
int status; int status;
bool success = true; bool success{true};
char fileName[128]; char fileName[128];
bool fourier = false; bool fourier{false};
bool avg = false; bool avg{false};
bool theoAtData = false; // theory points only at data points bool theoAtData{false}; // theory points only at data points
bool graphicsOutput = false; bool graphicsOutput{false};
bool asciiOutput = false; bool asciiOutput{false};
char graphicsExtension[128]; char graphicsExtension[128];
int timeout = 0; int timeout{0};
bool show_errMsgBox{false};
std::stringstream errMsg;
memset(fileName, '\0', sizeof(fileName)); memset(fileName, '\0', sizeof(fileName));
@@ -188,6 +205,8 @@ int main(int argc, char *argv[])
show_syntax = true; show_syntax = true;
break; break;
} }
} else if (!strcmp(argv[i], "-s") || !strcmp(argv[i], "--show-errMsgBox")) {
show_errMsgBox = true;
} else { } else {
show_syntax = true; show_syntax = true;
break; break;
@@ -227,17 +246,24 @@ int main(int argc, char *argv[])
std::unique_ptr<PMsrHandler> msrHandler = std::make_unique<PMsrHandler>(fileName); std::unique_ptr<PMsrHandler> msrHandler = std::make_unique<PMsrHandler>(fileName);
status = msrHandler->ReadMsrFile(); status = msrHandler->ReadMsrFile();
if (status != PMUSR_SUCCESS) { if (status != PMUSR_SUCCESS) {
errMsg << msrHandler->GetLastErrorMsg();
switch (status) { switch (status) {
case PMUSR_MSR_FILE_NOT_FOUND: case PMUSR_MSR_FILE_NOT_FOUND:
std::cerr << std::endl << ">> musrview **ERROR** couldn't find '" << fileName << "'" << std::endl << std::endl; errMsg << "\n";
errMsg << ">> musrview **ERROR** couldn't find '" << fileName << "'\n\n";
break; break;
case PMUSR_MSR_SYNTAX_ERROR: case PMUSR_MSR_SYNTAX_ERROR:
std::cerr << std::endl << ">> musrview **SYNTAX ERROR** in file " << fileName << ", full stop here." << std::endl << std::endl; errMsg << "\n";
errMsg << ">> musrview **SYNTAX ERROR** in file " << fileName << ", full stop here.\n\n";
break; break;
default: default:
std::cerr << std::endl << ">> musrview **UNKNOWN ERROR** when trying to read the msr-file" << std::endl << std::endl; errMsg << "\n";
errMsg << ">> musrview **UNKNOWN ERROR** when trying to read the msr-file.\n\n";
break; break;
} }
std::cerr << errMsg.str();
if (show_errMsgBox)
musrview_error_msg(errMsg.str());
return status; return status;
} }
// make a plot list vector // make a plot list vector