From 26c1f49554289515e1b9b9ae77d1e9bbbc022f73 Mon Sep 17 00:00:00 2001 From: Andreas Suter Date: Thu, 17 Mar 2022 13:07:00 +0100 Subject: [PATCH] added depth profiler skeleton for MM. --- src/external/CMakeLists.txt | 1 + src/external/DepthProfile/CMakeLists.txt | 1 + src/external/DepthProfile/README | 1 + src/external/DepthProfile/inc/PDepthProfile.h | 81 ++++++++++ .../DepthProfile/inc/PDepthProfileLinkDef.h | 39 +++++ src/external/DepthProfile/src/CMakeLists.txt | 78 +++++++++ .../DepthProfile/src/PDepthProfile.cpp | 150 ++++++++++++++++++ .../DepthProfile/src/PDepthProfile.pc.in | 10 ++ 8 files changed, 361 insertions(+) create mode 100644 src/external/DepthProfile/CMakeLists.txt create mode 100644 src/external/DepthProfile/README create mode 100644 src/external/DepthProfile/inc/PDepthProfile.h create mode 100644 src/external/DepthProfile/inc/PDepthProfileLinkDef.h create mode 100644 src/external/DepthProfile/src/CMakeLists.txt create mode 100644 src/external/DepthProfile/src/PDepthProfile.cpp create mode 100644 src/external/DepthProfile/src/PDepthProfile.pc.in diff --git a/src/external/CMakeLists.txt b/src/external/CMakeLists.txt index cb76d6b9..16f22b0f 100644 --- a/src/external/CMakeLists.txt +++ b/src/external/CMakeLists.txt @@ -4,6 +4,7 @@ if (ASlibs) add_subdirectory(libPhotoMeissner) add_subdirectory(libSpinValve) add_subdirectory(libGbGLF) + add_subdirectory(DepthProfile) endif (ASlibs) if (BMWlibs) diff --git a/src/external/DepthProfile/CMakeLists.txt b/src/external/DepthProfile/CMakeLists.txt new file mode 100644 index 00000000..febd4f0a --- /dev/null +++ b/src/external/DepthProfile/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(src) diff --git a/src/external/DepthProfile/README b/src/external/DepthProfile/README new file mode 100644 index 00000000..93adff36 --- /dev/null +++ b/src/external/DepthProfile/README @@ -0,0 +1 @@ +Will describe what this is all about... diff --git a/src/external/DepthProfile/inc/PDepthProfile.h b/src/external/DepthProfile/inc/PDepthProfile.h new file mode 100644 index 00000000..a0f95a35 --- /dev/null +++ b/src/external/DepthProfile/inc/PDepthProfile.h @@ -0,0 +1,81 @@ +/*************************************************************************** + + PDepthProfile.h + + Author: Andreas Suter + e-mail: andreas.suter@psi.ch + +***************************************************************************/ + +/*************************************************************************** + * Copyright (C) 2013-2022 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 _PDEPTHPROFILE_H_ +#define _PDEPTHPROFILE_H_ + +#include + +#include "PUserFcnBase.h" +#include "PRgeHandler.h" + +class PDepthProfileGlobal +{ + public: + PDepthProfileGlobal(); + virtual ~PDepthProfileGlobal(); + + Bool_t IsValid() { return fValid; } + 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); } + + private: + Bool_t fValid{true}; + + mutable std::vector fPreviousParam; + + PRgeHandler *fRgeHandler{nullptr}; + + ClassDef(PDepthProfileGlobal, 1) +}; + +class PDepthProfile : public PUserFcnBase +{ + public: + PDepthProfile() {} + virtual ~PDepthProfile(); + + virtual Bool_t NeedGlobalPart() const { return true; } + 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; + + private: + Bool_t fValid{true}; + Bool_t fInvokedGlobal{false}; + Int_t fIdxGlobal; + + PDepthProfileGlobal *fDepthProfileGlobal{nullptr}; + + // definition of the class for the ROOT dictionary + ClassDef(PDepthProfile, 1) +}; + +#endif // _PDEPTHPROFILE_H_ diff --git a/src/external/DepthProfile/inc/PDepthProfileLinkDef.h b/src/external/DepthProfile/inc/PDepthProfileLinkDef.h new file mode 100644 index 00000000..cce23057 --- /dev/null +++ b/src/external/DepthProfile/inc/PDepthProfileLinkDef.h @@ -0,0 +1,39 @@ +/*************************************************************************** + + PDepthProfileLinkDef.h + + Author: Andreas Suter + e-mail: andreas.suter@psi.ch + +***************************************************************************/ + +/*************************************************************************** + * Copyright (C) 2013-2022 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 PDepthProfileGlobal+; +#pragma link C++ class PDepthProfile+; + +#endif diff --git a/src/external/DepthProfile/src/CMakeLists.txt b/src/external/DepthProfile/src/CMakeLists.txt new file mode 100644 index 00000000..6aa386c9 --- /dev/null +++ b/src/external/DepthProfile/src/CMakeLists.txt @@ -0,0 +1,78 @@ +# - DepthProfile library ------------------------------------------------------ + +#--- generate necessary dictionaries ------------------------------------------ +set(MUSRFIT_INC ${CMAKE_SOURCE_DIR}/src/include) +set(DEPTH_PROFILE_INC ${CMAKE_CURRENT_SOURCE_DIR}/../inc) +# ROOT requires that the dictonary header files are found at configuration time. +# Hence, target_include_directories cannot be used here because, targets are +# setup only afterwards. +include_directories(${DEPTH_PROFILE_INC}) + +root_generate_dictionary( + PDepthProfileDict + PDepthProfile.h + OPTIONS + -I${FFTW3_INCLUDE_DIR} + -I${MUSRFIT_INC} + -I${DEPTH_PROFILE_INC} + -inlineInputHeader + LINKDEF ${DEPTH_PROFILE_INC}/PDepthProfileLinkDef.h + MODULE PDepthProfile +) + +#--- create pkg-config info --------------------------------------------------- +set(prefix "${CMAKE_INSTALL_PREFIX}") +set(exec_prefix "\$\{prefix\}") +set(libdir "\$\{exec_prefix\}/lib") +set(includedir "\$\{prefix\}/include") +set(P_DEPTH_PROFILE_VERSION "1.0.0") +set(P_DEPTH_PROFILE_LIBRARY_NAME "PDepthProfile") +configure_file("PDepthProfile.pc.in" "PDepthProfile.pc" @ONLY) + +#--- lib creation ------------------------------------------------------------- +add_library(PDepthProfile SHARED + PDepthProfile.cpp + PDepthProfileDict.cxx +) + +#--- set target properties, e.g. version -------------------------------------- +set_target_properties(PDepthProfile + PROPERTIES + VERSION ${P_DEPTH_PROFILE_VERSION} +) + +#--- make sure that the include directory is found ---------------------------- +target_include_directories( + PDepthProfile BEFORE PRIVATE + $ + $ + $ +) + +#--- add library dependencies ------------------------------------------------- +target_link_libraries(PDepthProfile ${FFTW3_LIBRARY} ${ROOT_LIBRARIES} PUserFcnBase) + +#--- install PDepthProfile solib ---------------------------------------------- +install(TARGETS PDepthProfile DESTINATION lib) + +#--- install root pcm's and rootmaps ------------------------------------------ +install( + FILES ${CMAKE_CURRENT_BINARY_DIR}/libPDepthProfile_rdict.pcm + ${CMAKE_CURRENT_BINARY_DIR}/libPDepthProfile.rootmap + DESTINATION lib +) + +#--- install DepthProfile header ---------------------------------------------- +install( + FILES + ${CMAKE_CURRENT_SOURCE_DIR}/../inc/PDepthProfile.h + DESTINATION + include +) + +#--- install pkg-config info -------------------------------------------------- +install( + FILES ${CMAKE_CURRENT_BINARY_DIR}/PDepthProfile.pc + DESTINATION lib/pkgconfig +) + diff --git a/src/external/DepthProfile/src/PDepthProfile.cpp b/src/external/DepthProfile/src/PDepthProfile.cpp new file mode 100644 index 00000000..b4d9795f --- /dev/null +++ b/src/external/DepthProfile/src/PDepthProfile.cpp @@ -0,0 +1,150 @@ +/*************************************************************************** + + PDepthProfile.cpp + + Author: Andreas Suter + e-mail: andreas.suter@psi.ch + +***************************************************************************/ + +/*************************************************************************** + * Copyright (C) 2009-2022 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 "PDepthProfile.h" + +ClassImp(PDepthProfileGlobal) + +//-------------------------------------------------------------------------- +// Constructor (PDepthProfileGlobal) +//-------------------------------------------------------------------------- +/** + *

Constructor. Reads the necessary rge-files based on the depth_profile_startup.xml + */ +PDepthProfileGlobal::PDepthProfileGlobal() +{ + // load all the TRIM.SP rge-files + fRgeHandler = new PRgeHandler("./depth_profile_startup.xml"); + if (!fRgeHandler->IsValid()) { + std::cout << std::endl << ">> PDepthProfileGlobal::PDepthProfileGlobal **PANIC ERROR**"; + std::cout << std::endl << ">> rge data handler too unhappy. Will terminate unfriendly, sorry."; + std::cout << std::endl; + fValid = false; + } +} + +//-------------------------------------------------------------------------- +// Destructor (PDepthProfileGlobal) +//-------------------------------------------------------------------------- +/** + *

Clean up the rge-handler. + */ +PDepthProfileGlobal::~PDepthProfileGlobal() +{ + if (fRgeHandler) { + delete fRgeHandler; + fRgeHandler = nullptr; + } +} + +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +ClassImp(PDepthProfile) + +//-------------------------------------------------------------------------- +// Destructor (PDepthProfile) +//-------------------------------------------------------------------------- +/** + *

Clean up the global part. + */ +PDepthProfile::~PDepthProfile() +{ + if ((fDepthProfileGlobal != 0) && fInvokedGlobal) { + delete fDepthProfileGlobal; + fDepthProfileGlobal = nullptr; + } +} + +//-------------------------------------------------------------------------- +// SetGlobalPart (public) +//-------------------------------------------------------------------------- +/** + *

+ * + * return: + * + * \param globalPart + * \param idx + */ +void PDepthProfile::SetGlobalPart(std::vector &globalPart, UInt_t idx) +{ + fIdxGlobal = static_cast(idx); + + if ((Int_t)globalPart.size() <= fIdxGlobal) { + fDepthProfileGlobal = new PDepthProfileGlobal(); + if (fDepthProfileGlobal == nullptr) { + fValid = false; + std::cerr << std::endl << ">> PDepthProfile::SetGlobalPart(): **ERROR** Couldn't invoke global user function object, sorry ..." << std::endl; + } else if (!fDepthProfileGlobal->IsValid()) { + fValid = false; + std::cerr << std::endl << ">> PDepthProfile::SetGlobalPart(): **ERROR** initialization of global user function object failed, sorry ..." << std::endl; + } else { + fValid = true; + fInvokedGlobal = true; + globalPart.resize(fIdxGlobal+1); + globalPart[fIdxGlobal] = dynamic_cast(fDepthProfileGlobal); + } + } else { + fValid = true; + fDepthProfileGlobal = (PDepthProfileGlobal*)globalPart[fIdxGlobal]; + } +} + +//-------------------------------------------------------------------------- +// GlobalPartIsValid (public) +//-------------------------------------------------------------------------- +/** + *

+ * + * return: + */ +Bool_t PDepthProfile::GlobalPartIsValid() const +{ + return (fValid && fDepthProfileGlobal->IsValid()); +} + +//-------------------------------------------------------------------------- +// operator() +//-------------------------------------------------------------------------- +/** + *

Yet to be implemented. + */ +Double_t PDepthProfile::operator()(Double_t t, const std::vector ¶m) const +{ + return 0.0; +} + diff --git a/src/external/DepthProfile/src/PDepthProfile.pc.in b/src/external/DepthProfile/src/PDepthProfile.pc.in new file mode 100644 index 00000000..ad9d9912 --- /dev/null +++ b/src/external/DepthProfile/src/PDepthProfile.pc.in @@ -0,0 +1,10 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: PDepthProfile +Description: C++ shared library providing the depth profile fitter class +Version: @P_DEPTH_PROFILE_VERSION@ +Libs: -L${libdir} -l@P_DEPTH_PROFILE_LIBRARY_NAME@ +Cflags: -I${includedir}