Merged muonspin/musrfit:root6 into master
This commit is contained in:
commit
c638456afe
@ -5,13 +5,14 @@ if (CMAKE_VERSION GREATER_EQUAL 3.12)
|
||||
cmake_policy(SET CMP0075 NEW)
|
||||
endif (CMAKE_VERSION GREATER_EQUAL 3.12)
|
||||
|
||||
project(musrfit VERSION 1.7.1 LANGUAGES C CXX)
|
||||
project(musrfit VERSION 1.7.2 LANGUAGES C CXX)
|
||||
|
||||
#--- musrfit specific options -------------------------------------------------
|
||||
option(nexus "build optional NeXus support. Needed for ISIS" OFF)
|
||||
option(ASlibs "build optional ASlibs" OFF)
|
||||
option(BMWlibs "build optional BMWlibs" OFF)
|
||||
option(BNMRlibs "build optional beta-NMR libs" OFF)
|
||||
option(DummyUserFcn "build optional dummy user function" OFF)
|
||||
option(qt_based_tools "try to install Qt based tools (musredit, musrWiz, musrStep, mupp)" ON)
|
||||
option(try_OpenMP "try to use OpenMP if available" ON)
|
||||
# define qt_version with possible values 'auto' or version '3', '4', '5', '6'
|
||||
@ -311,6 +312,9 @@ if (BNMRlibs)
|
||||
else (BNMRlibs)
|
||||
message(" BNMRlibs : no")
|
||||
endif (BNMRlibs)
|
||||
if (DummyUserFcn)
|
||||
message(" PDummyUserFcn : yes")
|
||||
endif (DummyUserFcn)
|
||||
|
||||
if (qt_based_tools)
|
||||
if (Qt6Core_FOUND)
|
||||
|
14
ChangeLog
14
ChangeLog
@ -12,7 +12,19 @@ or
|
||||
|
||||
https://bitbucket.org/muonspin/musrfit/commits/all
|
||||
|
||||
Release of V1.7.0, 2021/03/30
|
||||
Release of V1.7.2, 2021/04/16
|
||||
=============================
|
||||
|
||||
add a full dummy user function class with a global part. This can be used as
|
||||
a starting point to develop new polarization functions.
|
||||
Currently no rge-handling present.
|
||||
|
||||
Release of V1.7.1, 2021/04/09
|
||||
=============================
|
||||
|
||||
update of the docu. More version info. Dealing with the upcoming ROOT V6.24.
|
||||
|
||||
Release of V1.7.0, 2021/04/30
|
||||
=============================
|
||||
|
||||
Centralize the rge-handling for user functions.
|
||||
|
18
doc/examples/UserFcnWithGlobal/README
Normal file
18
doc/examples/UserFcnWithGlobal/README
Normal file
@ -0,0 +1,18 @@
|
||||
/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
|
||||
|
||||
Simple Example for a User Function *with* a Global Part
|
||||
|
||||
/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
|
||||
|
||||
The source code is found under
|
||||
|
||||
<musrfit-dir>src/external/DummyUserFcn
|
||||
|
||||
For details see there.
|
||||
|
||||
This dummy user function implements an exp(-lambda*t)
|
||||
in the global part. This is the most efficient way,
|
||||
since the function time vector is only calculated once
|
||||
when the parameter (lambda) changes. For all the
|
||||
subsequent calls a lookup table is used to return the
|
||||
value of the user function.
|
@ -0,0 +1,73 @@
|
||||
FeSe 9p4 TF100 p107apr09_sample*1p02
|
||||
###############################################################
|
||||
FITPARAMETER
|
||||
# Nr. Name Value Step Pos_Error Boundaries
|
||||
1 Asy 0.2622 -0.0014 0.0014 0 0.33
|
||||
2 Rate 0.3188 -0.0044 0.0044
|
||||
3 Field 97.853 -0.056 0.056 0 200
|
||||
4 Phase_L 178.95 -0.41 0.41
|
||||
5 Phase_R 1.75 -0.39 0.39
|
||||
6 N0_L 1097.9 -1.0 1.0
|
||||
7 N0_R 1159.7 -1.0 1.0
|
||||
8 Bkg_L 54.47 -0.20 0.20
|
||||
9 Bkg_R 46.70 -0.19 0.19
|
||||
|
||||
###############################################################
|
||||
THEORY
|
||||
asymmetry 1
|
||||
userFcn libPDummyUserFcn PDummyUserFcn 2 (rate)
|
||||
TFieldCos map1 fun1 (phase frequency)
|
||||
|
||||
###############################################################
|
||||
FUNCTIONS
|
||||
fun1 = par3 * gamma_mu
|
||||
|
||||
###############################################################
|
||||
GLOBAL
|
||||
fittype 0 (single histogram fit)
|
||||
fit 0 8.2
|
||||
packing 1
|
||||
|
||||
###############################################################
|
||||
RUN ../data/deltat_pta_gpd_0423 PIE1 PSI PSI-BIN (name beamline institute data-file-format)
|
||||
norm 6
|
||||
backgr.fit 8
|
||||
map 4 0 0 0 0 0 0 0 0 0
|
||||
forward 1
|
||||
data 165 7965
|
||||
t0 162.0
|
||||
|
||||
RUN ../data/deltat_pta_gpd_0423 PIE1 PSI PSI-BIN (name beamline institute data-file-format)
|
||||
norm 7
|
||||
backgr.fit 9
|
||||
map 5 0 0 0 0 0 0 0 0 0
|
||||
forward 2
|
||||
data 205 7965
|
||||
t0 202.0
|
||||
|
||||
###############################################################
|
||||
COMMANDS
|
||||
SCALE_N0_BKG TRUE
|
||||
MINIMIZE
|
||||
MINOS
|
||||
SAVE
|
||||
|
||||
###############################################################
|
||||
PLOT 0 (single histo plot)
|
||||
lifetimecorrection
|
||||
runs 1 2
|
||||
range 0.0 9.5 -0.3 0.3
|
||||
view_packing 25
|
||||
|
||||
###############################################################
|
||||
FOURIER
|
||||
units Gauss # units either 'Gauss', 'Tesla', 'MHz', or 'Mc/s'
|
||||
fourier_power 12
|
||||
apodization NONE # NONE, WEAK, MEDIUM, STRONG
|
||||
plot REAL # REAL, IMAG, REAL_AND_IMAG, POWER, PHASE
|
||||
phase par4 par5
|
||||
range 0.0 200.0
|
||||
|
||||
###############################################################
|
||||
STATISTIC --- 2015-01-05 14:09:47
|
||||
chisq = 663.9, NDF = 515, chisq/NDF = 1.289169
|
4
src/external/CMakeLists.txt
vendored
4
src/external/CMakeLists.txt
vendored
@ -29,3 +29,7 @@ if (nexus)
|
||||
add_subdirectory(nexus)
|
||||
endif (nexus)
|
||||
|
||||
if (DummyUserFcn)
|
||||
add_subdirectory(DummyUserFcn)
|
||||
endif (DummyUserFcn)
|
||||
|
||||
|
1
src/external/DummyUserFcn/CMakeLists.txt
vendored
Normal file
1
src/external/DummyUserFcn/CMakeLists.txt
vendored
Normal file
@ -0,0 +1 @@
|
||||
add_subdirectory(src)
|
99
src/external/DummyUserFcn/README
vendored
Normal file
99
src/external/DummyUserFcn/README
vendored
Normal file
@ -0,0 +1,99 @@
|
||||
/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
|
||||
|
||||
Simple Example for a User Function *with* a Global Part
|
||||
|
||||
/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
|
||||
|
||||
This is a full implementation of a user function with a global part.
|
||||
For a general intro to user function, please check the manual under
|
||||
|
||||
http://lmu.web.psi.ch/musrfit/user/html/user-manual.html#id38
|
||||
|
||||
The implemented user function is
|
||||
|
||||
exp(-lambda*t)
|
||||
|
||||
with lambda, being the only parameter.
|
||||
|
||||
Short description of the PDummyUserFcn and PDummyUserFcnGlobal classes.
|
||||
|
||||
PDummyUserFcn:
|
||||
-------------
|
||||
|
||||
This class derives from the PUserFcnBase which is necessary to make this
|
||||
user function available to musrfit.
|
||||
|
||||
The three functions:
|
||||
|
||||
virtual Bool_t NeedGlobalPart() const { return true; }
|
||||
virtual void SetGlobalPart(std::vector<void*> &globalPart, UInt_t idx);
|
||||
virtual Bool_t GlobalPartIsValid() const;
|
||||
|
||||
are used to bind the global part of the user function.
|
||||
|
||||
The method
|
||||
|
||||
virtual Double_t operator()(Double_t t, const std::vector<Double_t> ¶m) const;
|
||||
|
||||
is called by musrfit when evaluate the function.
|
||||
|
||||
The private variables:
|
||||
|
||||
Bool_t fValid{true};
|
||||
Bool_t fInvokedGlobal{false};
|
||||
Int_t fIdxGlobal;
|
||||
|
||||
PDummyUserFcnGlobal *fDummyUserFcnGlobal{nullptr};
|
||||
|
||||
have the following purpose:
|
||||
|
||||
fValid is a boolean variable holding the state of the user function.
|
||||
If true, it means that the user function is useable. In case
|
||||
something would go wrong during the initialization stage fValid
|
||||
is set to false, and no calculation will take place!
|
||||
fInvokedGlobal is a boolean variable which is set to true is the global
|
||||
part of the user function is properly invoked.
|
||||
fIdxGlobal holds the index of the global user function part.
|
||||
|
||||
PDummyUserFcnGlobal:
|
||||
-------------------
|
||||
|
||||
This class holds the gloabl user function part, which handles the actual
|
||||
calculation of the user function.
|
||||
|
||||
CalculatePol(const std::vector<Double_t> ¶m) const; -> carries out the
|
||||
necessary calculations of this user function. This is ONLY carried
|
||||
out if the parameter set has changed!
|
||||
|
||||
GetPolValue(const Double_t t) const; -> This is used in the operator() of
|
||||
the user function to get the value of the user function (here a
|
||||
value of a polarization function exp()).
|
||||
|
||||
mutable std::vector<Double_t> fPreviousParam; -> holds the previous
|
||||
parmeter set in order to check if a parameter set has changed.
|
||||
|
||||
mutable std::vector<Double_t> fPol; -> lookup table for the polarization
|
||||
function for the current parameter set.
|
||||
|
||||
How to build:
|
||||
------------
|
||||
|
||||
When configure musrfit, there is a switch DummyUserFcn available which
|
||||
needs to be enabled (default: OFF), e.g.
|
||||
|
||||
cmake ../ -DCMAKE_INSTALL_PREFIX=$ROOTSYS -Dnexus=1 -DDummyUserFcn=1
|
||||
|
||||
Files:
|
||||
-----
|
||||
CMakeLists.txt <- this File is needed to allow to build an install
|
||||
this dummy example with the cmake build system.
|
||||
inc/PDummyUserFcn.h <- header file definig the needed classes for
|
||||
the user function and its globale part.
|
||||
inc/PDummyUserFcnLinkDef.h <- Needed as a glue to generate the necessary
|
||||
root dictionaries.
|
||||
src/CMakeLists.txt <- needed for the cmake build/install process.
|
||||
src/PDummyUserFcn.cpp <- source code which implements all the necessary
|
||||
parts of the user function.
|
||||
src/PDummyUserFcn.pc.in <- cmake input file to generate the propoer
|
||||
pkg-config file for the library
|
||||
|
81
src/external/DummyUserFcn/inc/PDummyUserFcn.h
vendored
Normal file
81
src/external/DummyUserFcn/inc/PDummyUserFcn.h
vendored
Normal file
@ -0,0 +1,81 @@
|
||||
/***************************************************************************
|
||||
|
||||
PDummyUserFcn.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 _PDUMMYUSERFNC_H_
|
||||
#define _PDUMMYUSERFNC_H_
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "PUserFcnBase.h"
|
||||
|
||||
class PDummyUserFcnGlobal
|
||||
{
|
||||
public:
|
||||
PDummyUserFcnGlobal();
|
||||
virtual ~PDummyUserFcnGlobal();
|
||||
|
||||
Bool_t IsValid() { return fValid; }
|
||||
virtual void CalculatePol(const std::vector<Double_t> ¶m) const;
|
||||
virtual Double_t GetPolValue(const Double_t t) const;
|
||||
|
||||
private:
|
||||
Bool_t fValid{true};
|
||||
|
||||
mutable std::vector<Double_t> fPreviousParam;
|
||||
|
||||
mutable Double_t fTimeStep{1.0e-3}; // time in (us), time step 1 (ns) here
|
||||
mutable std::vector<Double_t> fPol;
|
||||
|
||||
ClassDef(PDummyUserFcnGlobal, 1)
|
||||
};
|
||||
|
||||
class PDummyUserFcn : public PUserFcnBase
|
||||
{
|
||||
public:
|
||||
PDummyUserFcn() {}
|
||||
virtual ~PDummyUserFcn();
|
||||
|
||||
virtual Bool_t NeedGlobalPart() const { return true; }
|
||||
virtual void SetGlobalPart(std::vector<void*> &globalPart, UInt_t idx);
|
||||
virtual Bool_t GlobalPartIsValid() const;
|
||||
|
||||
virtual Double_t operator()(Double_t t, const std::vector<Double_t> ¶m) const;
|
||||
|
||||
private:
|
||||
Bool_t fValid{true};
|
||||
Bool_t fInvokedGlobal{false};
|
||||
Int_t fIdxGlobal;
|
||||
|
||||
PDummyUserFcnGlobal *fDummyUserFcnGlobal{nullptr};
|
||||
|
||||
// definition of the class for the ROOT dictionary
|
||||
ClassDef(PDummyUserFcn, 1)
|
||||
};
|
||||
|
||||
#endif // _PDUMMYUSERFNC_H_
|
39
src/external/DummyUserFcn/inc/PDummyUserFcnLinkDef.h
vendored
Normal file
39
src/external/DummyUserFcn/inc/PDummyUserFcnLinkDef.h
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
/***************************************************************************
|
||||
|
||||
PDummyUserFcnLinkDef.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 PDummyUserFcnGlobal+;
|
||||
#pragma link C++ class PDummyUserFcn+;
|
||||
|
||||
#endif
|
78
src/external/DummyUserFcn/src/CMakeLists.txt
vendored
Normal file
78
src/external/DummyUserFcn/src/CMakeLists.txt
vendored
Normal file
@ -0,0 +1,78 @@
|
||||
# - DummyUserFcn library --------------------------------------------------------
|
||||
|
||||
#--- generate necessary dictionaries ------------------------------------------
|
||||
set(MUSRFIT_INC ${CMAKE_SOURCE_DIR}/src/include)
|
||||
set(DUMMY_USER_FUNC_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(${DUMMY_USER_FUNC_INC})
|
||||
|
||||
root_generate_dictionary(
|
||||
PDummyUserFcnDict
|
||||
PDummyUserFcn.h
|
||||
OPTIONS
|
||||
-I${FFTW3_INCLUDE_DIR}
|
||||
-I${MUSRFIT_INC}
|
||||
-I${DUMMY_USER_FUNC_INC}
|
||||
-inlineInputHeader
|
||||
LINKDEF ${DUMMY_USER_FUNC_INC}/PDummyUserFcnLinkDef.h
|
||||
MODULE PDummyUserFcn
|
||||
)
|
||||
|
||||
#--- create pkg-config info ---------------------------------------------------
|
||||
set(prefix "${CMAKE_INSTALL_PREFIX}")
|
||||
set(exec_prefix "\$\{prefix\}")
|
||||
set(libdir "\$\{exec_prefix\}/lib")
|
||||
set(includedir "\$\{prefix\}/include")
|
||||
set(P_DUMMY_USER_FUNC_VERSION "1.0.0")
|
||||
set(P_DUMMY_USER_FUNC_LIBRARY_NAME "PDummyUserFcn")
|
||||
configure_file("PDummyUserFcn.pc.in" "PDummyUserFcn.pc" @ONLY)
|
||||
|
||||
#--- lib creation -------------------------------------------------------------
|
||||
add_library(PDummyUserFcn SHARED
|
||||
PDummyUserFcn.cpp
|
||||
PDummyUserFcnDict.cxx
|
||||
)
|
||||
|
||||
#--- set target properties, e.g. version --------------------------------------
|
||||
set_target_properties(PDummyUserFcn
|
||||
PROPERTIES
|
||||
VERSION ${P_DUMMY_USER_FUNC_VERSION}
|
||||
)
|
||||
|
||||
#--- make sure that the include directory is found ----------------------------
|
||||
target_include_directories(
|
||||
PDummyUserFcn BEFORE PRIVATE
|
||||
$<BUILD_INTERFACE:${FFTW3_INCLUDE_DIR}>
|
||||
$<BUILD_INTERFACE:${MUSRFIT_INC}>
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../inc>
|
||||
)
|
||||
|
||||
#--- add library dependencies -------------------------------------------------
|
||||
target_link_libraries(PDummyUserFcn ${FFTW3_LIBRARY} ${ROOT_LIBRARIES} PUserFcnBase)
|
||||
|
||||
#--- install PDummyUserFcn solib -------------------------------------------------
|
||||
install(TARGETS PDummyUserFcn DESTINATION lib)
|
||||
|
||||
#--- install root pcm's and rootmaps ------------------------------------------
|
||||
install(
|
||||
FILES ${CMAKE_CURRENT_BINARY_DIR}/libPDummyUserFcn_rdict.pcm
|
||||
${CMAKE_CURRENT_BINARY_DIR}/libPDummyUserFcn.rootmap
|
||||
DESTINATION lib
|
||||
)
|
||||
|
||||
#--- install PDummyUserFcn header ------------------------------------------------
|
||||
install(
|
||||
FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../inc/PDummyUserFcn.h
|
||||
DESTINATION
|
||||
include
|
||||
)
|
||||
|
||||
#--- install pkg-config info --------------------------------------------------
|
||||
install(
|
||||
FILES ${CMAKE_CURRENT_BINARY_DIR}/PDummyUserFcn.pc
|
||||
DESTINATION lib/pkgconfig
|
||||
)
|
||||
|
227
src/external/DummyUserFcn/src/PDummyUserFcn.cpp
vendored
Normal file
227
src/external/DummyUserFcn/src/PDummyUserFcn.cpp
vendored
Normal file
@ -0,0 +1,227 @@
|
||||
/***************************************************************************
|
||||
|
||||
PDummyUserFcn.cpp
|
||||
|
||||
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. *
|
||||
***************************************************************************/
|
||||
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <TMath.h>
|
||||
|
||||
#include "PDummyUserFcn.h"
|
||||
|
||||
|
||||
ClassImp(PDummyUserFcnGlobal)
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Constructor
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>Here would go all the stuff which will be needed by the global part.
|
||||
* For instance specific information which come from a startup XML file.
|
||||
* This could be case if muon-stopping information is needed for the
|
||||
* calculation, or any other user function specific stuff which is not
|
||||
* part of the parameters which will be propagated from the msr-file.
|
||||
*/
|
||||
PDummyUserFcnGlobal::PDummyUserFcnGlobal()
|
||||
{
|
||||
// nothing needed here for the dummy
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Destructor
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
*
|
||||
*/
|
||||
PDummyUserFcnGlobal::~PDummyUserFcnGlobal()
|
||||
{
|
||||
fPreviousParam.clear();
|
||||
fPol.clear();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// CalculatePol (public)
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>Calculates the polarization function for the dummy user function.
|
||||
* For the Dummy this is just an exp(-lambda t), where lambda is comming
|
||||
* from the param.
|
||||
*
|
||||
* \param param the parameter for this user function
|
||||
*/
|
||||
void PDummyUserFcnGlobal::CalculatePol(const std::vector<Double_t> ¶m) const
|
||||
{
|
||||
// param: [0] lambda
|
||||
|
||||
// check that param is new and hence a calculation is needed
|
||||
Bool_t newParams = false;
|
||||
if (fPreviousParam.size() == 0) {
|
||||
for (UInt_t i=0; i<param.size(); i++)
|
||||
fPreviousParam.push_back(param[i]);
|
||||
newParams = true;
|
||||
} else {
|
||||
assert(param.size() == fPreviousParam.size());
|
||||
|
||||
for (UInt_t i=0; i<param.size(); i++) {
|
||||
if (param[i] != fPreviousParam[i]) {
|
||||
newParams = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!newParams)
|
||||
return;
|
||||
|
||||
// keep parameters
|
||||
for (UInt_t i=0; i<param.size(); i++)
|
||||
fPreviousParam[i] = param[i];
|
||||
|
||||
// calculate the "polarization" in the time interval t = [0, 20] us
|
||||
Double_t dt = fTimeStep, t = 0.0;
|
||||
Int_t noOfPoints = 20.0 / dt;
|
||||
fPol.resize(noOfPoints); // this makes sure that the polarization vector is long enough
|
||||
for (Int_t i=0; i<noOfPoints; i++) {
|
||||
t = i*dt;
|
||||
fPol[i] = exp(-param[0] * i * dt);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// GetMagneticField
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
*
|
||||
*/
|
||||
Double_t PDummyUserFcnGlobal::GetPolValue(const Double_t t) const
|
||||
{
|
||||
Double_t result = -1.0;
|
||||
|
||||
if (t < 0)
|
||||
return 1.0;
|
||||
|
||||
if (t >= 20.0)
|
||||
return 0.0;
|
||||
|
||||
Int_t idx = (Int_t)(t/fTimeStep);
|
||||
|
||||
if ((idx >=0) && (idx < fPol.size()))
|
||||
result = fPol[idx];
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
ClassImp(PDummyUserFcn)
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Destructor
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
*
|
||||
*/
|
||||
PDummyUserFcn::~PDummyUserFcn()
|
||||
{
|
||||
if ((fDummyUserFcnGlobal != nullptr) && fInvokedGlobal) {
|
||||
delete fDummyUserFcnGlobal;
|
||||
fDummyUserFcnGlobal = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// SetGlobalPart (public)
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* <b>return:</b>
|
||||
*
|
||||
* \param globalPart
|
||||
* \param idx
|
||||
*/
|
||||
void PDummyUserFcn::SetGlobalPart(std::vector<void*> &globalPart, UInt_t idx)
|
||||
{
|
||||
fIdxGlobal = static_cast<Int_t>(idx);
|
||||
|
||||
if ((Int_t)globalPart.size() <= fIdxGlobal) {
|
||||
fDummyUserFcnGlobal = new PDummyUserFcnGlobal();
|
||||
if (fDummyUserFcnGlobal == nullptr) {
|
||||
fValid = false;
|
||||
std::cerr << std::endl << ">> PDummyUserFcn::SetGlobalPart(): **ERROR** Couldn't invoke global user function object, sorry ..." << std::endl;
|
||||
} else if (!fDummyUserFcnGlobal->IsValid()) {
|
||||
fValid = false;
|
||||
std::cerr << std::endl << ">> PDummyUserFcn::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<PDummyUserFcnGlobal*>(fDummyUserFcnGlobal);
|
||||
}
|
||||
} else {
|
||||
fValid = true;
|
||||
fDummyUserFcnGlobal = (PDummyUserFcnGlobal*)globalPart[fIdxGlobal];
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// GlobalPartIsValid (public)
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* <b>return:</b>
|
||||
*/
|
||||
Bool_t PDummyUserFcn::GlobalPartIsValid() const
|
||||
{
|
||||
return (fValid && fDummyUserFcnGlobal->IsValid());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// operator()
|
||||
//--------------------------------------------------------------------------
|
||||
/**
|
||||
*
|
||||
*/
|
||||
Double_t PDummyUserFcn::operator()(Double_t t, const std::vector<Double_t> ¶m) const
|
||||
{
|
||||
// param: [0] lambda
|
||||
assert(param.size() == 1);
|
||||
|
||||
// for negative time return polarization == 1
|
||||
if (t <= 0.0)
|
||||
return 1.0;
|
||||
|
||||
// calculate field if parameter have changed
|
||||
fDummyUserFcnGlobal->CalculatePol(param);
|
||||
|
||||
// return the lookup table value
|
||||
return fDummyUserFcnGlobal->GetPolValue(t);
|
||||
}
|
10
src/external/DummyUserFcn/src/PDummyUserFcn.pc.in
vendored
Normal file
10
src/external/DummyUserFcn/src/PDummyUserFcn.pc.in
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
libdir=@libdir@
|
||||
includedir=@includedir@
|
||||
|
||||
Name: PDummyUserFcn
|
||||
Description: C++ shared library providing the spin valve fitter class
|
||||
Version: @P_DUMMY_USER_FUNC_VERSION@
|
||||
Libs: -L${libdir} -l@P_DUMMY_USER_FUNC_LIBRARY_NAME@
|
||||
Cflags: -I${includedir}
|
Loading…
x
Reference in New Issue
Block a user