From 21213a45ebcb7c7e1e5909120141a95179a6cad4 Mon Sep 17 00:00:00 2001 From: Andreas Suter Date: Tue, 30 Mar 2021 15:39:45 +0200 Subject: [PATCH 1/9] add a central rge-handler which can be used by all user function classes. --- src/classes/PRgeHandler.cpp | 603 +++++++++++++++++++++++++++++++ src/include/PRgeHandler.h | 128 +++++++ src/include/PRgeHandlerLinkDef.h | 39 ++ 3 files changed, 770 insertions(+) create mode 100644 src/classes/PRgeHandler.cpp create mode 100644 src/include/PRgeHandler.h create mode 100644 src/include/PRgeHandlerLinkDef.h diff --git a/src/classes/PRgeHandler.cpp b/src/classes/PRgeHandler.cpp new file mode 100644 index 00000000..8c2e44bc --- /dev/null +++ b/src/classes/PRgeHandler.cpp @@ -0,0 +1,603 @@ +/*************************************************************************** + + PRgeHandler.cpp + + Author: Andreas Suter + e-mail: andreas.suter@psi.ch + +***************************************************************************/ + +/*************************************************************************** + * Copyright (C) 2007-2021 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 +#include +#include +#include + +#include +#include + +#include "PRgeHandler.h" + +ClassImpQ(PXmlRgeHandler) + +//-------------------------------------------------------------------------- +// OnStartDocument +//-------------------------------------------------------------------------- +/** + *

Called on start of the XML file reading. Initializes all necessary variables. + */ +void PXmlRgeHandler::OnStartDocument() +{ + fKey = eEmpty; +} + +//-------------------------------------------------------------------------- +// OnEndDocument +//-------------------------------------------------------------------------- +/** + *

