Nonlocal: Raw -> Smart Pointers. Improved config of standalone dump_nonlocal_field.
This commit is contained in:
parent
fb8ca28ea3
commit
2eec7bd182
40
src/external/Nonlocal/PNL_PippardFitter.cpp
vendored
40
src/external/Nonlocal/PNL_PippardFitter.cpp
vendored
@ -31,6 +31,7 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include <TSAXParser.h>
|
#include <TSAXParser.h>
|
||||||
#include <TMath.h>
|
#include <TMath.h>
|
||||||
@ -52,14 +53,14 @@ PNL_PippardFitterGlobal::PNL_PippardFitterGlobal()
|
|||||||
{
|
{
|
||||||
// read XML startup file
|
// read XML startup file
|
||||||
char startup_path_name[128];
|
char startup_path_name[128];
|
||||||
TSAXParser *saxParser = new TSAXParser();
|
std::unique_ptr<TSAXParser> saxParser = std::make_unique<TSAXParser>();
|
||||||
PNL_StartupHandler *fStartupHandler = new PNL_StartupHandler();
|
fStartupHandler = std::make_unique<PNL_StartupHandler>();
|
||||||
strcpy(startup_path_name, fStartupHandler->GetStartupFilePath().Data());
|
strcpy(startup_path_name, fStartupHandler->GetStartupFilePath().Data());
|
||||||
saxParser->ConnectToHandler("PNL_StartupHandler", fStartupHandler);
|
saxParser->ConnectToHandler("PNL_StartupHandler", fStartupHandler.get());
|
||||||
//Int_t status = saxParser->ParseFile(startup_path_name);
|
//Int_t status = saxParser->ParseFile(startup_path_name);
|
||||||
// parsing the file as above seems to lead to problems in certain environments;
|
// parsing the file as above seems to lead to problems in certain environments;
|
||||||
// use the parseXmlFile function instead (see PUserFcnBase.cpp for the definition)
|
// use the parseXmlFile function instead (see PUserFcnBase.cpp for the definition)
|
||||||
Int_t status = parseXmlFile(saxParser, startup_path_name);
|
Int_t status = parseXmlFile(saxParser.get(), startup_path_name);
|
||||||
// check for parse errors
|
// check for parse errors
|
||||||
if (status) { // error
|
if (status) { // error
|
||||||
std::cout << std::endl << ">> PNL_PippardFitterGlobal::PNL_PippardFitterGlobal: **WARNING** Reading/parsing nonlocal_startup.xml failed.";
|
std::cout << std::endl << ">> PNL_PippardFitterGlobal::PNL_PippardFitterGlobal: **WARNING** Reading/parsing nonlocal_startup.xml failed.";
|
||||||
@ -67,14 +68,8 @@ PNL_PippardFitterGlobal::PNL_PippardFitterGlobal()
|
|||||||
fValid = false;
|
fValid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// clean up
|
|
||||||
if (saxParser) {
|
|
||||||
delete saxParser;
|
|
||||||
saxParser = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// check if everything went fine with the startup handler
|
// check if everything went fine with the startup handler
|
||||||
if (!fStartupHandler->IsValid()) {
|
if (!fStartupHandler->IsValid() && fValid) {
|
||||||
std::cout << std::endl << ">> PNL_PippardFitterGlobal::PNL_PippardFitterGlobal **PANIC ERROR**";
|
std::cout << std::endl << ">> PNL_PippardFitterGlobal::PNL_PippardFitterGlobal **PANIC ERROR**";
|
||||||
std::cout << std::endl << ">> startup handler too unhappy. Will terminate unfriendly, sorry.";
|
std::cout << std::endl << ">> startup handler too unhappy. Will terminate unfriendly, sorry.";
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
@ -84,12 +79,14 @@ PNL_PippardFitterGlobal::PNL_PippardFitterGlobal()
|
|||||||
fFourierPoints = fStartupHandler->GetFourierPoints();
|
fFourierPoints = fStartupHandler->GetFourierPoints();
|
||||||
|
|
||||||
// load all the TRIM.SP rge-files
|
// load all the TRIM.SP rge-files
|
||||||
fRgeHandler = new PRgeHandler("./nonlocal_startup.xml");
|
if (fValid) {
|
||||||
if (!fRgeHandler->IsValid()) {
|
fRgeHandler = std::make_unique<PRgeHandler>("./nonlocal_startup.xml");
|
||||||
std::cout << std::endl << ">> PNL_PippardFitterGlobal::PNL_PippardFitterGlobal **PANIC ERROR**";
|
if (!fRgeHandler->IsValid()) {
|
||||||
std::cout << std::endl << ">> rge data handler too unhappy. Will terminate unfriendly, sorry.";
|
std::cout << std::endl << ">> PNL_PippardFitterGlobal::PNL_PippardFitterGlobal **PANIC ERROR**";
|
||||||
std::cout << std::endl;
|
std::cout << std::endl << ">> rge data handler too unhappy. Will terminate unfriendly, sorry.";
|
||||||
fValid = false;
|
std::cout << std::endl;
|
||||||
|
fValid = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fPlanPresent = false;
|
fPlanPresent = false;
|
||||||
@ -124,15 +121,6 @@ PNL_PippardFitterGlobal::~PNL_PippardFitterGlobal()
|
|||||||
fftw_free(fFieldq);
|
fftw_free(fFieldq);
|
||||||
fFieldB = 0;
|
fFieldB = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fRgeHandler) {
|
|
||||||
delete fRgeHandler;
|
|
||||||
fRgeHandler = 0;
|
|
||||||
}
|
|
||||||
if (fStartupHandler) {
|
|
||||||
delete fStartupHandler;
|
|
||||||
fStartupHandler = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
|
6
src/external/Nonlocal/PNL_PippardFitter.h
vendored
6
src/external/Nonlocal/PNL_PippardFitter.h
vendored
@ -36,6 +36,8 @@
|
|||||||
//#endif
|
//#endif
|
||||||
#include <fftw3.h>
|
#include <fftw3.h>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include "PMusr.h"
|
#include "PMusr.h"
|
||||||
#include "PUserFcnBase.h"
|
#include "PUserFcnBase.h"
|
||||||
#include "PNL_StartupHandler.h"
|
#include "PNL_StartupHandler.h"
|
||||||
@ -57,8 +59,8 @@ class PNL_PippardFitterGlobal
|
|||||||
private:
|
private:
|
||||||
Bool_t fValid{true};
|
Bool_t fValid{true};
|
||||||
|
|
||||||
PNL_StartupHandler *fStartupHandler{nullptr};
|
std::unique_ptr<PNL_StartupHandler> fStartupHandler;
|
||||||
PRgeHandler *fRgeHandler{nullptr};
|
std::unique_ptr<PRgeHandler> fRgeHandler;
|
||||||
|
|
||||||
mutable std::vector<Double_t> fPreviousParam;
|
mutable std::vector<Double_t> fPreviousParam;
|
||||||
|
|
||||||
|
4
src/external/Nonlocal/cmake/dnlf_config.h.in
vendored
4
src/external/Nonlocal/cmake/dnlf_config.h.in
vendored
@ -2,3 +2,7 @@
|
|||||||
|
|
||||||
#define PROJECT_VERSION "@PROJECT_VERSION@"
|
#define PROJECT_VERSION "@PROJECT_VERSION@"
|
||||||
|
|
||||||
|
#define GIT_BRANCH "@GIT_BRANCH@"
|
||||||
|
#define GIT_CURRENT_SHA1 @GIT_CURRENT_SHA1@
|
||||||
|
|
||||||
|
#define ROOT_VERSION_USED "@ROOT_VERSION_USED@"
|
||||||
|
55
src/external/Nonlocal/prog/CMakeLists.txt
vendored
55
src/external/Nonlocal/prog/CMakeLists.txt
vendored
@ -1,23 +1,64 @@
|
|||||||
#--- dump_nonlocal_field ------------------------------------------------------
|
#--- dump_nonlocal_field ------------------------------------------------------
|
||||||
|
|
||||||
|
cmake_minimum_required(VERSION 3.15)
|
||||||
|
|
||||||
project(dump_nonlocal_field VERSION 1.0.0 LANGUAGES C CXX)
|
project(dump_nonlocal_field VERSION 1.0.0 LANGUAGES C CXX)
|
||||||
|
|
||||||
|
#--- 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_USED)
|
||||||
|
string(STRIP ${ROOT_VERSION_USED} ROOT_VERSION_USED)
|
||||||
|
execute_process(COMMAND root-config --incdir OUTPUT_VARIABLE ROOT_INC)
|
||||||
|
string(STRIP ${ROOT_INC} ROOT_INC)
|
||||||
|
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)
|
||||||
|
|
||||||
|
#--- check for boost ----------------------------------------------------------
|
||||||
|
find_package(Boost REQUIRED
|
||||||
|
COMPONENTS
|
||||||
|
system
|
||||||
|
filesystem
|
||||||
|
)
|
||||||
|
message(STATUS "Boost libs: ${Boost_LIBRARIES}")
|
||||||
|
|
||||||
|
#--- check for fftw3 ----------------------------------------------------------
|
||||||
|
#find_package(FFTW3 REQUIRED)
|
||||||
|
|
||||||
|
# Get the current working branch
|
||||||
|
execute_process(
|
||||||
|
COMMAND git rev-parse --abbrev-ref HEAD
|
||||||
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||||
|
OUTPUT_VARIABLE GIT_BRANCH
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
)
|
||||||
|
|
||||||
|
# Get the latest abbreviated commit hash of the working branch
|
||||||
|
execute_process(
|
||||||
|
COMMAND git log -1 --pretty="%h, %ci"
|
||||||
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||||
|
OUTPUT_VARIABLE GIT_CURRENT_SHA1
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
#--- feed dnlf_config.h -----------------------------------------
|
#--- feed dnlf_config.h -----------------------------------------
|
||||||
set(HAVE_DNLF_CONFIG_H 1 CACHE INTERNAL "dnlf_config.h is available")
|
set(HAVE_DNLF_CONFIG_H 1 CACHE INTERNAL "dnlf_config.h is available")
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/dnlf_config.h.in ${CMAKE_CURRENT_BINARY_DIR}/dnlf_config.h)
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/dnlf_config.h.in ${CMAKE_CURRENT_BINARY_DIR}/dnlf_config.h)
|
||||||
|
|
||||||
#--- start create git-revision.h ----------------------------------------------
|
|
||||||
if (IS_GIT_REPO)
|
|
||||||
set(HAVE_GIT_REV_H "-DHAVE_GIT_REV_H")
|
|
||||||
else (IS_GIT_REPO)
|
|
||||||
set(HAVE_GIT_REV_H "")
|
|
||||||
endif (IS_GIT_REPO)
|
|
||||||
|
|
||||||
add_executable(dump_nonlocal_field dump_nonlocal_field.cpp)
|
add_executable(dump_nonlocal_field dump_nonlocal_field.cpp)
|
||||||
target_compile_options(dump_nonlocal_field BEFORE PRIVATE "-DHAVE_CONFIG_H" "-DHAVE_DNLF_CONFIG_H" "${HAVE_GIT_REV_H}")
|
target_compile_options(dump_nonlocal_field BEFORE PRIVATE "-DHAVE_CONFIG_H" "-DHAVE_DNLF_CONFIG_H" "${HAVE_GIT_REV_H}")
|
||||||
target_include_directories(dump_nonlocal_field
|
target_include_directories(dump_nonlocal_field
|
||||||
BEFORE PRIVATE
|
BEFORE PRIVATE
|
||||||
$<BUILD_INTERFACE:${Boost_INCLUDE_DIR}>
|
$<BUILD_INTERFACE:${Boost_INCLUDE_DIR}>
|
||||||
|
$<BUILD_INTERFACE:${ROOT_INC}>
|
||||||
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}>
|
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}>
|
||||||
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/src>
|
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/src>
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
|
||||||
|
@ -38,15 +38,9 @@
|
|||||||
|
|
||||||
#include "PNL_PippardFitter.h"
|
#include "PNL_PippardFitter.h"
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include "config.h"
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_DNLF_CONFIG_H
|
#ifdef HAVE_DNLF_CONFIG_H
|
||||||
#include "dnlf_config.h"
|
#include "dnlf_config.h"
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_GIT_REV_H
|
|
||||||
#include "git-revision.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
@ -202,18 +196,10 @@ int main(int argc, char* argv[])
|
|||||||
if (argv[i][0] != '-') { // must be the msr-file name
|
if (argv[i][0] != '-') { // must be the msr-file name
|
||||||
msrFileName = argv[i];
|
msrFileName = argv[i];
|
||||||
} else if (!strcmp(argv[i], "--version")) {
|
} else if (!strcmp(argv[i], "--version")) {
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_DNLF_CONFIG_H
|
||||||
#ifdef HAVE_GIT_REV_H
|
std::cout << std::endl << "dump_nonlocal_field version: " << PROJECT_VERSION << ", git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << ", ROOT version: " << ROOT_VERSION_USED << std::endl << std::endl;
|
||||||
std::cout << std::endl << "dump_nonlocal_field version: " << PROJECT_VERSION << " (" << PACKAGE_VERSION << "), git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << " (" << BUILD_TYPE << "), ROOT version: " << ROOT_VERSION_USED << std::endl << std::endl;
|
|
||||||
#else
|
#else
|
||||||
std::cout << std::endl << "dump_nonlocal_field version: " << PROJECT_VERSION << " (" << PACKAGE_VERSION << "/" << BUILD_TYPE << "), ROOT version: " << ROOT_VERSION_USED << std::endl << std::endl;
|
std::cout << std::endl << "dump_nonlocal_field version: " << PROJECT_VERSION << ", ROOT version: " << ROOT_VERSION_USED << std::endl << std::endl;
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
#ifdef HAVE_GIT_REV_H
|
|
||||||
std::cout << std::endl << "dump_nonlocal_field git-branch: " << GIT_BRANCH << ", git-rev: " << GIT_CURRENT_SHA1 << std::endl << std::endl;
|
|
||||||
#else
|
|
||||||
std::cout << std::endl << "dump_nonlocal_field version: unknown" << std::endl << std::endl;
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
} else if (!strcmp(argv[i], "--help")) {
|
} else if (!strcmp(argv[i], "--help")) {
|
||||||
@ -260,14 +246,17 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
// calculate field and write it to file
|
// calculate field and write it to file
|
||||||
PNL_PippardFitterGlobal pip;
|
PNL_PippardFitterGlobal pip;
|
||||||
pip.CalculateField(param);
|
if (pip.IsValid())
|
||||||
|
pip.CalculateField(param);
|
||||||
|
else
|
||||||
|
return -3;
|
||||||
|
|
||||||
std::ofstream fout(outFileName.c_str(), std::ofstream::out);
|
std::ofstream fout(outFileName.c_str(), std::ofstream::out);
|
||||||
if (!fout.is_open()) {
|
if (!fout.is_open()) {
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
std::cerr << "**ERROR** can not write to file '" << outFileName << "'." << std::endl;
|
std::cerr << "**ERROR** can not write to file '" << outFileName << "'." << std::endl;
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
return -3;
|
return -4;
|
||||||
}
|
}
|
||||||
// write header
|
// write header
|
||||||
fout << "% z (nm), field (G)" << std::endl;
|
fout << "% z (nm), field (G)" << std::endl;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user