Merged muonspin/musrfit:root6 into master

This commit is contained in:
Zaher Salman 2020-04-07 11:03:10 +02:00
commit 479e81cc68
14 changed files with 533 additions and 396 deletions

View File

@ -48,6 +48,7 @@ set(SOURCE_FILES
Pmupp.cpp Pmupp.cpp
PmuppScript.cpp PmuppScript.cpp
PmuppGui.cpp PmuppGui.cpp
PGetNormValDialog.cpp
) )
if (APPLE) if (APPLE)

View File

@ -0,0 +1,75 @@
/***************************************************************************
PGetNormValDialog.cpp
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2020 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 <QVBoxLayout>
#include <QHBoxLayout>
#include <QLabel>
#include <QLineEdit>
#include <QDoubleValidator>
#include <QPushButton>
#include "PGetNormValDialog.h"
//------------------------------------------------------------------------------
PGetNormValDialog::PGetNormValDialog(double dval, QWidget *parent, Qt::WindowFlags f) :
QDialog(parent, f), fValue(dval)
{
QVBoxLayout *vbox = new QVBoxLayout;
QHBoxLayout *hbox1 = new QHBoxLayout;
QHBoxLayout *hbox2 = new QHBoxLayout;
vbox->addLayout(hbox1);
vbox->addLayout(hbox2);
QLabel *lab = new QLabel("Norm Value: ");
QLineEdit *fEdit = new QLineEdit();
fEdit->setValidator(new QDoubleValidator());
fEdit->setText(QString("%1").arg(fValue));
hbox1->addWidget(lab);
hbox1->addWidget(fEdit);
QPushButton *ok = new QPushButton("OK");
QPushButton *cancel = new QPushButton("Cancel");
hbox2->addWidget(ok);
hbox2->addWidget(cancel);
setModal(true);
setLayout(vbox);
connect( fEdit, SIGNAL(textChanged(const QString&)), this, SLOT(gotValue(const QString&)));
connect( ok, SIGNAL(clicked()), this, SLOT(accept()));
connect( cancel, SIGNAL(clicked()), this, SLOT(reject()));
}
//------------------------------------------------------------------------------
void PGetNormValDialog::gotValue(const QString& str)
{
fValue = str.toDouble();
}

View File

@ -0,0 +1,54 @@
/***************************************************************************
PGetNormValDialog.h
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2020 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 _PGETNORMVALDIALOG_H_
#define _PGETNORMVALDIALOG_H_
#include <QDialog>
#include <QLineEdit>
class PGetNormValDialog : public QDialog
{
Q_OBJECT
public:
PGetNormValDialog(double dval, QWidget *parent = 0, Qt::WindowFlags f = 0);
virtual ~PGetNormValDialog() {}
virtual double getValue() { return fValue; }
private:
double fValue;
QLineEdit *fEdit;
private slots:
virtual void gotValue(const QString& str);
};
#endif // _PGETNORMVALDIALOG_H_

View File

@ -60,6 +60,7 @@ using namespace std;
#include "mupp_version.h" #include "mupp_version.h"
#include "PmuppGui.h" #include "PmuppGui.h"
#include "PGetNormValDialog.h"
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
/** /**
@ -207,7 +208,11 @@ PmuppGui::PmuppGui( QStringList fln, QWidget *parent, Qt::WindowFlags f )
fDatime = dt.toTime_t(); fDatime = dt.toTime_t();
fMuppInstance = -1; fMuppInstance = -1;
fMuppPlot = 0; fMuppPlot = nullptr;
fNormalizeAction = nullptr;
fNormalize = false;
fNormVal = 0.0;
fMacroPath = QString("./"); fMacroPath = QString("./");
fMacroName = QString(""); fMacroName = QString("");
@ -526,6 +531,19 @@ void PmuppGui::setupToolActions()
a->setStatusTip( tr("Dump XY parameter list") ); a->setStatusTip( tr("Dump XY parameter list") );
connect( a, SIGNAL( triggered() ), this, SLOT( toolDumpXY() ) ); connect( a, SIGNAL( triggered() ), this, SLOT( toolDumpXY() ) );
menu->addAction(a); menu->addAction(a);
menu->addSeparator();
fNormalizeAction = new QAction(tr( "Normalize" ), this);
fNormalizeAction->setStatusTip( tr("Plot Data Normalized (y-axis)") );
fNormalizeAction->setCheckable(true);
connect( fNormalizeAction, SIGNAL( changed() ), this, SLOT( normalize() ) );
menu->addAction(fNormalizeAction);
a = new QAction(tr( "Normalize by Value" ), this);
a->setStatusTip( tr("Normalize by Value") );
connect( a, SIGNAL( triggered() ), this, SLOT( normVal() ) );
menu->addAction(a);
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
@ -666,6 +684,33 @@ void PmuppGui::toolDumpXY()
} }
} }
//----------------------------------------------------------------------------------------------------
void PmuppGui::normalize()
{
fNormalize = fNormalizeAction->isChecked();
}
//----------------------------------------------------------------------------------------------------
void PmuppGui::normVal()
{
PGetNormValDialog *dlg = new PGetNormValDialog(fNormVal);
if (dlg == nullptr) {
QMessageBox::critical(this, "**ERROR**", "Couldn't invoke dialog, sorry :-(", QMessageBox::Ok, QMessageBox::NoButton);
return;
}
dlg->exec();
if (dlg->result() != QDialog::Accepted) {
delete dlg;
return;
}
fNormVal = dlg->getValue();
delete dlg;
}
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
/** /**
* @brief PmuppGui::helpCmds * @brief PmuppGui::helpCmds
@ -1657,6 +1702,27 @@ void PmuppGui::plot()
yLabel = substituteDefaultLabels(yLabel); yLabel = substituteDefaultLabels(yLabel);
fout << "yLabel: " << yLabel << endl; fout << "yLabel: " << yLabel << endl;
// normalize if wished
if (fNormalize) {
double max=0.0;
for (int k=0; k<yyy.size(); k++) {
max=0.0;
if (fNormVal == 0.0) {
for (int j=0; j<xx.size(); j++) {
if (yyy[k][j] > max)
max = yyy[k][j];
}
} else {
max = fNormVal;
}
for (int j=0; j<xx.size(); j++) {
yyy[k][j] /= max;
yyyPosErr[k][j] /= max;
yyyNegErr[k][j] /= max;
}
}
}
// data // data
for (int j=0; j<xx.size(); j++) { for (int j=0; j<xx.size(); j++) {
fout << xx[j] << ", "; fout << xx[j] << ", ";
@ -2012,22 +2078,62 @@ void PmuppGui::getMinMax(QVector<double> &data, double &min, double &max)
*/ */
QString PmuppGui::substituteDefaultLabels(QString label) QString PmuppGui::substituteDefaultLabels(QString label)
{ {
if (label == "dataT") QString result(label);
return QString("T (K)");
else if (label == "dataB") if (label == "dataT") {
return QString("B (G)"); result = QString("T (K)");
else if (label == "dataE") } else if (label == "dataB") {
return QString("E (keV)"); result = QString("B (G)");
else if (!label.compare("sigma", Qt::CaseInsensitive)) } else if (label == "dataE") {
return QString("#sigma (1/#mus)"); result =QString("E (keV)");
else if (!label.compare("lambda", Qt::CaseInsensitive)) } else if (!label.compare("sigma", Qt::CaseInsensitive)) {
return QString("#lambda (1/#mus)"); if (fNormalize) {
else if (!label.compare("alpha_LR", Qt::CaseInsensitive)) if (fNormVal == 0.0)
return QString("#alpha_{LR}"); result = QString("#sigma/max(#sigma)");
else if (!label.compare("alpha_TB", Qt::CaseInsensitive)) else
return QString("#alpha_{TB}"); result = QString("#sigma/%1 (1/#mus)").arg(fNormVal);
else } else {
return label; result = QString("#sigma (1/#mus)");
}
} else if (!label.compare("lambda", Qt::CaseInsensitive)) {
if (fNormalize) {
if (fNormVal == 0.0)
result = QString("#lambda/max(#lambda)");
else
result = QString("#lambda/%1 (1/#mus)").arg(fNormVal);
} else {
result = QString("#lambda (1/#mus)");
}
} else if (!label.compare("alpha_LR", Qt::CaseInsensitive)) {
if (fNormalize) {
if (fNormVal == 0.0)
result = QString("#alpha_{LR}/max(#alpha_{LR})");
else
result = QString("#alpha_{LR}/%1").arg(fNormVal);
} else {
result = QString("#alpha_{LR}");
}
} else if (!label.compare("alpha_TB", Qt::CaseInsensitive)) {
if (fNormalize) {
if (fNormVal == 0.0)
result = QString("#alpha_{TB}/max(#alpha_{TB})");
else
result = QString("#alpha_{TB}/%1").arg(fNormVal);
} else {
result = QString("#alpha_{TB}");
}
} else {
if (fNormalize) {
if (fNormVal == 0.0) {
result = QString("Normalized ");
result += label;
} else {
result = QString("%1/%2").arg(label).arg(fNormVal);
}
}
}
return result;
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------

View File

@ -8,7 +8,7 @@
***************************************************************************/ ***************************************************************************/
/*************************************************************************** /***************************************************************************
* Copyright (C) 2007-2017 by Andreas Suter * * Copyright (C) 2007-2020 by Andreas Suter *
* andreas.suter@psi.ch * * andreas.suter@psi.ch *
* * * *
* This program is free software; you can redistribute it and/or modify * * This program is free software; you can redistribute it and/or modify *
@ -114,6 +114,8 @@ public slots:
void toolDumpCollections(); void toolDumpCollections();
void toolDumpXY(); void toolDumpXY();
void normalize();
void normVal();
void helpCmds(); void helpCmds();
void helpAbout(); void helpAbout();
@ -128,6 +130,8 @@ private:
PmuppAdmin *fAdmin; PmuppAdmin *fAdmin;
bool fDarkTheme; bool fDarkTheme;
bool fDarkToolBarIcon; bool fDarkToolBarIcon;
bool fNormalize;
double fNormVal;
uint fDatime; uint fDatime;
uint fMuppInstance; uint fMuppInstance;
@ -142,6 +146,7 @@ private:
QMenu *fRecentFilesMenu; ///< recent file menu QMenu *fRecentFilesMenu; ///< recent file menu
QAction *fRecentFilesAction[MAX_RECENT_FILES]; ///< array of the recent file actions QAction *fRecentFilesAction[MAX_RECENT_FILES]; ///< array of the recent file actions
QAction *fNormalizeAction;
QBoxLayout *fBoxLayout_Main; // top->bottom (0) QBoxLayout *fBoxLayout_Main; // top->bottom (0)
QBoxLayout *fBoxLayout_Top; // left->right (1) QBoxLayout *fBoxLayout_Top; // left->right (1)

View File

@ -0,0 +1,93 @@
# - musrfit
cmake_minimum_required(VERSION 3.9)
if (CMAKE_VERSION GREATER_EQUAL 3.12)
cmake_policy(SET CMP0075 NEW)
endif (CMAKE_VERSION GREATER_EQUAL 3.12)
project(eventHandler VERSION 1.0.0 LANGUAGES C CXX)
#--- set a default build type if none was specified ---------------------------
set(default_build_type "Release")
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
#--- perform some checks and generate the config.h ----------------------------
#--- the next two lines are needed that the math functions are found ----------
set(CMAKE_REQUIRED_INCLUDES math.h)
set(CMAKE_REQUIRED_LIBRARIES m)
include(CheckTypeSize)
include(CheckIncludeFiles)
include(CheckFunctionExists)
check_include_files(alloca.h HAVE_ALLOCA_H)
check_include_files("sys/ipc.h;sys/shm.h" HAVE_SHMGET)
check_include_files(dlfcn.h HAVE_DLFCN_H)
check_function_exists(erf HAVE_ERF)
check_function_exists(getloadavg HAVE_GETLOADAVG)
check_include_files(inttypes.h HAVE_INTTYPES_H)
check_include_files(memory.h HAVE_MEMORY_H)
check_function_exists(powl HAVE_POWL)
check_include_files(memory.h HAVE_MEMORY_H)
check_include_files(stdint.h HAVE_STDINT_H)
check_include_files(stdlib.h HAVE_STDLIB_H)
check_include_files(string.h HAVE_STRING_H)
check_include_files(strings.h HAVE_STRINGS_H)
check_include_files(sys/stat.h HAVE_SYS_STAT_H)
check_include_files(sys/types.h HAVE_SYS_TYPES_H)
check_include_files(sys/unistd.h HAVE_UNISTD_H)
check_type_size("long double" LONG_DOUBLE)
check_type_size("double" DOUBLE)
if (${LONG_DOUBLE} GREATER ${DOUBLE})
set(HAVE_LONG_DOUBLE 1)
set(HAVE_LONG_DOUBLE_WIDER 1)
endif (${LONG_DOUBLE} GREATER ${DOUBLE})
#--- check for all the needed packages ----------------------------------------
#--- check for git ------------------------------------------------------------
find_package(Git REQUIRED)
#--- check for ROOT -----------------------------------------------------------
find_package(ROOT 6.18 REQUIRED COMPONENTS Gui MathMore Minuit2 XMLParser)
if (ROOT_mathmore_FOUND)
execute_process(COMMAND root-config --bindir OUTPUT_VARIABLE ROOT_BINDIR)
string(STRIP ${ROOT_BINDIR} ROOT_BINDIR)
execute_process(COMMAND root-config --version OUTPUT_VARIABLE ROOT_VERSION)
string(STRIP ${ROOT_VERSION} ROOT_VERSION)
message("-- Found ROOT: ${ROOT_BINDIR} (found version: ${ROOT_VERSION})")
#---Define useful ROOT functions and macros (e.g. ROOT_GENERATE_DICTIONARY)
include(${ROOT_USE_FILE})
endif (ROOT_mathmore_FOUND)
#--- generate necessary dictionaries ------------------------------------------
root_generate_dictionary(
PEventHandlerTestDict
PEventHandlerTest.h
OPTIONS
-inlineInputHeader
LINKDEF PEventHandlerTestLinkDef.h
MODULE PEventHandlerTest
)
#--- add all executables ------------------------------------------------------
add_executable(eventHandler
PEventHandlerTest.cpp
PEventHandlerTestDict.cxx
eventHandlerTest.cpp
)
target_include_directories(eventHandler
BEFORE PRIVATE
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}>
)
target_link_libraries(eventHandler ${ROOT_LIBRARIES})
#--- end ----------------------------------------------------------------------

View File

@ -1,92 +0,0 @@
#---------------------------------------------------
# Makefile
#
# Author: Andreas Suter
# e-mail: andreas.suter@psi.ch
#
# $Id$
#
#---------------------------------------------------
#---------------------------------------------------
# get compilation and library flags from root-config
ROOTCFLAGS = $(shell $(ROOTSYS)/bin/root-config --cflags)
ROOTLIBS = $(shell $(ROOTSYS)/bin/root-config --libs)
ROOTGLIBS = $(shell $(ROOTSYS)/bin/root-config --glibs)
#---------------------------------------------------
# depending on the architecture, choose the compiler,
# linker, and the flags to use
#
OSTYPE = $(shell uname)
ifeq ($(OSTYPE),Linux)
OS = LINUX
endif
ifeq ($(OSTYPE),Linux-gnu)
OS = LINUX
endif
ifeq ($(OSTYPE),Darwin)
OS = DARWIN
endif
# -- Linux
ifeq ($(OS),LINUX)
CXX = g++
CXXFLAGS = -g -Wall -Wno-trigraphs -fPIC
INCLUDES = -I./
LD = g++
LDFLAGS = -g
SOFLAGS = -O -shared
endif
# -- Darwin
ifeq ($(OS),DARWIN)
CXX = g++
CXXFLAGS = -g -Wall -Wno-trigraphs -fPIC
INCLUDES = -I../include
LD = g++
LDFLAGS = -g
SOFLAGS = -dynamic
endif
# the output from the root-config script:
CXXFLAGS += $(ROOTCFLAGS)
LDFLAGS +=
# the ROOT libraries (G = graphic)
LIBS = $(ROOTLIBS) -lXMLParser
GLIBS = $(ROOTGLIBS) -lXMLParser
EXEC = eventHandlerTest
# some definitions: headers (used to generate *Dict* stuff), sources, objects,...
OBJS =
OBJS += $(EXEC).o
OBJS += PEventHandlerTest.o PEventHandlerTestDict.o
# make the executable:
#
all: $(EXEC)
$(EXEC): $(OBJS)
@echo "---> Building $(EXEC) ..."
$(LD) $(OBJS) -o $(EXEC) $(GLIBS)
@echo "done"
# clean up: remove all object file (and core files)
# semicolon needed to tell make there is no source
# for this target!
#
clean:; @rm -f $(OBJS) *Dict* core*
@echo "---> removing $(OBJS)"
#
$(OBJS): %.o: %.cpp
$(CXX) $(INCLUDES) $(CXXFLAGS) -c $<
PEventHandlerTestDict.cpp: ./PEventHandlerTest.h ./PEventHandlerTestLinkDef.h
@echo "Generating dictionary $@..."
rootcint -v -f $@ -c -p $^

View File

@ -1,65 +0,0 @@
INFO
System: Fedora 13
Compiler: gcc/g++ (GCC) 4.4.4 20100630
ROOT: ROOT 5.27/07 trunk@36421
===========================================================
*** Break *** segmentation violation
===========================================================
There was a crash (#7 0x00e7fb6d in SigHandler(ESignals) () from /opt/cern/root/lib/libCore.so).
This is the entire stack trace of all threads:
===========================================================
#0 0x00ca7416 in __kernel_vsyscall ()
#1 0x014ae463 in __waitpid_nocancel () from /lib/libc.so.6
#2 0x0144a753 in do_system () from /lib/libc.so.6
#3 0x0140475d in system () from /lib/libpthread.so.0
#4 0x00e7891d in TUnixSystem::Exec(char const*) () from /opt/cern/root/lib/libCore.so
#5 0x00e7e750 in TUnixSystem::StackTrace() () from /opt/cern/root/lib/libCore.so
#6 0x00e7fa5f in TUnixSystem::DispatchSignals(ESignals) () from /opt/cern/root/lib/libCore.so
#7 0x00e7fb6d in SigHandler(ESignals) () from /opt/cern/root/lib/libCore.so
#8 0x00e754e2 in sighandler(int) () from /opt/cern/root/lib/libCore.so
#9 <signal handler called>
#10 0x0159a49b in main_arena () from /lib/libc.so.6
#11 0x0a5a04c0 in ?? ()
#12 0x00be6bd3 in TCanvas::HandleInput(EEventType, int, int) () from /opt/cern/root/lib/libGpad.so
#13 0x0205dea3 in TRootCanvas::HandleContainerMotion(Event_t*) () from /opt/cern/root/lib/libGui.so
#14 0x020648ea in TRootContainer::HandleMotion(Event_t*) () from /opt/cern/root/lib/libGui.so
#15 0x01f9bd38 in TGFrame::HandleEvent(Event_t*) () from /opt/cern/root/lib/libGui.so
#16 0x01f69c0b in TGClient::HandleEvent(Event_t*) () from /opt/cern/root/lib/libGui.so
#17 0x01f6a934 in TGClient::ProcessOneEvent() () from /opt/cern/root/lib/libGui.so
#18 0x01f6a99d in TGClient::HandleInput() () from /opt/cern/root/lib/libGui.so
#19 0x01f6a9d0 in TGInputHandler::Notify() () from /opt/cern/root/lib/libGui.so
#20 0x00e7c6bd in TUnixSystem::DispatchOneEvent(bool) () from /opt/cern/root/lib/libCore.so
#21 0x00dfd271 in TSystem::InnerLoop() () from /opt/cern/root/lib/libCore.so
#22 0x00dff569 in TSystem::Run() () from /opt/cern/root/lib/libCore.so
#23 0x00da48f7 in TApplication::Run(bool) () from /opt/cern/root/lib/libCore.so
#24 0x08051d0f in main (argc=1, argv=0xbff04da4) at eventHandlerTest.cpp:52
===========================================================
The lines below might hint at the cause of the crash.
If they do not help you then please submit a bug report at
http://root.cern.ch/bugs. Please post the ENTIRE stack trace
from above as an attachment in addition to anything else
that might help us fixing this issue.
===========================================================
#10 0x0159a49b in main_arena () from /lib/libc.so.6
#11 0x0a5a04c0 in ?? ()
#12 0x00be6bd3 in TCanvas::HandleInput(EEventType, int, int) () from /opt/cern/root/lib/libGpad.so
#13 0x0205dea3 in TRootCanvas::HandleContainerMotion(Event_t*) () from /opt/cern/root/lib/libGui.so
#14 0x020648ea in TRootContainer::HandleMotion(Event_t*) () from /opt/cern/root/lib/libGui.so
#15 0x01f9bd38 in TGFrame::HandleEvent(Event_t*) () from /opt/cern/root/lib/libGui.so
#16 0x01f69c0b in TGClient::HandleEvent(Event_t*) () from /opt/cern/root/lib/libGui.so
#17 0x01f6a934 in TGClient::ProcessOneEvent() () from /opt/cern/root/lib/libGui.so
#18 0x01f6a99d in TGClient::HandleInput() () from /opt/cern/root/lib/libGui.so
#19 0x01f6a9d0 in TGInputHandler::Notify() () from /opt/cern/root/lib/libGui.so
#20 0x00e7c6bd in TUnixSystem::DispatchOneEvent(bool) () from /opt/cern/root/lib/libCore.so
#21 0x00dfd271 in TSystem::InnerLoop() () from /opt/cern/root/lib/libCore.so
#22 0x00dff569 in TSystem::Run() () from /opt/cern/root/lib/libCore.so
#23 0x00da48f7 in TApplication::Run(bool) () from /opt/cern/root/lib/libCore.so
#24 0x08051d0f in main (argc=1, argv=0xbff04da4) at eventHandlerTest.cpp:52
===========================================================

View File

@ -1,68 +0,0 @@
INFO:
System: MacOS X 10.6.4
Compiler: gcc/g++ 4.2.1 (build 5664)
ROOT: 5.27/06 (trunk@35856)
==========================================================
*** Break *** segmentation violation
===========================================================
There was a crash.
This is the entire stack trace of all threads:
===========================================================
Thread 2 (process 218):
#0 0x00007fff8407208a in kevent ()
#1 0x00007fff84073f5d in _dispatch_mgr_invoke ()
#2 0x00007fff84073c34 in _dispatch_queue_invoke ()
#3 0x00007fff8407375e in _dispatch_worker_thread2 ()
#4 0x00007fff84073088 in _pthread_wqthread ()
#5 0x00007fff84072f25 in start_wqthread ()
Thread 1 (process 218):
#0 0x00007fff840d6c90 in wait4 ()
#1 0x00007fff840eb23e in system ()
#2 0x0000000100128ab5 in TUnixSystem::StackTrace ()
#3 0x0000000100126431 in TUnixSystem::DispatchSignals ()
#4 <signal handler called>
#5 0x0000000101a576c6 in TCanvas::EnterLeave ()
#6 0x0000000101a5b1a2 in TCanvas::HandleInput ()
#7 0x00000001024e955b in TRootCanvas::HandleContainerMotion ()
#8 0x00000001024ef6e0 in TRootContainer::HandleMotion ()
#9 0x0000000102443390 in TGFrame::HandleEvent ()
#10 0x0000000102413570 in TGClient::HandleEvent ()
#11 0x0000000102413e6b in TGClient::ProcessOneEvent ()
#12 0x0000000102413ede in TGClient::HandleInput ()
#13 0x0000000102413efd in TGInputHandler::Notify ()
#14 0x000000010012655c in TUnixSystem::DispatchOneEvent ()
#15 0x00000001000bef6d in TSystem::InnerLoop ()
#16 0x00000001000c1213 in TSystem::Run ()
#17 0x0000000100080867 in TApplication::Run ()
#18 0x0000000100001aaf in main ()
===========================================================
The lines below might hint at the cause of the crash.
If they do not help you then please submit a bug report at
http://root.cern.ch/bugs. Please post the ENTIRE stack trace
from above as an attachment in addition to anything else
that might help us fixing this issue.
===========================================================
#5 0x0000000101a576c6 in TCanvas::EnterLeave ()
#6 0x0000000101a5b1a2 in TCanvas::HandleInput ()
#7 0x00000001024e955b in TRootCanvas::HandleContainerMotion ()
#8 0x00000001024ef6e0 in TRootContainer::HandleMotion ()
#9 0x0000000102443390 in TGFrame::HandleEvent ()
#10 0x0000000102413570 in TGClient::HandleEvent ()
#11 0x0000000102413e6b in TGClient::ProcessOneEvent ()
#12 0x0000000102413ede in TGClient::HandleInput ()
#13 0x0000000102413efd in TGInputHandler::Notify ()
#14 0x000000010012655c in TUnixSystem::DispatchOneEvent ()
#15 0x00000001000bef6d in TSystem::InnerLoop ()
#16 0x00000001000c1213 in TSystem::Run ()
#17 0x0000000100080867 in TApplication::Run ()
#18 0x0000000100001aaf in main ()
===========================================================

View File

@ -1,76 +0,0 @@
INFO
System: Scientific Linux 5.1
Compiler: gcc/g++ (GCC) 4.1.2 20080704
ROOT: ROOT 5.27/07 trunk@36261
===========================================================
*** Break *** segmentation violation
===========================================================
There was a crash (#7 0x00d6569d in SigHandler () from /apps/cern/root/lib/libCore.so).
This is the entire stack trace of all threads:
===========================================================
#0 0x004b4410 in __kernel_vsyscall ()
#1 0x03f8c353 in __waitpid_nocancel () from /lib/libc.so.6
#2 0x03f33bbf in do_system () from /lib/libc.so.6
#3 0x062031ad in system () from /lib/libpthread.so.0
#4 0x00d60e1d in TUnixSystem::Exec () from /apps/cern/root/lib/libCore.so
#5 0x00d6805d in TUnixSystem::StackTrace ()
from /apps/cern/root/lib/libCore.so
#6 0x00d655ce in TUnixSystem::DispatchSignals ()
from /apps/cern/root/lib/libCore.so
#7 0x00d6569d in SigHandler () from /apps/cern/root/lib/libCore.so
#8 0x00d5e6c4 in sighandler () from /apps/cern/root/lib/libCore.so
#9 <signal handler called>
#10 0x08914070 in ?? ()
#11 0x003ed6fb in TCanvas::EnterLeave () from /apps/cern/root/lib/libGpad.so
#12 0x003f1ed7 in TCanvas::HandleInput () from /apps/cern/root/lib/libGpad.so
#13 0x01522c04 in TRootCanvas::HandleContainerMotion ()
from /apps/cern/root/lib/libGui.so
#14 0x0152a0aa in TRootContainer::HandleMotion ()
from /apps/cern/root/lib/libGui.so
#15 0x014525be in TGFrame::HandleEvent () from /apps/cern/root/lib/libGui.so
#16 0x0141633d in TGClient::HandleEvent () from /apps/cern/root/lib/libGui.so
#17 0x0141668e in TGClient::ProcessOneEvent ()
from /apps/cern/root/lib/libGui.so
#18 0x014166fd in TGClient::HandleInput () from /apps/cern/root/lib/libGui.so
#19 0x01416730 in TGInputHandler::Notify () from /apps/cern/root/lib/libGui.so
#20 0x00d64edd in TUnixSystem::DispatchOneEvent ()
from /apps/cern/root/lib/libCore.so
#21 0x00cd56b1 in TSystem::InnerLoop () from /apps/cern/root/lib/libCore.so
#22 0x00cd9381 in TSystem::Run () from /apps/cern/root/lib/libCore.so
#23 0x00c73308 in TApplication::Run () from /apps/cern/root/lib/libCore.so
#24 0x08051de9 in main (argc=0, argv=0x1c35) at eventHandlerTest.cpp:52
===========================================================
The lines below might hint at the cause of the crash.
If they do not help you then please submit a bug report at
http://root.cern.ch/bugs. Please post the ENTIRE stack trace
from above as an attachment in addition to anything else
that might help us fixing this issue.
===========================================================
#10 0x08914070 in ?? ()
#11 0x003ed6fb in TCanvas::EnterLeave () from /apps/cern/root/lib/libGpad.so
#12 0x003f1ed7 in TCanvas::HandleInput () from /apps/cern/root/lib/libGpad.so
#13 0x01522c04 in TRootCanvas::HandleContainerMotion ()
from /apps/cern/root/lib/libGui.so
#14 0x0152a0aa in TRootContainer::HandleMotion ()
from /apps/cern/root/lib/libGui.so
#15 0x014525be in TGFrame::HandleEvent () from /apps/cern/root/lib/libGui.so
#16 0x0141633d in TGClient::HandleEvent () from /apps/cern/root/lib/libGui.so
#17 0x0141668e in TGClient::ProcessOneEvent ()
from /apps/cern/root/lib/libGui.so
#18 0x014166fd in TGClient::HandleInput () from /apps/cern/root/lib/libGui.so
#19 0x01416730 in TGInputHandler::Notify () from /apps/cern/root/lib/libGui.so
#20 0x00d64edd in TUnixSystem::DispatchOneEvent ()
from /apps/cern/root/lib/libCore.so
#21 0x00cd56b1 in TSystem::InnerLoop () from /apps/cern/root/lib/libCore.so
#22 0x00cd9381 in TSystem::Run () from /apps/cern/root/lib/libCore.so
#23 0x00c73308 in TApplication::Run () from /apps/cern/root/lib/libCore.so
#24 0x08051de9 in main (argc=0, argv=0x1c35) at eventHandlerTest.cpp:52
===========================================================

View File

@ -1,75 +0,0 @@
==30642== Memcheck, a memory error detector.
==30642== Copyright (C) 2002-2006, and GNU GPL'd, by Julian Seward et al.
==30642== Using LibVEX rev 1658, a library for dynamic binary translation.
==30642== Copyright (C) 2004-2006, and GNU GPL'd, by OpenWorks LLP.
==30642== Using valgrind-3.2.1, a dynamic binary instrumentation framework.
==30642== Copyright (C) 2000-2006, and GNU GPL'd, by Julian Seward et al.
==30642== For more details, rerun with: -v
==30642==
==30642== My PID = 30642, parent PID = 19037. Prog and args are:
==30642== ./eventHandlerTest
==30642==
==30642== Syscall param writev(vector[...]) points to uninitialised byte(s)
==30642== at 0xC188B8: writev (in /lib/libc-2.5.so)
==30642== by 0xD30A2D: (within /usr/lib/libX11.so.6.2.0)
==30642== by 0xD3081E: _X11TransWritev (in /usr/lib/libX11.so.6.2.0)
==30642== by 0xD36508: _XSend (in /usr/lib/libX11.so.6.2.0)
==30642== by 0xD2742A: XQueryExtension (in /usr/lib/libX11.so.6.2.0)
==30642== by 0xD1BD4A: XInitExtension (in /usr/lib/libX11.so.6.2.0)
==30642== by 0x238C3F: XFixesFindDisplay (in /usr/lib/libXfixes.so.3.1.0)
==30642== by 0x23769E: XFixesSetCursorName (in /usr/lib/libXfixes.so.3.1.0)
==30642== by 0x22D8E6: XcursorImagesLoadCursor (in /usr/lib/libXcursor.so.1.0.2)
==30642== by 0x230F79: XcursorTryShapeCursor (in /usr/lib/libXcursor.so.1.0.2)
==30642== by 0xD0FCE1: XCreateGlyphCursor (in /usr/lib/libX11.so.6.2.0)
==30642== by 0xD1016C: XCreateFontCursor (in /usr/lib/libX11.so.6.2.0)
==30642== Address 0x7674690 is 256 bytes inside a block of size 16,384 alloc'd
==30642== at 0x40046FF: calloc (vg_replace_malloc.c:279)
==30642== by 0xD214A6: XOpenDisplay (in /usr/lib/libX11.so.6.2.0)
==30642== by 0x76A52DD: TGX11::OpenDisplay(char const*) (in /apps/cern/root-5.27.04/lib/libGX11.so)
==30642== by 0x608CED8: TGClient::TGClient(char const*) (in /apps/cern/root-5.27.04/lib/libGui.so)
==30642== by 0x6186B83: TRootApplication::TRootApplication(char const*, int*, char**) (in /apps/cern/root-5.27.04/lib/libGui.so)
==30642== by 0x61A9094: TRootGuiFactory::CreateApplicationImp(char const*, int*, char**) (in /apps/cern/root-5.27.04/lib/libGui.so)
==30642== by 0x4151C8E: TApplication::InitializeGraphics() (in /apps/cern/root-5.27.04/lib/libCore.so)
==30642== by 0x4154065: TApplication::TApplication(char const*, int*, char**, void*, int) (in /apps/cern/root-5.27.04/lib/libCore.so)
==30642== by 0x8051D74: main (eventHandlerTest.cpp:41)
==30642==
==30642== Invalid read of size 4
==30642== at 0x57356DD: TCanvas::EnterLeave(TPad*, TObject*) (in /apps/cern/root-5.27.04/lib/libGpad.so)
==30642== by 0x5739ED6: TCanvas::HandleInput(EEventType, int, int) (in /apps/cern/root-5.27.04/lib/libGpad.so)
==30642== by 0x6199C03: TRootCanvas::HandleContainerMotion(Event_t*) (in /apps/cern/root-5.27.04/lib/libGui.so)
==30642== by 0x61A10A9: TRootContainer::HandleMotion(Event_t*) (in /apps/cern/root-5.27.04/lib/libGui.so)
==30642== by 0x60C95BD: TGFrame::HandleEvent(Event_t*) (in /apps/cern/root-5.27.04/lib/libGui.so)
==30642== by 0x608D33C: TGClient::HandleEvent(Event_t*) (in /apps/cern/root-5.27.04/lib/libGui.so)
==30642== by 0x608D68D: TGClient::ProcessOneEvent() (in /apps/cern/root-5.27.04/lib/libGui.so)
==30642== by 0x608D6FC: TGClient::HandleInput() (in /apps/cern/root-5.27.04/lib/libGui.so)
==30642== by 0x608D72F: TGInputHandler::Notify() (in /apps/cern/root-5.27.04/lib/libGui.so)
==30642== by 0x4242EDC: TUnixSystem::DispatchOneEvent(bool) (in /apps/cern/root-5.27.04/lib/libCore.so)
==30642== by 0x41B36B0: TSystem::InnerLoop() (in /apps/cern/root-5.27.04/lib/libCore.so)
==30642== by 0x41B7380: TSystem::Run() (in /apps/cern/root-5.27.04/lib/libCore.so)
==30642== Address 0x6EF0BF0 is 0 bytes inside a block of size 100 free'd
==30642== at 0x4004CF1: operator delete(void*) (vg_replace_malloc.c:244)
==30642== by 0x41A38C3: TStorage::ObjectDealloc(void*) (in /apps/cern/root-5.27.04/lib/libCore.so)
==30642== by 0x4182296: TObject::operator delete(void*) (in /apps/cern/root-5.27.04/lib/libCore.so)
==30642== by 0x516E46A: TGraph::~TGraph() (in /apps/cern/root-5.27.04/lib/libHist.so)
==30642== by 0x41E8279: TCollection::GarbageCollect(TObject*) (in /apps/cern/root-5.27.04/lib/libCore.so)
==30642== by 0x41EF1A6: TList::Delete(char const*) (in /apps/cern/root-5.27.04/lib/libCore.so)
==30642== by 0x51E7D67: TMultiGraph::~TMultiGraph() (in /apps/cern/root-5.27.04/lib/libHist.so)
==30642== by 0x805249C: PEventHandlerTest::SwitchGraph() (PEventHandlerTest.cpp:129)
==30642== by 0x8052267: PEventHandlerTest::HandleCmdKey(int, int, int, TObject*) (PEventHandlerTest.cpp:108)
==30642== by 0x8056979: G__PEventHandlerTestDict_274_0_3(G__value*, char const*, G__param*, int) (PEventHandlerTestDict.cpp:286)
==30642== by 0x4833B9E: Cint::G__CallFunc::Execute(void*) (in /apps/cern/root-5.27.04/lib/libCint.so)
==30642== by 0x41FDD0A: TCint::CallFunc_Exec(void*, void*) const (in /apps/cern/root-5.27.04/lib/libCore.so)
==30642==
==30642== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 87 from 2)
==30642== malloc/free: in use at exit: 3,484,199 bytes in 72,209 blocks.
==30642== malloc/free: 204,308 allocs, 132,099 frees, 15,526,505 bytes allocated.
==30642== For counts of detected errors, rerun with: -v
==30642== searching for pointers to 72,209 not-freed blocks.
==30642== checked 8,510,996 bytes.
==30642==
==30642== LEAK SUMMARY:
==30642== definitely lost: 2,426 bytes in 41 blocks.
==30642== possibly lost: 164,286 bytes in 3,612 blocks.
==30642== still reachable: 3,317,487 bytes in 68,556 blocks.
==30642== suppressed: 0 bytes in 0 blocks.
==30642== Use --leak-check=full to see details of leaked memory.

View File

@ -30,7 +30,6 @@
***************************************************************************/ ***************************************************************************/
#include <iostream> #include <iostream>
using namespace std;
#include "TApplication.h" #include "TApplication.h"
@ -42,7 +41,7 @@ int main(int argc, char *argv[])
PEventHandlerTest *eht = new PEventHandlerTest(); PEventHandlerTest *eht = new PEventHandlerTest();
if (eht == 0) { if (eht == 0) {
cerr << endl << "**ERROR** couldn't invoke eht ..." << endl; std::cerr << std::endl << "**ERROR** couldn't invoke eht ..." << std::endl;
return 0; return 0;
} }

View File

@ -0,0 +1,95 @@
# - musrfit
cmake_minimum_required(VERSION 3.9)
if (CMAKE_VERSION GREATER_EQUAL 3.12)
cmake_policy(SET CMP0075 NEW)
endif (CMAKE_VERSION GREATER_EQUAL 3.12)
project(vortex-film VERSION 1.0.0 LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 11)
#set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
#--- set a default build type if none was specified ---------------------------
set(default_build_type "Debug")
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
#--- perform some checks and generate the config.h ----------------------------
#--- the next two lines are needed that the math functions are found ----------
set(CMAKE_REQUIRED_INCLUDES math.h)
set(CMAKE_REQUIRED_LIBRARIES m)
include(CheckTypeSize)
include(CheckIncludeFiles)
include(CheckFunctionExists)
check_include_files(alloca.h HAVE_ALLOCA_H)
check_include_files("sys/ipc.h;sys/shm.h" HAVE_SHMGET)
check_include_files(dlfcn.h HAVE_DLFCN_H)
check_function_exists(erf HAVE_ERF)
check_function_exists(getloadavg HAVE_GETLOADAVG)
check_include_files(inttypes.h HAVE_INTTYPES_H)
check_include_files(memory.h HAVE_MEMORY_H)
check_function_exists(powl HAVE_POWL)
check_include_files(memory.h HAVE_MEMORY_H)
check_include_files(stdint.h HAVE_STDINT_H)
check_include_files(stdlib.h HAVE_STDLIB_H)
check_include_files(string.h HAVE_STRING_H)
check_include_files(strings.h HAVE_STRINGS_H)
check_include_files(sys/stat.h HAVE_SYS_STAT_H)
check_include_files(sys/types.h HAVE_SYS_TYPES_H)
check_include_files(sys/unistd.h HAVE_UNISTD_H)
check_type_size("long double" LONG_DOUBLE)
check_type_size("double" DOUBLE)
if (${LONG_DOUBLE} GREATER ${DOUBLE})
set(HAVE_LONG_DOUBLE 1)
set(HAVE_LONG_DOUBLE_WIDER 1)
endif (${LONG_DOUBLE} GREATER ${DOUBLE})
#--- check for all the needed packages ----------------------------------------
#--- check for git ------------------------------------------------------------
find_package(Git REQUIRED)
#--- check for ROOT -----------------------------------------------------------
find_package(ROOT 6.18 REQUIRED COMPONENTS Gui MathMore Minuit2 XMLParser)
if (ROOT_mathmore_FOUND)
execute_process(COMMAND root-config --bindir OUTPUT_VARIABLE ROOT_BINDIR)
string(STRIP ${ROOT_BINDIR} ROOT_BINDIR)
execute_process(COMMAND root-config --version OUTPUT_VARIABLE ROOT_VERSION)
string(STRIP ${ROOT_VERSION} ROOT_VERSION)
message("-- Found ROOT: ${ROOT_BINDIR} (found version: ${ROOT_VERSION})")
#---Define useful ROOT functions and macros (e.g. ROOT_GENERATE_DICTIONARY)
include(${ROOT_USE_FILE})
endif (ROOT_mathmore_FOUND)
#--- define the BMWlibs -------------------------------------------------------
set(BMWlibs
BMWtools
FitPofB
)
#--- add all executables ------------------------------------------------------
add_executable(vortex_film
vortex_film.cpp
)
target_include_directories(vortex_film
BEFORE PRIVATE
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}>
)
target_link_directories(vortex_film
BEFORE PRIVATE
$ENV{ROOTSYS}/lib
)
target_link_libraries(vortex_film ${ROOT_LIBRARIES} ${BMWlibs})
#--- end ----------------------------------------------------------------------

View File

@ -0,0 +1,85 @@
/***************************************************************************
vortex-film.cpp
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
***************************************************************************/
/***************************************************************************
* Copyright (C) 2020 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 <cstdlib>
#include <memory>
#include <iostream>
#include "TFilmTriVortexFieldCalc.h"
void vortex_film_syntax()
{
std::cout << std::endl;
std::cout << "usage: vortex_film field penetration_depth coherence_length layer_thickness [stepXY stepZ]" << std::endl;
std::cout << std::endl;
}
int main(int argc, char *argv[])
{
if ((argc != 5) && (argc != 7)) {
vortex_film_syntax();
return -1;
}
std::vector<float> param;
for (unsigned int i=1; i<5; i++)
param.push_back((float)atof(argv[i]));
unsigned int stepXY = 256;
unsigned int stepZ = 32;
if (argc == 7) {
stepXY = (unsigned int)strtol(argv[5], nullptr, 10);
stepZ = (unsigned int)strtol(argv[6], nullptr, 10);
}
std::string wisdom("");
// c++11
std::unique_ptr<TFilmTriVortexNGLFieldCalc> vl(new TFilmTriVortexNGLFieldCalc(wisdom));
/* will only work for c++14
std::unique_ptr<TFilmTriVortexNGLFieldCalc> vl = std::make_unique<TFilmTriVortexNGLFieldCalc>(wisdom);
*/
// set parameter
vl->SetParameters(param);
// calculate the vortex lattice
vl->CalculateGrid();
std::cout << ">> Bmin: " << vl->GetBmin() << std::endl;
std::cout << ">> Bmax: " << vl->GetBmax() << std::endl;
std::vector<float*> field = vl->DataB();
for (unsigned int i=0; i<stepXY; i++) {
std::cout << i << ", " << field[2][stepZ*i] << ", " << field[2][stepXY*stepXY/2+stepZ*i] << std::endl;
}
return 0;
}