Called on end of XML file reading. + */ +void PXmlRgeHandler::OnEndDocument() +{ + if (!fIsValid) + return; + + // check if anything was set + if (fTrimSpDataPath.empty()) { + std::string err = " content is missing!"; + fIsValid = false; + OnError(err.c_str()); + } + if (fTrimSpFlnPre.empty()) { + std::string err = " content is missing!"; + fIsValid = false; + OnError(err.c_str()); + } + if (fTrimSpDataEnergyList.size()==0) { + std::string err = "no implantation energies present!"; + fIsValid = false; + OnError(err.c_str()); + } +} + +//-------------------------------------------------------------------------- +// OnStartElement +//-------------------------------------------------------------------------- +/** + *

Called when a XML start element is found. Filters out the needed elements + * and sets a proper key. + * + * \param str XML element name + * \param attributes not used + */ +void PXmlRgeHandler::OnStartElement(const Char_t *str, const TList *attributes) +{ + if (!strcmp(str, "trim_sp")) { + isTrimSp=true; + } else if (!strcmp(str, "data_path") && isTrimSp) { + fKey = eDataPath; + } else if (!strcmp(str, "rge_fln_pre") && isTrimSp) { + fKey = eFlnPre; + } else if (!strcmp(str, "energy") && isTrimSp) { + fKey = eEnergy; + } +} + +//-------------------------------------------------------------------------- +// OnEndElement +//-------------------------------------------------------------------------- +/** + *

Called when a XML end element is found. Resets the handler key. + * + * \param str not used + */ +void PXmlRgeHandler::OnEndElement(const Char_t *str) +{ + if (!strcmp(str, "trim_sp")) { + isTrimSp=false; + } + + fKey = eEmpty; +} + +//-------------------------------------------------------------------------- +// OnCharacters +//-------------------------------------------------------------------------- +/** + *

Content of a given XML element. Filters out the data and feeds them to + * the internal variables. + * + * \param str XML element string + */ +void PXmlRgeHandler::OnCharacters(const Char_t *str) +{ + int ival; + std::string msg(""), sstr(str); + size_t pos; + + switch(fKey) { + case eDataPath: + fTrimSpDataPath=str; + break; + case eFlnPre: + fTrimSpFlnPre=str; + break; + case eEnergy: + try { + ival = std::stoi(str, &pos); + } catch(std::invalid_argument& e) { + fIsValid = false; + msg = "The found energy '" + sstr + "' which is not a number"; + OnError(msg.c_str()); + } catch(std::out_of_range& e) { + fIsValid = false; + msg = "The found energy '" + sstr + "' which is out-of-range."; + OnError(msg.c_str()); + } catch(...) { + fIsValid = false; + msg = "The found energy '" + sstr + "' which generates an error."; + OnError(msg.c_str()); + } + if (pos != sstr.length()) { + fIsValid = false; + msg = "The found energy '" + sstr + "' which is not an integer"; + OnError(msg.c_str()); + } + fTrimSpDataEnergyList.push_back(ival); + break; + default: + break; + } +} + +//-------------------------------------------------------------------------- +// OnComment +//-------------------------------------------------------------------------- +/** + *

Called when a XML comment is found. Not used. + * + * \param str not used. + */ +void PXmlRgeHandler::OnComment(const Char_t *str) +{ + // nothing to be done for now +} + +//-------------------------------------------------------------------------- +// OnWarning +//-------------------------------------------------------------------------- +/** + *

Called when the XML parser emits a warning. + * + * \param str warning string + */ +void PXmlRgeHandler::OnWarning(const Char_t *str) +{ + std::cerr << std::endl << "PXmlRgeHandler **WARNING** " << str; + std::cerr << std::endl; +} + +//-------------------------------------------------------------------------- +// OnError +//-------------------------------------------------------------------------- +/** + *

Called when the XML parser emits an error. + * + * \param str error string + */ +void PXmlRgeHandler::OnError(const Char_t *str) +{ + std::cerr << std::endl << "PXmlRgeHandler **ERROR** " << str; + std::cerr << std::endl; +} + +//-------------------------------------------------------------------------- +// OnFatalError +//-------------------------------------------------------------------------- +/** + *

Called when the XML parser emits a fatal error. + * + * \param str fatal error string + */ +void PXmlRgeHandler::OnFatalError(const Char_t *str) +{ + std::cerr << std::endl << "PXmlRgeHandler **FATAL ERROR** " << str; + std::cerr << std::endl; +} + +//-------------------------------------------------------------------------- +// OnCdataBlock +//-------------------------------------------------------------------------- +/** + *

Not used. + * + * \param str not used + * \param len not used + */ +void PXmlRgeHandler::OnCdataBlock(const Char_t *str, Int_t len) +{ + // nothing to be done for now +} + +//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +ClassImp(PRgeHandler) + +//-------------------------------------------------------------------------- +// Ctor +//-------------------------------------------------------------------------- +/** + * @brief PRgeHandler::PRgeHandler + * @param fln + */ +PRgeHandler::PRgeHandler(const std::string fln) +{ + // make sure there is an xml-startup file name + if (fln.empty()) { // fln not given + std::cerr << std::endl; + std::cerr << "**ERROR** NO xml file name provided." << std::endl; + std::cerr << std::endl; + fValid=false; + return; + } + + // read the startup xml-file to extract the necessary rge infos. + if (!boost::filesystem::exists(fln)) { + std::cerr << std::endl; + std::cerr << "**ERROR** xml file named: " << fln << " does not exist." << std::endl; + std::cerr << std::endl; + fValid=false; + return; + } + + // create the rge xml handler + PXmlRgeHandler *xmlRge = new PXmlRgeHandler(); + if (xmlRge == nullptr) { + std::cerr << std::endl; + std::cerr << "**ERROR** couldn't invoke PXmlRgeHandler." << std::endl; + std::cerr << std::endl; + fValid=false; + return; + } + + // create the SAX parser + TSAXParser *saxParser = new TSAXParser(); + if (saxParser == nullptr) { + std::cerr << std::endl; + std::cerr << "**ERROR** couldn't invoke TSAXParser." << std::endl; + std::cerr << std::endl; + fValid=false; + return; + } + saxParser->SetStopOnError(); + + // connect SAX parser and rge handler + saxParser->ConnectToHandler("PXmlRgeHandler", xmlRge); + int status = saxParser->ParseFile(fln.c_str()); + if (status != 0) { + std::cerr << std::endl; + std::cerr << "**ERROR** parsing the xml-file: " << fln << "." << std::endl; + std::cerr << std::endl; + fValid=false; + return; + } + if (xmlRge->IsValid()) + fValid = true; + else + fValid = false; + + // read the rge-file(s) content if everything went fine so far + std::string rgeFln; + PRgeData dataSet; + if (fValid) { + const PIntVector energy = xmlRge->GetTrimSpDataVectorList(); + for (int i=0; iGetTrimSpDataPath(); + if (rgeFln[rgeFln.size()-1] != '/') + rgeFln += "/"; + rgeFln += xmlRge->GetTrimSpFlnPre(); + rgeFln += std::to_string(energy[i]); + rgeFln += ".rge"; + if (!boost::filesystem::exists(rgeFln)) { + fValid = false; + std::cerr << std::endl; + std::cerr << "**ERROR** rge-file: " << rgeFln << " not found." << std::endl; + std::cerr << std::endl; + break; + } + // init data set + dataSet.energy = energy[i]; + dataSet.depth.clear(); + dataSet.amplitude.clear(); + if (!ReadRgeFile(rgeFln, dataSet)) { + fValid = false; + std::cerr << std::endl; + std::cerr << "**ERROR** read error in rge-file: " << rgeFln << " not found." << std::endl; + std::cerr << std::endl; + break; + } + + // get the total number of particles + double tot=0.0; + for (int j=0; jRead the content of a rge-file. + * + * @param fln file name of the rge-file + * @return true on success. + */ +bool PRgeHandler::ReadRgeFile(const std::string fln, PRgeData &data) +{ + std::ifstream fin(fln); + if (!fin.is_open()) + return false; + + std::string line, msg; + std::vector tok; + Double_t zz, nn; + size_t pos; + int lineNo=0; + + while (fin.good() && fValid) { + std::getline(fin, line); + lineNo++; + boost::algorithm::trim(line); + if (line.empty()) + continue; + if (!std::isdigit(line[0])) + continue; + tok.clear(); + boost::algorithm::split(tok, line, boost::algorithm::is_any_of(" \t"), boost::algorithm::token_compress_on); + if (tok.size() != 2) { + std::cerr << std::endl; + std::cerr << "**ERROR** in rge-file: " << fln << ", unexpected number of tokens (" << tok.size() << ")." << std::endl; + std::cerr << std::endl; + fin.close(); + return false; + } + // check distance + try { + zz = std::stod(tok[0], &pos); + } catch(std::invalid_argument& e) { + fValid = false; + msg = "The found depth '" + tok[0] + "' which is not a number"; + std::cerr << std::endl; + std::cerr << "**ERROR** in rge-file: " << fln << ": lineNo: " << lineNo << std::endl; + std::cerr << " " << msg << std::endl; + std::cerr << std::endl; + } catch(std::out_of_range& e) { + fValid = false; + msg = "The found depth '" + tok[0] + "' which is out-of-range."; + std::cerr << std::endl; + std::cerr << "**ERROR** in rge-file: " << fln << ": lineNo: " << lineNo << std::endl; + std::cerr << " " << msg << std::endl; + std::cerr << std::endl; + } catch(...) { + fValid = false; + msg = "The found depth '" + tok[0] + "' which generates an error."; + std::cerr << std::endl; + std::cerr << "**ERROR** in rge-file: " << fln << ": lineNo: " << lineNo << std::endl; + std::cerr << " " << msg << std::endl; + std::cerr << std::endl; + } + if (pos != tok[0].length()) { + fValid = false; + msg = "The found depth '" + tok[0] + "' which is not an number."; + std::cerr << std::endl; + std::cerr << "**ERROR** in rge-file: " << fln << ": lineNo: " << lineNo << std::endl; + std::cerr << " " << msg << std::endl; + std::cerr << std::endl; + } + // check number of implanted particles + try { + nn = std::stod(tok[1], &pos); + } catch(std::invalid_argument& e) { + fValid = false; + msg = "The found #particles '" + tok[1] + "' which is not a number"; + std::cerr << std::endl; + std::cerr << "**ERROR** in rge-file: " << fln << ": lineNo: " << lineNo << std::endl; + std::cerr << " " << msg << std::endl; + std::cerr << std::endl; + } catch(std::out_of_range& e) { + fValid = false; + msg = "The found #particles '" + tok[1] + "' which is out-of-range."; + std::cerr << std::endl; + std::cerr << "**ERROR** in rge-file: " << fln << ": lineNo: " << lineNo << std::endl; + std::cerr << " " << msg << std::endl; + std::cerr << std::endl; + } catch(...) { + fValid = false; + msg = "The found #particles '" + tok[1] + "' which generates an error."; + std::cerr << std::endl; + std::cerr << "**ERROR** in rge-file: " << fln << ": lineNo: " << lineNo << std::endl; + std::cerr << " " << msg << std::endl; + std::cerr << std::endl; + } + if (pos != tok[1].length()) { + fValid = false; + msg = "The found #particles '" + tok[1] + "' which is not an integer."; + std::cerr << std::endl; + std::cerr << "**ERROR** in rge-file: " << fln << ": lineNo: " << lineNo << std::endl; + std::cerr << " " << msg << std::endl; + std::cerr << std::endl; + } + data.depth.push_back(zz/10.0); // distance in nm + data.amplitude.push_back(nn); + } + + fin.close(); + + return true; +} + +//-------------------------------------------------------------------------- +// GetZmax via energy +//-------------------------------------------------------------------------- +/** + *

Get maximal depth for a given energy. + * + * @param energy energy in (eV) + * @return zMax if energy is found, -1 otherwise. + */ +Double_t PRgeHandler::GetZmax(const Double_t energy) +{ + int idx=-1; + for (int i=0; iGet maximal depth for a given index. + * + * @param idx index for which zMax is requested. + * @return zMax if idx is in range, -1 otherwise. + */ +Double_t PRgeHandler::GetZmax(const Int_t idx) +{ + if ((idx < 0) || (idx >= fData.size())) + return -1.0; + + return fData[idx].depth[fData[idx].depth.size()-1]; +} + +//-------------------------------------------------------------------------- +// Get_n via energy +//-------------------------------------------------------------------------- +/** + *

Get the normalized n(E,z) value. + * + * @param energy (eV) + * @param z (nm) + * @return n(E,z) if energy and z are in proper range, -1.0 otherwise. + */ +Double_t PRgeHandler::Get_n(const Double_t energy, const Double_t z) +{ + int idx=-1; + for (int i=0; iGet the normalized n(idx,z) value. + * + * @param idx index of the rge-dataset + * @param z (nm) + * @return n(idx,z) if idx and z are in proper range, -1.0 otherwise. + */ +Double_t PRgeHandler::Get_n(const Int_t idx, const Double_t z) +{ + if ((idx < 0) || (idx >= fData.size())) + return -1.0; + + if ((z < 0.0) || (z > GetZmax(idx))) + return 0.0; + + int pos=0; + for (int i=0; iGet the energy index by providing an energy in (eV). + * + * @param energy in (eV). + * @return energy index if energy was found, -1 otherwise. + */ +Int_t PRgeHandler::GetEnergyIndex(const Double_t energy) +{ + int idx=-1; + for (int i=0; i +#include + +#include +#include +#include + +#include "PMusr.h" + +//----------------------------------------------------------------------------- +/** + *

Keep a single rge table from TrimSP for a given energy. + */ +typedef struct { + Double_t energy; + PDoubleVector depth; + PDoubleVector amplitude; + PDoubleVector nn; // normalized int n(z) dz = 1 amplitudes + Double_t noOfParticles; +} PRgeData; + +//----------------------------------------------------------------------------- +/** + *

Keep all rge tables from TrimSP. + */ +typedef std::vector PRgeDataList; + +//----------------------------------------------------------------------------- +/** + *

Reads the xml-startup file in order to extract all necessary information + * about the RGE files (TrimSP) needed. + */ +class PXmlRgeHandler : public TObject, public TQObject +{ + public: + PXmlRgeHandler() {} + virtual ~PXmlRgeHandler() {} + + virtual void OnStartDocument(); // SLOT + virtual void OnEndDocument(); // SLOT + virtual void OnStartElement(const char*, const TList*); // SLOT + virtual void OnEndElement(const char*); // SLOT + virtual void OnCharacters(const char*); // SLOT + virtual void OnComment(const char*); // SLOT + virtual void OnWarning(const char*); // SLOT + virtual void OnError(const char*); // SLOT + virtual void OnFatalError(const char*); // SLOT + virtual void OnCdataBlock(const char*, Int_t); // SLOT + + virtual bool IsValid() { return fIsValid; } + virtual std::string GetTrimSpDataPath() { return fTrimSpDataPath; } + virtual std::string GetTrimSpFlnPre() { return fTrimSpFlnPre; } + virtual const PIntVector GetTrimSpDataVectorList() const { return fTrimSpDataEnergyList; } + + private: + enum EKeyWords {eEmpty, eDataPath, eFlnPre, eEnergy}; + EKeyWords fKey; + + bool isTrimSp{false}; + bool fIsValid{true}; + + std::string fTrimSpDataPath{""}; //< where to find the rge-files + std::string fTrimSpFlnPre{""}; //< keeps the preface of the rge file name, e.g. LCCO_E + PIntVector fTrimSpDataEnergyList; //< TrimSP implantation energy list (in eV) + + ClassDef(PXmlRgeHandler, 1) +}; + +//----------------------------------------------------------------------------- +/** + * @brief The PRegHandler class + */ +class PRgeHandler : public TObject +{ + public: + PRgeHandler(std::string fln=""); + virtual ~PRgeHandler() {} + + virtual bool IsValid() { return fValid; } + virtual PRgeDataList GetRgeData() { return fData; } + virtual Double_t GetZmax(const Double_t energy); + virtual Double_t GetZmax(const Int_t idx); + virtual Double_t Get_n(const Double_t energy, const Double_t z); + virtual Double_t Get_n(const Int_t idx, const Double_t z); + virtual Int_t GetEnergyIndex(const Double_t energy); + + private: + bool fValid{false}; + PRgeDataList fData; + + virtual bool ReadRgeFile(const std::string fln, PRgeData &data); + + ClassDef(PRgeHandler, 1) +}; + +#endif // _PRGEHANDLER_H_ diff --git a/src/include/PRgeHandlerLinkDef.h b/src/include/PRgeHandlerLinkDef.h new file mode 100644 index 00000000..4bac86bc --- /dev/null +++ b/src/include/PRgeHandlerLinkDef.h @@ -0,0 +1,39 @@ +/*************************************************************************** + + PRgeHandlerLinkDef.h + + Author: Andreas Suter + e-mail: andreas.suter@psi.ch + +***************************************************************************/ + +/*************************************************************************** + * Copyright (C) 2007-2021 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 PXmlRgeHandler+; +#pragma link C++ class PRgeHandler+; + +#endif From 0dc1c4d9753ada602dacf21f25618403aa888ae9 Mon Sep 17 00:00:00 2001 From: Andreas Suter Date: Tue, 30 Mar 2021 15:41:38 +0200 Subject: [PATCH 2/9] add some boost component checks. Increase the musrfit version number. --- CMakeLists.txt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6e4ead4e..6f998dac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,7 @@ if (CMAKE_VERSION GREATER_EQUAL 3.12) cmake_policy(SET CMP0075 NEW) endif (CMAKE_VERSION GREATER_EQUAL 3.12) -project(musrfit VERSION 1.6.5 LANGUAGES C CXX) +project(musrfit VERSION 1.7.0 LANGUAGES C CXX) #--- musrfit specific options ------------------------------------------------- option(nexus "build optional NeXus support. Needed for ISIS" OFF) @@ -83,7 +83,12 @@ if (ROOT_mathmore_FOUND) endif (ROOT_mathmore_FOUND) #--- check for boost ---------------------------------------------------------- -find_package(Boost REQUIRED) +find_package(Boost REQUIRED + COMPONENTS + system + filesystem +) +message(STATUS "Boost libs: ${Boost_LIBRARIES}") #--- check for gsl ------------------------------------------------------------ find_package(GSL REQUIRED) From cb0e8d2e65b938e1356796ff5d11ded8598281d2 Mon Sep 17 00:00:00 2001 From: Andreas Suter Date: Tue, 30 Mar 2021 15:43:26 +0200 Subject: [PATCH 3/9] update of the ChangeLog. --- ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ChangeLog b/ChangeLog index c4abcd11..a1dd2273 100644 --- a/ChangeLog +++ b/ChangeLog @@ -12,6 +12,11 @@ or https://bitbucket.org/muonspin/musrfit/commits/all +Release of V1.7.0, 2021/03/30 +============================= + +Centralize the rge-handling for user functions. + Release of V1.6.5, 2021/01/22 ============================= From 113996aa4ecf8c37fccb5894f102ac0222fd40ea Mon Sep 17 00:00:00 2001 From: Andreas Suter Date: Tue, 30 Mar 2021 15:48:51 +0200 Subject: [PATCH 4/9] changed the user function for nonlocal fitting to the new rge-handler. This breaks the backwards compatibility! --- doc/examples/ASlibs/nonlocal_startup.xml | 9 +- doc/examples/ASlibs/test-nonlocal.msr | 32 +-- src/external/Nonlocal/CMakeLists.txt | 23 +- src/external/Nonlocal/PNL_PippardFitter.cpp | 35 ++-- src/external/Nonlocal/PNL_PippardFitter.h | 11 +- src/external/Nonlocal/PNL_RgeHandler.cpp | 208 ------------------- src/external/Nonlocal/PNL_RgeHandler.h | 55 ----- src/external/Nonlocal/PNL_StartupHandler.cpp | 70 +------ src/external/Nonlocal/PNL_StartupHandler.h | 24 +-- src/external/Nonlocal/PNonlocal.h | 65 ------ src/external/Nonlocal/nonlocal_startup.xml | 32 +-- 11 files changed, 90 insertions(+), 474 deletions(-) delete mode 100644 src/external/Nonlocal/PNL_RgeHandler.cpp delete mode 100644 src/external/Nonlocal/PNL_RgeHandler.h delete mode 100644 src/external/Nonlocal/PNonlocal.h diff --git a/doc/examples/ASlibs/nonlocal_startup.xml b/doc/examples/ASlibs/nonlocal_startup.xml index 9871ca63..1cc3264f 100644 --- a/doc/examples/ASlibs/nonlocal_startup.xml +++ b/doc/examples/ASlibs/nonlocal_startup.xml @@ -1,13 +1,14 @@ - $Id: nonlocal_startup.xml 4047 2009-07-02 13:36:18Z nemu $ + nonlocal_startup.xml 262144 - - profiles/Sn_E + + ./profiles/ + Sn_E 1000 2000 @@ -22,5 +23,5 @@ 25000 27300 - + diff --git a/doc/examples/ASlibs/test-nonlocal.msr b/doc/examples/ASlibs/test-nonlocal.msr index 185249f9..d3145ed5 100644 --- a/doc/examples/ASlibs/test-nonlocal.msr +++ b/doc/examples/ASlibs/test-nonlocal.msr @@ -4,21 +4,21 @@ FITPARAMETER # Nr. Name Value Step Pos_Error Boundaries 1 one 1 0 none 2 zero 0 0 none - 3 Asy 0.2235 -0.0066 0.0072 0 0.33 - 4 energy 22 0 none + 3 Asy 0.2235 -0.0065 0.0072 0 0.33 + 4 energy 22000 0 none 5 redTemp 0.8683 0 none 6 thickness 5000 0 none 7 ell 12000 0 none 8 xi 94 0 none - 9 lambdaL 52.5 -1.4 1.2 + 9 lambdaL 52.5 -1.3 1.2 10 Bext 47.11 0 none - 11 deadLayer 0.00052 -0.00052 6.89563 0 none + 11 deadLayer 0.0004 0.0037 none 0 none 12 RateSmear 0.418 -0.015 0.015 - 13 N0_L 301.61 0.62 none - 14 Bkg_L 24.442 0.076 none + 13 N0_L 301.6 -1.1 1.2 + 14 Bkg_L 24.441 -0.092 0.092 15 Phase_L 42.0 -2.2 2.2 - 16 Alpha_LR 1.0614 -0.0066 0.0064 - 17 Bkg_R 27.646 -0.090 0.090 + 16 Alpha_LR 1.0613 -0.0066 0.0064 + 17 Bkg_R 27.646 -0.089 0.090 18 RelPhase_R 154.4 -1.1 1.1 ############################################################### @@ -37,7 +37,6 @@ RUN data/lem10_his_0825 MUE4 PSI ROOT-NPP (name beamline institute data-file-f fittype 0 (single histogram fit) norm 13 backgr.fit 14 -lifetimecorrection map 1 2 0 0 0 0 0 0 0 0 forward 1 data 3289 65000 @@ -49,7 +48,6 @@ RUN data/lem10_his_0825 MUE4 PSI ROOT-NPP (name beamline institute data-file-f fittype 0 (single histogram fit) norm fun1 backgr.fit 17 -lifetimecorrection map 16 18 0 0 0 0 0 0 0 0 forward 3 data 3289 65000 @@ -69,23 +67,27 @@ SAVE ############################################################### PLOT 0 (single histo plot) +lifetimecorrection runs 1 2 range 0 9 -0.3 0.3 view_packing 500 ############################################################### FOURIER -units Gauss # units either 'Gauss', 'MHz', or 'Mc/s' +units Gauss # units either 'Gauss', 'Tesla', 'MHz', or 'Mc/s' fourier_power 10 apodization STRONG # NONE, WEAK, MEDIUM, STRONG -plot POWER # REAL, IMAG, REAL_AND_IMAG, POWER, PHASE +plot POWER # REAL, IMAG, REAL_AND_IMAG, POWER, PHASE, PHASE_OPT_REAL phase 8.5 #range_for_phase_correction 50.0 70.0 -range 0.0 200.0 +range 0 200 ############################################################### -STATISTIC --- 2014-11-05 12:34:54 - maxLH = 415.6, NDF = 358, maxLH/NDF = 1.160933 +STATISTIC --- 2021-03-30 15:04:30 + maxLH = 415.6, NDF = 358, maxLH/NDF = 1.160942 + expected maxLH = 418.1, NDF = 358, expected maxLH/NDF = 1.168011 + run block 1: (NDF/red.maxLH/red.maxLH_e) = (177/1.072511/1.087460) + run block 2: (NDF/red.maxLH/red.maxLH_e) = (175/1.290186/1.289528) diff --git a/src/external/Nonlocal/CMakeLists.txt b/src/external/Nonlocal/CMakeLists.txt index f28725cd..8ae7e864 100644 --- a/src/external/Nonlocal/CMakeLists.txt +++ b/src/external/Nonlocal/CMakeLists.txt @@ -2,6 +2,7 @@ #--- generate necessary dictionaries ------------------------------------------ set(MUSRFIT_INC ${CMAKE_SOURCE_DIR}/src/include) +set(MUSRFIT_CLASSES ${CMAKE_SOURCE_DIR}/src/classes) set(NONLOCAL_INC ${CMAKE_SOURCE_DIR}/src/external/Nonlocal) # ROOT requires that the dictonary header files are found at configuration time. # Hence, target_include_directories cannot be used here because, targets are @@ -30,13 +31,24 @@ root_generate_dictionary( LINKDEF PNL_StartupHandlerLinkDef.h MODULE PNL_StartupHandler ) +root_generate_dictionary( + PRgeHandlerDict + PRgeHandler.h + OPTIONS + -I${NONLOCAL_INC} + -I${MUSRFIT_INC} + -I${CMAKE_CURRENT_SOURCE_DIR} + -inlineInputHeader + LINKDEF ${MUSRFIT_INC}/PRgeHandlerLinkDef.h + MODULE PRgeHandler +) #--- create pkg-config info --------------------------------------------------- set(prefix "${CMAKE_INSTALL_PREFIX}") set(exec_prefix "\$\{prefix\}") set(libdir "\$\{exec_prefix\}/lib") set(includedir "\$\{prefix\}/include") -set(PNL_PIPPARDFITTER_VERSION "1.0.0") +set(PNL_PIPPARDFITTER_VERSION "1.1.0") set(PNL_PIPPARDFITTER_LIBRARY_NAME "PNL_PippardFitter") configure_file("PNL_PippardFitter.pc.in" "PNL_PippardFitter.pc" @ONLY) @@ -44,7 +56,8 @@ configure_file("PNL_PippardFitter.pc.in" "PNL_PippardFitter.pc" @ONLY) add_library(PNL_PippardFitter SHARED PNL_PippardFitter.cpp PNL_PippardFitterDict.cxx - PNL_RgeHandler.cpp + ${MUSRFIT_CLASSES}/PRgeHandler.cpp + PRgeHandlerDict.cxx PNL_StartupHandler.cpp PNL_StartupHandlerDict.cxx ) @@ -63,7 +76,7 @@ set_target_properties(PNL_PippardFitter ) #--- add library dependencies ------------------------------------------------- -target_link_libraries(PNL_PippardFitter ${FFTW3_LIBRARY} ${ROOT_LIBRARIES} PUserFcnBase) +target_link_libraries(PNL_PippardFitter ${Boost_LIBRARIES} ${FFTW3_LIBRARY} ${ROOT_LIBRARIES} PUserFcnBase) #--- install PNL_PippardFitter solib ------------------------------------------ install(TARGETS PNL_PippardFitter DESTINATION lib) @@ -73,6 +86,8 @@ install( FILES ${CMAKE_CURRENT_BINARY_DIR}/libPNL_PippardFitter_rdict.pcm ${CMAKE_CURRENT_BINARY_DIR}/libPNL_PippardFitter.rootmap ${CMAKE_CURRENT_BINARY_DIR}/libPNL_StartupHandler_rdict.pcm + ${CMAKE_CURRENT_BINARY_DIR}/libPRgeHandler.rootmap + ${CMAKE_CURRENT_BINARY_DIR}/libPRgeHandler_rdict.pcm ${CMAKE_CURRENT_BINARY_DIR}/libPNL_StartupHandler.rootmap DESTINATION lib ) @@ -80,9 +95,7 @@ install( #--- install PNL_PippardFitter header ----------------------------------------- install( FILES - PNonlocal.h PNL_PippardFitter.h - PNL_RgeHandler.h PNL_StartupHandler.h DESTINATION include diff --git a/src/external/Nonlocal/PNL_PippardFitter.cpp b/src/external/Nonlocal/PNL_PippardFitter.cpp index 290145a9..5f4d630e 100644 --- a/src/external/Nonlocal/PNL_PippardFitter.cpp +++ b/src/external/Nonlocal/PNL_PippardFitter.cpp @@ -31,7 +31,6 @@ #include #include -using namespace std; #include #include @@ -67,8 +66,8 @@ PNL_PippardFitterGlobal::PNL_PippardFitterGlobal() Int_t status = parseXmlFile(saxParser, startup_path_name); // check for parse errors if (status) { // error - cout << endl << ">> PNL_PippardFitterGlobal::PNL_PippardFitterGlobal: **WARNING** Reading/parsing nonlocal_startup.xml failed."; - cout << endl; + std::cout << std::endl << ">> PNL_PippardFitterGlobal::PNL_PippardFitterGlobal: **WARNING** Reading/parsing nonlocal_startup.xml failed."; + std::cout << std::endl; fValid = false; } @@ -80,20 +79,20 @@ PNL_PippardFitterGlobal::PNL_PippardFitterGlobal() // check if everything went fine with the startup handler if (!fStartupHandler->IsValid()) { - cout << endl << ">> PNL_PippardFitterGlobal::PNL_PippardFitterGlobal **PANIC ERROR**"; - cout << endl << ">> startup handler too unhappy. Will terminate unfriendly, sorry."; - cout << endl; + 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; fValid = false; } fFourierPoints = fStartupHandler->GetFourierPoints(); // load all the TRIM.SP rge-files - fRgeHandler = new PNL_RgeHandler(fStartupHandler->GetTrimSpDataPathList(), fStartupHandler->GetTrimSpDataVectorList()); + fRgeHandler = new PRgeHandler("./nonlocal_startup.xml"); if (!fRgeHandler->IsValid()) { - cout << endl << ">> PNL_PippardFitterGlobal::PNL_PippardFitterGlobal **PANIC ERROR**"; - cout << endl << ">> rge data handler too unhappy. Will terminate unfriendly, sorry."; - cout << endl; + std::cout << std::endl << ">> PNL_PippardFitterGlobal::PNL_PippardFitterGlobal **PANIC ERROR**"; + std::cout << std::endl << ">> rge data handler too unhappy. Will terminate unfriendly, sorry."; + std::cout << std::endl; fValid = false; } @@ -182,16 +181,16 @@ void PNL_PippardFitterGlobal::CalculateField(const std::vector ¶m) if (fFieldq == 0) { fFieldq = (fftw_complex *) fftw_malloc(sizeof(fftw_complex) * fFourierPoints); if (fFieldq == 0) { - cout << endl << "PPippard::CalculateField(): **ERROR** couldn't allocate memory for fFieldq"; - cout << endl; + std::cout << std::endl << "PPippard::CalculateField(): **ERROR** couldn't allocate memory for fFieldq"; + std::cout << std::endl; return; } } if (fFieldB == 0) { fFieldB = (fftw_complex *) fftw_malloc(sizeof(fftw_complex) * fFourierPoints); if (fFieldB == 0) { - cout << endl << "PPippard::CalculateField(): **ERROR** couldn't allocate memory for fFieldB"; - cout << endl; + std::cout << std::endl << "PPippard::CalculateField(): **ERROR** couldn't allocate memory for fFieldB"; + std::cout << std::endl; return; } } @@ -387,7 +386,7 @@ PNL_PippardFitter::~PNL_PippardFitter() * \param globalPart * \param idx */ -void PNL_PippardFitter::SetGlobalPart(vector &globalPart, UInt_t idx) +void PNL_PippardFitter::SetGlobalPart(std::vector &globalPart, UInt_t idx) { fIdxGlobal = static_cast(idx); @@ -395,10 +394,10 @@ void PNL_PippardFitter::SetGlobalPart(vector &globalPart, UInt_t idx) fPippardFitterGlobal = new PNL_PippardFitterGlobal(); if (fPippardFitterGlobal == 0) { fValid = false; - cerr << endl << ">> PNL_PippardFitter::SetGlobalPart(): **ERROR** Couldn't invoke global user function object, sorry ..." << endl; + std::cerr << std::endl << ">> PNL_PippardFitter::SetGlobalPart(): **ERROR** Couldn't invoke global user function object, sorry ..." << std::endl; } else if (!fPippardFitterGlobal->IsValid()) { fValid = false; - cerr << endl << ">> PNL_PippardFitter::SetGlobalPart(): **ERROR** initialization of global user function object failed, sorry ..." << endl; + std::cerr << std::endl << ">> PNL_PippardFitter::SetGlobalPart(): **ERROR** initialization of global user function object failed, sorry ..." << std::endl; } else { fValid = true; fInvokedGlobal = true; @@ -447,7 +446,7 @@ Double_t PNL_PippardFitter::operator()(Double_t t, const std::vector & fPippardFitterGlobal->CalculateField(param); Int_t energyIndex = fPippardFitterGlobal->GetEnergyIndex(param[0]); if (energyIndex == -1) { // energy not found - cerr << endl << ">> PNL_PippardFitter::operator() energy " << param[0] << " not found. Will terminate." << endl; + std::cerr << std::endl << ">> PNL_PippardFitter::operator() energy " << param[0] << " not found. Will terminate." << std::endl; assert(0); } diff --git a/src/external/Nonlocal/PNL_PippardFitter.h b/src/external/Nonlocal/PNL_PippardFitter.h index b4ac7f9e..21f4917b 100644 --- a/src/external/Nonlocal/PNL_PippardFitter.h +++ b/src/external/Nonlocal/PNL_PippardFitter.h @@ -36,9 +36,10 @@ //#endif #include +#include "PMusr.h" #include "PUserFcnBase.h" #include "PNL_StartupHandler.h" -#include "PNL_RgeHandler.h" +#include "PRgeHandler.h" class PNL_PippardFitterGlobal { @@ -49,15 +50,15 @@ class PNL_PippardFitterGlobal Bool_t IsValid() { return fValid; } virtual void SetTempExponent(const Double_t nn) { f_nn = nn; } virtual void CalculateField(const std::vector ¶m) const; - virtual Int_t GetEnergyIndex(const Double_t energy) { return fRgeHandler->GetRgeEnergyIndex(energy); } - virtual Double_t GetMuonStoppingDensity(const Int_t energyIndex, const Double_t z) const { return fRgeHandler->GetRgeValue(energyIndex, z); } + virtual Int_t GetEnergyIndex(const Double_t energy) { return fRgeHandler->GetEnergyIndex(energy); } + virtual Double_t GetMuonStoppingDensity(const Int_t energyIndex, const Double_t z) const { return fRgeHandler->Get_n(energyIndex, z); } virtual Double_t GetMagneticField(const Double_t z) const; private: Bool_t fValid; PNL_StartupHandler *fStartupHandler; - PNL_RgeHandler *fRgeHandler; + PRgeHandler *fRgeHandler; mutable std::vector fPreviousParam; @@ -89,7 +90,7 @@ class PNL_PippardFitter : public PUserFcnBase virtual ~PNL_PippardFitter(); virtual Bool_t NeedGlobalPart() const { return true; } - virtual void SetGlobalPart(vector &globalPart, UInt_t idx); + virtual void SetGlobalPart(std::vector &globalPart, UInt_t idx); virtual Bool_t GlobalPartIsValid() const; virtual Double_t operator()(Double_t t, const std::vector ¶m) const; diff --git a/src/external/Nonlocal/PNL_RgeHandler.cpp b/src/external/Nonlocal/PNL_RgeHandler.cpp deleted file mode 100644 index a08aeb89..00000000 --- a/src/external/Nonlocal/PNL_RgeHandler.cpp +++ /dev/null @@ -1,208 +0,0 @@ -/*************************************************************************** - - PNL_RgeHandler.cpp - - Author: Andreas Suter - e-mail: andreas.suter@psi.ch - - $Id$ - -***************************************************************************/ - -/*************************************************************************** - * Copyright (C) 2009 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 - -#include -#include - -#include "PNL_RgeHandler.h" - -//-------------------------------------------------------------------------- -// Constructor -//-------------------------------------------------------------------------- -/** - * - */ -PNL_RgeHandler::PNL_RgeHandler(const PStringVector &rgeDataPathList, const PDoubleVector &rgeDataEnergyList) -{ - fIsValid = false; - - fIsValid = LoadRgeData(rgeDataPathList, rgeDataEnergyList); -} - -//-------------------------------------------------------------------------- -// Destructor -//-------------------------------------------------------------------------- -/** - * - */ -PNL_RgeHandler::~PNL_RgeHandler() -{ - fRgeDataList.clear(); -} - -//-------------------------------------------------------------------------- -// GetRgeEnergyIndex -//-------------------------------------------------------------------------- -/** - * - */ -Int_t PNL_RgeHandler::GetRgeEnergyIndex(const Double_t energy) -{ - Int_t idx = -1; - - for (UInt_t i=0; i dist) { - distIdx = i-1; - break; - } - } - - // get the proper n(z) value - if (distIdx < 0) { - rgeVal = 0.0; - } else { - rgeVal = fRgeDataList[index].stoppingAmplitude[distIdx] + - (fRgeDataList[index].stoppingAmplitude[distIdx+1] - fRgeDataList[index].stoppingAmplitude[distIdx]) * - (dist-fRgeDataList[index].stoppingDistance[distIdx])/(fRgeDataList[index].stoppingDistance[distIdx+1]-fRgeDataList[index].stoppingDistance[distIdx]); - } - - return rgeVal; -} - -//-------------------------------------------------------------------------- -// GetRgeValue -//-------------------------------------------------------------------------- -/** - * - */ -Double_t PNL_RgeHandler::GetRgeValue(const Double_t energy, const Double_t dist) -{ - // check if energy is present in rge data list - Int_t idx = -1; - - for (UInt_t i=0; i #include +#include + #include "PNL_StartupHandler.h" ClassImpQ(PNL_StartupHandler) @@ -44,46 +46,26 @@ ClassImpQ(PNL_StartupHandler) */ PNL_StartupHandler::PNL_StartupHandler() { - fIsValid = true; - - fStartupFileFound = false; - fStartupFilePath = ""; - - fFourierPoints = 0; - fTrimSpDataPath = TString(""); - // get default path (for the moment only linux like) char startup_path_name[512]; char *home_str=0; // check if the startup file is found in the current directory strcpy(startup_path_name, "./nonlocal_startup.xml"); - if (StartupFileExists(startup_path_name)) { + if (boost::filesystem::exists(startup_path_name)) { fStartupFileFound = true; fStartupFilePath = TString(startup_path_name); } else { // startup file is not found in the current directory std::cout << std::endl << "PNL_StartupHandler(): **WARNING** Couldn't find nonlocal_startup.xml in the current directory, will try default one." << std::endl; home_str = getenv("HOME"); snprintf(startup_path_name, sizeof(startup_path_name), "%s/.musrfit/nonlocal_startup.xml", home_str); - if (StartupFileExists(startup_path_name)) { + if (boost::filesystem::exists(startup_path_name)) { fStartupFileFound = true; fStartupFilePath = TString(startup_path_name); } } } -//-------------------------------------------------------------------------- -// Destructor -//-------------------------------------------------------------------------- -/** - * - */ -PNL_StartupHandler::~PNL_StartupHandler() -{ - fTrimSpDataPathList.clear(); - fTrimSpDataEnergyList.clear(); -} - //-------------------------------------------------------------------------- // OnStartDocument //-------------------------------------------------------------------------- @@ -124,10 +106,6 @@ void PNL_StartupHandler::OnStartElement(const char *str, const TList *attributes { if (!strcmp(str, "fourier_points")) { fKey = eFourierPoints; - } else if (!strcmp(str, "data_path")) { - fKey = eDataPath; - } else if (!strcmp(str, "energy")) { - fKey = eEnergy; } } @@ -167,23 +145,6 @@ void PNL_StartupHandler::OnCharacters(const char *str) std::cout << std::endl; } break; - case eDataPath: - fTrimSpDataPath = str; - break; - case eEnergy: - tstr = str; - if (tstr.IsFloat()) { - fTrimSpDataEnergyList.push_back(tstr.Atof()); - tstr = fTrimSpDataPath; - tstr += str; - tstr += ".rge"; - fTrimSpDataPathList.push_back(tstr); - } else { - std::cout << std::endl << "PNL_StartupHandler::OnCharacters: **ERROR** when finding energy:"; - std::cout << std::endl << "\"" << str << "\" is not a floating point number, will ignore it and use the default value."; - std::cout << std::endl; - } - break; default: break; } @@ -257,29 +218,6 @@ void PNL_StartupHandler::OnCdataBlock(const char *str, Int_t len) // nothing to be done for now } -//-------------------------------------------------------------------------- -// StartupFileExists -//-------------------------------------------------------------------------- -/** - *

- * - */ -bool PNL_StartupHandler::StartupFileExists(char *fln) -{ - bool result = false; - - std::ifstream ifile(fln); - - if (ifile.fail()) { - result = false; - } else { - result = true; - ifile.close(); - } - - return result; -} - // ------------------------------------------------------------------------- // end // ------------------------------------------------------------------------- diff --git a/src/external/Nonlocal/PNL_StartupHandler.h b/src/external/Nonlocal/PNL_StartupHandler.h index e70b0614..ea80c2e2 100644 --- a/src/external/Nonlocal/PNL_StartupHandler.h +++ b/src/external/Nonlocal/PNL_StartupHandler.h @@ -5,8 +5,6 @@ Author: Andreas Suter e-mail: andreas.suter@psi.ch - $Id$ - ***************************************************************************/ /*************************************************************************** @@ -36,13 +34,11 @@ #include #include -#include "PNonlocal.h" - class PNL_StartupHandler : public TObject { public: PNL_StartupHandler(); - virtual ~PNL_StartupHandler(); + virtual ~PNL_StartupHandler() {} virtual void OnStartDocument(); // SLOT virtual void OnEndDocument(); // SLOT @@ -58,26 +54,18 @@ class PNL_StartupHandler : public TObject virtual bool IsValid() { return fIsValid; } virtual TString GetStartupFilePath() { return fStartupFilePath; } virtual const Int_t GetFourierPoints() const { return fFourierPoints; } - virtual const PStringVector GetTrimSpDataPathList() const { return fTrimSpDataPathList; } - virtual const PDoubleVector GetTrimSpDataVectorList() const { return fTrimSpDataEnergyList; } - virtual bool StartupFileFound() { return fStartupFileFound; } private: - enum EKeyWords {eEmpty, eComment, eFourierPoints, eDataPath, eEnergy}; + enum EKeyWords {eEmpty, eFourierPoints}; EKeyWords fKey; - bool fIsValid; + bool fIsValid{true}; - bool fStartupFileFound; - TString fStartupFilePath; + bool fStartupFileFound{false}; + TString fStartupFilePath{""}; - Int_t fFourierPoints; - TString fTrimSpDataPath; - PStringVector fTrimSpDataPathList; - PDoubleVector fTrimSpDataEnergyList; - - bool StartupFileExists(char *fln); + Int_t fFourierPoints{0}; ClassDef(PNL_StartupHandler, 1) }; diff --git a/src/external/Nonlocal/PNonlocal.h b/src/external/Nonlocal/PNonlocal.h deleted file mode 100644 index 3a315771..00000000 --- a/src/external/Nonlocal/PNonlocal.h +++ /dev/null @@ -1,65 +0,0 @@ -/*************************************************************************** - - PNonlocal.h - - Author: Andreas Suter - e-mail: andreas.suter@psi.ch - -***************************************************************************/ - -/*************************************************************************** - * Copyright (C) 2009-2021 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 _PNONLOCAL_H_ -#define _PNONLOCAL_H_ - -#include - -#include - -//------------------------------------------------------------- -/** - *

typedef to make to code more readable. - */ -typedef std::vector PStringVector; - -//------------------------------------------------------------- -/** - *

typedef to make to code more readable. - */ -typedef std::vector PDoubleVector; - -//------------------------------------------------------------- -/** - *

- */ -typedef struct { - Double_t energy; - PDoubleVector stoppingDistance; - PDoubleVector stoppingAmplitude; -} PNL_RgeData; - -//------------------------------------------------------------- -/** - *

- */ -typedef std::vector PNL_RgeDataList; - -#endif // _PNONLOCAL_H_ diff --git a/src/external/Nonlocal/nonlocal_startup.xml b/src/external/Nonlocal/nonlocal_startup.xml index 26eaa87d..e66722c7 100644 --- a/src/external/Nonlocal/nonlocal_startup.xml +++ b/src/external/Nonlocal/nonlocal_startup.xml @@ -1,25 +1,27 @@ - trim.sp meta information + Fourier and TrimSp information 262144 - - /afs/psi.ch/project/nemu/analysis/2009/Nonlocal/trimsp/InSne + + ./profiles/ + Sn_E - 2.5 - 4.0 - 6.0 - 8.0 - 10.0 - 12.5 - 14.1 - 17.5 - 22.0 - 25.0 - 28.2 + 1000 + 2000 + 4000 + 6000 + 8000 + 10000 + 12000 + 14100 + 18000 + 22000 + 25000 + 27300 - + From 72c085a0a83583ef8abee1452246a5cd08496b27 Mon Sep 17 00:00:00 2001 From: Andreas Suter Date: Thu, 1 Apr 2021 14:26:26 +0200 Subject: [PATCH 5/9] make PRgeHandler to a shared libs. Adopted Nonlocal and PMagProximity accordingly. --- src/classes/CMakeLists.txt | 38 +++- src/classes/PRgeHandler.pc.in | 10 + src/external/MagProximity/CMakeLists.txt | 4 +- src/external/MagProximity/PMPRgeHandler.cpp | 212 ------------------ src/external/MagProximity/PMPRgeHandler.h | 53 ----- .../MagProximity/PMagProximityFitter.cpp | 2 +- .../MagProximity/PMagProximityFitter.h | 8 +- .../MagProximity/mag_proximity_startup.xml | 7 +- src/external/Nonlocal/CMakeLists.txt | 18 +- 9 files changed, 58 insertions(+), 294 deletions(-) create mode 100644 src/classes/PRgeHandler.pc.in delete mode 100644 src/external/MagProximity/PMPRgeHandler.cpp delete mode 100644 src/external/MagProximity/PMPRgeHandler.h diff --git a/src/classes/CMakeLists.txt b/src/classes/CMakeLists.txt index b7dab816..2aba211a 100644 --- a/src/classes/CMakeLists.txt +++ b/src/classes/CMakeLists.txt @@ -1,4 +1,4 @@ -#--- build the PMusr and PUserFcnBase libs ------------------------------------ +#--- build the PMusr, PUserFcnBase, and PRgeHandler libs ---------------------- #--- generate necessary dictionaries ------------------------------------------ set(MUSRFIT_INC ${CMAKE_SOURCE_DIR}/src/include) @@ -53,6 +53,18 @@ root_generate_dictionary( -I${FFTW3_INCLUDE_DIR} -I${MUSRFIT_INC} MODULE PUserFcnBase ) +root_generate_dictionary( + PRgeHandlerDict + PRgeHandler.h + OPTIONS + -I${NONLOCAL_INC} + -I${MUSRFIT_INC} + -I${CMAKE_CURRENT_SOURCE_DIR} + -inlineInputHeader + LINKDEF ${MUSRFIT_INC}/PRgeHandlerLinkDef.h + MODULE PRgeHandler +) + #--- create pkg-config info --------------------------------------------------- set(prefix "${CMAKE_INSTALL_PREFIX}") @@ -64,6 +76,8 @@ set(MUSR_LIBRARY_NAME "PMusr") configure_file("PMusr.pc.in" "PMusr.pc" @ONLY) set(USERFCN_LIBRARY_NAME "PUserFcnBase") configure_file("PUserFcnBase.pc.in" "PUserFcnBase.pc" @ONLY) +set(PRGEHANDLER_LIBRARY_NAME "PRgeHandler") +configure_file("PRgeHandler.pc.in" "PRgeHandler.pc" @ONLY) #--- lib creation ------------------------------------------------------------- add_library(PMusr SHARED @@ -117,6 +131,11 @@ add_library(PUserFcnBase SHARED PUserFcnBaseDict.cxx ) +add_library(PRgeHandler SHARED + PRgeHandler.cpp + PRgeHandlerDict.cxx +) + #--- set target properties, e.g. version -------------------------------------- set_target_properties(PMusr PROPERTIES @@ -126,11 +145,20 @@ set_target_properties(PUserFcnBase PROPERTIES VERSION ${MUSR_VERSION} ) +set_target_properties(PRgeHandler + PROPERTIES + VERSION ${MUSR_VERSION} +) + #--- make sure that the include directory is found ---------------------------- target_include_directories( PUserFcnBase BEFORE PRIVATE $ ) +target_include_directories( + PRgeHandler BEFORE PRIVATE $ +) + #--- add OpenMP compile options if needed ------------------------------------- if (OpenMP_FOUND) target_compile_options(PMusr PUBLIC ${OpenMP_CXX_FLAGS}) @@ -157,11 +185,15 @@ if (OpenMP_FOUND) endif (OpenMP_FOUND) target_link_libraries(PUserFcnBase ${ROOT_LIBRARIES}) +target_link_libraries(PRgeHandler ${ROOT_LIBRARIES}) target_link_libraries(PMusr ${DependOnLibs}) #--- install PUserFcnBase solib ----------------------------------------------- install(TARGETS PUserFcnBase DESTINATION lib) +#--- install PRgeHandler solib ----------------------------------------------- +install(TARGETS PRgeHandler DESTINATION lib) + #--- install PMusr solib ------------------------------------------------------ install(TARGETS PMusr DESTINATION lib) @@ -173,6 +205,8 @@ install( ${CMAKE_CURRENT_BINARY_DIR}/libPMusrCanvas.rootmap ${CMAKE_CURRENT_BINARY_DIR}/libPMusrT0_rdict.pcm ${CMAKE_CURRENT_BINARY_DIR}/libPMusrT0.rootmap + ${CMAKE_CURRENT_BINARY_DIR}/libPRgeHandler_rdict.pcm + ${CMAKE_CURRENT_BINARY_DIR}/libPRgeHandler.rootmap ${CMAKE_CURRENT_BINARY_DIR}/libPStartupHandler_rdict.pcm ${CMAKE_CURRENT_BINARY_DIR}/libPStartupHandler.rootmap ${CMAKE_CURRENT_BINARY_DIR}/libPUserFcnBase_rdict.pcm @@ -195,6 +229,7 @@ install( ${MUSRFIT_INC}/PMusr.h ${MUSRFIT_INC}/PMusrT0.h ${MUSRFIT_INC}/PPrepFourier.h + ${MUSRFIT_INC}/PRgeHandler.h ${MUSRFIT_INC}/PRunAsymmetry.h ${MUSRFIT_INC}/PRunAsymmetryBNMR.h ${MUSRFIT_INC}/PRunAsymmetryRRF.h @@ -214,6 +249,7 @@ install( #--- install pkg-config info -------------------------------------------------- install( FILES ${CMAKE_CURRENT_BINARY_DIR}/PUserFcnBase.pc + ${CMAKE_CURRENT_BINARY_DIR}/PRgeHandler.pc ${CMAKE_CURRENT_BINARY_DIR}/PMusr.pc DESTINATION lib/pkgconfig ) diff --git a/src/classes/PRgeHandler.pc.in b/src/classes/PRgeHandler.pc.in new file mode 100644 index 00000000..674345df --- /dev/null +++ b/src/classes/PRgeHandler.pc.in @@ -0,0 +1,10 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: PRgeHandler +Description: C++ shared library providing the support for handling of TrimSP rge-files +Version: @MUSR_VERSION@ +Libs: -L${libdir} -l@PRGEHANDLER_LIBRARY_NAME@ +Cflags: -I${includedir} diff --git a/src/external/MagProximity/CMakeLists.txt b/src/external/MagProximity/CMakeLists.txt index 2e09a573..9da18aa6 100644 --- a/src/external/MagProximity/CMakeLists.txt +++ b/src/external/MagProximity/CMakeLists.txt @@ -38,7 +38,6 @@ configure_file("PMagProximityFitter.pc.in" "PMagProximityFitter.pc" @ONLY) add_library(PMagProximityFitter SHARED PMagProximityFitter.cpp PMagProximityFitterDict.cxx - PMPRgeHandler.cpp PMPStartupHandler.cpp PMPStartupHandlerDict.cxx ) @@ -57,7 +56,7 @@ set_target_properties(PMagProximityFitter ) #--- add library dependencies ------------------------------------------------- -target_link_libraries(PMagProximityFitter ${FFTW3_LIBRARY} ${ROOT_LIBRARIES} PUserFcnBase) +target_link_libraries(PMagProximityFitter ${FFTW3_LIBRARY} ${ROOT_LIBRARIES} PRgeHandler PUserFcnBase) #--- install PMagProximityFitter solib ---------------------------------------- install(TARGETS PMagProximityFitter DESTINATION lib) @@ -76,7 +75,6 @@ install( FILES PMagProximity.h PMagProximityFitter.h - PMPRgeHandler.h PMPStartupHandler.h DESTINATION include diff --git a/src/external/MagProximity/PMPRgeHandler.cpp b/src/external/MagProximity/PMPRgeHandler.cpp deleted file mode 100644 index fad7a898..00000000 --- a/src/external/MagProximity/PMPRgeHandler.cpp +++ /dev/null @@ -1,212 +0,0 @@ -/*************************************************************************** - - PMPRgeHandler.cpp - - Author: Andreas Suter - e-mail: andreas.suter@psi.ch - -***************************************************************************/ - -/*************************************************************************** - * Copyright (C) 2011-2021 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 - -#include -#include - -#include "PMPRgeHandler.h" - -//-------------------------------------------------------------------------- -// Constructor -//-------------------------------------------------------------------------- -/** - * - */ -PMPRgeHandler::PMPRgeHandler(const PStringVector &rgeDataPathList, const PDoubleVector &rgeDataEnergyList) -{ - fIsValid = false; - - fIsValid = LoadRgeData(rgeDataPathList, rgeDataEnergyList); -} - -//-------------------------------------------------------------------------- -// Destructor -//-------------------------------------------------------------------------- -/** - * - */ -PMPRgeHandler::~PMPRgeHandler() -{ - fRgeDataList.clear(); -} - -//-------------------------------------------------------------------------- -// GetRgeEnergyIndex -//-------------------------------------------------------------------------- -/** - * - * \param energy in (keV) - */ -Int_t PMPRgeHandler::GetRgeEnergyIndex(const Double_t energy) -{ - Int_t idx = -1; - - for (UInt_t i=0; i(dist/(fRgeDataList[index].stoppingDistance[1]-fRgeDataList[index].stoppingDistance[0])); - - if (distIdx >= fRgeDataList[index].stoppingDistance.size()) { - rgeVal = 0.0; - } else { - rgeVal = fRgeDataList[index].stoppingAmplitude[distIdx] + - (fRgeDataList[index].stoppingAmplitude[distIdx+1] - fRgeDataList[index].stoppingAmplitude[distIdx]) * - (dist-fRgeDataList[index].stoppingDistance[distIdx])/(fRgeDataList[index].stoppingDistance[distIdx+1]-fRgeDataList[index].stoppingDistance[distIdx]); - } - - return rgeVal; -} - -//-------------------------------------------------------------------------- -// GetRgeValue -//-------------------------------------------------------------------------- -/** - * - * \param energy in (keV) - * \param dist in (nm) - */ -Double_t PMPRgeHandler::GetRgeValue(const Double_t energy, const Double_t dist) -{ - // check if energy is present in rge data list - Int_t idx = -1; - - for (UInt_t i=0; iGetTrimSpDataPathList(), fStartupHandler->GetTrimSpDataVectorList()); + fRgeHandler = new PRgeHandler(); if (!fRgeHandler->IsValid()) { std::cout << std::endl << ">> PMagProximityFitterGlobal::PMagProximityFitterGlobal **PANIC ERROR**"; std::cout << std::endl << ">> rge data handler too unhappy. Will terminate unfriendly, sorry."; diff --git a/src/external/MagProximity/PMagProximityFitter.h b/src/external/MagProximity/PMagProximityFitter.h index cdcce124..fdd34d63 100644 --- a/src/external/MagProximity/PMagProximityFitter.h +++ b/src/external/MagProximity/PMagProximityFitter.h @@ -32,7 +32,7 @@ #include "PUserFcnBase.h" #include "PMPStartupHandler.h" -#include "PMPRgeHandler.h" +#include "PRgeHandler.h" class PMagProximityFitterGlobal { @@ -42,15 +42,15 @@ class PMagProximityFitterGlobal Bool_t IsValid() { return fValid; } virtual void CalculateField(const std::vector ¶m) const; - virtual Int_t GetEnergyIndex(const Double_t energy) { return fRgeHandler->GetRgeEnergyIndex(energy); } - virtual Double_t GetMuonStoppingDensity(const Int_t energyIndex, const Double_t z) const { return fRgeHandler->GetRgeValue(energyIndex, z); } + virtual Int_t GetEnergyIndex(const Double_t energy) { return fRgeHandler->GetEnergyIndex(energy); } + virtual Double_t GetMuonStoppingDensity(const Int_t energyIndex, const Double_t z) const { return fRgeHandler->Get_n(energyIndex, z); } virtual Double_t GetMagneticField(const Double_t z) const; private: Bool_t fValid; PMPStartupHandler *fStartupHandler; - PMPRgeHandler *fRgeHandler; + PRgeHandler *fRgeHandler; mutable std::vector fPreviousParam; diff --git a/src/external/MagProximity/mag_proximity_startup.xml b/src/external/MagProximity/mag_proximity_startup.xml index d23326f3..402ac07e 100644 --- a/src/external/MagProximity/mag_proximity_startup.xml +++ b/src/external/MagProximity/mag_proximity_startup.xml @@ -3,13 +3,14 @@ contains meta file infromation of the needed trim.sp files. - - /mnt/home/nemu/analysis/2010/EuS-Co/trimsp2/EuS-Co_E + + /afs/psi.ch/project/nemu/analysis/2010/EuS-Co/trimsp2 + EuS-Co_E 5030 6330 7530 8730 - + diff --git a/src/external/Nonlocal/CMakeLists.txt b/src/external/Nonlocal/CMakeLists.txt index 8ae7e864..d35d5c41 100644 --- a/src/external/Nonlocal/CMakeLists.txt +++ b/src/external/Nonlocal/CMakeLists.txt @@ -2,7 +2,6 @@ #--- generate necessary dictionaries ------------------------------------------ set(MUSRFIT_INC ${CMAKE_SOURCE_DIR}/src/include) -set(MUSRFIT_CLASSES ${CMAKE_SOURCE_DIR}/src/classes) set(NONLOCAL_INC ${CMAKE_SOURCE_DIR}/src/external/Nonlocal) # ROOT requires that the dictonary header files are found at configuration time. # Hence, target_include_directories cannot be used here because, targets are @@ -31,17 +30,6 @@ root_generate_dictionary( LINKDEF PNL_StartupHandlerLinkDef.h MODULE PNL_StartupHandler ) -root_generate_dictionary( - PRgeHandlerDict - PRgeHandler.h - OPTIONS - -I${NONLOCAL_INC} - -I${MUSRFIT_INC} - -I${CMAKE_CURRENT_SOURCE_DIR} - -inlineInputHeader - LINKDEF ${MUSRFIT_INC}/PRgeHandlerLinkDef.h - MODULE PRgeHandler -) #--- create pkg-config info --------------------------------------------------- set(prefix "${CMAKE_INSTALL_PREFIX}") @@ -56,8 +44,6 @@ configure_file("PNL_PippardFitter.pc.in" "PNL_PippardFitter.pc" @ONLY) add_library(PNL_PippardFitter SHARED PNL_PippardFitter.cpp PNL_PippardFitterDict.cxx - ${MUSRFIT_CLASSES}/PRgeHandler.cpp - PRgeHandlerDict.cxx PNL_StartupHandler.cpp PNL_StartupHandlerDict.cxx ) @@ -76,7 +62,7 @@ set_target_properties(PNL_PippardFitter ) #--- add library dependencies ------------------------------------------------- -target_link_libraries(PNL_PippardFitter ${Boost_LIBRARIES} ${FFTW3_LIBRARY} ${ROOT_LIBRARIES} PUserFcnBase) +target_link_libraries(PNL_PippardFitter ${Boost_LIBRARIES} ${FFTW3_LIBRARY} ${ROOT_LIBRARIES} PRgeHandler PUserFcnBase) #--- install PNL_PippardFitter solib ------------------------------------------ install(TARGETS PNL_PippardFitter DESTINATION lib) @@ -86,8 +72,6 @@ install( FILES ${CMAKE_CURRENT_BINARY_DIR}/libPNL_PippardFitter_rdict.pcm ${CMAKE_CURRENT_BINARY_DIR}/libPNL_PippardFitter.rootmap ${CMAKE_CURRENT_BINARY_DIR}/libPNL_StartupHandler_rdict.pcm - ${CMAKE_CURRENT_BINARY_DIR}/libPRgeHandler.rootmap - ${CMAKE_CURRENT_BINARY_DIR}/libPRgeHandler_rdict.pcm ${CMAKE_CURRENT_BINARY_DIR}/libPNL_StartupHandler.rootmap DESTINATION lib ) From cab8703f8597da794a5bd9b19512a599087c0a0c Mon Sep 17 00:00:00 2001 From: Andreas Suter Date: Thu, 1 Apr 2021 20:30:53 +0200 Subject: [PATCH 6/9] fix an error number of theory points for the view data. --- src/classes/PRunAsymmetry.cpp | 2 +- src/classes/PRunSingleHisto.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/classes/PRunAsymmetry.cpp b/src/classes/PRunAsymmetry.cpp index 1a9f3d72..71e3caad 100644 --- a/src/classes/PRunAsymmetry.cpp +++ b/src/classes/PRunAsymmetry.cpp @@ -1297,7 +1297,7 @@ Bool_t PRunAsymmetry::PrepareViewData(PRawRunData* runData, UInt_t histoNo[2]) // calculate theory Double_t time; - UInt_t size = runData->GetDataBin(histoNo[0])->size(); + UInt_t size = runData->GetDataBin(histoNo[0])->size()/packing; Int_t factor = 8; // 8 times more points for the theory (if fTheoAsData == false) fData.SetTheoryTimeStart(fData.GetDataTimeStart()); diff --git a/src/classes/PRunSingleHisto.cpp b/src/classes/PRunSingleHisto.cpp index 6aab2152..72c8c17e 100644 --- a/src/classes/PRunSingleHisto.cpp +++ b/src/classes/PRunSingleHisto.cpp @@ -1315,7 +1315,7 @@ Bool_t PRunSingleHisto::PrepareViewData(PRawRunData* runData, const UInt_t histo // calculate theory Double_t theoryValue; - UInt_t size = fForward.size(); + UInt_t size = fForward.size()/packing; Int_t factor = 8; // 8 times more points for the theory (if fTheoAsData == false) UInt_t rebinRRF = 0; From 56f094dad06183703c36f335d344e53c6b4522c9 Mon Sep 17 00:00:00 2001 From: Andreas Suter Date: Thu, 1 Apr 2021 20:37:08 +0200 Subject: [PATCH 7/9] slightly improved the rge handler. --- src/classes/CMakeLists.txt | 2 +- src/classes/PRgeHandler.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/classes/CMakeLists.txt b/src/classes/CMakeLists.txt index 2aba211a..eb822ebf 100644 --- a/src/classes/CMakeLists.txt +++ b/src/classes/CMakeLists.txt @@ -185,7 +185,7 @@ if (OpenMP_FOUND) endif (OpenMP_FOUND) target_link_libraries(PUserFcnBase ${ROOT_LIBRARIES}) -target_link_libraries(PRgeHandler ${ROOT_LIBRARIES}) +target_link_libraries(PRgeHandler ${Boost_LIBRARIES} ${ROOT_LIBRARIES}) target_link_libraries(PMusr ${DependOnLibs}) #--- install PUserFcnBase solib ----------------------------------------------- diff --git a/src/classes/PRgeHandler.cpp b/src/classes/PRgeHandler.cpp index 8c2e44bc..224746f3 100644 --- a/src/classes/PRgeHandler.cpp +++ b/src/classes/PRgeHandler.cpp @@ -536,10 +536,10 @@ Double_t PRgeHandler::Get_n(const Double_t energy, const Double_t z) break; } } - if (idx != -1) - return Get_n(idx, z); + if (idx == -1) + return 0.0; - return -1.0; + return Get_n(idx, z); } //-------------------------------------------------------------------------- @@ -555,7 +555,7 @@ Double_t PRgeHandler::Get_n(const Double_t energy, const Double_t z) Double_t PRgeHandler::Get_n(const Int_t idx, const Double_t z) { if ((idx < 0) || (idx >= fData.size())) - return -1.0; + return 0.0; if ((z < 0.0) || (z > GetZmax(idx))) return 0.0; @@ -570,7 +570,7 @@ Double_t PRgeHandler::Get_n(const Int_t idx, const Double_t z) Double_t nn=0.0; if (pos < 0) { - nn = 0.0; + nn = fData[idx].nn[0] * z/(fData[idx].depth[1]-fData[idx].depth[0]); } else { // linear interpolation nn = fData[idx].nn[pos] + (fData[idx].nn[pos+1] - fData[idx].nn[pos]) * From 7de55705d201c5da01a0e5011fefbaf99a71b379 Mon Sep 17 00:00:00 2001 From: Andreas Suter Date: Thu, 1 Apr 2021 20:38:32 +0200 Subject: [PATCH 8/9] slightly more modern c++ init style. --- src/external/Nonlocal/PNL_PippardFitter.cpp | 19 +------------------ src/external/Nonlocal/PNL_PippardFitter.h | 14 +++++++------- 2 files changed, 8 insertions(+), 25 deletions(-) diff --git a/src/external/Nonlocal/PNL_PippardFitter.cpp b/src/external/Nonlocal/PNL_PippardFitter.cpp index 5f4d630e..7a751332 100644 --- a/src/external/Nonlocal/PNL_PippardFitter.cpp +++ b/src/external/Nonlocal/PNL_PippardFitter.cpp @@ -50,10 +50,6 @@ ClassImp(PNL_PippardFitterGlobal) */ PNL_PippardFitterGlobal::PNL_PippardFitterGlobal() { - fValid = true; - fStartupHandler = 0; - fRgeHandler = 0; - // read XML startup file char startup_path_name[128]; TSAXParser *saxParser = new TSAXParser(); @@ -348,19 +344,6 @@ Double_t PNL_PippardFitterGlobal::XiP_T(const Double_t xi0, const Double_t meanF ClassImp(PNL_PippardFitter) -//-------------------------------------------------------------------------- -// Constructor -//-------------------------------------------------------------------------- -/** - * - */ -PNL_PippardFitter::PNL_PippardFitter() -{ - fValid = false; - fInvokedGlobal = false; - fPippardFitterGlobal = 0; -} - //-------------------------------------------------------------------------- // Destructor //-------------------------------------------------------------------------- @@ -392,7 +375,7 @@ void PNL_PippardFitter::SetGlobalPart(std::vector &globalPart, UInt_t idx if ((Int_t)globalPart.size() <= fIdxGlobal) { fPippardFitterGlobal = new PNL_PippardFitterGlobal(); - if (fPippardFitterGlobal == 0) { + if (fPippardFitterGlobal == nullptr) { fValid = false; std::cerr << std::endl << ">> PNL_PippardFitter::SetGlobalPart(): **ERROR** Couldn't invoke global user function object, sorry ..." << std::endl; } else if (!fPippardFitterGlobal->IsValid()) { diff --git a/src/external/Nonlocal/PNL_PippardFitter.h b/src/external/Nonlocal/PNL_PippardFitter.h index 21f4917b..c026f908 100644 --- a/src/external/Nonlocal/PNL_PippardFitter.h +++ b/src/external/Nonlocal/PNL_PippardFitter.h @@ -55,10 +55,10 @@ class PNL_PippardFitterGlobal virtual Double_t GetMagneticField(const Double_t z) const; private: - Bool_t fValid; + Bool_t fValid{true}; - PNL_StartupHandler *fStartupHandler; - PRgeHandler *fRgeHandler; + PNL_StartupHandler *fStartupHandler{nullptr}; + PRgeHandler *fRgeHandler{nullptr}; mutable std::vector fPreviousParam; @@ -86,7 +86,7 @@ class PNL_PippardFitterGlobal class PNL_PippardFitter : public PUserFcnBase { public: - PNL_PippardFitter(); + PNL_PippardFitter() {} virtual ~PNL_PippardFitter(); virtual Bool_t NeedGlobalPart() const { return true; } @@ -96,11 +96,11 @@ class PNL_PippardFitter : public PUserFcnBase virtual Double_t operator()(Double_t t, const std::vector ¶m) const; private: - Bool_t fValid; - Bool_t fInvokedGlobal; + Bool_t fValid{true}; + Bool_t fInvokedGlobal{false}; Int_t fIdxGlobal; - PNL_PippardFitterGlobal *fPippardFitterGlobal; + PNL_PippardFitterGlobal *fPippardFitterGlobal{nullptr}; ClassDef(PNL_PippardFitter, 1) }; From 7089e4b3d6f030d02925aebc042584681c7bbdb1 Mon Sep 17 00:00:00 2001 From: Andreas Suter Date: Thu, 1 Apr 2021 20:41:00 +0200 Subject: [PATCH 9/9] switched libPhotoMeissner to the new centralized PRgeHandler. --- .../libPhotoMeissner/classes/CMakeLists.txt | 17 +- .../classes/PPhotoMeissner.cpp | 68 +-- .../classes/PStartupHandler_PM.cpp | 507 ------------------ .../libPhotoMeissner/include/PPhotoMeissner.h | 8 +- .../include/PStartupHandler_PM.h | 139 ----- .../include/PStartupHandler_PMLinkDef.h | 38 -- .../test/photoMeissner_startup.xml | 7 +- 7 files changed, 26 insertions(+), 758 deletions(-) delete mode 100644 src/external/libPhotoMeissner/classes/PStartupHandler_PM.cpp delete mode 100644 src/external/libPhotoMeissner/include/PStartupHandler_PM.h delete mode 100644 src/external/libPhotoMeissner/include/PStartupHandler_PMLinkDef.h diff --git a/src/external/libPhotoMeissner/classes/CMakeLists.txt b/src/external/libPhotoMeissner/classes/CMakeLists.txt index 2cbb7432..6e7b1ba1 100644 --- a/src/external/libPhotoMeissner/classes/CMakeLists.txt +++ b/src/external/libPhotoMeissner/classes/CMakeLists.txt @@ -21,16 +21,6 @@ root_generate_dictionary( LINKDEF ${PHOTO_MEISSNER_INC}/PPhotoMeissnerLinkDef.h MODULE PPhotoMeissner ) -root_generate_dictionary( - PStartupHandler_PMDict - PStartupHandler_PM.h - OPTIONS - -I${MUSRFIT_INC} - -I${PHOTO_MEISSNER_INC} - -inlineInputHeader - LINKDEF ${PHOTO_MEISSNER_INC}/PStartupHandler_PMLinkDef.h - MODULE PStartupHandler_PM -) #--- create pkg-config info --------------------------------------------------- set(prefix "${CMAKE_INSTALL_PREFIX}") @@ -45,8 +35,6 @@ configure_file("PPhotoMeissner.pc.in" "PPhotoMeissner.pc" @ONLY) add_library(PPhotoMeissner SHARED PPhotoMeissner.cpp PPhotoMeissnerDict.cxx - PStartupHandler_PM.cpp - PStartupHandler_PMDict.cxx ) #--- set target properties, e.g. version -------------------------------------- @@ -67,7 +55,7 @@ target_include_directories( #--- add library dependencies ------------------------------------------------- target_link_libraries(PPhotoMeissner - ${FFTW3_LIBRARY} ${GSL_LIBRARY} ${ROOT_LIBRARIES} PUserFcnBase + ${FFTW3_LIBRARY} ${GSL_LIBRARY} ${ROOT_LIBRARIES} PRgeHandler PUserFcnBase ) #--- install PPhotoMeissner solib --------------------------------------------- @@ -77,8 +65,6 @@ install(TARGETS PPhotoMeissner DESTINATION lib) install( FILES ${CMAKE_CURRENT_BINARY_DIR}/libPPhotoMeissner_rdict.pcm ${CMAKE_CURRENT_BINARY_DIR}/libPPhotoMeissner.rootmap - ${CMAKE_CURRENT_BINARY_DIR}/libPStartupHandler_PM_rdict.pcm - ${CMAKE_CURRENT_BINARY_DIR}/libPStartupHandler_PM.rootmap DESTINATION lib ) @@ -86,7 +72,6 @@ install( install( FILES ${CMAKE_CURRENT_SOURCE_DIR}/../include/PPhotoMeissner.h - ${CMAKE_CURRENT_SOURCE_DIR}/../include/PStartupHandler_PM.h DESTINATION include ) diff --git a/src/external/libPhotoMeissner/classes/PPhotoMeissner.cpp b/src/external/libPhotoMeissner/classes/PPhotoMeissner.cpp index 4eab5d46..670504a0 100644 --- a/src/external/libPhotoMeissner/classes/PPhotoMeissner.cpp +++ b/src/external/libPhotoMeissner/classes/PPhotoMeissner.cpp @@ -8,7 +8,7 @@ ***************************************************************************/ /*************************************************************************** - * Copyright (C) 2013 by Andreas Suter * + * Copyright (C) 2013-2021 by Andreas Suter * * andreas.suter@psi.ch * * * * This program is free software; you can redistribute it and/or modify * @@ -30,15 +30,11 @@ #include #include #include -using namespace std; #include -#include - #include "PMusr.h" - -#include "../include/PPhotoMeissner.h" +#include "PPhotoMeissner.h" ClassImp(PPhotoMeissner) // for ROOT dictionary @@ -51,38 +47,14 @@ ClassImp(PPhotoMeissner) // for ROOT dictionary */ PPhotoMeissner::PPhotoMeissner() { - // init - fStartupHandler = 0; - fValid = true; - // read XML startup file - char startup_path_name[128]; - TSAXParser *saxParser = new TSAXParser(); - fStartupHandler = new PStartupHandler_PM(); - strcpy(startup_path_name, fStartupHandler->GetStartupFilePath().Data()); - saxParser->ConnectToHandler("PStartupHandler_PM", fStartupHandler); - //Int_t status = saxParser->ParseFile(startup_path_name); - // parsing the file as above seems to lead to problems in certain environments; - // use the parseXmlFile function instead (see PUserFcnBase.cpp for the definition) - Int_t status = parseXmlFile(saxParser, startup_path_name); - // check for parse errors - if (status) { // error - cout << endl << ">> PPhotoMeissner::PPhotoMeissner: **WARNING** Reading/parsing photoMeissner_startup.xml failed."; - cout << endl; - fValid = false; - } - - // clean up - if (saxParser) { - delete saxParser; - saxParser = 0; - } + fRgeHandler = new PRgeHandler("./photoMeissner_startup.xml"); // check if everything went fine with the startup handler - if (!fStartupHandler->IsValid()) { - cout << endl << ">> PPhotoMeissner::PPhotoMeissner **PANIC ERROR**"; - cout << endl << ">> startup handler too unhappy. Will terminate unfriendly, sorry."; - cout << endl; + if (!fRgeHandler->IsValid()) { + std::cout << std::endl << ">> PPhotoMeissner::PPhotoMeissner **PANIC ERROR**"; + std::cout << std::endl << ">> startup handler too unhappy. Will terminate unfriendly, sorry."; + std::cout << std::endl; fValid = false; } } @@ -95,8 +67,8 @@ PPhotoMeissner::PPhotoMeissner() */ PPhotoMeissner::~PPhotoMeissner() { - if (fStartupHandler) - delete fStartupHandler; + if (fRgeHandler) + delete fRgeHandler; } //-------------------------------------------------------------------------- @@ -108,9 +80,9 @@ PPhotoMeissner::~PPhotoMeissner() * \param t * \param par */ -Double_t PPhotoMeissner::operator()(Double_t t, const vector &par) const +Double_t PPhotoMeissner::operator()(Double_t t, const std::vector &par) const { - // expected parameters: (0) implantation energy (kV), (1) dead layer (nm), (2) Bext (G), (3) lambdaLondon (nm), + // expected parameters: (0) implantation energy (eV), (1) dead layer (nm), (2) Bext (G), (3) lambdaLondon (nm), // (4) lambdaPhoto (nm), (5) z0 (nm), (6) detector phase (°), [(7) layer thickness] assert((par.size() == 7) || (par.size() == 8)); @@ -122,39 +94,33 @@ Double_t PPhotoMeissner::operator()(Double_t t, const vector &par) con Double_t dz = 1.0; // go in 1A steps Double_t zz = 0.0; Double_t nn = 0.0; - Double_t sum = 0.0; Double_t BB = 0.0; Double_t gamma = fTwoPi*GAMMA_BAR_MUON; + int idx = fRgeHandler->GetEnergyIndex(par[0]); int done = 0; if (par.size() == 7) { // semi-infinite sample do { - nn = fStartupHandler->GetRgeValue(par[0], zz); + nn = fRgeHandler->Get_n(idx, zz); BB = FieldHalfSpace(zz, par); result += nn*cos(gamma*BB*t+fDegToRad*par[6]); zz += dz; - sum += nn; if (nn == 0.0) done++; } while (done < 5); } else { // film do { - nn = fStartupHandler->GetRgeValue(par[0], zz); + nn = fRgeHandler->Get_n(idx, zz); BB = FieldFilm(zz, par); result += nn*cos(gamma*BB*t+fDegToRad*par[6]); zz += dz; - sum += nn; if (nn == 0.0) done++; } while (done < 5); } - if (sum == 0.0) { - cerr << endl << ">> PPhotoMeissner::operator(): **PANIC ERROR** sum of RGE values == 0!" << endl; - assert(0); - } - return result/sum; + return result; } //-------------------------------------------------------------------------- @@ -180,7 +146,7 @@ Double_t PPhotoMeissner::InuMinus(const Double_t nu, const Double_t x) const * * \param par */ -Double_t PPhotoMeissner::FieldFilm(const Double_t z, const vector &par) const +Double_t PPhotoMeissner::FieldFilm(const Double_t z, const std::vector &par) const { // prevent dividing by zero double lamL = par[3]; @@ -217,7 +183,7 @@ Double_t PPhotoMeissner::FieldFilm(const Double_t z, const vector &par * * \param par */ -Double_t PPhotoMeissner::FieldHalfSpace(const Double_t z, const vector &par) const +Double_t PPhotoMeissner::FieldHalfSpace(const Double_t z, const std::vector &par) const { // prevent dividing by zero double lamL = par[3]; diff --git a/src/external/libPhotoMeissner/classes/PStartupHandler_PM.cpp b/src/external/libPhotoMeissner/classes/PStartupHandler_PM.cpp deleted file mode 100644 index 3a02c0e4..00000000 --- a/src/external/libPhotoMeissner/classes/PStartupHandler_PM.cpp +++ /dev/null @@ -1,507 +0,0 @@ -/*************************************************************************** - - PStartupHandler_PM.cpp - - Author: Andreas Suter - e-mail: andreas.suter@psi.ch - -***************************************************************************/ - -/*************************************************************************** - * Copyright (C) 2013-2021 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 - -#include -#include - -#include "PStartupHandler_PM.h" - -//-------------------------------------------------------------------------- -// Constructor -//-------------------------------------------------------------------------- -/** - * - */ -PRgeHandler_PM::PRgeHandler_PM(const PStringVector &rgeDataPathList, const PDoubleVector &rgeDataEnergyList) -{ - fIsValid = false; - - fIsValid = LoadRgeData(rgeDataPathList, rgeDataEnergyList); -} - -//-------------------------------------------------------------------------- -// Destructor -//-------------------------------------------------------------------------- -/** - * - */ -PRgeHandler_PM::~PRgeHandler_PM() -{ - fRgeDataList.clear(); -} - -//-------------------------------------------------------------------------- -// GetRgeEnergyIndex -//-------------------------------------------------------------------------- -/** - * - * \param energy in (keV) - */ -Int_t PRgeHandler_PM::GetRgeEnergyIndex(const Double_t energy) -{ - Int_t idx = -1; - - for (UInt_t i=0; i(dist/(fRgeDataList[index].stoppingDistance[1]-fRgeDataList[index].stoppingDistance[0])); - - if (distIdx >= fRgeDataList[index].stoppingDistance.size()) { - rgeVal = 0.0; - } else { - rgeVal = fRgeDataList[index].stoppingAmplitude[distIdx] + - (fRgeDataList[index].stoppingAmplitude[distIdx+1] - fRgeDataList[index].stoppingAmplitude[distIdx]) * - (dist-fRgeDataList[index].stoppingDistance[distIdx])/(fRgeDataList[index].stoppingDistance[distIdx+1]-fRgeDataList[index].stoppingDistance[distIdx]); - } - - return rgeVal; -} - -//-------------------------------------------------------------------------- -// GetRgeValue -//-------------------------------------------------------------------------- -/** - * - * \param energy in (keV) - * \param dist in (nm) - */ -Double_t PRgeHandler_PM::GetRgeValue(const Double_t energy, const Double_t dist) -{ - // check if energy is present in rge data list - Int_t idx = -1; - - for (UInt_t i=0; i> PStartupHandler_PM(): **WARNING** Couldn't find photoMeissner_startup.xml in the current directory, will try default one." << std::endl; - home_path = getenv("HOME"); - snprintf(startup_path_name, sizeof(startup_path_name), "%s/.musrfit/external/photoMeissner_startup.xml", home_path); - if (StartupFileExists(startup_path_name)) { - fStartupFileFound = true; - fStartupFilePath = TString(startup_path_name); - } - } - - // init RGE handler - fRgeHandler = nullptr; -} - -//-------------------------------------------------------------------------- -// OnStartDocument -//-------------------------------------------------------------------------- -/** - *

- */ -void PStartupHandler_PM::OnStartDocument() -{ - fKey = eEmpty; -} - -//-------------------------------------------------------------------------- -// OnEndDocument -//-------------------------------------------------------------------------- -/** - *

- */ -void PStartupHandler_PM::OnEndDocument() -{ - if (!fIsValid) - return; - - // generate the file path list - TString str; - for (unsigned int i=0; i> PStartupHandler_PM::OnEndDocument(): **ERROR** couldn't invoke RGE handler." << std::endl << std::endl; - return; - } - - if (!fRgeHandler->IsValid()) { // severe problem - fIsValid = false; - std::cerr << std::endl << ">> PStartupHandler_PM::OnEndDocument(): **ERROR** RGE handler not valid." << std::endl << std::endl; - return; - } -} - -//-------------------------------------------------------------------------- -// OnStartElement -//-------------------------------------------------------------------------- -/** - *

- * - * \param str - * \param attributes - */ -void PStartupHandler_PM::OnStartElement(const char *str, const TList *attributes) -{ - if (!strcmp(str, "data_path")) { - fKey = eDataPath; - } else if (!strcmp(str, "energy")) { - fKey = eEnergy; - } -} - -//-------------------------------------------------------------------------- -// OnEndElement -//-------------------------------------------------------------------------- -/** - *

- * - * \param str - */ -void PStartupHandler_PM::OnEndElement(const char *str) -{ - fKey = eEmpty; -} - -//-------------------------------------------------------------------------- -// OnCharacters -//-------------------------------------------------------------------------- -/** - *

- * - * \param str - */ -void PStartupHandler_PM::OnCharacters(const char *str) -{ - TString tstr; - Double_t dval; - - switch (fKey) { - case eDataPath: - fRgePath = str; - break; - case eEnergy: - tstr = str; - if (tstr.IsFloat()) { - dval = tstr.Atof(); - fRgeDataEnergyList.push_back(dval); - } else { - std::cerr << std::endl << "PStartupHandler_PM::OnCharacters: **ERROR** when finding energy:"; - std::cerr << std::endl << "\"" << str << "\" is not a floating point number, will ignore it."; - std::cerr << std::endl; - } - break; - default: - break; - } -} - -//-------------------------------------------------------------------------- -// OnComment -//-------------------------------------------------------------------------- -/** - *

- * - * \param str - */ -void PStartupHandler_PM::OnComment(const char *str) -{ - // nothing to be done for now -} - -//-------------------------------------------------------------------------- -// OnWarning -//-------------------------------------------------------------------------- -/** - *

- * - * \param str - */ -void PStartupHandler_PM::OnWarning(const char *str) -{ - std::cerr << std::endl << "PStartupHandler_PM **WARNING** " << str; - std::cerr << std::endl; -} - -//-------------------------------------------------------------------------- -// OnError -//-------------------------------------------------------------------------- -/** - *

- * - * \param str - */ -void PStartupHandler_PM::OnError(const char *str) -{ - std::cerr << std::endl << "PStartupHandler_PM **ERROR** " << str; - std::cerr << std::endl; -} - -//-------------------------------------------------------------------------- -// OnFatalError -//-------------------------------------------------------------------------- -/** - *

- * - * \param str - */ -void PStartupHandler_PM::OnFatalError(const char *str) -{ - std::cerr << std::endl << "PStartupHandler_PM **FATAL ERROR** " << str; - std::cerr << std::endl; -} - -//-------------------------------------------------------------------------- -// OnCdataBlock -//-------------------------------------------------------------------------- -/** - *

- * - * \param str - */ -void PStartupHandler_PM::OnCdataBlock(const char *str, Int_t len) -{ - // nothing to be done for now -} - -//-------------------------------------------------------------------------- -// GetRgeEnergyIndex -//-------------------------------------------------------------------------- -/** - *

- * - * \param energy - */ -Int_t PStartupHandler_PM::GetRgeEnergyIndex(const Double_t energy) -{ - Int_t result = -1; - if (fIsValid) - result = fRgeHandler->GetRgeEnergyIndex(energy); - return result; -} - -//-------------------------------------------------------------------------- -// GetRgeValue -//-------------------------------------------------------------------------- -/** - *

- * - * \param energy - * \param dist - */ -Double_t PStartupHandler_PM::GetRgeValue(const Double_t energy, const Double_t dist) -{ - Double_t result = 0.0; - if (fIsValid) - result = fRgeHandler->GetRgeValue(energy, dist); - return result; -} - -//-------------------------------------------------------------------------- -// GetRgeValue -//-------------------------------------------------------------------------- -/** - *

- * - * \param index - * \param dist - */ -Double_t PStartupHandler_PM::GetRgeValue(const Int_t index, const Double_t dist) -{ - Double_t result = 0.0; - if (fIsValid) - result = fRgeHandler->GetRgeValue(index, dist); - return result; -} - -//-------------------------------------------------------------------------- -// StartupFileExists -//-------------------------------------------------------------------------- -/** - *

- * - */ -bool PStartupHandler_PM::StartupFileExists(char *fln) -{ - bool result = false; - - std::ifstream ifile(fln); - - if (ifile.fail()) { - result = false; - } else { - result = true; - ifile.close(); - } - - return result; -} - -// ------------------------------------------------------------------------- -// end -// ------------------------------------------------------------------------- diff --git a/src/external/libPhotoMeissner/include/PPhotoMeissner.h b/src/external/libPhotoMeissner/include/PPhotoMeissner.h index 9f12b7e9..f4853216 100644 --- a/src/external/libPhotoMeissner/include/PPhotoMeissner.h +++ b/src/external/libPhotoMeissner/include/PPhotoMeissner.h @@ -33,7 +33,7 @@ #include #include "PUserFcnBase.h" -#include "PStartupHandler_PM.h" +#include "PRgeHandler.h" class PPhotoMeissner : public PUserFcnBase { @@ -44,12 +44,12 @@ class PPhotoMeissner : public PUserFcnBase virtual Bool_t IsValid() { return fValid; } // function operator - Double_t operator()(Double_t, const std::vector&) const; + Double_t operator()(Double_t t, const std::vector ¶m) const; private: - PStartupHandler_PM *fStartupHandler; + PRgeHandler *fRgeHandler{nullptr}; - Bool_t fValid; ///< flag indicating if initialization went through smoothly + Bool_t fValid{true}; ///< flag indicating if initialization went through smoothly constexpr static const Double_t fDegToRad = 0.0174532925199432955; constexpr static const Double_t fTwoPi = 6.28318530717958623; diff --git a/src/external/libPhotoMeissner/include/PStartupHandler_PM.h b/src/external/libPhotoMeissner/include/PStartupHandler_PM.h deleted file mode 100644 index 0a4eb315..00000000 --- a/src/external/libPhotoMeissner/include/PStartupHandler_PM.h +++ /dev/null @@ -1,139 +0,0 @@ -/*************************************************************************** - - PStartupHandler_PM.h - - Author: Andreas Suter - e-mail: andreas.suter@psi.ch - -***************************************************************************/ - -/*************************************************************************** - * Copyright (C) 2013-2021 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 _PSTARTUPHANDLER_PM_H_ -#define _PSTARTUPHANDLER_PM_H_ - -#include - -#include -#include -#include - -//------------------------------------------------------------- -/** - *

typedef to make to code more readable. - */ -typedef std::vector PStringVector; - -//------------------------------------------------------------- -/** - *

typedef to make to code more readable. - */ -typedef std::vector PDoubleVector; - -//------------------------------------------------------------- -/** - *

- */ -typedef struct { - Double_t energy; - PDoubleVector stoppingDistance; - PDoubleVector stoppingAmplitude; -} PRgeData_PM; - -//------------------------------------------------------------- -/** - *

- */ -typedef std::vector PRgeData_PM_List; - -//------------------------------------------------------------- -/** - *

- */ -class PRgeHandler_PM -{ - public: - PRgeHandler_PM(const PStringVector &rgeDataPathList, const PDoubleVector &rgeDataEnergyList); - virtual ~PRgeHandler_PM(); - - virtual Bool_t IsValid() { return fIsValid; } - virtual Int_t GetRgeEnergyIndex(const Double_t energy); - virtual Double_t GetRgeValue(const Double_t energy, const Double_t dist); - virtual Double_t GetRgeValue(const Int_t index, const Double_t dist); - - private: - Bool_t fIsValid; - PRgeData_PM_List fRgeDataList; - - virtual Bool_t LoadRgeData(const PStringVector &rgeDataPathList, const PDoubleVector &rgeDataEnergyList); -}; - -//------------------------------------------------------------- -/** - *

- */ -class PStartupHandler_PM : public TObject -{ - public: - PStartupHandler_PM(); - virtual ~PStartupHandler_PM() {} - - virtual void OnStartDocument(); // SLOT - virtual void OnEndDocument(); // SLOT - virtual void OnStartElement(const char*, const TList*); // SLOT - virtual void OnEndElement(const char*); // SLOT - virtual void OnCharacters(const char*); // SLOT - virtual void OnComment(const char*); // SLOT - virtual void OnWarning(const char*); // SLOT - virtual void OnError(const char*); // SLOT - virtual void OnFatalError(const char*); // SLOT - virtual void OnCdataBlock(const char*, Int_t); // SLOT - - virtual bool IsValid() { return fIsValid; } - virtual TString GetStartupFilePath() { return fStartupFilePath; } - - virtual bool StartupFileFound() { return fStartupFileFound; } - - virtual Int_t GetRgeEnergyIndex(const Double_t energy); - virtual Double_t GetRgeValue(const Double_t energy, const Double_t dist); - virtual Double_t GetRgeValue(const Int_t index, const Double_t dist); - - private: - enum EKeyWords {eEmpty, eDataPath, eEnergy}; - EKeyWords fKey; - - bool fIsValid; - - bool fStartupFileFound; - TString fStartupFilePath; - - TString fRgePath; - PStringVector fRgeFilePathList; - PDoubleVector fRgeDataEnergyList; - - PRgeHandler_PM *fRgeHandler; - - bool StartupFileExists(char *fln); - - ClassDef(PStartupHandler_PM, 1) -}; - -#endif // _PSTARTUPHANDLER_PM_H_ diff --git a/src/external/libPhotoMeissner/include/PStartupHandler_PMLinkDef.h b/src/external/libPhotoMeissner/include/PStartupHandler_PMLinkDef.h deleted file mode 100644 index fcbe47ac..00000000 --- a/src/external/libPhotoMeissner/include/PStartupHandler_PMLinkDef.h +++ /dev/null @@ -1,38 +0,0 @@ -/*************************************************************************** - - PStartupHandler_PMLinkDef.h - - Author: Andreas Suter - e-mail: andreas.suter@psi.ch - -***************************************************************************/ - -/*************************************************************************** - * Copyright (C) 2013-2021 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 PStartupHandler_PM+; - -#endif diff --git a/src/external/libPhotoMeissner/test/photoMeissner_startup.xml b/src/external/libPhotoMeissner/test/photoMeissner_startup.xml index 535389aa..43202eb5 100644 --- a/src/external/libPhotoMeissner/test/photoMeissner_startup.xml +++ b/src/external/libPhotoMeissner/test/photoMeissner_startup.xml @@ -3,8 +3,9 @@ contains the needed trim.sp meta-file information - - ./trimsp/YBCO_E + + ./trimsp + YBCO_E 1000 3000 @@ -16,5 +17,5 @@ 20300 24300 - +