Merged muonspin/musrfit:root6 into master

This commit is contained in:
Zaher Salman 2022-12-04 19:33:25 +01:00
commit dd733164d1
7 changed files with 114 additions and 22 deletions

View File

@ -1,7 +1,7 @@
# - musrfit
cmake_minimum_required(VERSION 3.17)
project(musrfit VERSION 1.8.1 LANGUAGES C CXX)
project(musrfit VERSION 1.8.2 LANGUAGES C CXX)
#--- musrfit specific options -------------------------------------------------
option(nexus "build optional NeXus support. Needed for ISIS" OFF)

View File

@ -2495,12 +2495,14 @@ void PMsr2Data::WriteValue(std::fstream &outFile, const double &value, const uns
//-------------------------------------------------------------
/**
* <p>
* <p>Write a value to the outFile stream. The string length is determined on its error.
* E.g. 17.0023 +- 0.0018, or 73212.081 +- 0.033, etc.
*
* \param outFile
* \param value
* \param errValue
* \param width
* \param outFile output stream object
* \param value to be written to stream outFile
* \param errValue error of the value. needed to determine the needed accuracy
* \param width field width for outFile for formatted output
* \param db true for db-file output, false for dat-file output. Needed to have at least on space between numbers for dat-file output
*/
void PMsr2Data::WriteValue(std::fstream &outFile, const double &value, const double &errValue, const unsigned int &width, const bool &db) const
{
@ -2528,9 +2530,12 @@ void PMsr2Data::WriteValue(std::fstream &outFile, const double &value, const dou
//-------------------------------------------------------------
/**
* <p>
* <p>Determines the first significant digit of the provided number value.
* E.g. for value=2.03 it will return 1, for value=0.00023 it will return 4, etc.
*
* \param value
* \param value for which the first significant digit needs to be determined.
*
* \return first significant digit of the provided number value
*/
int PMsr2Data::GetFirstSignificantDigit(const double &value) const
{
@ -2554,7 +2559,13 @@ int PMsr2Data::GetFirstSignificantDigit(const double &value) const
//-------------------------------------------------------------
/**
* <p>Checks paramValue is found in the paramList. If paramList
* is empty, ALL paramValues will be accepted, i.e. return true.
*
* \param paramValue paramValue to be checked
* \param paramList parameter list
*
* \return true if the paramValue if found in paramList, or true if paramList is empty.
*/
bool PMsr2Data::InParameterList(const unsigned int &paramValue, const std::vector<unsigned int> &paramList) const
{

View File

@ -169,6 +169,9 @@ void PMuppCanvas::HandleCmdKey(Int_t event, Int_t x, Int_t y, TObject *selected)
Done(0);
} else if (x == 'b') { // about
new TGMsgBox(gClient->GetRoot(), 0, "About mupp", "created by Andreas Suter\nPSI/NUM/LMU/LEM\n2018", kMBIconAsterisk);
} else if (x == 'l') { // draw with lines
fWithLines = !fWithLines;
UpdateGraphs();
}
}
@ -182,7 +185,10 @@ void PMuppCanvas::HandleCmdKey(Int_t event, Int_t x, Int_t y, TObject *selected)
*/
void PMuppCanvas::HandleMenuPopup(Int_t id)
{
if (id == P_MENU_ID_EXPORT) {
if (id == P_MENU_ID_WITH_LINE) {
fWithLines = !fWithLines;
UpdateGraphs();
} else if (id == P_MENU_ID_EXPORT) {
ExportData();
} else if (id == P_MENU_ID_ABOUT) {
new TGMsgBox(gClient->GetRoot(), 0, "About mupp", "created by Andreas Suter\nPSI/NUM/LMU/LEM\n2017", kMBIconAsterisk);
@ -267,6 +273,7 @@ void PMuppCanvas::InitMuppCanvas(const Char_t *title, Int_t wtopx, Int_t wtopy,
fBar = fImp->GetMenuBar();
fPopupMain = fBar->AddPopup("&Mupp");
fPopupMain->AddEntry("Toggle with&Line", P_MENU_ID_WITH_LINE);
fPopupMain->AddEntry("Export &Data", P_MENU_ID_EXPORT);
fPopupMain->AddSeparator();
fPopupMain->AddEntry("A&bout", P_MENU_ID_ABOUT);
@ -599,10 +606,14 @@ void PMuppCanvas::UpdateGraphs()
}
for (UInt_t i=0; i<fGraphE.size(); i++) {
fMultiGraph->Add(fGraphE[i], "p");
fMultiGraph->Add(fGraphE[i]);
}
fMultiGraph->Draw("a");
if (fWithLines) {
fMultiGraph->Draw("ALP");
} else {
fMultiGraph->Draw("AP");
}
// set x-axis limits. This is needed that the graphs x-axis starts at 0.0
Double_t xmin=fMultiGraph->GetXaxis()->GetXmin();

View File

@ -46,8 +46,9 @@
#include "mupp.h"
// Canvas menu id's
#define P_MENU_ID_EXPORT 10001
#define P_MENU_ID_ABOUT 10002
#define P_MENU_ID_WITH_LINE 10001
#define P_MENU_ID_EXPORT 10002
#define P_MENU_ID_ABOUT 10003
//--------------------------------------------------------------------------
struct PDataPoint {
@ -113,6 +114,8 @@ private:
PDoubleVector fMarkerSizeList;
PIntVector fColorList;
bool fWithLines{false};
virtual void CreateStyle();
virtual void InitMuppCanvas(const Char_t* title, Int_t wtopx, Int_t wtopy, Int_t ww, Int_t wh);

View File

@ -169,6 +169,9 @@ void PMuppCanvas::HandleCmdKey(Int_t event, Int_t x, Int_t y, TObject *selected)
Done(0);
} else if (x == 'b') { // about
new TGMsgBox(gClient->GetRoot(), 0, "About mupp", "created by Andreas Suter\nPSI/NUM/LMU/LEM\n2018", kMBIconAsterisk);
} else if (x == 'l') { // draw with lines
fWithLines = !fWithLines;
UpdateGraphs();
}
}
@ -182,7 +185,10 @@ void PMuppCanvas::HandleCmdKey(Int_t event, Int_t x, Int_t y, TObject *selected)
*/
void PMuppCanvas::HandleMenuPopup(Int_t id)
{
if (id == P_MENU_ID_EXPORT) {
if (id == P_MENU_ID_WITH_LINE) {
fWithLines = !fWithLines;
UpdateGraphs();
} else if (id == P_MENU_ID_EXPORT) {
ExportData();
} else if (id == P_MENU_ID_ABOUT) {
new TGMsgBox(gClient->GetRoot(), 0, "About mupp", "created by Andreas Suter\nPSI/NUM/LMU/LEM\n2017", kMBIconAsterisk);
@ -267,6 +273,7 @@ void PMuppCanvas::InitMuppCanvas(const Char_t *title, Int_t wtopx, Int_t wtopy,
fBar = fImp->GetMenuBar();
fPopupMain = fBar->AddPopup("&Mupp");
fPopupMain->AddEntry("Toggle with&Line", P_MENU_ID_WITH_LINE);
fPopupMain->AddEntry("Export &Data", P_MENU_ID_EXPORT);
fPopupMain->AddSeparator();
fPopupMain->AddEntry("A&bout", P_MENU_ID_ABOUT);
@ -599,10 +606,14 @@ void PMuppCanvas::UpdateGraphs()
}
for (UInt_t i=0; i<fGraphE.size(); i++) {
fMultiGraph->Add(fGraphE[i], "p");
fMultiGraph->Add(fGraphE[i]);
}
fMultiGraph->Draw("a");
if (fWithLines) {
fMultiGraph->Draw("ALP");
} else {
fMultiGraph->Draw("AP");
}
// set x-axis limits. This is needed that the graphs x-axis starts at 0.0
Double_t xmin=fMultiGraph->GetXaxis()->GetXmin();

View File

@ -46,8 +46,9 @@
#include "mupp.h"
// Canvas menu id's
#define P_MENU_ID_EXPORT 10001
#define P_MENU_ID_ABOUT 10002
#define P_MENU_ID_WITH_LINE 10001
#define P_MENU_ID_EXPORT 10002
#define P_MENU_ID_ABOUT 10003
//--------------------------------------------------------------------------
struct PDataPoint {
@ -113,6 +114,8 @@ private:
PDoubleVector fMarkerSizeList;
PIntVector fColorList;
bool fWithLines{false};
virtual void CreateStyle();
virtual void InitMuppCanvas(const Char_t* title, Int_t wtopx, Int_t wtopy, Int_t ww, Int_t wh);

View File

@ -43,6 +43,7 @@ void syntax()
std::cout << " -x, --xml <fln>: path-name of the xml-startup file." << std::endl;
std::cout << " -d, --dump : dump rge-infos." << std::endl;
std::cout << " -s, --set <no> : dump rge-vector number <no>." << std::endl;
std::cout << " -c, --cum-freq <no> : dump vector of the cumulative frequency of rge set <no>." << std::endl;
std::cout << " -v, --version : rgeHandlerTest version" << std::endl;
std::cout << " -h, --help : this help." << std::endl;
std::cout << std::endl;
@ -58,6 +59,7 @@ int main(int argc, char* argv[])
std::string fln("");
bool dump(false);
int set_no = -1;
bool cumFreq(false);
for (int i=1; i<argc; i++) {
if (!strcmp(argv[i], "-x") || !strcmp(argv[i], "--xml")) {
if (i+1 >= argc) {
@ -72,7 +74,7 @@ int main(int argc, char* argv[])
} else if (!strcmp(argv[i], "-d") || !strcmp(argv[i], "--dump")) {
dump = true;
} else if (!strcmp(argv[i], "-s") || !strcmp(argv[i], "--set")) {
if (i+1 > argc) {
if (i+1 >= argc) {
std::cout << std::endl;
std::cout << "**ERROR** found -s/--set without rge set number." << std::endl;
std::cout << std::endl;
@ -98,6 +100,34 @@ int main(int argc, char* argv[])
return 3;
}
i++;
} else if (!strcmp(argv[i], "-c") || !strcmp(argv[i], "--cum-freq")) {
if (i+1 >= argc) {
std::cout << std::endl;
std::cout << "**ERROR** found -c/--cum-freq without rge set number." << std::endl;
std::cout << std::endl;
syntax();
return 1;
}
try {
set_no = std::stoi(argv[i+1]);
} catch(std::invalid_argument& e) {
std::cout << std::endl;
std::cout << "**ERROR** set number '" << argv[i+1] << "' is not a number." << std::endl;
std::cout << std::endl;
return 3;
} catch(std::out_of_range& e) {
std::cout << std::endl;
std::cout << "**ERROR** set number '" << argv[i+1] << "' is out-of-range." << std::endl;
std::cout << std::endl;
return 3;
} catch(...) {
std::cout << std::endl;
std::cout << "**ERROR** set number '" << argv[i+1] << "' leads to an unexpected error." << std::endl;
std::cout << std::endl;
return 3;
}
cumFreq=true;
i++;
} else if (!strcmp(argv[i], "-v") || !strcmp(argv[i], "--version")) {
std::cout << std::endl;
#ifdef HAVE_CONFIG_H
@ -135,7 +165,7 @@ int main(int argc, char* argv[])
}
std::cout << std::endl;
}
if (set_no != -1) {
if ((set_no != -1) && !cumFreq) { // dump rge-set
PRgeDataList list = rgeHandler->GetRgeData();
if (set_no > list.size()) {
std::cout << std::endl;
@ -150,12 +180,35 @@ int main(int argc, char* argv[])
delete rgeHandler;
return 4;
}
std::cout << "rge-data set " << set_no << ": energy: " << list[set_no-1].energy << " (eV), no-of-particles: " << list[set_no-1].noOfParticles << std::endl;
std::cout << "depth (nm), ampl, amplNorm" << std::endl;
std::cout << "# rge-data set " << set_no << ": energy: " << list[set_no-1].energy << " (eV), no-of-particles: " << list[set_no-1].noOfParticles << std::endl;
std::cout << "# depth (nm), ampl, amplNorm" << std::endl;
for (int i=0; i<list[set_no-1].depth.size(); i++) {
std::cout << list[set_no-1].depth[i] << ", " << list[set_no-1].amplitude[i] << ", " << list[set_no-1].nn[i] << std::endl;
}
}
if ((set_no != -1) && cumFreq) { // dump cumulative frequency of rge-set
PRgeDataList list = rgeHandler->GetRgeData();
if (set_no > list.size()) {
std::cout << std::endl;
std::cout << "**ERROR** requested set number " << set_no << " > number of rge-data sets (" << list.size() << ")." << std::endl;
std::cout << std::endl;
delete rgeHandler;
return 4;
} else if (set_no == 0) {
std::cout << std::endl;
std::cout << "**ERROR** rge set-number count start at 1 not 0." << std::endl;
std::cout << std::endl;
delete rgeHandler;
return 4;
}
std::cout << "# cumulative frequency of rge-data set " << set_no << ": energy: " << list[set_no-1].energy << " (eV), no-of-particles: " << list[set_no-1].noOfParticles << std::endl;
std::cout << "# depth (nm), ampl, amplNorm, cumFreq" << std::endl;
double cumFreqVal(0.0);
for (int i=0; i<list[set_no-1].depth.size(); i++) {
cumFreqVal += list[set_no-1].nn[i];
std::cout << list[set_no-1].depth[i] << ", " << list[set_no-1].amplitude[i] << ", " << list[set_no-1].nn[i] << ", " << cumFreqVal << std::endl;
}
}
if (rgeHandler) {
delete rgeHandler;