musrfit/doc/html/user/MUSR/MusrFit.html

1361 lines
121 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en_US">
<!-- Mirrored from intranet.psi.ch/MUSR/MusrFit?cover=print by HTTrack Website Copier/3.x [XR&CO'2010], Fri, 02 Sep 2011 17:10:41 GMT -->
<!-- Added by HTTrack --><meta http-equiv="content-type" content="text/html;charset=iso-8859-1"><!-- /Added by HTTrack -->
<head>
<link rel="stylesheet" href="../pub/System/HeadlinesPlugin/style.css" type="text/css" media="all" />
<title> MUSR :: MusrFit</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <meta name="robots" content="noindex" /> <link rel="alternate" type="application/rss+xml" title="RSS Feed" href="WebRsshtml.html" />
<meta name="scripturl" content="https://intranet.psi.ch/wiki/bin" />
<meta name="scriptsuffix" content="" />
<meta name="WEBTOPIC" content="MusrFit" />
<meta name="WEB" content="MUSR" />
<meta name="SCRIPTURLPATH" content="/wiki/bin" />
<meta name="SCRIPTSUFFIX" content="" />
<meta name="TEXT_JUMP" content="Jump" />
<meta name="TEXT_SEARCH" content="Search" />
<meta name="TEXT_NUM_TOPICS" content="Number of topics:" />
<meta name="TEXT_MODIFY_SEARCH" content="Modify search" />
<link rel="icon" href="../pub/Main/WebPreferences/favicon.ico" type="image/x-icon" /> <link rel="shortcut icon" href="../pub/Main/WebPreferences/favicon.ico" type="image/x-icon" />
<link rel="alternate" href="https://intranet.psi.ch/wiki/bin/edit/MUSR/MusrFit?t=1314983426" type="application/x-wiki" title="edit MusrFit" />
<meta name="description" content="MusrFit" />
<base /><!--[if IE]></base><![endif]-->
<style type="text/css" media="all">
@import url('../pub/System/SkinTemplates/base.css');
</style>
<style type="text/css" media="all">
@import url('../pub/System/PatternSkinTheme2009/layout.css');
@import url('../pub/System/PatternSkinTheme2009/style.css');
@import url('../pub/System/PatternSkinTheme2009/colors.css');
</style>
<style type="text/css" media="all">
@import url('../pub/System/PatternSkinTheme2009/column_left.css');
@import url('../pub/System/PatternSkinTheme2009/variant_twiki.css');
</style><style type="text/css" media="all">
/* Styles that are set using variables */
.patternBookView .foswikiTopRow,
.patternWebIndicator a img,
.patternWebIndicator a:hover img {
background-color:#D0D0D0;
}
#patternTopBarContents { background-image:url(../pub/System/PatternSkin/header5.gif); background-repeat:repeat-x;}
#patternTopBarContents { background-color:#ffffff;}
.patternBookView {
border-color:#D0D0D0;
}
.patternPreviewPage #patternMain {
/* uncomment to set the preview image */
/*background-image:url("/pub/System/PreviewBackground/preview2bg.gif");*/
}
</style>
<style type="text/css" media="all">
@import url("../pub/System/PsiSkin/psicolors.css");
@import url("../pub/System/PsiSkin/psistyle.css");
.foswikiTopic {overflow: hidden;}
</style>
<style type="text/css" media="all">
@import url("../pub/System/PatternSkin/print.css");
.foswikiAttachments, #patternInfo, #patternBottomBar {display: none;}
.patternContent {overflow: visible}
</style>
<!--[if IE]><style type="text/css" media="screen">
pre {
height:1%;
overflow-x:auto;
}
.foswikiAttachments,
.foswikiForm,
.foswikiHelp,
.foswikiPreviewArea,
.patternPreviewPage .foswikiForm,
.patternSigLine,
.patternToolBar,
.patternTop,
.patternTopicAction,
#patternSideBarContents .patternLeftBarPersonal,
#patternSideBarContents h2,
#patternSideBarContents li,
#patternTopBarButtons ul {
height:1%;
}
#patternSideBarContents .patternLeftBarPersonal {
width:100%;
}
.foswikiFormStep {
height:100%;
}
#foswikiLogin,
.patternShadow {
border:10px solid #fff;
margin-top:10px;
margin-bottom:10px;
border:2px solid #ccc;
}
</style><![endif]-->
<!--[if gt IE 8 ]><style type="text/css" media="screen">
#foswikiLogin,
.patternShadow {
border:10px solid #fff;
margin-top:10px;
margin-bottom:10px;
box-shadow: 0 0 10px #ccc;
}
</style><![endif]-->
<script src="https://intranet.psi.ch/pub/System/ChecklistPlugin/itemstatechange.js" language="javascript" type="text/javascript"></script><script src="https://intranet.psi.ch/pub/System/TimeTablePlugin/timetabletooltips.js" language="javascript" type="text/javascript"></script></head>
<body class="patternViewPage patternPrintPage" id="BodyTop">
<a name="PageTop"></a><div class="foswikiPage"><div id="patternScreen">
<div id="patternPageShadow">
<div id="patternPage">
<div id="patternOuter">
<div id="patternFloatWrap">
<div id="patternMain">
<div id="patternMainContents">
<div class="patternContent"><div class="foswikiTopic">
<a name="UserManual"></a>
<h1><a name="A_61_61musrfit_61_61_User_Manual"></a> <code><b>musrfit</b></code> User Manual </h1>
<a name="foswikiTOC"></a><div class="foswikiToc"> <ul>
<li> <a href="MusrFit.html#A_61_61musrfit_61_61_User_Manual"> musrfit User Manual </a>
</li> <li> <a href="MusrFit.html#A_1_Introduction"> 1 Introduction </a>
</li> <li> <a href="MusrFit.html#A_2_Available_Executables_44_Configuration_Files_and_their_Basic_Usage"> 2 Available Executables, Configuration Files and their Basic Usage </a> <ul>
<li> <a href="MusrFit.html#A_2.1_musrfit"> 2.1 musrfit </a>
</li> <li> <a href="MusrFit.html#A_2.2_musrview"> 2.2 musrview </a>
</li> <li> <a href="MusrFit.html#A_2.3_musrt0"> 2.3 musrt0 </a>
</li> <li> <a href="MusrFit.html#A_2.4_musrparam"> 2.4 musrparam </a>
</li> <li> <a href="MusrFit.html#A_2.5_musrfit_startup.xml"> 2.5 musrfit_startup.xml </a>
</li> <li> <a href="MusrFit.html#A_2.6_msr2msr"> 2.6 msr2msr </a>
</li></ul>
</li> <li> <a href="MusrFit.html#A_3_Auxiliary_Programs"> 3 Auxiliary Programs </a>
</li> <li> <a href="MusrFit.html#A_4_Description_of_the_msr_File_Format"> 4 Description of the msr File Format </a> <ul>
<li> <a href="MusrFit.html#A_4.1_The_Title"> 4.1 The Title </a>
</li> <li> <a href="MusrFit.html#A_4.2_The_FITPARAMETER_Block"> 4.2 The FITPARAMETER Block </a>
</li> <li> <a href="MusrFit.html#A_4.3_The_THEORY_Block"> 4.3 The THEORY Block </a> <ul>
<li> <a href="MusrFit.html#A_4.3.1_Maps"> 4.3.1 Maps </a>
</li> <li> <a href="MusrFit.html#A_4.3.2_Functions"> 4.3.2 Functions </a>
</li> <li> <a href="MusrFit.html#A_4.3.3_User_Functions"> 4.3.3 User Functions </a>
</li></ul>
</li> <li> <a href="MusrFit.html#A_4.4_The_FUNCTIONS_Block"> 4.4 The FUNCTIONS Block </a>
</li> <li> <a href="MusrFit.html#A_4.5_The_RUN_Block"> 4.5 The RUN Block </a>
</li> <li> <a href="MusrFit.html#A_4.6_The_COMMANDS_Block"> 4.6 The COMMANDS Block </a>
</li> <li> <a href="MusrFit.html#A_4.7_The_FOURIER_Block"> 4.7 The FOURIER Block </a>
</li> <li> <a href="MusrFit.html#A_4.8_The_PLOT_Block"> 4.8 The PLOT Block </a>
</li> <li> <a href="MusrFit.html#A_4.9_The_STATISTIC_Block"> 4.9 The STATISTIC Block </a>
</li></ul>
</li> <li> <a href="MusrFit.html#A_5_The_Fit_Types"> 5 The Fit Types </a> <ul>
<li> <a href="MusrFit.html#A_5.1_Single_Histogram_Fit"> 5.1 Single Histogram Fit </a>
</li> <li> <a href="MusrFit.html#A_5.2_Asymmetry_Fit"> 5.2 Asymmetry Fit </a>
</li> <li> <a href="MusrFit.html#A_5.3_Rotating_45Reference_45Frame_Asymmetry_Fit"> 5.3 Rotating-Reference-Frame Asymmetry Fit </a>
</li> <li> <a href="MusrFit.html#A_5.4_Non_45SR_Fit"> 5.4 Non-&mu;SR Fit </a>
</li></ul>
</li> <li> <a href="MusrFit.html#A_6_User_Functions"> 6 User Functions </a> <ul>
<li> <a href="MusrFit.html#A_6.1_User_Function_without_global_user_45function_45object_access"> 6.1 User Function without global user-function-object access </a>
</li> <li> <a href="MusrFit.html#A_6.2_User_Function_with_global_user_45function_45object_access"> 6.2 User Function with global user-function-object access </a>
</li></ul>
</li> <li> <a href="MusrFit.html#A_7_Technical_Description_of_the_musrfit_framework"> 7 Technical Description of the musrfit framework </a>
</li> <li> <a href="MusrFit.html#A_8_Bugtracking"> 8 Bugtracking </a>
</li></ul>
</div>
<a name="IntroDuction"></a>
<h1><a name="A_1_Introduction"></a> 1 Introduction </h1>
<p></p>
<code>musrfit</code> is a software tool for analyzing time-differential &mu;SR data. The program suite is <a href="http://www.gnu.org/philosophy/free-sw.html" target="_top">free software</a> and licensed under the <a href="http://www.gnu.org/licenses/old-licenses/gpl-2.0.html" target="_top">GNU GPL version 2</a> or any later version (at your option). It is implemented in <code>C++/<a href="http://root.cern.ch/" target="_top">ROOT</a></code> and uses the <a href="http://seal.web.cern.ch/seal/MathLibs/Minuit2/html/index.html" target="_top">MINUIT2</a> libraries developed at <a href="http://www.cern.ch/" target="_top">CERN</a> for fitting data. Installation instructions for GNU/Linux, MS Windows, and Mac OS X can be found <a href="MusrFitSetup.html">here</a>. For people familiar with the &mu;SR data analysis program <code>WKM</code> there is a short <a href="QuickStart.html">quick start page</a> explaining the major differences between <code>WKM</code> and <code>musrfit</code>. Recent changes of the program are listed in the <a href="http://svn.psi.ch/websvn/filedetails.php?repname=nemu/lem&amp;path=%2Ftrunk%2Fanalysis%2Fmusrfit%2FChangeLog&amp;rev=0&amp;sc=0" target="_top">ChangeLog</a>.
<p></p>
<h1><a name="A_2_Available_Executables_44_Configuration_Files_and_their_Basic_Usage"></a> 2 Available Executables, Configuration Files and their Basic Usage </h1>
<p></p>
<a name="MusrFit"></a>
<h2><a name="A_2.1_musrfit"></a> 2.1 musrfit </h2>
<code>musrfit</code> is the actual fitting program. It defines the FCN routine passed to <code>MINUIT2</code> and performs &#967;<sup>2</sup> or log-likelihood fitting.
If called from within a shell it accepts several parameters: <dl>
<dt> &lt;msr_file&gt; </dt><dd> filename of the msr input file defining all the details needed for performing a fit to a specified set of data&mdash;the only mandatory parameter
</dd> <dt> -k, --keep-mn2-output </dt><dd> selects the option for keeping the output of <code>MINUIT2</code> including the correlation coefficients between different parameters and renaming the files <code><b>MINUIT2.OUTPUT</b></code> and <code><b>MINUIT2.root</b></code> to <code><b>&lt;msr_file_without_extension&gt;-mn2.output</b></code> and <code><b>&lt;msr_file_without_extension&gt;-mn2.root</b></code>, repectively, e.g. <strong>&lt;msr_file&gt;</strong> = <code><b>8472.msr</b></code> &rarr; <code><b>8472-mn2.output</b></code> , <code><b>8472-mn2.root</b></code>
</dd> <dt> -c, --chisq-only </dt><dd> Instead of fitting the model, <code>musrfit</code> calculates &#967;<sup>2</sup> only once and sends the result to the standard output if called with this option. This might be useful for the adjustment of the initial values of the fit parameters.
</dd> <dt> -t, --title-from-data-file </dt><dd> If this option is given <code>musrfit</code> will replace the title in the <strong>&lt;msr_file&gt;</strong> by the run title in the data file of the first run appearing in a RUN block. In case there is no run title in the data file no substitution is done.
</dd> <dt> --dump &lt;type&gt; </dt><dd> is writing a data file with the fit data and the theory; <strong>&lt;type&gt;</strong> can be <strong>ascii</strong> (data in columns) or <strong>root</strong> (data in <code>ROOT</code> histograms)
</dd> <dt> --help </dt><dd> displays a small help notice in the shell explaining the basic usage of the program
</dd> <dt> --version </dt><dd> prints the version number of <code>musrfit</code>
</dd></dl>
<p></p>
If called with a msr input file, e.g.
<pre class="bash">musrfit 8472.msr</pre>
the fit described in the input file will be executed and the results will be written to a mlog output file&mdash;in the example <code><b>8472.mlog</b></code>. When the fitting has terminated the msr file and the mlog file are swapped, so that the resultant parameter values can be found in the msr file and the mlog file contains a copy of the input file. The format of the mlog file is the same as that of the msr file. For a detailed description of the msr file format refer to <a href="#DescriptionOfTheMsrFileFormat" class="foswikiCurrentTopicLink">the corresponding section</a>.
<p></p>
<a name="MusrView"></a>
<h2><a name="A_2.2_musrview"></a> 2.2 musrview </h2>
<code>musrview</code> is an interactive graphical user interface for the presentation of the analyzed data and the corresponding fits. If called from within a shell it accepts the following parameters: <dl>
<dt> &lt;msr_file&gt; </dt><dd> name of the msr input or output file to be displayed&mdash;this parameter is mandatory
</dd> <dt> --&lt;graphic_format_extension&gt; </dt><dd> will produce a graphics output file without starting a <code>ROOT</code> session. The filename is based on the name of the <strong>&lt;msr_file&gt;</strong>, e.g. <code><b>8472.msr</b></code> &rarr; <code><b>8472_0.png</b></code> <br> Supported values for <strong>&lt;graphic_format_extension&gt;</strong> are <strong>eps</strong>, <strong>pdf</strong>, <strong>gif</strong>, <strong>jpg</strong>, <strong>png</strong>, <strong>svg</strong>, <strong>xpm</strong>, <strong>root</strong>
</dd> <dt> --help </dt><dd> displays a small help notice in the shell explaining the basic usage of the program
</dd> <dt> --version </dt><dd> prints the version number of <code>musrview</code>
</dd></dl>
<p></p>
If called with a msr file and the <strong>--&lt;graphic_format_extension&gt;</strong> option, e.g.
<pre class="bash">musrview 8472.msr --jpg</pre>
for each PLOT block in the the msr file a file 8472_<b>X</b>.jpg is produced where <b>X</b> counts the PLOT blocks starting from zero.
<p></p>
If called only with a msr file, e.g.
<pre class="bash">musrview 8472.msr</pre>
a <code>ROOT</code> canvas is drawn; it contains all experimental data and fits specified in the PLOT block of the msr file.
For a description of the various plotting types refer to <a href="#DescriptionOfTheMsrFileFormat" class="foswikiCurrentTopicLink">the corresponding section</a>.
<p></p>
Within the drawn canvas all standard actions applicable to <code>ROOT</code> canvases might be performed.
In the menu bar the <strong>Musrfit</strong> menu can be found. From there some <code>musrfit</code>-specific actions might be taken: <dl>
<dt> Fourier </dt><dd> performs the Fourier transformation of the selected data and shows the result
</dd> <dt> Difference </dt><dd> shows the difference between the selected data and the fit
</dd> <dt> Save Data </dt><dd> saves the selected data in a simple multi-column ASCII file
</dd></dl>
<p></p>
Additionally, some functions can be accessed using key-shortcuts: <dl>
<dt> q </dt><dd> quits <code>musrview</code>
</dd> <dt> d </dt><dd> shows the difference between the selected data and the fit
</dd> <dt> f </dt><dd> performs the Fourier transformation of the selected data and shows the result
</dd> <dt> u </dt><dd> reset the plotting range to the area given in the msr file ("unzoom")
</dd></dl>
<p></p>
<a name="MusrT0"></a>
<h2><a name="A_2.3_musrt0"></a> 2.3 musrt0 </h2>
<code>musrt0</code> is a user interface for the determination of <strong>t0</strong> and the time windows of <strong>data</strong> and <strong>background</strong> needed to be specified in the <a href="#TheRunBlock" class="foswikiCurrentTopicLink">RUN blocks</a> of the msr file. It can be operated either as an interactive program or in a non-interactive mode. In the non-interactive mode it accepts the following parameters: <dl>
<dt> &lt;msr_file&gt; </dt><dd> name of an msr file
</dd> <dt> -g, --getT0FromPromptPeak [&lt;firstGoodBinOffset&gt;] </dt><dd> tries to estimate <strong>t0</strong> from the <em>prompt peak</em> (maximum entry) in each histogram and writes the corresponding values to the <a href="#TimeZero" class="foswikiCurrentTopicLink">t0 lines</a> in the <a href="#TheRunBlock" class="foswikiCurrentTopicLink">RUN blocks</a> of the msr file. If an optional number <strong>&lt;firstGoodBinOffset&gt;</strong> is given, the lower limit of the <a href="#DataRange" class="foswikiCurrentTopicLink"><b>data</b> range</a> will be set to <strong>t0 + &lt;firstGoodBinOffset&gt;</strong>.
</dd> <dt> --help </dt><dd> displays a small help notice in the shell explaining the basic usage of the program
</dd> <dt> --version </dt><dd> prints the version number of <code>musrt0</code>
</dd></dl>
<p></p>
The interactive mode of <code>musrt0</code> is started if the program is called with a sole msr-file argument, e.g.
<pre class="bash">musrt0 8472.msr</pre>
Then a <code>ROOT</code> canvas depicting the histogram of the data set mentioned first in the <a href="#TheRunBlock" class="foswikiCurrentTopicLink">RUN block</a> is drawn in different colors:<br />
<img src="../pub/MUSR/MusrFit/musrt0.png" alt="musrt0" width='626' height='424' align="center" /><br />
The colors of the data points represent the choice of the time windows of <strong><font color="#0000ff">data (blue)</font></strong> and <strong><font color="#ff0000">background (red)</font></strong>, as well as <strong><font color="#008000">t0 (green line)</font></strong>. In order to change these ranges the mouse cross-hair is moved to a channel of choice and one of the following keys is pressed: <dl>
<dt> q </dt><dd> close the currently open histogram and opens the next (see also below)
</dd> <dt> Q </dt><dd> quit <code>musrt0</code> without writing into the msr file
</dd> <dt> z </dt><dd> zoom into the region about the <strong>t0</strong>
</dd> <dt> u </dt><dd> unzoom to the full range
</dd> <dt> t </dt><dd> set <strong>t0</strong>
</dd> <dt> T </dt><dd> automatically set <strong>t0</strong>, i.e. jump to the maximum of the histogram
</dd> <dt> b </dt><dd> set the lower limit of the <strong>background</strong> range
</dd> <dt> B </dt><dd> set the upper limit of the <strong>background</strong> range
</dd> <dt> d </dt><dd> set the lower limit of the <strong>data</strong> range
</dd> <dt> D </dt><dd> set the upper limit of the <strong>data</strong> range
</dd></dl>
When all channels have been set correctly for the first histogram, pressing of the key <strong>q</strong> opens the subsequent histogram listed in a RUN block and the respective channels can be updated there. This procedure is repeated until all histograms given in the RUN blocks are processed.
<p></p>
Using the key <strong>Q</strong>, <code>musrt0</code> can be interrupted. No changes to the msr file are applied in this case.<br>
Closing a window by clicking the <strong>X</strong> button is equivalent to pressing <strong>Q</strong>, i.e. <code>musrt0</code> is simply terminated.
<p></p>
<a name="MusrParam"></a>
<h2><a name="A_2.4_musrparam"></a> 2.4 musrparam </h2>
<code>musrparam</code> is used in order to extract the fit parameters of multiple msr output files and to summarize them in a multi-column ASCII file which then can be imported by other programs like <a href="http://www.gnuplot.info/" target="_top">gnuplot</a>, <a href="http://soft.proindependent.com/qtiplot.html" target="_top">qtiplot</a> or <a href="http://www.originlab.com/" target="_top">Origin<sup>&reg;</sup></a> to name just a few.
As mandatory parameters it accepts two file names in the following order: <dl>
<dt> &lt;input_file_name&gt; </dt><dd> file name of the control file to extract the parameters.
</dd></dl>
The input file itself has the following structure:
<pre>
msr-file-name-1, independent-var1-1, independent-var2-1
msr-file-name-2, independent-var1-2, independent-var2-2
etc.
</pre>
It is allowed to add comment lines starting with <strong>%</strong>.
<p></p> <dl>
<dt> &lt;output_file_name&gt; </dt><dd> file name of the generated output file.
</dd></dl>
The output will have the structure:
<pre>
msr-file-name-1, independent-var1-1, ..., par1, err&#95;par1, par2, err&#95;par2, par3, err&#95;par3, ...
msr-file-name-2, independent-var1-2, ..., par1, err&#95;par1, par2, err&#95;par2, par3, err&#95;par3, ...
etc.
</pre>
If positive and negative errors are present, it will be
<pre>
msr-file-name-1, independent-var1-1, ..., par1, err&#95;par1-, err&#95;par1+, par2, err&#95;par2-, err&#95;par2+, ...
etc.
</pre>
<p></p>
<a name="MusrfitStartupXml"></a>
<h2><a name="A_2.5_musrfit_startup.xml"></a> 2.5 musrfit_startup.xml </h2>
<code><b>musrfit_startup.xml</b></code> is a configuration file located at the <code>musrfit</code> binary path. In this file the following XML tags are allowed to define settings: <dl>
<dt> &lt;data_path&gt;PATH_TO_DATA&lt;/data_path&gt; </dt><dd> add the new path <strong>PATH_TO_DATA</strong> where <code>musrfit</code> and <code>musrview</code> will search for data files
</dd> <dt> &lt;write_per_run_block_chisq&gt;<b>y/n</b>&lt;/write_per_run_block_chisq&gt; </dt><dd> if enabled &chi;<sup>2</sup> for each RUN block will be written to the <a href="#TheStatisticBlock" class="foswikiCurrentTopicLink">STATISTIC block</a> of the resulting <code>msr</code> file. Additionally, in case a &chi;<sup>2</sup> <a href="#SingleHistogramFit" class="foswikiCurrentTopicLink">single-histogram fit</a> is done, also <a href="http://en.wikipedia.org/wiki/Pearson's_chi-square_test" target="_top">Pearson's &chi;<sup>2</sup></a> will be added.
</dd> <dt> &lt;fourier_settings&gt;&lt;/fourier_settings&gt; </dt><dd> set the default parameters for the Fourier transform in <code>musrview</code>. For further details refer to <a href="#TheFourierBlock" class="foswikiCurrentTopicLink">the description of the msr file</a>. <dl>
<dt> &lt;units&gt;UNITS&lt;/units&gt; </dt><dd> specify the units of the frequency or field-domain. Valid units are <strong>Gauss</strong>, <strong>MHz</strong> and <strong>Mc/s</strong> (inside a &lt;fourier_settings&gt; environment)
</dd> <dt> &lt;fourier_power&gt;<i>n</i>&lt;/fourier_power&gt; </dt><dd> specify the number of points 2<sup><b><i>n</i></b></sup> (<b><i>n</i></b> &lt; 21) to be used for the Fourier transform (inside a &lt;fourier_settings&gt; environment)
</dd> <dt> &lt;apodization&gt;APOD&lt;/apodization&gt; </dt><dd> set the default apodization method. Valid apodizations are <strong>none</strong>, <strong>weak</strong>, <strong>medium</strong> and <strong>strong</strong> (inside a &lt;fourier_settings&gt; environment)
</dd> <dt> &lt;plot&gt;PLOT&lt;/plot&gt; </dt><dd> specify which part of the Fourier transform is plotted by default. You can choose between <strong>real</strong>, <strong>imag</strong>, <strong>real_and_imag</strong>, <strong>power</strong> and <strong>phase</strong> (inside a &lt;fourier_settings&gt; environment)
</dd> <dt> &lt;phase&gt;PH&lt;/phase&gt; </dt><dd> set the initial phase shift <strong>PH</strong> (in degrees) of the data to be Fourier transformed (inside a &lt;fourier_settings&gt; environment)
</dd> <dt> &lt;phase_increment&gt;PHINCR&lt;/phase_increment&gt; </dt><dd> change the default value of the phase increment (in degrees) used for the phase optimization to <strong>PHINCR</strong> (inside a &lt;fourier_settings&gt; environment)
</dd></dl>
</dd> <dt> &lt;root_settings&gt;&lt;/root_settings&gt; </dt><dd> change the default <code>ROOT</code> settings <dl>
<dt> &lt;marker_list&gt;&lt;/marker_list&gt; </dt><dd> specify the order in which <code>musrview</code> should use markers when plotting data (inside a &lt;root_settings&gt; environment) <dl>
<dt> &lt;marker&gt;X&lt;/marker&gt; </dt><dd> use the <code>ROOT</code> marker number <strong>X</strong> (inside a &lt;marker_list&gt; environment)
</dd></dl>
</dd> <dt> &lt;color_list&gt;&lt;/color_list&gt; </dt><dd> specify the order in which <code>musrview</code> should use colors when plotting data (inside a &lt;root_settings&gt; environment) <dl>
<dt> &lt;color&gt;<font color="#ff0000">R</font>,<font color="#008000">G</font>,<font color="#0000ff">B</font>&lt;/color&gt; </dt><dd> use the RGB coded color (inside a &lt;color_list&gt; environment)
</dd></dl>
</dd></dl>
</dd></dl>
<p></p>
An example would look like:
<pre class="html">
&#60;?xml version&#61;&#34;1.0&#34; encoding&#61;&#34;UTF-8&#34;?&#62;
&#60;musrfit xmlns&#61;&#34;https://intranet.psi.ch/MUSR/MusrFit&#34;&#62;
&#60;data&#95;path&#62;/mnt/data/nemu/his&#60;/data&#95;path&#62;
&#60;write&#95;per&#95;run&#95;block&#95;chisq&#62;y&#60;/write&#95;per&#95;run&#95;block&#95;chisq&#62;
&#60;fourier&#95;settings&#62;
&#60;units&#62;Gauss&#60;/units&#62;
&#60;fourier&#95;power&#62;0&#60;/fourier&#95;power&#62;
&#60;apodization&#62;none&#60;/apodization&#62;
&#60;plot&#62;real&#95;and&#95;imag&#60;/plot&#62;
&#60;phase&#62;0.0&#60;/phase&#62;
&#60;phase&#95;increment&#62;1.0&#60;/phase&#95;increment&#62;
&#60;/fourier&#95;settings&#62;
&#60;root&#95;settings&#62;
&#60;marker&#95;list&#62;
&#60;!-- Root marker numbers --&#62;
&#60;marker&#62;24&#60;/marker&#62;
&#60;marker&#62;25&#60;/marker&#62;
&#60;marker&#62;26&#60;/marker&#62;
&#60;marker&#62;27&#60;/marker&#62;
&#60;/marker&#95;list&#62;
&#60;color&#95;list&#62;
&#60;!-- Color as RGB coded string --&#62;
&#60;color&#62;0,0,0&#60;/color&#62;
&#60;color&#62;255,0,0&#60;/color&#62;
&#60;color&#62;0,255,0&#60;/color&#62;
&#60;color&#62;0,0,255&#60;/color&#62;
&#60;/color&#95;list&#62;
&#60;/root&#95;settings&#62;
&#60;/musrfit&#62;
</pre>
<p></p>
<a name="Msr2Msr"></a>
<h2><a name="A_2.6_msr2msr"></a> 2.6 msr2msr </h2>
<code>msr2msr</code> is a small utility for converting existing <code>WKM</code> msr files into <code>musrfit</code> msr files. It accepts the following parameters: <dl>
<dt> &lt;msr_file_in&gt; </dt><dd> input <code>WKM</code> msr file (mandatory first parameter)
</dd> <dt> &lt;msr_file_out&gt; </dt><dd> converted output <code>musrfit</code> msr file (mandatory second parameter)
</dd> <dt> --help </dt><dd> displays a small help notice in the shell explaining the basic usage of the program
</dd></dl>
<p></p>
A typical example then looks like:
<pre class="bash">msr2msr 8472-WKM.msr 8472-musrfit.msr</pre>
If the input file has already the <code>musrfit</code> msr file structure, the output file will be just a copy of the input file.
<p></p>
<a name="AuxiliaryPrograms"></a>
<h1><a name="A_3_Auxiliary_Programs"></a> 3 Auxiliary Programs </h1>
Additionally to the programs mentioned above editor front ends called <code><a href="MusrGui.html">musrgui/musredit</a></code> and another tool named <code><a href="Msr2Data.html">msr2data</a></code> are available. The purpose of <code>msr2data</code> is to process multiple msr files with the same parameters and to summarize the fitting results either in a <strong>DB</strong> or a <strong>column ASCII</strong> file. Also, new msr files can be generated from a template. For details refer to its <a href="Msr2Data.html">manual</a>.
<p></p>
<strong><font color="#ff0000">Before going to use <code>musrgui</code> / <code>musredit</code> it is strongly recommended to read this manual first!</font></strong>
<p></p>
<a name="DescriptionOfTheMsrFileFormat"></a>
<h1><a name="A_4_Description_of_the_msr_File_Format"></a> 4 Description of the msr File Format </h1>
The programs are using an input file to control their action. This input file has the extension .msr (msr file). The msr file is built up from different blocks. Each block starts with a keyword and is&mdash;with the exception of the title&mdash;terminated by an empty line. Comments start with the character <strong>#</strong>. The various input blocks are described below.
<p></p>
<a name="TheTitle"></a>
<h2><a name="A_4.1_The_Title"></a> 4.1 The Title </h2>
The first line of the msr file is the title line. Unlike all the other input blocks, it does not start with a block keyword. It is just a simple text line, in which any information can be placed. The title text will be used in the graphical representation of the data as a headline.
<p></p>
<a name="TheFitparameterBlock"></a>
<h2><a name="A_4.2_The_FITPARAMETER_Block"></a> 4.2 The FITPARAMETER Block </h2>
The FITPARAMETER block is used to define the fit parameters in a <code>MINUIT</code> typical style. There
are various possible parameter definitions which are listed here:
<pre>
1. &#60;no&#62; &#60;name&#62; &#60;value&#62; &#60;step&#62;
2. &#60;no&#62; &#60;name&#62; &#60;value&#62; &#60;step&#62; &#60;lower&#95;boundary&#62; &#60;upper&#95;boundary&#62;
3. &#60;no&#62; &#60;name&#62; &#60;value&#62; &#60;step&#62; &#60;pos&#95;error&#62; &#60;lower&#95;boundary&#62; &#60;upper&#95;boundary&#62;
</pre>
where <strong>&lt;no&gt;</strong> is the parameter number, <strong>&lt;name&gt;</strong> is the parameter name <a name="FootNote1text"></a><span class="FootNoteTextLink" title=" a standard string without whitespace "><a href="#FootNote1note" class="foswikiCurrentTopicLink">(1)</a></span>, <strong>&lt;value&gt;</strong> is the initial guess of the parameter, <strong>&lt;step&gt;</strong> the inital step width, <strong>&lt;lower/upper_boundary&gt;</strong> is the lower/upper boundary for the parameter <a name="FootNote2text"></a><span class="FootNoteTextLink" title=" According to the &#61;MINUIT&#61; manual this should be avoided whenever possible&#33; "><a href="#FootNote2note" class="foswikiCurrentTopicLink">(2)</a></span>.
<p></p>
In the output file, <strong>&lt;value&gt;</strong> will be the <code>MINUIT</code> fit value, <strong>&lt;step&gt;</strong> will contain the error estimate (or the negative error estimate if <code>MINOS</code> was successfully used), <strong>&lt;pos_error&gt;</strong> will have the value <strong>none</strong> if <code>MINOS</code> has not been used, otherwise it will show the positive error estimate.
<p></p>
A typical example looks like this:
<pre>
FITPARAMETER
# No Name Value Step Pos&#95;Error Boundaries
1 alpha 1 0.02 none 0 1.8
2 asy 0.1042 0.004713 none 0 0.33
3 phase 15 1.0 none
4 freq 0.9 0.0379 none
5 rate 0.03 0.00579 none
</pre>
<p></p>
There is also the possibility to constrain the parameters to semi-defined intervals (like par &gt; a or par &lt; b). The syntax is as follows:
<pre>
FITPARAMETER
# No Name Value Step Pos&#95;Error Boundaries
# Specify only a lower boundary for the parameter
1 Asy1 0.04501 -0.00208 0.00211 0 none
# Specify only an upper boundary for the parameter
2 Rate1 0.14245 -0.02501 0.02279 none 10
# Specify lower and upper boundaries for the parameter
3 Asy2 0.14501 -0.00208 0.00211 0 0.33
# Do not specify boundaries at all
4 Field2 343.212 -2.27960 2.27885
5 Rate2 0.42045 -0.02501 0.02279 none none
</pre>
<p></p>
<p></p>
<p></p>
Notes
<p></p>
<a name="FootNote1note"></a><span class="FootNoteLabel"><a href="MusrFit.html#FootNote1text" class="foswikiCurrentWebHomeLink"> <strong>1</strong> </a></span>: <span class="FootNote"> a standard string without whitespace </span>
<p></p>
<a name="FootNote2note"></a><span class="FootNoteLabel"><a href="MusrFit.html#FootNote2text" class="foswikiCurrentWebHomeLink"> <strong>2</strong> </a></span>: <span class="FootNote"> According to the <code>MINUIT</code> manual this should be avoided whenever possible! </span>
<p></p>
<p></p>
<p></p>
<hr />
<p></p>
<a name="TheTheoryBlock"></a>
<h2><a name="A_4.3_The_THEORY_Block"></a> 4.3 The THEORY Block </h2>
The THEORY block is used to define the fit function. There is a set of predefined functions available. It is also possible to use externally defined functions. How to use them will be explained afterwards, here only the predefined functions are described.
<p></p>
<a name="TheoryTable"></a>
<table class="foswikiTable" rules="none" border="1">
<thead>
<tr class="foswikiTableOdd foswikiTableRowdataBgSorted0 foswikiTableRowdataBg0">
<th class="foswikiTableCol0 foswikiFirstCol"> <a rel="nofollow" href="https://intranet.psi.ch/MUSR/MusrFit?cover=print;sortcol=0;table=1;up=0#sorted_table" title="Sort by this column">name</a> </th>
<th class="foswikiTableCol1"> <a rel="nofollow" href="https://intranet.psi.ch/MUSR/MusrFit?cover=print;sortcol=1;table=1;up=0#sorted_table" title="Sort by this column">abbreviation</a> </th>
<th class="foswikiTableCol2"> <a rel="nofollow" href="https://intranet.psi.ch/MUSR/MusrFit?cover=print;sortcol=2;table=1;up=0#sorted_table" title="Sort by this column">parameters</a> </th>
<th class="foswikiTableCol3"> <a rel="nofollow" href="https://intranet.psi.ch/MUSR/MusrFit?cover=print;sortcol=3;table=1;up=0#sorted_table" title="Sort by this column">mathematical expression</a> </th>
<th rowspan="5" class="foswikiTableCol4 foswikiLastCol"> <a rel="nofollow" href="https://intranet.psi.ch/MUSR/MusrFit?cover=print;sortcol=4;table=1;up=0#sorted_table" title="Sort by this column">reference</a> </th>
</tr>
</thead>
<tbody>
<tr class="foswikiTableEven foswikiTableRowdataBgSorted0 foswikiTableRowdataBg0">
<td class="foswikiTableCol0 foswikiFirstCol"> asymmetry </td>
<td class="foswikiTableCol1"> a </td>
<td class="foswikiTableCol2"> <img alt="A\,(1)" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_facd1d42ae8b62aa1043316d525d3af4.png" /> </td>
<td class="foswikiTableCol3"> <img alt="A" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_be8817308ad9fe2fa99fe00abdaba828.png" /> </td>
</tr>
<tr class="foswikiTableOdd foswikiTableRowdataBgSorted1 foswikiTableRowdataBg1">
<td class="foswikiTableCol0 foswikiFirstCol"> simplExpo </td>
<td class="foswikiTableCol1"> se </td>
<td class="foswikiTableCol2"> <img alt="\lambda\,(\mu\text{s}^{-1})" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_020e973cf5b1293c76cb3ecef5a269f8.png" /> </td>
<td class="foswikiTableCol3"> <img alt="\exp\left(-\lambda t\right)" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_6a34fe0c88c79d8a90defad81f36da6d.png" /> </td>
</tr>
<tr class="foswikiTableEven foswikiTableRowdataBgSorted0 foswikiTableRowdataBg0">
<td class="foswikiTableCol0 foswikiFirstCol"> generExpo </td>
<td class="foswikiTableCol1"> ge </td>
<td class="foswikiTableCol2"> <img alt="\lambda\,(\mu\text{s}^{-1})" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_020e973cf5b1293c76cb3ecef5a269f8.png" />, <img alt="\beta\,(1)" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_aad467dd15ac57481f24ada5fbe5d85f.png" /> </td>
<td class="foswikiTableCol3"> <img alt="\exp\left&#91;-\left(\lambda t\right)^{\beta}\right]" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_8b46c96933bc8a754fde5aa613d0e806.png" /> </td>
</tr>
<tr class="foswikiTableOdd foswikiTableRowdataBgSorted1 foswikiTableRowdataBg1">
<td class="foswikiTableCol0 foswikiFirstCol"> simpleGss </td>
<td class="foswikiTableCol1"> sg </td>
<td class="foswikiTableCol2"> <img alt="\sigma\,(\mu\text{s}^{-1})" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_6b6bbc4add4da0bde8220c54594658f3.png" /> </td>
<td class="foswikiTableCol3"> <img alt="\exp\left&#91;-\frac{1}{2}\left(\sigma t\right)^2\right]" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_d284ec460bdb1abb64e7f9156d87d659.png" /> </td>
</tr>
<tr class="foswikiTableEven foswikiTableRowdataBgSorted0 foswikiTableRowdataBg0">
<td class="foswikiTableCol0 foswikiFirstCol"> statGssKT </td>
<td class="foswikiTableCol1"> stg </td>
<td class="foswikiTableCol2"> <img alt="\sigma\,(\mu\text{s}^{-1})" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_6b6bbc4add4da0bde8220c54594658f3.png" /> </td>
<td class="foswikiTableCol3"> <img alt="\frac{1}{3} + \frac{2}{3} \left&#91;1-(\sigma t)^2\right] \exp\left&#91;-\frac{1}{2}\left(\sigma t\right)^2\right]" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_1f1b2becd9ba1bee3b5d7f897bd8db7e.png" /> </td>
<td class="foswikiTableCol4 foswikiLastCol"> <img src="../pub/Main/SmiliesPluginPSI/skull.gif" alt="dead!" title="dead!" border="0" /> </td>
</tr>
<tr class="foswikiTableOdd foswikiTableRowdataBgSorted1 foswikiTableRowdataBg1">
<td class="foswikiTableCol0 foswikiFirstCol"> statGssKTLF </td>
<td class="foswikiTableCol1"> sgktlf </td>
<td class="foswikiTableCol2"> <img alt="\nu\,(\mathrm{MHz})" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_7188605a647615e4fb92cc89274b22a0.png" />, <img alt="\sigma\,(\mu\text{s}^{-1})" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_6b6bbc4add4da0bde8220c54594658f3.png" /> </td>
<td class="foswikiTableCol3"> <img alt="G&#95;{\mathrm{G,LF}}(t) \equiv 1-\frac{2\sigma^2}{(2\pi\nu)^2}\left&#91;1-\exp\left(-\frac{1}{2}\sigma^2t^2\right)\cos(2\pi\nu t)\right]+\frac{2\sigma^4}{(2\pi\nu)^3}\int^t&#95;0 \exp\left(-\frac{1}{2}\sigma^2\tau^2\right)\sin(2\pi\nu\tau)\mathrm{d}\tau" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_e9a0c0aa5d84cb4ea67265a3b06b9af5.png" /> </td>
<td class="foswikiTableCol4 foswikiLastCol"> <a name="FootNote3text"></a><span class="FootNoteTextLink" title=" R&#46; S&#46; Hayano _et al&#46;_&#44; &#91;&#91;http&#58;&#47;&#47;link&#46;aps&#46;org&#47;doi&#47;10&#46;1103&#47;PhysRevB&#46;20&#46;850&#93;&#91;Phys&#46; Rev&#46; B &#42;20&#42; &#40;1979&#41; 850&#93;&#93; "><a href="#FootNote3note" class="foswikiCurrentTopicLink">(4)</a></span> </td>
</tr>
<tr class="foswikiTableEven foswikiTableRowdataBgSorted0 foswikiTableRowdataBg0">
<td class="foswikiTableCol0 foswikiFirstCol"> dynGssKTLF </td>
<td class="foswikiTableCol1"> dgktlf </td>
<td class="foswikiTableCol2"> <img alt="\nu\,(\mathrm{MHz})" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_7188605a647615e4fb92cc89274b22a0.png" />, <img alt="\sigma\,(\mu\text{s}^{-1})" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_6b6bbc4add4da0bde8220c54594658f3.png" />, <img alt="\Gamma\,(\mathrm{MHz})" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_f87b1352f663a35bf263bc7e9a214ca3.png" /> </td>
<td class="foswikiTableCol3"> <img alt="\frac{1}{2\pi \imath}\int&#95;{\gamma-\imath\infty}^{\gamma+\imath\infty} \frac{f&#95;{\mathrm{G}}(s+\Gamma)}{1-\Gamma f&#95;{\mathrm{G}}(s+\Gamma)} \exp(s t) \mathrm{d}s,\mathrm{where}\,f&#95;{\mathrm{G}}(s)\equiv \int&#95;0^{\infty}G&#95;{\mathrm{G,LF}}(t)\exp(-s t) \mathrm{d}t" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_cb688f85a062f09bfaff5cf9144860a9.png" /> </td>
<td class="foswikiTableCol4 foswikiLastCol"> <a name="FootNote4text"></a><span class="FootNoteTextLink" title=" R&#46; S&#46; Hayano _et al&#46;_&#44; &#91;&#91;http&#58;&#47;&#47;link&#46;aps&#46;org&#47;doi&#47;10&#46;1103&#47;PhysRevB&#46;20&#46;850&#93;&#91;Phys&#46; Rev&#46; B &#42;20&#42; &#40;1979&#41; 850&#93;&#93;&#59; P&#46; Dalmas de R&#38;eacute&#59;otier and A&#46; Yaouanc&#44; &#91;&#91;http&#58;&#47;&#47;dx&#46;doi&#46;org&#47;10&#46;1088&#47;0953&#45;8984&#47;4&#47;18&#47;020&#93;&#91;J&#46; Phys&#46;&#58; Condens&#46; Matter &#42;4&#42; &#40;1992&#41; 4533&#93;&#93;&#59; A&#46; Keren&#44; &#91;&#91;http&#58;&#47;&#47;link&#46;aps&#46;org&#47;doi&#47;10&#46;1103&#47;PhysRevB&#46;50&#46;10039&#93;&#91;Phys&#46; Rev&#46; B &#42;50&#42; &#40;1994&#41; 10039&#93;&#93; "><a href="#FootNote4note" class="foswikiCurrentTopicLink">(5)</a></span> </td>
</tr>
<tr class="foswikiTableOdd foswikiTableRowdataBgSorted1 foswikiTableRowdataBg1">
<td class="foswikiTableCol0 foswikiFirstCol"> statExpKT </td>
<td class="foswikiTableCol1"> sekt </td>
<td class="foswikiTableCol2"> <img alt="\lambda\,(\mu\text{s}^{-1})" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_020e973cf5b1293c76cb3ecef5a269f8.png" /> </td>
<td class="foswikiTableCol3"> <img alt="\frac{1}{3} + \frac{2}{3} \left&#91;1-\lambda t\right] \exp\left(-\lambda t\right)" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_6466a97e4b7c510909bffce51d31c4b9.png" /> </td>
<td class="foswikiTableCol4 foswikiLastCol"> <a name="FootNote5text"></a><span class="FootNoteTextLink" title=" Y&#46; J&#46; Uemura _et al&#46;_&#44; &#91;&#91;http&#58;&#47;&#47;link&#46;aps&#46;org&#47;doi&#47;10&#46;1103&#47;PhysRevB&#46;31&#46;546&#93;&#91;Phys&#46; Rev&#46; B &#42;31&#42; &#40;1985&#41; 546&#93;&#93; "><a href="#FootNote5note" class="foswikiCurrentTopicLink">(6)</a></span> </td>
</tr>
<tr class="foswikiTableEven foswikiTableRowdataBgSorted0 foswikiTableRowdataBg0">
<td class="foswikiTableCol0 foswikiFirstCol"> statExpKTLF </td>
<td class="foswikiTableCol1"> sektlf </td>
<td class="foswikiTableCol2"> <img alt="\nu\,(\mathrm{MHz})" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_7188605a647615e4fb92cc89274b22a0.png" />, <img alt="a\,(\mu\text{s}^{-1})" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_26a5ae8799badcc3bcbe1823265a9053.png" /> </td>
<td class="foswikiTableCol3"> <img alt="1-\frac{a}{2\pi\nu}j&#95;1(2\pi\nu t)\exp\left(-at\right)-\left(\frac{a}{2\pi\nu}\right)^2 \left&#91;j&#95;0(2\pi\nu t)\exp\left(-at\right)-1\right]-a\left&#91;1+\left(\frac{a}{2\pi\nu}\right)^2\right]\int^t&#95;0 \exp\left(-a\tau\right)j&#95;0(2\pi\nu\tau)\mathrm{d}\tau \equiv G&#95;{\mathrm{L,LF}}(t)" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_df4770dd7b14577f14410b4f7ab59721.png" /> </td>
<td class="foswikiTableCol4 foswikiLastCol"> <a name="FootNote6text"></a><span class="FootNoteTextLink" title=" Y&#46; J&#46; Uemura _et al&#46;_&#44; &#91;&#91;http&#58;&#47;&#47;link&#46;aps&#46;org&#47;doi&#47;10&#46;1103&#47;PhysRevB&#46;31&#46;546&#93;&#91;Phys&#46; Rev&#46; B &#42;31&#42; &#40;1985&#41; 546&#93;&#93; "><a href="#FootNote6note" class="foswikiCurrentTopicLink">(7)</a></span> </td>
</tr>
<tr class="foswikiTableOdd foswikiTableRowdataBgSorted1 foswikiTableRowdataBg1">
<td class="foswikiTableCol0 foswikiFirstCol"> dynExpKTLF </td>
<td class="foswikiTableCol1"> dektlf </td>
<td class="foswikiTableCol2"> <img alt="\nu\,(\mathrm{MHz})" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_7188605a647615e4fb92cc89274b22a0.png" />, <img alt="a\,(\mu\text{s}^{-1})" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_26a5ae8799badcc3bcbe1823265a9053.png" />, <img alt="\Gamma\,(\mathrm{MHz})" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_f87b1352f663a35bf263bc7e9a214ca3.png" /> </td>
<td class="foswikiTableCol3"> <img alt="\frac{1}{2\pi \imath}\int&#95;{\gamma-\imath\infty}^{\gamma+\imath\infty} \frac{f&#95;{\mathrm{L}}(s+\Gamma)}{1-\Gamma f&#95;{\mathrm{L}}(s+\Gamma)} \exp(s t) \mathrm{d}s,\mathrm{where}\,f&#95;{\mathrm{L}}(s)\equiv \int&#95;0^{\infty}G&#95;{\mathrm{L,LF}}(t)\exp(-s t) \mathrm{d}t" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_c5c6dea10611dae1d470a5615869073a.png" /> </td>
<td class="foswikiTableCol4 foswikiLastCol"> <a name="FootNote7text"></a><span class="FootNoteTextLink" title=" R&#46; S&#46; Hayano _et al&#46;_&#44; &#91;&#91;http&#58;&#47;&#47;link&#46;aps&#46;org&#47;doi&#47;10&#46;1103&#47;PhysRevB&#46;20&#46;850&#93;&#91;Phys&#46; Rev&#46; B &#42;20&#42; &#40;1979&#41; 850&#93;&#93;&#59; P&#46; Dalmas de R&#38;eacute&#59;otier and A&#46; Yaouanc&#44; &#91;&#91;http&#58;&#47;&#47;dx&#46;doi&#46;org&#47;10&#46;1088&#47;0953&#45;8984&#47;4&#47;18&#47;020&#93;&#91;J&#46; Phys&#46;&#58; Condens&#46; Matter &#42;4&#42; &#40;1992&#41; 4533&#93;&#93; "><a href="#FootNote7note" class="foswikiCurrentTopicLink">(8)</a></span> </td>
</tr>
<tr class="foswikiTableEven foswikiTableRowdataBgSorted0 foswikiTableRowdataBg0">
<td class="foswikiTableCol0 foswikiFirstCol"> combiLGKT </td>
<td class="foswikiTableCol1"> lgkt </td>
<td class="foswikiTableCol2"> <img alt="\lambda\,(\mu\text{s}^{-1})" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_020e973cf5b1293c76cb3ecef5a269f8.png" />, <img alt="\sigma\,(\mu\text{s}^{-1})" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_6b6bbc4add4da0bde8220c54594658f3.png" /> </td>
<td class="foswikiTableCol3"> <img alt="\frac{1}{3}+\frac{2}{3}\left(1-\sigma^2 t^2-\lambda t\right)\exp\left(-\frac{\sigma^2t^2}{2}-\lambda t\right)" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_95da508ef32b516260a14999eaf14f46.png" /> </td>
<td class="foswikiTableCol4 foswikiLastCol"> <img src="../pub/Main/SmiliesPluginPSI/skull.gif" alt="dead!" title="dead!" border="0" /> </td>
</tr>
<tr class="foswikiTableOdd foswikiTableRowdataBgSorted1 foswikiTableRowdataBg1">
<td class="foswikiTableCol0 foswikiFirstCol"> spinGlass </td>
<td class="foswikiTableCol1"> spg </td>
<td class="foswikiTableCol2"> <img alt="\lambda\,(\mu\text{s}^{-1})" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_020e973cf5b1293c76cb3ecef5a269f8.png" />, <img alt="\gamma\,(\mu\text{s}^{-1})" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_8aad0e0c2c1f20995c483933a896ca0d.png" />, <img alt="q\,(1)" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_16b8c518c1e529e6c963929287ef3a56.png" /> </td>
<td class="foswikiTableCol3"> <img alt="\frac{1}{3}\exp\left(-\sqrt{\frac{4\lambda^2(1-q)t}{\gamma}}\right)+\frac{2}{3}\left(1-\frac{q\lambda^2t^2}{\sqrt{\frac{4\lambda^2(1-q)t}{\gamma}+q\lambda^2t^2}}\right)\exp\left(-\sqrt{\frac{4\lambda^2(1-q)t}{\gamma}+q\lambda^2t^2}\right)" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_e35c4217aa50607f25e6eadf9f27f874.png" /> </td>
<td class="foswikiTableCol4 foswikiLastCol"> <img src="../pub/Main/SmiliesPluginPSI/skull.gif" alt="dead!" title="dead!" border="0" /> </td>
</tr>
<tr class="foswikiTableEven foswikiTableRowdataBgSorted0 foswikiTableRowdataBg0">
<td class="foswikiTableCol0 foswikiFirstCol"> rdAnisoHf </td>
<td class="foswikiTableCol1"> rahf </td>
<td class="foswikiTableCol2"> <img alt="\nu\,(\mathrm{MHz})" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_7188605a647615e4fb92cc89274b22a0.png" />, <img alt="\lambda\,(\mu\text{s}^{-1})" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_020e973cf5b1293c76cb3ecef5a269f8.png" /> </td>
<td class="foswikiTableCol3"> <img alt="\frac{1}{6}\left(1-\frac{\nu t}{2}\right)\exp\left(-\frac{\nu t}{2}\right)+\frac{1}{3}\left(1-\frac{\nu t}{4}\right)\exp\left(-\frac{\nu t + 2.44949\lambda t}{4}\right)" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_f91ff8255a7b8a99c5eefcb2c29f9262.png" /> </td>
<td class="foswikiTableCol4 foswikiLastCol"> <a name="FootNote8text"></a><span class="FootNoteTextLink" title=" R&#46; E&#46; Turner and D&#46; R&#46; Harshman&#44; &#91;&#91;http&#58;&#47;&#47;link&#46;aps&#46;org&#47;doi&#47;10&#46;1103&#47;PhysRevB&#46;34&#46;4467&#93;&#91;Phys&#46; Rev&#46; B &#42;34&#42; &#40;1986&#41; 4467&#93;&#93; "><a href="#FootNote8note" class="foswikiCurrentTopicLink">(9)</a></span> </td>
</tr>
<tr class="foswikiTableOdd foswikiTableRowdataBgSorted1 foswikiTableRowdataBg1">
<td class="foswikiTableCol0 foswikiFirstCol"> TFieldCos </td>
<td class="foswikiTableCol1"> tf </td>
<td class="foswikiTableCol2"> <img alt="\varphi\,(^{\circ})" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_61136f20673ad20f955c43e43b8cec9d.png" />, <img alt="\nu\,(\mathrm{MHz})" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_7188605a647615e4fb92cc89274b22a0.png" /> </td>
<td class="foswikiTableCol3"> <img alt="\cos\left(2\pi\nu t+\frac{\pi\varphi}{180}\right)" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_51757d805f7111ffe6e0b430b6d137c7.png" /> </td>
<td class="foswikiTableCol4 foswikiLastCol"> <img src="../pub/Main/SmiliesPluginPSI/skull.gif" alt="dead!" title="dead!" border="0" /> </td>
</tr>
<tr class="foswikiTableEven foswikiTableRowdataBgSorted0 foswikiTableRowdataBg0">
<td class="foswikiTableCol0 foswikiFirstCol"> internFld </td>
<td class="foswikiTableCol1"> if </td>
<td class="foswikiTableCol2"> <img alt="\alpha\,(1)" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_f266f29ff7212b8d77bf67567eac1fd3.png" />, <img alt="\varphi\,(^{\circ})" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_61136f20673ad20f955c43e43b8cec9d.png" />, <img alt="\nu\,(\mathrm{MHz})" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_7188605a647615e4fb92cc89274b22a0.png" />, <img alt="\lambda&#95;{\mathrm{T}}\,(\mu\text{s}^{-1})" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_49046b617890ffeaca8bc16ae66d0dc5.png" />, <img alt="\lambda&#95;{\mathrm{L}}\,(\mu\text{s}^{-1})" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_b0c4a8cbbcf4189b64418b381939a979.png" /> </td>
<td class="foswikiTableCol3"> <img alt="\alpha\,\cos\left(2\pi\nu t+\frac{\pi\varphi}{180}\right)\exp\left(-\lambda&#95;{\mathrm{T}}t\right)+(1-\alpha)\,\exp\left(-\lambda&#95;{\mathrm{L}}t\right)" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_1582d158c5651581ca9e800ee698ce9f.png" /> </td>
<td class="foswikiTableCol4 foswikiLastCol"> <img src="../pub/Main/SmiliesPluginPSI/skull.gif" alt="dead!" title="dead!" border="0" /> </td>
</tr>
<tr class="foswikiTableOdd foswikiTableRowdataBgSorted1 foswikiTableRowdataBg1">
<td class="foswikiTableCol0 foswikiFirstCol"> Bessel </td>
<td class="foswikiTableCol1"> b </td>
<td class="foswikiTableCol2"> <img alt="\varphi\,(^{\circ})" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_61136f20673ad20f955c43e43b8cec9d.png" />, <img alt="\nu\,(\mathrm{MHz})" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_7188605a647615e4fb92cc89274b22a0.png" /> </td>
<td class="foswikiTableCol3"> <img alt="j&#95;0\left(2\pi\nu t+\frac{\pi\varphi}{180}\right)" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_cff60a46de8608e97a33bbae7c4e566d.png" /> </td>
<td class="foswikiTableCol4 foswikiLastCol"> <img src="../pub/Main/SmiliesPluginPSI/skull.gif" alt="dead!" title="dead!" border="0" /> </td>
</tr>
<tr class="foswikiTableEven foswikiTableRowdataBgSorted0 foswikiTableRowdataBg0">
<td class="foswikiTableCol0 foswikiFirstCol"> internBsl </td>
<td class="foswikiTableCol1"> ib </td>
<td class="foswikiTableCol2"> <img alt="\alpha\,(1)" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_f266f29ff7212b8d77bf67567eac1fd3.png" />, <img alt="\varphi\,(^{\circ})" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_61136f20673ad20f955c43e43b8cec9d.png" />, <img alt="\nu\,(\mathrm{MHz})" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_7188605a647615e4fb92cc89274b22a0.png" />, <img alt="\lambda&#95;{\mathrm{T}}\,(\mu\text{s}^{-1})" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_49046b617890ffeaca8bc16ae66d0dc5.png" />, <img alt="\lambda&#95;{\mathrm{L}}\,(\mu\text{s}^{-1})" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_b0c4a8cbbcf4189b64418b381939a979.png" /> </td>
<td class="foswikiTableCol3"> <img alt="\alpha\,j&#95;0\left(2\pi\nu t+\frac{\pi\varphi}{180}\right)\exp\left(-\lambda&#95;{\mathrm{T}}t\right)+(1-\alpha)\,\exp\left(-\lambda&#95;{\mathrm{L}}t\right)" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_23ec8fc398b4e415b86bbd2b65f9a63c.png" /> </td>
<td class="foswikiTableCol4 foswikiLastCol"> <img src="../pub/Main/SmiliesPluginPSI/skull.gif" alt="dead!" title="dead!" border="0" /> </td>
</tr>
<tr class="foswikiTableOdd foswikiTableRowdataBgSorted1 foswikiTableRowdataBg1">
<td class="foswikiTableCol0 foswikiFirstCol"> abragam </td>
<td class="foswikiTableCol1"> ab </td>
<td class="foswikiTableCol2"> <img alt="\sigma\,(\mu\text{s}^{-1})" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_6b6bbc4add4da0bde8220c54594658f3.png" />, <img alt="\gamma\,(\mathrm{MHz})" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_ebef6cda2881306e993839c1b4bcaa4c.png" /> </td>
<td class="foswikiTableCol3"> <img alt="\exp\left&#91;-\frac{\sigma^2}{\gamma^2}\left(e^{-\gamma t}-1+\gamma t\right)\right]" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_e56be15b7e230ec52a9f6632e552ca4b.png" /> </td>
<td class="foswikiTableCol4 foswikiLastCol"> <img src="../pub/Main/SmiliesPluginPSI/skull.gif" alt="dead!" title="dead!" border="0" /> </td>
</tr>
<tr class="foswikiTableEven foswikiTableRowdataBgSorted0 foswikiTableRowdataBg0">
<td class="foswikiTableCol0 foswikiFirstCol"> skewedGss </td>
<td class="foswikiTableCol1"> skg </td>
<td class="foswikiTableCol2"> <img alt="\varphi\,(^{\circ})" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_61136f20673ad20f955c43e43b8cec9d.png" />, <img alt="\nu\,(\mathrm{MHz})" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_7188605a647615e4fb92cc89274b22a0.png" />, <img alt="\sigma&#95;{-}\,(\mu\text{s}^{-1})" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_bd5c765027d46aa1433dda03f540c17e.png" />, <img alt="\sigma&#95;{+}\,(\mu\text{s}^{-1})" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_82adbab00b6a057f04037b44746e33eb.png" /> </td>
<td class="foswikiTableCol3"> <img alt="\frac{\sigma&#95;{-}}{\sigma&#95;{+}+\sigma&#95;{-}}\exp\left&#91;-\frac{\sigma&#95;{-}^2t^2}{2}\right]\left\lbrace\cos\left(2\pi\nu t+\frac{\pi\varphi}{180}\right)+\sin\left(2\pi\nu t+\frac{\pi\varphi}{180}\right)\mathrm{Erfi}\left(\frac{\sigma&#95;{-}t}{\sqrt{2}}\right)\right\rbrace+ \frac{\sigma&#95;{+}}{\sigma&#95;{+}+\sigma&#95;{-}}\exp\left&#91;-\frac{\sigma&#95;{+}^2t^2}{2}\right]\left\lbrace\cos\left(2\pi\nu t+\frac{\pi\varphi}{180}\right)-\sin\left(2\pi\nu t+\frac{\pi\varphi}{180}\right)\mathrm{Erfi}\left(\frac{\sigma&#95;{+}t}{\sqrt{2}}\right)\right\rbrace" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_7f4cd42199fbf712ad5a86f9d94bd698.png" /> </td>
<td class="foswikiTableCol4"> <a href="http://nemu.web.psi.ch/doc/LEM_Memo/skewedGaussian/skewedGaussian.pdf" target="_top">memo</a> <span class="foswikiIcon"><img src="../pub/System/DocumentGraphics/pdf.png" width="16" height="16" alt="pdf" /></span> </td>
</tr>
<tr class="foswikiTableOdd foswikiTableRowdataBgSorted1 foswikiTableRowdataBg1">
<td class="foswikiTableCol0 foswikiFirstCol foswikiLast"> polynom </td>
<td class="foswikiTableCol1 foswikiLast"> p </td>
<td class="foswikiTableCol2 foswikiLast"> <img alt="t&#95;0\,(&#91;t])" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_20651e8230c7eb66c452bb1f01dc4633.png" />, <img alt="a&#95;0\,(1),\,a&#95;1\,(1),\,\dots,\,a&#95;{n}\,(1)" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_03095d51eca2bcb1dda113e995238fc0.png" /> </td>
<td class="foswikiTableCol3 foswikiLast"> <img alt="\sum\limits&#95;{i&#61;0}^{n}a&#95;i \left(t-t&#95;0\right)^i" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_6355c4cb1ccffc332963726dd3077985.png" /> </td>
<td class="foswikiTableCol4 foswikiLastCol foswikiLast"> &nbsp; </td>
</tr>
</tbody></table>
<p></p>
<p></p>
Every theory function has to be written on a single line. It starts with the theory function name or its abbreviation followed by the parameters. Consecutive lines of theory functions will be multiplied. If theory functions need to be added, a line with a <strong>+</strong> has to separate them. The parameters are given as the numbers assigned to them in the <a href="#TheFitparameterBlock" class="foswikiCurrentTopicLink">FITPARAMETER block</a>. The order of the parameters is given in the <a href="#TheoryTable" class="foswikiCurrentTopicLink">table above</a>. As an example
<pre>
simplExpo 4
</pre>
defines an exponential function with a depolarization rate &lambda; given by the parameter 4 of the FITPARAMETER-block. A full fetched THEORY block could be
<pre>
THEORY
asymmetry 2
simplExpo 3
TFieldCos 4 5
+
asymmetry 6
simplExpo 7
</pre>
which means <i>A</i>(<i>t</i>) = <i>p</i><sub>2</sub> e<sup>-<i>p</i><sub>3</sub><i>t</i></sup> cos(2&pi; <i>p</i><sub>5</sub><i>t</i> + <i>p</i><sub>4</sub> &pi;/180) + <i>p</i><sub>6</sub> e<sup>-<i>p</i><sub>7</sub><i>t</i></sup>, where <i>p</i><sub>&alpha;</sub> is the parameter &alpha;.
<p></p>
<p></p>
<p></p>
Notes
<p></p>
<a name="FootNote3note"></a><span class="FootNoteLabel"><a href="MusrFit.html#FootNote3text" class="foswikiCurrentWebHomeLink"> <strong>4</strong> </a></span>: <span class="FootNote"> R. S. Hayano <em>et al.</em>, <a href="http://link.aps.org/doi/10.1103/PhysRevB.20.850" target="_top">Phys. Rev. B <strong>20</strong> (1979) 850</a> </span>
<p></p>
<a name="FootNote4note"></a><span class="FootNoteLabel"><a href="MusrFit.html#FootNote4text" class="foswikiCurrentWebHomeLink"> <strong>5</strong> </a></span>: <span class="FootNote"> R. S. Hayano <em>et al.</em>, <a href="http://link.aps.org/doi/10.1103/PhysRevB.20.850" target="_top">Phys. Rev. B <strong>20</strong> (1979) 850</a>; P. Dalmas de R&eacute;otier and A. Yaouanc, <a href="http://dx.doi.org/10.1088/0953-8984/4/18/020" target="_top">J. Phys.: Condens. Matter <strong>4</strong> (1992) 4533</a>; A. Keren, <a href="http://link.aps.org/doi/10.1103/PhysRevB.50.10039" target="_top">Phys. Rev. B <strong>50</strong> (1994) 10039</a> </span>
<p></p>
<a name="FootNote5note"></a><span class="FootNoteLabel"><a href="MusrFit.html#FootNote5text" class="foswikiCurrentWebHomeLink"> <strong>6</strong> </a></span>,<a name="FootNote6note"></a><span class="FootNoteLabel"><a href="MusrFit.html#FootNote6text" class="foswikiCurrentWebHomeLink"> <strong>7</strong> </a></span>: <span class="FootNote"> Y. J. Uemura <em>et al.</em>, <a href="http://link.aps.org/doi/10.1103/PhysRevB.31.546" target="_top">Phys. Rev. B <strong>31</strong> (1985) 546</a> </span>
<p></p>
<a name="FootNote7note"></a><span class="FootNoteLabel"><a href="MusrFit.html#FootNote7text" class="foswikiCurrentWebHomeLink"> <strong>8</strong> </a></span>: <span class="FootNote"> R. S. Hayano <em>et al.</em>, <a href="http://link.aps.org/doi/10.1103/PhysRevB.20.850" target="_top">Phys. Rev. B <strong>20</strong> (1979) 850</a>; P. Dalmas de R&eacute;otier and A. Yaouanc, <a href="http://dx.doi.org/10.1088/0953-8984/4/18/020" target="_top">J. Phys.: Condens. Matter <strong>4</strong> (1992) 4533</a> </span>
<p></p>
<a name="FootNote8note"></a><span class="FootNoteLabel"><a href="MusrFit.html#FootNote8text" class="foswikiCurrentWebHomeLink"> <strong>9</strong> </a></span>: <span class="FootNote"> R. E. Turner and D. R. Harshman, <a href="http://link.aps.org/doi/10.1103/PhysRevB.34.4467" target="_top">Phys. Rev. B <strong>34</strong> (1986) 4467</a> </span>
<p></p>
<p></p>
<p></p>
<hr />
<p></p>
<a name="MaPs"></a>
<h3><a name="A_4.3.1_Maps"></a> 4.3.1 Maps </h3>
In case different runs are fitted simultaneously, it is very often necessary that for a given theory function, some parameters are run-dependent. An example could be a temperature scan, where the parameters (asymmetry, depolarization rates, etc.) will depend on the temperature. In order to handle such situations, a mapping of parameters in the THEORY block is possible. That means, instead of a parameter number, the mapping of the parameter is given. The definition of the mapping block is part of the <a href="#TheRunBlock" class="foswikiCurrentTopicLink">RUN block</a> and will be described there. For example
<pre>
THEORY
asymmetry 2
simplExpo 3
TFieldCos 4 5
+
asymmetry map1
simplExpo map2
</pre>
means that the first part of this theory function is common to all runs, as for instance the background, and the second part is changing from run to run, i.e. <code><b>map1/2</b></code> will point to different parameters depending on the run.
<p></p>
<a name="FuncTions"></a>
<h3><a name="A_4.3.2_Functions"></a> 4.3.2 Functions </h3>
Yet another useful feature is the possibility to define functions in the <a href="#TheFunctionsBlock" class="foswikiCurrentTopicLink">FUNCTIONS block</a>. Within the THEORY block these functions can be addressed as <code><b>fun&alpha;</b></code>, where &alpha; is the function number, e.g. <code><b>fun2</b></code>.
<p></p>
<a name="UserFunctions"></a>
<h3><a name="A_4.3.3_User_Functions"></a> 4.3.3 User Functions </h3>
In the case complicated and not predefined functions are needed to fit data, <code>musrfit</code> offers the possibility to implement external functions and introduce them to <code>musrfit</code> through the <code>ROOT</code> dictionary mechanism. The detailed rules these user-defined functions have to obey will be discussed in the according <a href="#UserFunctions1" class="foswikiCurrentTopicLink">section</a>. Here only the syntax for the msr file is provided.
To call a user function in the THEORY block the keyword <code><b>userFcn</b></code> is used. It is followed by the name of the shared library which holds the <code>C++</code> class where the function is implemented and the name of the class. Finally, all parameters are given in the order needed by the class. Of course it is also possible to use mapped parameters or functions instead of specifying the parameters directly.
<p></p>
A THEORY block including a user function may then look like
<pre>
THEORY
asymmetry 1
userFcn libMyLibrary.so TMyFunction 2 3 4 map1 fun1
+
...
</pre>
<p></p>
<a name="TheFunctionsBlock"></a>
<h2><a name="A_4.4_The_FUNCTIONS_Block"></a> 4.4 The FUNCTIONS Block </h2>
<code>musrfit</code> utilizes a <a href="http://boost-spirit.com/home/" target="_top">powerful parser</a>. Therefore, it is possible to define even rather complicated functional relations between the fit parameters and use these in the THEORY block (and <a href="#NormFun" class="foswikiCurrentTopicLink">in one exceptional case</a> also in the RUN-block). Supported is the use of basic arithmetics: <dl>
<dt> + </dt><dd> Addition
</dd> <dt> - </dt><dd> Subtraction
</dd> <dt> * </dt><dd> Multiplication
</dd> <dt> / </dt><dd> Division
</dd> <dt> () </dt><dd> Parentheses
</dd></dl>
<p></p>
The following functions are built-in and can be used in a function definition: <strong>cos()</strong>, <strong>sin()</strong>, <strong>tan()</strong>, <strong>acos()</strong>, <strong>asin()</strong>, <strong>atan()</strong>, <strong>cosh()</strong>, <strong>sinh()</strong>, <strong>tanh()</strong>, <strong>acosh()</strong>, <strong>asinh()</strong>, <strong>atanh()</strong>, <strong>exp()</strong>, <strong>log()</strong>, <strong>ln()</strong>, <strong>sqrt()</strong>, <strong>pow(base, exponent)</strong>
<p></p>
Furthermore, some constants are predefined and might also be used: <ul>
<li> <strong>gamma_mu</strong> = &#947;<sub>&#956;</sub>/2&#960; = 0.0135538817 MHz/G
</li> <li> <strong>pi</strong> = &#960; = 3.14159265358979323846
</li></ul>
<p></p>
The fit parameters are accessed either directly through <code><b>par&alpha;</b></code>, where &alpha; is the number of the parameter in the FITPARAMETER block, e.g. <code><b>par5</b></code> or through a mapping with <code><b>map&delta;</b></code>, where &delta; specifies the mapping number in the RUN block as explained <a href="#TheRunBlock" class="foswikiCurrentTopicLink">below</a>.
<p></p>
The defined functions are denoted as <code><b>fun&alpha;</b></code>, where &alpha; is the function number, i.e. <code><b>fun1</b></code>, <code><b>fun2</b></code>, etc. and have to be placed separately on one line each. Afterwards they might be used in the <a href="#TheTheoryBlock" class="foswikiCurrentTopicLink">THEORY block</a>.
<p></p>
It follows an example to illustrate the usage of functions in the THEORY block. The total asymmetry of a signal consisting of two parts should be a fit parameter. The fraction of each of the parts will then be expressed as a function of the total asymmetry.
<p></p>
<pre>
FITPARAMETER
# No Name Value Step Pos&#95;Error Boundaries
1 alpha 1 0.02 none 0 1.8
2 phase 15 1.0 none
3 asy 0.2542 0.004713 none 0 0.33
4 rate1 15 1.0 none 0 none
5 frac1 0.33 0.0379 none 0 1
6 rate2 0.13 0.00579 none 0 10
###############################################################
THEORY
asymmetry fun1
simplExpo 4 (rate)
+
asymmetry fun2
simplExpo 6 (rate)
###############################################################
FUNCTIONS
fun1 &#61; par3 &#42; par5
fun2 &#61; par3 &#42; ( 1.0 - par5 )
</pre>
<p></p>
In the case that functions have to be fitted which cannot be defined in the FUNCTIONS block, the functions can be implemented externally and made usable through the <a href="#UserFunctions" class="foswikiCurrentTopicLink">userFunc mechanism</a>.
<p></p>
<a name="TheRunBlock"></a>
<h2><a name="A_4.5_The_RUN_Block"></a> 4.5 The RUN Block </h2>
The RUN block is used to collect the data needed for a particular run to be fitted. This includes the run name, fit type, data format, etc. The RUN block is slightly differently organized than the other blocks. The information is collected via labels followed by the information. Each run to be fitted has its own RUN block. A RUN block starts with a run-file line which has the structure
<pre>
RUN &#60;run&#95;file&#95;name&#62; &#60;beamline&#62; &#60;facility&#62; &#60;file&#95;format&#62;
</pre>
<p></p>
<table class="foswikiTable" rules="none" border="1">
<thead>
<tr class="foswikiTableOdd foswikiTableRowdataBgSorted0 foswikiTableRowdataBg0">
<th class="foswikiTableCol0 foswikiFirstCol"> <a rel="nofollow" href="https://intranet.psi.ch/MUSR/MusrFit?cover=print;sortcol=0;table=2;up=0#sorted_table" title="Sort by this column">RUN-block tag</a> </th>
<th class="foswikiTableCol1 foswikiLastCol"> <a rel="nofollow" href="https://intranet.psi.ch/MUSR/MusrFit?cover=print;sortcol=1;table=2;up=0#sorted_table" title="Sort by this column">comment</a> </th>
</tr>
</thead>
<tbody>
<tr class="foswikiTableEven foswikiTableRowdataBgSorted0 foswikiTableRowdataBg0">
<td class="foswikiTableCol0 foswikiFirstCol"> &lt;run_file_name&gt; </td>
<td class="foswikiTableCol1 foswikiLastCol"> sub path and filename without extension </td>
</tr>
<tr class="foswikiTableOdd foswikiTableRowdataBgSorted1 foswikiTableRowdataBg1">
<td class="foswikiTableCol0 foswikiFirstCol"> &lt;beamline&gt; </td>
<td class="foswikiTableCol1 foswikiLastCol"> name of the beamline where the data were taken, e.g. MUE4. Used to generate a default path. </td>
</tr>
<tr class="foswikiTableEven foswikiTableRowdataBgSorted0 foswikiTableRowdataBg0">
<td class="foswikiTableCol0 foswikiFirstCol"> &lt;facility&gt; </td>
<td class="foswikiTableCol1 foswikiLastCol"> name of the facility where the data were recorded, e.g. PSI. Used to generate a default path. </td>
</tr>
<tr class="foswikiTableOdd foswikiTableRowdataBgSorted1 foswikiTableRowdataBg1">
<td class="foswikiTableCol0 foswikiFirstCol foswikiLast"> &lt;file_format&gt; </td>
<td class="foswikiTableCol1 foswikiLastCol foswikiLast"> file format: NEXUS, ROOT-NPP, ROOT-PPC, PSI-BIN, PSI-MDU, WKM, MUD, MDU-ASCII, ASCII, DB </td>
</tr>
</tbody></table>
<p></p>
The tokens following the RUN statement are used to identify the run, the potential location where the run might be found, and the file format in which the run data has been saved. In order to understand the meaning of all the above tokens, a short digression is needed.
<p></p>
<a name="PathToDataFiles"></a>
Where is <code>musrfit</code> looking for data files? There is a specific order how this is done: <ul>
<li> Check if the file is found in the current directory
</li> <li> Check if the path (or multiple paths) was (were) given in the <a href="#MusrfitStartupXml" class="foswikiCurrentTopicLink">XML startup file</a>.
</li> <li> Check if there is a system variable MUSRFULLDATAPATH. This system variable can contain multiple search paths separated by colons, e.g. <pre>
export MUSRFULLDATAPATH&#61;/mnt/data/nemu/wkm/:/mnt/data/nemu/his/:/afs/psi.ch/user/s/smith/
</pre>
</li> <li> Construct the search path from the RUN-block information in the following way: Based on the RUN line in the RUN block, default paths will be generated, e.g. for <pre>
RUN lem07&#95;his&#95;2018 MUE4 PSI ROOT-NPP
</pre> the generated search path will look like <pre>
musrFullDataPathToken/DATA/Facility/Beamline/Year/runName.ext
</pre> where <strong>musrFullDataPathToken</strong> is extracted from the MUSRFULLDATAPATH token by token, for the above example this might lead to the path <pre>
/afs/psi.ch/user/s/smith/DATA/PSI/MUE4/2007/lem07&#95;his&#95;2018.root
</pre>
</li></ul>
<p></p>
Here are some valid examples for the first line of a RUN block:<pre>
RUN 2007/lem07&#95;his&#95;2018 MUE4 PSI ROOT-NPP
RUN 2007/lem07&#95;2018&#95;rb1&#95;npp MUE4 PSI WKM
RUN d2007/deltat&#95;pta&#95;gps&#95;2650 PIM3 PSI PSI-BIN
RUN d2010/tdc/deltat&#95;tdc&#95;gpd&#95;8472 MUE1 PSI PSI-BIN
RUN beautiful-data MUE4 PSI DB
</pre>
<p></p>
After this short digression back to the RUN-block description.
<p></p>
In order to describe the operations needed for fitting and plotting, quite some information are needed. These information are following the RUN statement and are listed below. Depending on the fit type these information vary and hence it is indicated for which fit/plot type the information is applicable.
<a name="AddRun"></a> <dl>
<dt> ADDRUN &lt;run_file_name&gt; &lt;beamline&gt; &lt;facility&gt; &lt;file_format&gt; (optional) </dt><dd> If an ADDRUN is just following after a RUN statement, these runs will be added. More than one ADDRUN statements are possible, i.e. adding up as many runs as wished. It is also possible to add runs with different file formats. If the t0's are given in the data files, the ADDRUN statement is all what is needed, otherwise just add the t0's with the <a href="#AddTimeZero" class="foswikiCurrentTopicLink">addt0</a> statement.<br>
</dd></dl>
For a 'Single Histogram Fit' it will be <pre>
addt0 t0AddRun1
addt0 t0AddRun2
etc.
</pre> For an 'Asymmetry Fit' this reads <pre>
addt0 t0AddRun1Forward t0AddRun1Backward
addt0 t0AddRun2Forward t0AddRun2Backward
etc.
</pre> How will the background and data ranges be handled in this situation? First, the ADDRUN's will be shifted in time such that all the t0's have the same channel/bin number. Subsequently, the runs will be added. The background/data range is applied to this summed up new histogram. ADDRUN is not available for the fit type 'Non-&mu;SR Fit' (sorry <img src="../pub/Main/SmiliesPluginPSI/no.gif" alt="no" title="no" border="0" /> ).
<p></p>
<a name="FitTypes"></a> <dl>
<dt> fittype (required) </dt><dd> This tag is used to indicate which type of fit is wished. The supported fit types are: <dl>
<dt> 0 </dt><dd> Single Histogram Fit
</dd> <dt> 2 </dt><dd> Asymmetry Fit
</dd> <dt> 4 </dt><dd> Asymmetry Fit in a Rotating Reference Frame (Fitting is actually never going to be supported; eventually, it will be possible to plot data in a rotating reference frame)
</dd> <dt> 8 </dt><dd> Non-&mu;SR Fit
</dd></dl>
</dd></dl>
<p></p>
The description of these fit types can be found in <a href="#TheFitTypes" class="foswikiCurrentTopicLink">the corresponding section</a>.
<p></p> <dl>
<dt> alpha, beta (fit types 2, 4) </dt><dd> These parameters are used to correct the asymmetry for different detector efficiencies, solid angles and initial asymmetries. They are defined as &#945;&#8801;<i>N</i><sub>0,b</sub>/<i>N</i><sub>0,f</sub> and &#946;&#8801;&#124;<i>A</i><sub>0,b</sub>/<i>A</i><sub>0,f</sub>&#124;. If the parameters are not specified in the RUN block, for each one the value of 1 is assumed.
</dd></dl>
<p></p> <dl>
<dt> alpha2, beta2 (fit type 4) </dt><dd> &alpha; and &beta; parameters for the calculation of the asymmetry of the second pair of detectors for a plot in a rotating reference frame.
</dd></dl>
<p></p>
<a name="NormFun"></a> <dl>
<dt> norm (fit type 0) </dt><dd> Number of the fit parameter that represents the normalization constant <i>N</i><sub>0</sub> of the histogram; the value of this parameter is given either per nanosecond or per bin (see <a href="#ScaleNzero" class="foswikiCurrentTopicLink">below</a>). It is possible to substitute the parameter number by a function here (<u>and only here in a RUN block</u>), for instance to relate <i>N</i><sub>0</sub>s of different histograms through an &alpha; parameter.
</dd></dl>
<p></p> <dl>
<dt> backgr.fit (fit type 0) </dt><dd> Parameter number specifying the constant background in a histogram. Its value is given either per nanosecond or per bin (see <a href="#ScaleNzero" class="foswikiCurrentTopicLink">below</a>). If this keyword is present, any information on a <strong>background</strong> line are ignored.
</dd></dl>
<p></p> <dl>
<dt> lifetime (fit type 0) </dt><dd> Fit parameter representing the lifetime of the muon. If it is not specified the value &#964;<sub>&#956;</sub>=2.197019 &#956;s is used in the calculations.
</dd></dl>
<p></p>
<a name="LifeTimeCorrection"></a> <dl>
<dt> lifetimecorrection (fit type 0) </dt><dd> Does not accept any arguments. If present, the output in <code>musrview</code> is corrected for the exponential decay of the muon.
</dd></dl>
<p></p> <dl>
<dt> map </dt><dd> On this line the mapping of run-dependent parameters is done. Parameter numbers given here may be accessed through <code><b>map1</b></code>, <code><b>map2</b></code>, etc. in the THEORY and FUNCTIONS blocks (see also <a href="#MaPs" class="foswikiCurrentTopicLink">here</a>). The first ten maps are always present and have the value 0 if not used; however, the total number of maps is not restricted!
</dd></dl>
<p></p>
<a name="ForwardHisto"></a> <dl>
<dt> forward (fit type 0) </dt><dd> Number of the histogram in the data file to be processed. If histograms shall be grouped, all the numbers which shall be grouped. Examples: <pre>
forward 3 # no grouping, take histogram number 3
forward 1 2 # group histogram number 1 and 2
</pre>
</dd></dl>
<p></p> <dl>
<dt> forward, backward (fit types 2, 4) </dt><dd> Numbers of the histograms in the data file that should be taken to calculate the asymmetry. If histograms shall be grouped, all the numbers which shall be grouped. Examples: <pre>
# build forward/backward asymmetry with histogram 1 and 3
forward 1
backward 3
# build forward/backward asymmetry with groupings 1+2+3 and 7+8+9
forward 1 2 3
backward 7 8 9
</pre>
</dd></dl>
<p></p> <dl>
<dt> backgr.fix (fit types 0, 2, 4) </dt><dd> A fixed constant background in counts per nanosecond or per bin (see <a href="#ScaleNzero" class="foswikiCurrentTopicLink">below</a>) may be given at this point. The background is specified for all histograms in the order <i>B</i><sub>f</sub> <i>B</i><sub>b</sub> [<i>B</i><sub>r</sub> <i>B</i><sub>l</sub>]. If this keyword is present, any information on a <strong>background</strong> line is ignored.
</dd></dl>
<p></p> <dl>
<dt> background (fit type 0) </dt><dd> The numbers of the first and the last channel of an interval from which the constant background should be calculated are specified here. In case histograms are being grouped, the specified channels are interpreted with respect to the first histogram.
</dd></dl>
<p></p> <dl>
<dt> background (fit types 2, 4) </dt><dd> The numbers of the first and the last channel of an interval from which the constant background should be calculated are specified here. For all the histograms this is done together in the following order: <i>k</i><sub>f,first</sub> <i>k</i><sub>f,last</sub> <i>k</i><sub>b,first</sub> <i>k</i><sub>b,last</sub> [<i>k</i><sub>r,first</sub> <i>k</i><sub>r,last</sub> <i>k</i><sub>l,first</sub> <i>k</i><sub>l,last</sub>]. In case histograms are being grouped, the specified channels are interpreted with respect to the first histograms.
</dd></dl>
<p></p>
<a name="DataRange"></a> <dl>
<dt> data (fit type 0) </dt><dd> The numbers of the first and the last channel of an interval from which the data is taken are specified here. In case histograms are being grouped, the specified channels are interpreted with respect to the first histogram.
</dd></dl>
<p></p> <dl>
<dt> data (fit types 2, 4) </dt><dd> The numbers of the first and the last channel of an interval from which the data is taken are specified here. For all the histograms this is done together in the following order: <i>k</i><sub>f,first</sub> <i>k</i><sub>f,last</sub> <i>k</i><sub>b,first</sub> <i>k</i><sub>b,last</sub> [<i>k</i><sub>r,first</sub> <i>k</i><sub>r,last</sub> <i>k</i><sub>l,first</sub> <i>k</i><sub>l,last</sub>]. In case histograms are being grouped, the specified channels are interpreted with respect to the first histograms.
</dd></dl>
<a name="TimeZero"></a> <dl>
<dt> t0 (fit type 0) </dt><dd> The number of the time-zero channel of the histogram. Example: <pre>
t0 3419 # t0 channel &#61; 3419
t0 3419 3434 # t0 channels for groupings: forward f1 f2. 3419 t0 for f1, 3434 t0 for f2.
</pre>
</dd></dl>
<p></p> <dl>
<dt> t0 (fit types 2, 4) </dt><dd> The numbers of time-zero channels of the histograms in the order <i>t</i><sub>0,f</sub> <i>t</i><sub>0,b</sub>. Example: <pre>
t0 3419 3418 # t0 channels: forward (3419), backward (3418)
t0 3419 3418 3417 3416 # t0 channels (assuming forward f1 f2, backward b1 b2): forward (3419, f1), backward (3418, b1); forward (3417, f2), backward (3416, b2)
</pre>
</dd></dl>
<p></p>
<a name="AddTimeZero"></a> <dl>
<dt> addt0 (fit type 0) </dt><dd> The number of the time-zero channel of the histogram. If grouping of histograms is present (see <a href="#ForwardHisto" class="foswikiCurrentTopicLink">forward</a>) the same syntax as for <a href="#TimeZero" class="foswikiCurrentTopicLink">t0</a> applies. If one addt0 is given, the total number of addt0's needs to be equal to the total number of ADDRUN's!
</dd></dl>
<p></p> <dl>
<dt> addt0 (fit types 2, 4) </dt><dd> The numbers of time-zero channels of the histograms in the order <i>t</i><sub>0,f</sub> <i>t</i><sub>0,b</sub> [<i>t</i><sub>0,r</sub> <i>t</i><sub>0,l</sub>]. If grouping of histograms is present (see <a href="#ForwardHisto" class="foswikiCurrentTopicLink">forward</a>) the same syntax as for <a href="#TimeZero" class="foswikiCurrentTopicLink">t0</a> applies. If one addt0 is given, the total number of addt0's needs to be equal to the total number of ADDRUN's!
</dd></dl>
<p></p> <dl>
<dt> xy-data (fit type 8) </dt><dd> Specification of the data from an ASCII or DB file which should be used as <i>x</i> and <i>y</i> data (in this order). For a simple ASCII file the column numbers are used, in the case of a DB file one can either specify the variable numbers or the name of the variables as given in the DB header.
</dd></dl>
<p></p> <dl>
<dt> fit </dt><dd> The range of data that should be considered when the fitting is done. For the &mu;SR fit types <strong>0</strong>, <strong>2</strong>, and <strong>4</strong> here the starting and end times are given in microseconds. For the non-&mu;SR fit type <strong>8</strong> the starting and end points of the fitting range are given in the units of the <i>x</i> data.<br><font color="#ff0000">In case the fit range specified here is larger than the <a href="#DataRange" class="foswikiCurrentTopicLink">data range</a> (in any direction), eventually the <a href="#DataRange" class="foswikiCurrentTopicLink">data range</a> will be used as fit range.</font>
</dd></dl>
<p></p> <dl>
<dt> packing </dt><dd> Number of data channels to be binned together. For the non-&mu;SR fit type <strong>8</strong> the binning is supposed to be 1.
</dd></dl>
<p></p>
<a name="TheCommandsBlock"></a>
<h2><a name="A_4.6_The_COMMANDS_Block"></a> 4.6 The COMMANDS Block </h2>
The COMMANDS block is used to specify the commands which are passed from <code>musrfit</code> to <code>MINUIT2</code>. The supported commands after the COMMANDS keyword are <strong>STRATEGY</strong>, <strong>MIGRAD</strong>, <strong>SIMPLEX</strong>, <strong>MINIMIZE</strong>, <strong>MINOS</strong>, <strong>HESSE</strong>, <strong>SAVE</strong>, some additional commands described below, and for compatibility reasons <strong>SET BATCH</strong> and <strong>END RETURN</strong>. The last two commands may appear in the COMMANDS block but are simply ignored.
A detailed description of all of these commands can be found in the <a href="http://seal.web.cern.ch/seal/documents/minuit/mnusersguide.pdf" target="_top">MINUIT2 users guide</a> <span class="foswikiIcon"><img src="../pub/System/DocumentGraphics/pdf.png" width="16" height="16" alt="pdf" /></span>.
<p></p>
A standard COMMANDS block then looks like this:<pre>
COMMANDS
MINIMIZE
MINOS
SAVE
</pre>
<p></p>
Additional to the commands listed above also the command <strong>MAX_LIKELIHOOD</strong> is valid. This keyword can be placed anywhere in the block and switches from the default &#967;<sup>2</sup> minimization to the log-likelihood maximization which can be advantageous if one is dealing with low-statistics data.
<p></p>
Furthermore, it is possible to call the <code>MINUIT2</code> methods <strong>SCAN</strong> and <strong>CONTOURS</strong>. Exemplary invocations are as follows:<pre>
COMMANDS
SCAN 7
MNPLOT
</pre>
<p></p>
<pre>
COMMANDS
MINIMIZE
CONTOURS 8 9
MNPLOT
SAVE
</pre>
<p></p>
Sometimes it is necessary to guide <code>MINUIT2</code> to the global optimum. For this purpose it is useful to have the commands <strong>FIX list_of_param_to_be_fixed</strong>, <strong>RELEASE list_of_param_to_be_fixed</strong>, and <strong>RESTORE</strong> at hand. <strong>list_of_param_to_be_fixed</strong> is a list of the parameters to be fixed/released. It is a space- or comma-separated list of either parameter numbers and/or parameter names. <strong>RESTORE</strong> releases all the fixed parameters. A typical example could look like:<pre>
COMMANDS
FIX Freq1, Freq2
MINIMIZE
RESTORE
MINIMIZE
MINOS
SAVE
</pre>
<p></p>
It is important to understand that before <strong>MINOS</strong> is called, all the fixed parameters need to be released and another minimizer command (<strong>MINIMIZE</strong>, <strong>MIGRAD</strong>, or <strong>SIMPLEX</strong>) needs to be in place, otherwise <code>musrfit</code> will assume that the still fixed parameters have to be handled as constant parameters, i.e. setting the &lt;step&gt; value of the parameter to zero.
<p></p>
For even more complex fitting the additional command <strong>FIT_RANGE RESET | <i>t</i><sub>start</sub> <i>t</i><sub>end</sub> | <i>t</i><sub>s1</sub> <i>t</i><sub>e1</sub> <i>t</i><sub>s2</sub> <i>t</i><sub>e2</sub> ... <i>t</i><sub>s<i>n</i></sub> <i>t</i><sub>e<i>n</i></sub></strong> is provided. It allows to change the fit range during different iterations. The command <strong>FIT_RANGE <i>t</i><sub>start</sub> <i>t</i><sub>end</sub></strong> changes the current fit range for <code>all</code> the runs present in the msr file. <strong>FIT_RANGE RESET</strong> will restore to the original fit ranges as provided in the <a href="#TheRunBlock" class="foswikiCurrentTopicLink">RUN block</a>. If for each run of the msr file an individual fit range should be used, the third option applies. Here <strong><i>n</i></strong> has to correspond to the number of runs in the RUN block.
<p></p>
A typical example could look like:<pre>
COMMANDS
FIT&#95;RANGE 0.0 0.8
MINIMIZE
FIT&#95;RANGE RESET
MINIMIZE
MINOS
SAVE
</pre>
<p></p>
<a name="ScaleNzero"></a>
The last accepted command in the COMMAND block is <strong>SCALE_N0_BKG TRUE | FALSE</strong>. This command is only used in conjunction with single-histogram fits. The default is <strong>SCALE_N0_BKG TRUE</strong> which will result in a scaling of <i>N</i>(<i>t</i>) such that it is given in ns<sup>-1</sup>, whereas with <strong>SCALE_N0_BKG FALSE</strong> no scaling is performed and <i>N</i>(<i>t</i>) will be given in bin<sup>-1</sup>. If the command is not present at all, it will be interpreted as if <strong>SCALE_N0_BKG TRUE</strong> was present.
<p></p>
<a name="TheFourierBlock"></a>
<h2><a name="A_4.7_The_FOURIER_Block"></a> 4.7 The FOURIER Block </h2>
The Fourier transform is done and the results are plotted within <code>musrview</code> &mdash;as input data the actual data shown in <code>musrview</code> is used. In the FOURIER block of the msr file all necessary parameters for calculating and presenting the Fourier transform of the data specified in the <a href="#ThePlotBlock" class="foswikiCurrentTopicLink">PLOT block</a> is given. If the FOURIER block is not present in the msr file, either the parameters set in the <a href="#MusrfitStartupXml" class="foswikiCurrentTopicLink">XML startup file</a> or the system defaults are taken when the Fourier transform is performed. The block starts with the FOURIER keyword and may contain the following entries on the successive lines: <dl>
<dt> units </dt><dd> Here is specified in which domain the Fourier-transformed data is presented. One may choose between the field (<strong>Gauss</strong>), the frequency (<strong>MHz</strong>), and the angular-frequency domain (<strong>Mc/s</strong>).
</dd> <dt> fourier_power </dt><dd> It is possible (but not necessary) to set the number of data points used for the Fourier transform here. As argument the exponent <i>n</i>&lt;21 of a power of 2 is accepted. The number of data points is then 2<sup><i>n</i></sup>. <strong>Attention:</strong> If the number of points given here is bigger than the actual number of available data points, the input data vector is filled with zeros until the number of requested points is reached (zero padding)!
</dd> <dt> apodization </dt><dd> Here is decided if the data should be apodized before the Fourier transform is done and if yes, which apodization should be used<a name="FootNote9text"></a><span class="FootNoteTextLink" title="For further details about apodization of &#38;mu&#59;SR data refer to &#91;&#91;https&#58;&#47;&#47;dspace&#46;library&#46;ubc&#46;ca&#47;bitstream&#47;handle&#47;2429&#47;2004&#47;ubc&#38;&#35;95&#59;1993&#38;&#35;95&#59;spring&#38;&#35;95&#59;phd&#38;&#35;95&#59;riseman&#38;&#35;95&#59;tanya&#46;pdf&#63;sequence&#61;1&#93;&#91;the &#33;PhD thesis of T&#46;M&#46; Riseman&#93;&#93; &#60;span class&#61;&#34;foswikiIcon&#34;&#62;&#60;img src&#61;&#34;&#47;pub&#47;System&#47;DocumentGraphics&#47;pdf&#46;png&#34; width&#61;&#34;16&#34; height&#61;&#34;16&#34; alt&#61;&#34;pdf&#34; &#47;&#62;&#60;&#47;span&#62;"><a href="#FootNote9note" class="foswikiCurrentTopicLink">(10)</a></span>. The argument to be put after the keyword is therefore one of the following: <strong>NONE</strong>, <strong>WEAK</strong>, <strong>MEDIUM</strong> or <strong>STRONG</strong>. If the data should be apodized, they are manipulated as follows: each data value is multiplied by the function <img alt="\sum&#95;{j&#61;0}^4 c&#95;j \left(\frac{i}{n}\right)^{2j}" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_cf09f406a2bf16c5f0c20c11d502f3b6.png" size="footnotesize" />, where <img alt="i" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_c465118a8d86d5f25bba37cc1dcb38a0.png" /> is the data-point index and <img alt="n" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_2be9dcd7bf20bd9b6ae1aae11ded7c43.png" /> is the total number of data points. The coefficients <img alt="c&#95;j" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_efe7e111043faa761548a2e4bfa741ca.png" /> for the different apodizations are given by: <dl>
<dt> WEAK </dt><dd> <img alt="c&#95;0 &#61; 1,\, c&#95;1 &#61; -1.319391,\, c&#95;2 &#61; 0.703484,\, c&#95;3&#61;c&#95;4&#61;0" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_ab5be67e3c585fe71d839ada9222b051.png" />
</dd> <dt> MEDIUM </dt><dd> <img alt="c&#95;0 &#61; 1,\, c&#95;1 &#61; -1.831292,\, c&#95;2 &#61; 0.983734,\, c&#95;3&#61;c&#95;4&#61;0" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_f2ef2223eea8b06da51ecb20c450fa4a.png" />
</dd> <dt> STRONG </dt><dd> <img alt="c&#95;0 &#61; 1,\, c&#95;1 &#61; -2.708894,\, c&#95;2 &#61; 2.953575,\, c&#95;3&#61;-1.599128,\, c&#95;4&#61;0.399782" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_b8a915ef0eb8aa8e117519d01dfb10c1.png" />
</dd></dl>
</dd> <dt> plot </dt><dd> At this point it is possible to set the part of the Fourier-transformed data which should be plotted by default if the Fourier transform is done by pressing the <b>f</b>-key in <code>musrview</code>. The argument may be one of the following: <dl>
<dt> real </dt><dd> The real part of the (complex) Fourier transform is plotted.
</dd> <dt> imag </dt><dd> The imaginary part of the Fourier transform is plotted.
</dd> <dt> real_and_imag </dt><dd> Both the real and the imaginary parts of the Fourier transform are shown.
</dd> <dt> power </dt><dd> The absolute value of the Fourier transform is depicted.
</dd> <dt> phase </dt><dd> The phase of the Fourier transform is plotted.
</dd></dl>
</dd> <dt> phase </dt><dd> The initial phase of the input data is given here in degrees. Optionally the phase parameter from the FITPARAMETER block can be given, e.g. <code><b>par3</b></code>, which would take the value of parameter number 3.
</dd> <dt> range_for_phase_correction </dt><dd> An interval within which the initial phase should be optimized automatically can be specified here. The interval is given by its start and end values in degrees.
</dd> <dt> range </dt><dd> The plotting range is set here. The interval is specified through its start and end points given in the units set after the <strong>units</strong> tag.
</dd></dl>
<p></p>
Altogether, a possible FOURIER block might look like that:
<pre>
FOURIER
units Mc/s
fourier&#95;power 12
apodization NONE
plot real&#95;and&#95;imag
phase 22.6 # par3
#range&#95;for&#95;phase&#95;correction 10.0 40.0
range 0.0 17.03
</pre>
<p></p>
<p></p>
<p></p>
Notes
<p></p>
<a name="FootNote9note"></a><span class="FootNoteLabel"><a href="MusrFit.html#FootNote9text" class="foswikiCurrentWebHomeLink"> <strong>10</strong> </a></span>: <span class="FootNote">For further details about apodization of &mu;SR data refer to <a href="https://dspace.library.ubc.ca/bitstream/handle/2429/2004/ubc_1993_spring_phd_riseman_tanya.pdf?sequence=1" target="_top">the PhD thesis of T.M. Riseman</a> <span class="foswikiIcon"><img src="../pub/System/DocumentGraphics/pdf.png" width="16" height="16" alt="pdf" /></span></span>
<p></p>
<p></p>
<p></p>
<hr />
<p></p>
<a name="ThePlotBlock"></a>
<h2><a name="A_4.8_The_PLOT_Block"></a> 4.8 The PLOT Block </h2>
The PLOT block is intended to collect all the information needed for the graphical presentation of the data and fits using <code>musrview</code>. The PLOT keyword at the beginning of the block is followed by a number which indicates the plot type. The plot types match the <a href="#FitTypes" class="foswikiCurrentTopicLink">fit types</a>. Additionally, it is possible to provide information using the following keywords: <dl>
<dt> runs </dt><dd> The numbers of the runs to be plotted have to be put here. The runs are numbered according to their appearance in the RUN block.
</dd> <dt> range </dt><dd> Here it is possible to define the plotting range explicitly. Depending on the plot type the following settings are allowed where the times are given in microseconds and the <i>N</i> in counts: <dl>
<dt> 0 without <a href="#LifeTimeCorrection" class="foswikiCurrentTopicLink">lifetimecorrection</a> </dt><dd> <i>t</i><sub>min</sub> <i>t</i><sub>max</sub> [ <i>N</i><sub>min</sub> <i>N</i><sub>max</sub> ]
</dd> <dt> 0 with <a href="#LifeTimeCorrection" class="foswikiCurrentTopicLink">lifetimecorrection</a>, 2, 4 </dt><dd> <i>t</i><sub>min</sub> <i>t</i><sub>max</sub> [ <i>A</i><sub>min</sub> <i>A</i><sub>max</sub> ]
</dd> <dt> 8 </dt><dd> <i>x</i><sub>min</sub> <i>x</i><sub>max</sub> [ <i>y</i><sub>min</sub> <i>y</i><sub>max</sub> ]
</dd></dl>
</dd> <dt> sub_ranges </dt><dd> Here it is possible to define the plotting range for each run individually. For the different plot types the command has the structure <dl>
<dt> 0 without <a href="#LifeTimeCorrection" class="foswikiCurrentTopicLink">lifetimecorrection</a> </dt><dd> <i>t</i><sub>min</sub><sup>1</sup> <i>t</i><sub>max</sub><sup>1</sup> <i>t</i><sub>min</sub><sup>2</sup> <i>t</i><sub>max</sub><sup>2</sup> ... <i>t</i><sub>min</sub><sup><i>n</i></sup> <i>t</i><sub>max</sub><sup><i>n</i></sup> [ <i>N</i><sub>min</sub> <i>N</i><sub>max</sub> ] (<i>n</i> = the number of runs to be plotted)
</dd> <dt> 0 with <a href="#LifeTimeCorrection" class="foswikiCurrentTopicLink">lifetimecorrection</a>, 2, 4 </dt><dd> <i>t</i><sub>min</sub><sup>1</sup> <i>t</i><sub>max</sub><sup>1</sup> <i>t</i><sub>min</sub><sup>2</sup> <i>t</i><sub>max</sub><sup>2</sup> ... <i>t</i><sub>min</sub><sup><i>n</i></sup> <i>t</i><sub>max</sub><sup><i>n</i></sup> [ <i>A</i><sub>min</sub> <i>A</i><sub>max</sub> ] (<i>n</i> = the number of runs to be plotted)
</dd> <dt> 8 </dt><dd> not yet implemented.
</dd></dl>
</dd> <dt> use_fit_ranges [ <i>y</i><sub>min</sub> <i>y</i><sub>max</sub>] </dt><dd> The fit ranges of the individual runs are used to present the data. Optionally, an ordinate range can be provided.
</dd> <dt> view_packing </dt><dd> The data are presented in the packing given here rather than the binning used for the fit. <strong>WARNING</strong>: This is a global option and applies to <strong>all</strong> PLOT-blocks.
</dd> <dt> logx </dt><dd> Will present the time axis in a logarithmic scale. So far no checking of negative and zero-valued data is performed <img src="../pub/Main/SmiliesPluginPSI/wink.gif" alt="wink" title="wink" border="0" />
</dd> <dt> logy </dt><dd> Will present the axis of ordinates in a logarithmic scale. So far no checking of negative and zero-valued data is performed <img src="../pub/Main/SmiliesPluginPSI/wink.gif" alt="wink" title="wink" border="0" />
</dd> <dt> rrf_packing <code>value</code> </dt><dd> In the rotating-reference-frame (RRF) representation, this will be the value for the packing. <strong>WARNING</strong>: For the time being, this is a global option and applies to <strong>all</strong> PLOT blocks.
</dd> <dt> rrf_freq <code>value</code> <code>unit</code> </dt><dd> This entry provides the RRF "frequency" given by the <code>value</code> and the <code>unit</code> which can be: <code>kHz</code>, <code>MHz</code>, <code>Mc/s</code>, <code>G</code>, or <code>T</code>.
</dd> <dt> rrf_phase <code>value</code> </dt><dd> A phase of the RRF can be provided, either as a value in degrees, or as a <code>parX</code>, e.g. <code>par4</code>, where <code>X</code> is supposed to be the phase parameter number in the FITPARAMETER block.
</dd></dl>
<p></p>
If no plot range is given at all, the fit range of the first run also serves as time window for the plot. In the case no information on the axis of ordinates is available, the plotting range is chosen so that all data can be presented.
<p></p>
It is possible to define multiple PLOT blocks. Each PLOT block generates its own <code>ROOT</code> canvas.
<p></p>
<a name="TheStatisticBlock"></a>
<h2><a name="A_4.9_The_STATISTIC_Block"></a> 4.9 The STATISTIC Block </h2>
The STATISTIC block is the last block of a msr file. It contains some information on the fit: the date and time as well as the absolute and normalized values of &#967;<sup>2</sup> and the number of degrees of freedom in the fit.<br>
If enabled in the <a href="#MusrfitStartupXml" class="foswikiCurrentTopicLink">XML file</a> for &chi;<sup>2</sup>-<a href="#SingleHistogramFit" class="foswikiCurrentTopicLink">single-histogram fits</a> also <a href="http://en.wikipedia.org/wiki/Pearson's_chi-square_test" target="_top">Pearson's &chi;<sup>2</sup></a> will be written to the STATISTIC block.<br>
These information only have a meaning if the fitting procedure has been executed at least once and the fit has converged!
<p></p>
<a name="TheFitTypes"></a>
<h1><a name="A_5_The_Fit_Types"></a> 5 The Fit Types </h1>
<p></p>
<a name="SingleHistogramFit"></a>
<h2><a name="A_5.1_Single_Histogram_Fit"></a> 5.1 Single Histogram Fit </h2>
The single-histogram fit (fit type <strong>0</strong>) is used to fit a function directly to the raw data using
<div style="text-align:center">
<img alt="N(t)&#61;N&#95;0\,\mathrm{e}^{-t/\tau&#95;{\mu}} \left&#91;1 + A(t)\right] + B." class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_52d3660a04cd068055f8e72b5ae47097.png" />
</div>
The parameters are given by: <dl>
<dt> <img alt="N(t)" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_014e8cd7847b5402573b3292b2569731.png" /> </dt><dd> rebinned decay histogram
</dd> <dt> <img alt="N&#95;0" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_d2ada4d93e287ac42a3681e58c96b105.png" /> </dt><dd> normalization constant of the histogram (RUN block: <strong>norm</strong>)
</dd> <dt> <img alt="\tau&#95;{\mu}" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_568ee751220d0e7d171a7ebb6da328b9.png" /> </dt><dd> lifetime of the muon (RUN block: <strong>lifetime</strong>)
</dd> <dt> <img alt="B" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_8f88bba11aa1a2535ef7af4374ab4796.png" /> </dt><dd> constant background (RUN block: <strong>backgr.fit</strong> or <strong>background</strong>)
</dd> <dt> <img alt="A(t)" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_125ae4b9a7d16163023ce9cb3043aa0a.png" /> </dt><dd> decay asymmetry/depolarization function as given in the THEORY block
</dd></dl>
<p></p>
In the plot type <strong>0 without lifetimecorrection</strong> the rebinned histogram and the function <img alt="N(t)" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_014e8cd7847b5402573b3292b2569731.png" /> written above are presented.
If the option <strong>lifetimecorrection</strong> is set in the RUN block the asymmetry is plotted:
<div style="text-align:center">
<img alt="A(t)&#61;\frac{N(t)-B}{N&#95;0\,\mathrm{e}^{-t/\tau&#95;{\mu}}}-1" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_8749458be5ba9f4edf09b6ecde03313d.png" />
</div>
<p></p>
<a name="AsymmetryFit"></a>
<h2><a name="A_5.2_Asymmetry_Fit"></a> 5.2 Asymmetry Fit </h2>
For an asymmetry fit (fit type <strong>2</strong>) two histograms are needed. These are given by the <strong>forward</strong> and <strong>backward</strong> keywords in the RUN block.
Additionally, the parameters <strong>alpha</strong> and <strong>beta</strong> which relate the detector efficiencies, solid angles and initial asymmetries of the two detectors can be supplied.
The constant background for the two histograms is either given by <b>background</b>-determined intervals or specified through <strong>backgr.fix</strong> in the RUN-block.
<p></p>
The experimental asymmetry <img alt="a(k)" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_3285744b1914390b321f67f390129f79.png" /> then is inferred from the two histograms:
<div style="text-align:center">
<img alt="a(k)&#61;\frac{\left&#91;N&#95;{\mathrm{f}}(k)-B&#95;{\mathrm{f}}\right]-\left&#91;N&#95;{\mathrm{b}}(k)-B&#95;{\mathrm{b}}\right]}{\left&#91;N&#95;{\mathrm{f}}(k)-B&#95;{\mathrm{f}}\right]+\left&#91;N&#95;{\mathrm{b}}(k)-B&#95;{\mathrm{b}}\right]}," class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_82fec90aa9e6eeaba9267ad46f426909.png" />
</div>
with <dl>
<dt> <img alt="N&#95;{\mathrm{f}}(k)" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_24c06da56000c5aba89b43d3d082d566.png" /> </dt><dd> counts in the <strong>forward</strong> histogram channel <img alt="k" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_022741828ce174efdb6387e198d4d174.png" />
</dd> <dt> <img alt="N&#95;{\mathrm{b}}(k)" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_50ba40cfb1308d024ff074655f531705.png" /> </dt><dd> counts in the <strong>backward</strong> histogram channel <img alt="k" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_022741828ce174efdb6387e198d4d174.png" />
</dd> <dt> <img alt="B&#95;{\mathrm{f}}" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_b10bf8314f158b72e1e3462ba2d23fcc.png" /> </dt><dd> constant background in the <strong>forward</strong> histogram (RUN block: <strong>backgr.fix</strong> or <strong>background</strong>)
</dd> <dt> <img alt="B&#95;{\mathrm{b}}" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_984f3a1c5d0c04f9471fa518f6f4ab22.png" /> </dt><dd> constant background in the <strong>backward</strong> histogram (RUN block: <strong>backgr.fix</strong> or <strong>background</strong>).
</dd></dl>
<p></p>
This asymmetry <img alt="a(t)" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_e214a7f954b15a31e60dd40d50c4ad27.png" /> is used to fit the function
<div style="text-align:center">
<img alt="a(t)&#61;\frac{(\alpha\beta +1)A(t)-(\alpha -1)}{(\alpha +1)-(\alpha\beta -1)A(t)}," class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_08b9deccddc142bcb30845cad4579dd1.png" />
</div>
where <dl>
<dt> <img alt="\alpha" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_3e7298348ee1858b6fe4147c47afb5e3.png" /> </dt><dd> accounts for the different detector efficiencies and solid angles (RUN block: <strong>alpha</strong>)
</dd> <dt> <img alt="\beta" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_db3bf440f0c0846df16574e72743d947.png" /> </dt><dd> accounts for the different detector asymmetries (RUN block: <strong>beta</strong>)
</dd> <dt> <img alt="A(t)" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_125ae4b9a7d16163023ce9cb3043aa0a.png" /> </dt><dd> is the depolarization function as given in the THEORY block.
</dd></dl>
<p></p>
For the graphical representation in plot type <strong>2</strong> the equation above is rearranged to get <img alt="A(t)" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_125ae4b9a7d16163023ce9cb3043aa0a.png" />:
<div style="text-align:center">
<img alt="A(t)&#61;\frac{(\alpha -1)+(\alpha +1)a(t)}{(\alpha\beta +1)+(\alpha\beta -1)a(t)}&#61;\frac{\alpha\left&#91;N&#95;{\mathrm{f}}(t)-B&#95;{\mathrm{f}}\right]-\left&#91;N&#95;{\mathrm{b}}(t)-B&#95;{\mathrm{b}}\right]}{\alpha\beta\left&#91;N&#95;{\mathrm{f}}(t)-B&#95;{\mathrm{f}}\right]+\left&#91;N&#95;{\mathrm{b}}(t)-B&#95;{\mathrm{b}}\right]}" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_fb83ec4be8b40d398fd520ee8a09f36d.png" />
</div>
and plotted together with the function given in the THEORY block.
<p></p>
<a name="RotatingReferenceFrameAsymmetryFit"></a>
<h2><a name="A_5.3_Rotating_45Reference_45Frame_Asymmetry_Fit"></a> 5.3 Rotating-Reference-Frame Asymmetry Fit </h2>
(Is going to be implemented as pure plotting option...)
<p></p>
<a name="NonMusrFit"></a>
<h2><a name="A_5.4_Non_45SR_Fit"></a> 5.4 Non-&mu;SR Fit </h2>
In the case of a non-&mu;SR fit (fit type <strong>8</strong>) the fitting function is
<div style="text-align:center">
<img alt="y&#61;f(x)," class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_e46e9694bce68e1d38783e4cc8328e31.png" />
</div>
where <dl>
<dt> <img alt="x,\,y" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_e1a48f3da2196769b40a2a6183f83891.png" /> </dt><dd> are given by <strong>xy-data</strong> in the RUN block
</dd> <dt> <img alt="f(x)" class="mmpImage" src="../pub/MUSR/MusrFit/_MathModePlugin_2508962dd22d85bdaebb0d6a483c4b3f.png" /> </dt><dd> is the function defined in the THEORY block.
</dd></dl>
<p></p>
The same is valid for the plot with plot type <strong>8</strong>.
<p></p>
<a name="UserFunctions1"></a>
<h1><a name="A_6_User_Functions"></a> 6 User Functions </h1>
<code>musrfit</code> offers the possibility to plug-in user-defined functions implemented in <code>C++</code> classes to the fitting and plotting routines. In order to do so, basically two things are needed: <ol>
<li> a shared library containing the compiled class with the defined function
</li> <li> a <a href="http://root.cern.ch/drupal/content/interacting-shared-libraries-rootcint" target="_top">ROOT dictionary</a> that contains information about the functions in the shared library
</li></ol>
<p></p>
There are two possible ways to implement user functions and both will be explained below: <ol>
<li> a user function <strong>without</strong> global user-function-object access
</li> <li> a user function <strong>with</strong> global user-function-object access
</li></ol>
<p></p>
Since the first is simpler this will be explained using an explicit example, before it is discussed why the second option is needed and how it can be used.
<p></p>
<a name="UserFcnWithoutGlobal"></a>
<h2><a name="A_6.1_User_Function_without_global_user_45function_45object_access"></a> 6.1 User Function without global user-function-object access </h2>
<p></p>
In the following it is explained in detail how the implementation of a user function is done using the simple example of <i>f</i><sub><i>a</i></sub>(<i>x</i>) = sin(<i>ax</i>)/<i>ax</i>, where the parameter <i>a</i> should be determined by the fit. Although not necessary for this simple example, the source code is split into two parts, namely a header file <strong>TMyFunction.h</strong> containing the class declaration and a second file <strong>TMyFunction.cpp</strong> including the function implementation.
<p></p>
To plug in the class to <code>musrfit</code>, it is necessary that the class derives from the base class <strong>PUserFcnBase</strong> defined in the header file <strong>PUserFcnBase.h</strong>. In this abstract base class a function operator is defined that takes two arguments: the point where the function should be evaluated and a reference to a vector with all parameters of the function. Therefore, the user's header file could look like the following:
<pre class="cplusplus">
/&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;
TMyFunction.h
&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;/
#include &#34;PUserFcnBase.h&#34;
#include &#60;cassert&#62;
#include &#60;cmath&#62;
#include &#60;vector&#62;
using namespace std;
class TMyFunction : public PUserFcnBase {
public:
// default constructor and destructor
TMyFunction(){}
~TMyFunction(){}
// global user-function-access functions, here without any functionality
Bool&#95;t NeedGlobalPart() const { return false; }
void SetGlobalPart(vector&#60;void&#42;&#62; &#38;globalPart, UInt&#95;t idx) { }
Bool&#95;t GlobalPartIsValid() const { return true; }
// function operator
Double&#95;t operator()(Double&#95;t, const vector&#60;Double&#95;t&#62;&#38;) const;
// definition of the class for the ROOT dictionary
ClassDef(TMyFunction,1)
};
</pre>
<p></p>
In the header file above the constructor (destructor) of the class is empty. This is not necessary. Any code that should be executed when the RUN block is read and the class object is created (destroyed) may be implemented in the constructor (destructor). Another peculiarity is the ClassDef statement at the end of the class definition. It is needed for the <code>ROOT</code> dictionary generation and has as arguments the class name and a revision number.
<p></p>
Please also be aware of the const-ness of the operator(). For an introductory discussion on that topic look for example <a href="http://en.wikipedia.org/wiki/Const_correctness" target="_top">here</a> and the links herein.
<p></p>
The actual implementation of the user function is done in the second source file. In this example it only contains the definition of the function operator() declared in the header file and might look like:
<p></p>
<pre class="cplusplus">
/&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;
TMyFunction.cpp
&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;/
#include &#34;TMyFunction.h&#34;
ClassImp(TMyFunction) // for the ROOT dictionary
Double&#95;t TMyFunction::operator()(Double&#95;t x, const vector&#60;Double&#95;t&#62; &#38;par) const {
assert(par.size()&#61;&#61;1); // make sure the number of parameters handed to the function is correct
Double&#95;t arg(par&#91;0]&#42;x);
if(!arg)
return 1.0;
return sin(arg)/arg;
}
</pre>
<p></p>
Also this file contains a special statement for the <code>ROOT</code> dictionary generation (ClassImp), which is placed before the definition of the function. If functions of more than one class are defined in the file, the ClassImp statements for the other classes follow right after the first one.
<p></p>
What is further needed for the <code>ROOT</code> dictionary is a so-called LinkDef file which again contains the class names of all classes that should be accessible through the dictionary and has the following structure, where the "LinkDef.h" (or "linkdef.h" or "Linkdef.h") at the end of the file name is mandatory:
<p></p>
<pre class="cplusplus">
/&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;
TMyLibraryLinkDef.h
&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;/
#ifdef &#95;&#95;CINT&#95;&#95;
#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;
#pragma link C++ class TMyFunction+;
#endif //&#95;&#95;CINT&#95;&#95;
</pre>
<p></p>
For compiling and linking it is wise to use a Makefile as for example the attached <a href="../pub/MUSR/MusrFit/Makefile.TMyLibrary" target="_top">Makefile.TMyLibrary</a>. It assumes standard <code>ROOT</code> and <code>musrfit</code> installations and defines rules for the generation of the shared library <strong>libTMyLibrary.so</strong> including the class and the <code>ROOT</code> dictionary.
In order to get the library built and installed on the standard <code>ROOT</code> path just call:
<pre>
make -f Makefile.TMyLibrary
make -f Makefile.TMyLibrary install
</pre>
In case of a custom installation some paths in the Makefile might have to be changed. For further information about the <code>ROOT</code> dictionary mechanism please refer to the <a href="http://root.cern.ch/drupal/content/interacting-shared-libraries-rootcint" target="_top">documentation</a>.
<p></p>
After installing the shared library the defined user function might be used in <code>musrfit</code> as described <a href="#UserFunctions" class="foswikiCurrentTopicLink">above</a>.
<p></p>
Good luck! <img src="../pub/Main/SmiliesPluginPSI/wink.gif" alt="wink" title="wink" border="0" />
<p></p>
Finally, please be aware of the <a href="#UserFunctionRemark" class="foswikiCurrentTopicLink">remark</a> at the end of this section.
<p></p>
<a name="UserFcnWithGlobal"></a>
<h2><a name="A_6.2_User_Function_with_global_user_45function_45object_access"></a> 6.2 User Function with global user-function-object access </h2>
<p></p>
Before explaining how to use global objects within user functions, it will be shortly explained where is problem and why this might be a sensible approach.
In <code>musrfit</code> each RUN block (histogram, asymmetry, ...) is owning its own theory-function tree. An example is shown in the figure below. The bluish nodes are
default <code>musrfit</code> functions, whereas the red nodes represent user functions (here labeled by <code>uF1</code> and <code>uF2</code>). Without global user-function object, these nodes
are independent entities. This means if the msr file contains <em>n</em> run blocks, the user function <code>uF1</code> will be called <em>n</em> times for each step in the calculation.
If the user function is performing CPU-demanding calculations this is rather inefficient.
<p></p>
<a name="GlobalUserFunctionFigure"></a>
<img src="../pub/MUSR/MusrFit/Theory-Tree-with-UserFcn.png" alt="theory tree with user function and <strong>global</strong> user function objects" width='800'/>
<p></p>
Therefore, it is possible to associate to each user function (<code>uFx</code>) a global user-function object (<code>g_uFx</code>). The idea is the following: If <code>uFx</code> needs to
perform very time-consuming calculations (e.g. calculate an Abrikosov vortex lattice or the nonlocal response of a superconductor in the Meissner state) this can be
transferred to the <strong>global</strong> user-function object (<code>g_uFx</code>) and hence the time-consuming calculation is only performed once per cycle (compared to <em>n</em> times
without <code>g_uFx</code>), thus speeding up the fit.
<p></p>
After explaining the purpose of the global user-function-object approach, some explanations how to interface it follow here. Since the interface is very close to
the <a href="#UserFcnWithoutGlobal" class="foswikiCurrentTopicLink">user function <strong>without</strong> global objects</a>, only the additionally necessary overhead is explained here.
<p></p>
The user's header file could look like the following:
<pre class="cplusplus">
/&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;
TMyFunction.h
&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;&#42;/
#include &#34;PUserFcnBase.h&#34;
#include &#60;cassert&#62;
#include &#60;cmath&#62;
#include &#60;vector&#62;
using namespace std;
class TMyGlobalFunction {
public:
// default constructor and destructor
TMyGlobalFunction(){}
~TMyGlobalFunction(){}
Bool&#95;t IsValid() { return fValid; }
// the following function will check if something needs to be calculated, which
// is the case if param !&#61; fPrevParam
void CalcSomethingCPUExpensive(const vector&#60;Double&#95;t&#62; &#38;param);
// this routine will return the calculated values, e.g. B(z,E) for TMyFunction::operator()()
// (...) here sketches only that some parameters are likley to be fed
Double&#95;t GetWhatIsNeeded(...);
private:
Bool&#95;t fValid;
vector&#60;Double&#95;t&#62; fPrevParam;
// definition of the class for the ROOT-dictionary
ClassDef(TMyGlobalFunction,1)
};
class TMyFunction : public PUserFcnBase {
public:
// default constructor and destructor
TMyFunction(){}
~TMyFunction(){}
// global user-function-access functions, here with some functionality
Bool&#95;t NeedGlobalPart() const { return true; }
void SetGlobalPart(vector&#60;void&#42;&#62; &#38;globalPart, UInt&#95;t idx);
Bool&#95;t GlobalPartIsValid() const;
// function operator
Double&#95;t operator()(Double&#95;t, const vector&#60;Double&#95;t&#62;&#38;) const;
private:
Bool&#95;t fValid;
Bool&#95;t fInvokedGlobal;
Int&#95;t fIdxGlobal;
TMyGlobalFunction &#42; fGlobalUserFcn;
// definition of the class for the ROOT dictionary
ClassDef(TMyFunction,1)
};
</pre>
<p></p>
Compared to the <a href="#UserFcnWithoutGlobal" class="foswikiCurrentTopicLink">user function <strong>without</strong> global objects</a>, here the <code>NeedGlobalPart()</code> method returns <code>true</code> meaning that a global user-function object will be needed. Furthermore, the methods <code>SetGlobalPart(vector&lt;void*&gt; &amp;globalPart, UInt_t idx)</code> and <code>GlobalPartIsValid()</code> now need to be implemented.
The method <code>SetGlobalPart(vector&lt;void*&gt; &amp;globalPart, UInt_t idx)</code> is used to link the <code>fGlobalUserFcn</code> to the global user object. This routine will look like:
<p></p>
<pre class="cplusplus">
void TMyFunction::SetGlobalPart(vector&#60;void &#42;&#62; &#38;globalPart, UInt&#95;t idx)
{
fIdxGlobal &#61; static&#95;cast&#60;Int&#95;t&#62;(idx);
if ((Int&#95;t)globalPart.size() &#60;&#61; fIdxGlobal) { // global user function not present, invoke it
fGlobalUserFcn &#61; new TMyGlobalFunction();
if (fGlobalUserFcn &#61;&#61; 0) { // global user function object couldn&#39;t be invoked -&#62; error
fValid &#61; false;
cerr &#60;&#60; endl &#60;&#60; &#34;&#62;&#62; TMyFunction::SetGlobalPart(): &#42;&#42;ERROR&#42;&#42; Couldn&#39;t invoke global user function object, sorry ...&#34; &#60;&#60; endl;
} else { // global user function object could be invoked -&#62; resize to global user function vector and keep the pointer to the corresponding object
globalPart.resize(fIdxGlobal+1);
globalPart&#91;fIdxGlobal] &#61; dynamic&#95;cast&#60;TMyGlobalFunction&#42;&#62;(fGlobalUserFcn);
fValid &#61; true;
fInvokedGlobal &#61; true;
}
} else { // global user function already present hence just retrieve a pointer to it
fValid &#61; true;
fGlobalUserFcn &#61; (TMyGlobalFunction&#42;)globalPart&#91;fIdxGlobal];
}
}
</pre>
<p></p>
What it does is the following: it first checks if the object is already present in the global user-function-object vector and if not creates it. If it is already present, the pointer to the global object vector is just kept (see <a href="#GlobalUserFunctionFigure" class="foswikiCurrentTopicLink">figure above</a>).
<p></p>
A sketch of the method <code>operator()(Double_t, const vector<Double_t>&amp;) const</code> will then look like (pseudo-code snippet):
<p></p>
<pre class="cplusplus">
Double&#95;t TMyFunction::operator()(Double&#95;t t, const vector&#60;Double&#95;t&#62; &#38;param) const
{
Double&#95;t result &#61; 0.0;
// do something, checking, etc.
...
// call the global user function object (which will calculate something
// if param has changed). Hence it will only be done once in a iteration,
// and therefore only once for all run blocks.
fGlobalUserFcn-&#62;CalcSomethingCPUExpensive(param);
// extract the needed values from the global object
value(s) &#61; fGlobalUserFcn-&#62;GetWhatIsNeeded(...);
// use &#39;value(s)&#39; to do some run block specific calculations (not/less CPU demanding)
...
return result;
}
</pre>
<p></p>
This way the efficiency of the user function can be increased by almost a factor of <em>n</em> (where <em>n</em> is the number of RUN blocks).
<p></p>
<hr />
<a name="UserFunctionRemark"></a>
<font color="#ff0000"><b>Important remark:</b></font> If <code>musrfit</code> <a href="MusrFitSetup.html#MusrFitInstallation">has been built</a> with parallelization support (default for <code>GCC</code> &ge; 4.2) it should be taken care of the thread safety of the user-function <strong>operator()</strong>. During the function optimization of <code>musrfit</code> the <strong>operator()</strong> is called once for any given set of parameters in order to allow the safe execution of any calculation. Within the <a href="#SingleHistogramFit" class="foswikiCurrentTopicLink">single-histogram</a> and <a href="#AsymmetryFit" class="foswikiCurrentTopicLink">asymmetry</a> fits the calculation of &chi;<sup>2</sup> or the log-likelihood is parallelized and the <strong>operator()</strong> is expected to evaluate to reasonable values for a fixed set of parameters (but changing <i>t</i>) beginning with the second function call.
In case this cannot be ensured, the parallelization can be disabled by <strong>--disable-omp</strong> on the <a href="MusrFitSetup.html#MusrFitInstallation">configure level</a> of the program installation.
<hr />
<p></p>
<a name="TechnicalDescription"></a>
<h1><a name="A_7_Technical_Description_of_the_musrfit_framework"></a> 7 Technical Description of the musrfit framework </h1>
<p></p>
A technical description of the musrfit framework can be found <a href="http://lmu.web.psi.ch/facilities/software/musrfit/technical/" target="_top">here</a>.
<p></p>
<a name="BugTracking"></a>
<h1><a name="A_8_Bugtracking"></a> 8 Bugtracking </h1>
<p></p>
For reporting bugs or requesting new features and improvements please use the <a href="https://tracker.intranet.psi.ch/jira/browse/MUSR" target="_top">PSI Tracker</a> or send an e-mail to A. Suter.
<p></p>
-- <a href="http://www.fsf.org/register_form?referrer=8369" target="_top">BMW</a> &amp; <a href="http://lmu.web.psi.ch/lem/group.html" target="_top">AS</a></div><!-- /foswikiTopic-->
<p></p>
</div><!-- /patternContent-->
<hr />
This topic: MUSR<span class='foswikiSeparator'>&nbsp;&gt;&nbsp;</span><a href="WebHome.html" class="foswikiCurrentWebHomeLink">WebHome</a><span class='foswikiSeparator'>&nbsp;&gt;&nbsp;</span>MusrFit <br />
Topic revision: r96 - 02 Sep 2011 - 19:02:28 - <a href="https://intranet.psi.ch/Main/BastianWojek">BastianWojek</a>
</div>
</div>
</div>
<div class="clear">&nbsp;</div>
</div><div id="patternBottomBar"><div id="patternBottomBarContents"><div id="patternWebBottomBar">Ideas, requests, problems regarding <a href="https://intranet.psi.ch/Main/WebHome">PSI Wiki</a>? <a href="mailto:psi.intranet@psi.ch?subject=PSI%20Wiki%20Feedback%20on%20MUSR.MusrFit">Send feedback</a></div></div></div>
</div>
</div>
</div>
</div></div><!-- /endWrap -->
<p></p>
<p></p>
<p></p>
<p></p>
<!-- gugus --></body>
<!-- Mirrored from intranet.psi.ch/MUSR/MusrFit?cover=print by HTTrack Website Copier/3.x [XR&CO'2010], Fri, 02 Sep 2011 17:10:56 GMT -->
<!-- Added by HTTrack --><meta http-equiv="content-type" content="text/html;charset=iso-8859-1"><!-- /Added by HTTrack -->
</html>