Code indexing in gitaly is broken and leads to code not being visible to the user. We work on the issue with highest priority.

Skip to content
Snippets Groups Projects
Commit 32c892ca authored by suter_a's avatar suter_a
Browse files

add README files for the DummyUsrFcn with an example.

parent 93c537ba
No related branches found
No related tags found
No related merge requests found
/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
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.
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
/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment