add README files for the DummyUsrFcn with an example.

This commit is contained in:
suter_a 2021-04-19 08:09:53 +02:00
parent 93c537ba22
commit 32c892cad4
3 changed files with 190 additions and 0 deletions

View 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.

View File

@ -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

99
src/external/DummyUserFcn/README vendored Normal file
View 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> &param) 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> &param) 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