musrfit/doc/html/musr-root.html

935 lines
72 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>MusrRoot - an Extensible Open File Format for μSR &mdash; musrfit 1.7.1 documentation</title>
<link rel="stylesheet" href="_static/nature.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '1.7.1',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<link rel="top" title="musrfit 1.7.1 documentation" href="index.html" />
<link rel="next" title="Acknowledgements" href="acknowledgement.html" />
<link rel="prev" title="any2many - a Universal μSR-file-format converter" href="any2many.html" />
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="acknowledgement.html" title="Acknowledgements"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="any2many.html" title="any2many - a Universal μSR-file-format converter"
accesskey="P">previous</a> |</li>
<li><a href="index.html">musrfit 1.7.1 documentation</a> &raquo;</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="musrroot-an-extensible-open-file-format-for-mgrsr">
<span id="musrroot"></span><span id="index-0"></span><h1>MusrRoot - an Extensible Open File Format for μSR<a class="headerlink" href="#musrroot-an-extensible-open-file-format-for-mgrsr" title="Permalink to this headline"></a></h1>
<p>Until 2011 different μSR file formats were used within PSI. The bulk-μSR instruments were
writing their data in the <tt class="docutils literal"><span class="pre">PSI-BIN</span></tt> file format, which is a fixed binary format with rather stringent
limitations. The LE-μSR (LEM) instrument was using a ROOT (CERN) based file format which was tightly
tailored to the special needs of the LEM instrument. This situation was unsatisfactorily and hence it
was decided to move forward to a open file format called <tt class="docutils literal"><span class="pre">MusrRoot</span></tt> to be described in the following.</p>
<div class="section" id="some-basics-concerning-root-files">
<h2>Some Basics Concerning ROOT Files<a class="headerlink" href="#some-basics-concerning-root-files" title="Permalink to this headline"></a></h2>
<p>The μSR data acquisition systems at PSI are utilizing MIDAS (see <a class="reference external" href="https://midas.triumf.ca/MidasWiki/index.php/Main_Page">Midas Home Page</a>).
The MIDAS analyzer, which is responsible to build histograms, especially the μSR decay histograms, makes
it very easy to build ROOT (see <a class="reference external" href="https://root.cern.ch">ROOT/CERN home page</a> ) histogram objects (these
are <tt class="docutils literal"><span class="pre">TH1F</span></tt> objects for μSR decay histograms). ROOT is a <tt class="docutils literal"><span class="pre">C++</span></tt> object-oriented data mining and
analysis frame work. These histograms can be collected and saved in ROOT files (<tt class="docutils literal"><span class="pre">TFile</span></tt>). In order to ease
the understanding of the upcoming definitions, a few ROOT related things shall be summaries here. For details
concerning the ROOT frame work documentation please check <a class="reference external" href="https://root.cern.ch/root-user-guides-and-manuals">ROOT/CERN Users Guide(s)</a>
and <a class="reference external" href="https://root.cern.ch/guides/reference-guide">ROOT/CERN Reference Guide</a>.</p>
<p>ROOT files (<tt class="docutils literal"><span class="pre">TFile</span></tt>) are binary files which can hold any kind of objects. A <tt class="docutils literal"><span class="pre">TFile</span></tt> is organized similarly
to a directory structure of an operating system. Within the ROOT framework, there is a <tt class="docutils literal"><span class="pre">TFile</span></tt> browser available
which allows to inspect these files. This browser (<tt class="docutils literal"><span class="pre">TBrowser</span></tt>) will show all object saved in the <tt class="docutils literal"><span class="pre">TFile</span></tt> directly,
if they derive from <tt class="docutils literal"><span class="pre">TObject</span></tt>.</p>
<p>The <tt class="docutils literal"><span class="pre">MusrRoot</span></tt> file format to be described below is only using a small subset of possible ROOT objects, namely:</p>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">TFolder</span></tt>: this are the top level objects in the <tt class="docutils literal"><span class="pre">MusrRoot</span></tt> file.</li>
<li><tt class="docutils literal"><span class="pre">TH1F</span></tt>: Hold the μ-decay-histograms.</li>
<li><tt class="docutils literal"><span class="pre">TObjArray</span></tt>: Holding collection of header information.</li>
<li><tt class="docutils literal"><span class="pre">TObjString</span></tt>: Holding the content of any header information.</li>
</ul>
<p>Since all these objects are deriving form <tt class="docutils literal"><span class="pre">TObject</span></tt>, they will be directly accessible via the <tt class="docutils literal"><span class="pre">TBrowser</span></tt>-object.
For instance, the μ-decay-histograms can be directly plotted, are even fitted, out of the box.</p>
</div>
<div class="section" id="id1">
<h2>MusrRoot an Extensible Open File Format for μSR<a class="headerlink" href="#id1" title="Permalink to this headline"></a></h2>
<p>As mentioned before, ROOT files are open-file-format files meaning that they can contain more entries (and most probably will) than the ones specified in the following. The specified ones will be the mandatory ones for all instruments. Before defining all mandatory entries, the MusrRoot file structure shall be sketched.</p>
<p>The MusrRoot file structure looks like:</p>
<div class="highlight-python"><div class="highlight"><pre><span></span>histos ---|
|- DecayAnaModule ---|
| |- hDecay001
| |- hDecay002
| ...
|
|- SCAnaModule ---|
... |- hSampleTemperature
|- hSampleMagneticField
...
RunHeader ---|
|- RunInfo
|- DetectorInfo ---|
| |- Detector001
| |- Detector002
| ...
|
|- SampleEnvironmentInfo
|- MagneticFieldEnvironmentInfo
|- BeamlineInfo
...
</pre></div>
</div>
<p>where <tt class="docutils literal"><span class="pre">hDecay001</span></tt>, etc. are ROOT histograms (to be more specific: <tt class="docutils literal"><span class="pre">TH1F</span></tt>), containing the μSR decay histograms. There can be as many as needed, especially there is no limitation about their length. The histogram object names will be <tt class="docutils literal"><span class="pre">hDecayXXX</span></tt>, where <tt class="docutils literal"><span class="pre">XXX</span></tt> (leading zero int, <em>i.e.</em> <tt class="docutils literal"><span class="pre">%03d</span></tt>
in <tt class="docutils literal"><span class="pre">C/C++</span></tt> notation, starting with &#8216;1&#8217;) is the histogram number. The title and name of the histogram (see description of the <tt class="docutils literal"><span class="pre">TH1F</span></tt> ROOT class) contains the label of the histogram, like &#8216;top&#8217;, &#8216;forward&#8217;, etc. How many of these histograms are present is accessible through the <tt class="docutils literal"><span class="pre">RunInfo</span></tt> folder in which the necessary header information are found (details see next sections). The folder <tt class="docutils literal"><span class="pre">SCAnaModule</span></tt> contains histograms of some of the slow-control parameters, as for instance the sample temperature versus time, the applied field versus time, etc. Again the label of the histogram will give more specific information about its content.</p>
<div class="section" id="run-information-contained-in-runheader">
<h3>Run Information Contained in <tt class="docutils literal"><span class="pre">RunHeader</span></tt><a class="headerlink" href="#run-information-contained-in-runheader" title="Permalink to this headline"></a></h3>
<p>The <tt class="docutils literal"><span class="pre">RunHeader</span></tt> contains all needed meta-information to describe a μSR-run. The list of the minimal number of required &#8220;folders&#8221; of the <tt class="docutils literal"><span class="pre">RunHeader</span></tt> is given in the following structure:</p>
<div class="highlight-python"><div class="highlight"><pre><span></span>RunHeader (TFolder) ---|
|- RunInfo (TObjArray)
|- DetectorInfo (TObjArray)
|- SampleEnvironmentInfo (TObjArray)
|- MagneticFieldEnvironmentInfo (TObjArray)
|- BeamlineInfo (TObjArray)
</pre></div>
</div>
<p>In brackets the object type is given. <tt class="docutils literal"><span class="pre">RunInfo</span></tt> contains most information relevant for the user and will be itemized in <a class="reference internal" href="#musr-root-overview"><em>RunInfo Overview</em></a> and <a class="reference internal" href="#run-info-required"><em>RunInfo Required</em></a>. <tt class="docutils literal"><span class="pre">DetectorInfo</span></tt> contains detector specific information, like detector name, time zero bin, etc. (details is found under <a class="reference internal" href="#detector-info-required"><em>DetectorInfo Required</em></a>). <tt class="docutils literal"><span class="pre">SampleEnvironmentInfo</span></tt> (details under <a class="reference internal" href="#sample-environment-info-required"><em>SampleEnvironmentInfo Required</em></a>), and <tt class="docutils literal"><span class="pre">MagneticFieldEnvironmentInfo</span></tt> (details under <a class="reference internal" href="#magnetic-field-environment-info-required"><em>MagneticFieldEnvironmentInfo Required</em></a>) store additional, more detailed information concerning the sample environment. <tt class="docutils literal"><span class="pre">BeamlineInfo</span></tt> stores beamline relevant information (details under <a class="reference internal" href="#beamline-info-required"><em>BeamlineInfo Required</em></a>).</p>
<p>Before elaborating more on the required items within this structure, a few words on the ROOT types used here: <tt class="docutils literal"><span class="pre">RunHeader</span></tt> is a <tt class="docutils literal"><span class="pre">TFolder</span></tt> object. All the &#8220;sub-directory&#8221; entries are of type <tt class="docutils literal"><span class="pre">TObjArray</span></tt> and collect items of type <tt class="docutils literal"><span class="pre">TObjString</span></tt> or other <tt class="docutils literal"><span class="pre">TObjArray</span></tt> (<em>i.e.</em> sub-directories and sub-sub-directories, etc.).</p>
<div class="section" id="runinfo-overview">
<span id="musr-root-overview"></span><span id="index-1"></span><h4><tt class="docutils literal"><span class="pre">RunInfo</span></tt> Overview<a class="headerlink" href="#runinfo-overview" title="Permalink to this headline"></a></h4>
<table border="1" class="docutils">
<colgroup>
<col width="20%" />
<col width="23%" />
<col width="58%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Name</th>
<th class="head">Internal Type</th>
<th class="head">Comment</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>Version</td>
<td><tt class="docutils literal"><span class="pre">TString</span></tt></td>
<td>GIT version of <tt class="docutils literal"><span class="pre">TMusrRunHeader</span></tt></td>
</tr>
<tr class="row-odd"><td>Generic Validator URL</td>
<td><tt class="docutils literal"><span class="pre">TString</span></tt></td>
<td>URL of the generic <tt class="docutils literal"><span class="pre">MusrRoot</span></tt> validation xsd-file.</td>
</tr>
<tr class="row-even"><td>Specific Validator URL</td>
<td><tt class="docutils literal"><span class="pre">TString</span></tt></td>
<td>URL of the instrument specific validation xsd-file.</td>
</tr>
<tr class="row-odd"><td>Generator</td>
<td><tt class="docutils literal"><span class="pre">TString</span></tt></td>
<td>Program which wrote the <tt class="docutils literal"><span class="pre">MusrRoot</span></tt> file, <em>e.g.</em> <tt class="docutils literal"><span class="pre">nemu_analyzer</span></tt></td>
</tr>
<tr class="row-even"><td>File Name</td>
<td><tt class="docutils literal"><span class="pre">TString</span></tt></td>
<td>File name of the <tt class="docutils literal"><span class="pre">MusrRoot</span></tt> file, <em>e.g.</em> <tt class="docutils literal"><span class="pre">deltat_tdc_gps_4295.root</span></tt></td>
</tr>
<tr class="row-odd"><td>Run Title</td>
<td><tt class="docutils literal"><span class="pre">TString</span></tt></td>
<td>&nbsp;</td>
</tr>
<tr class="row-even"><td>Run Number</td>
<td><tt class="docutils literal"><span class="pre">Int_t</span></tt></td>
<td>&nbsp;</td>
</tr>
<tr class="row-odd"><td>Run Start Time</td>
<td><tt class="docutils literal"><span class="pre">TString</span></tt></td>
<td>ISO 8601 date time</td>
</tr>
<tr class="row-even"><td>Run Stop Time</td>
<td><tt class="docutils literal"><span class="pre">TString</span></tt></td>
<td>ISO 8601 date time</td>
</tr>
<tr class="row-odd"><td>Run Duration</td>
<td><tt class="docutils literal"><span class="pre">TMusrRunPhysicalQuantity</span></tt></td>
<td>run duration in sec</td>
</tr>
<tr class="row-even"><td>Laboratory</td>
<td><tt class="docutils literal"><span class="pre">TString</span></tt></td>
<td><em>e.g.</em> PSI</td>
</tr>
<tr class="row-odd"><td>Instrument</td>
<td><tt class="docutils literal"><span class="pre">TString</span></tt></td>
<td><em>e.g.</em> GPS</td>
</tr>
<tr class="row-even"><td>Muon Beam Momentum</td>
<td><tt class="docutils literal"><span class="pre">TMusrRunPhysicalQuantity</span></tt></td>
<td><em>e.g.</em> 28.1 MeV/c</td>
</tr>
<tr class="row-odd"><td>Muon Species</td>
<td><tt class="docutils literal"><span class="pre">TString</span></tt></td>
<td>positive, or negative muon</td>
</tr>
<tr class="row-even"><td>Muon Source</td>
<td><tt class="docutils literal"><span class="pre">TString</span></tt></td>
<td><em>e.g.</em> Target E - Low Energy Muons or &#8220;Target M&#8221; ...</td>
</tr>
<tr class="row-odd"><td>Setup</td>
<td><tt class="docutils literal"><span class="pre">TString</span></tt></td>
<td>&nbsp;</td>
</tr>
<tr class="row-even"><td>Comment</td>
<td><tt class="docutils literal"><span class="pre">TString</span></tt></td>
<td>&nbsp;</td>
</tr>
<tr class="row-odd"><td>Sample Name</td>
<td><tt class="docutils literal"><span class="pre">TString</span></tt></td>
<td>&nbsp;</td>
</tr>
<tr class="row-even"><td>Sample Temperature</td>
<td><tt class="docutils literal"><span class="pre">TMusrRunPhysicalQuantity</span></tt></td>
<td><em>e.g.</em> 3.21 +- 0.05 K; SP: 3.2; CF1</td>
</tr>
<tr class="row-odd"><td>Sample Magnetic Field</td>
<td><tt class="docutils literal"><span class="pre">TMusrRunPhysicalQuantity</span></tt></td>
<td><em>e.g.</em> 350.002 +- 0.005 G; SP: 350; WXY</td>
</tr>
<tr class="row-even"><td>No of Histos</td>
<td><tt class="docutils literal"><span class="pre">Int_t</span></tt></td>
<td>&nbsp;</td>
</tr>
<tr class="row-odd"><td>Time Resolution</td>
<td><tt class="docutils literal"><span class="pre">TMusrRunPhysicalQuantity</span></tt></td>
<td><em>e.g.</em> 0.1953125 ns</td>
</tr>
<tr class="row-even"><td>RedGreen Offsets</td>
<td><tt class="docutils literal"><span class="pre">TIntVector</span></tt></td>
<td><em>e.g.</em> 0; 20</td>
</tr>
</tbody>
</table>
<p>These entries should be clear except for the <tt class="docutils literal"><span class="pre">RedGreen</span> <span class="pre">Offsets</span></tt> and the column &#8220;Internal Type&#8221; which shortly will be discussed before specifying the content of the other required folders.</p>
<ol class="arabic">
<li><p class="first"><tt class="docutils literal"><span class="pre">RedGreen</span> <span class="pre">Offsets</span></tt>: in case experiments are performed with external stimuli, there will be a collection of related histograms.
For instance for electrical field experiments, there will be histograms for field on/off, doubling the number of needed histograms.
In order to distinguish them easier in the data file, the <tt class="docutils literal"><span class="pre">RedGreen</span> <span class="pre">Offsets</span></tt> were introduced. One selection of histograms
(assuming for the moment 8 detectors) will be numbered from 1 to 8 (lets say the field off ones). The other set of histograms
(field on in this example) will then start with 21 through 28 (see table above). The same will be true for the detector information
(see <a class="reference internal" href="#detector-info-required"><em>DetectorInfo Required</em></a>). The entry <tt class="docutils literal"><span class="pre">No</span> <span class="pre">of</span> <span class="pre">Histos</span></tt> will only give 8 for the given example,
meaning that red/green multiplication is defined rather via <tt class="docutils literal"><span class="pre">RedGreen</span> <span class="pre">Offsets</span></tt> than the number of histograms.</p>
</li>
<li><p class="first">Internal Types: in order to ease the handling of the <tt class="docutils literal"><span class="pre">MusrRoot</span></tt> run header, a class <tt class="docutils literal"><span class="pre">TMusrRunHeader</span></tt> is available which deals
with it. The &#8220;Internal Type&#8221; specified, corresponds to the internal representation in within this class. In the <tt class="docutils literal"><span class="pre">MusrRoot</span></tt> file
these entries are all saved as browsable ROOT strings (<tt class="docutils literal"><span class="pre">TObjStringv).</span> <span class="pre">The</span> <span class="pre">only</span> <span class="pre">special</span> <span class="pre">type</span> <span class="pre">is</span> <span class="pre">``TMusrRunPhysicalQuantity</span></tt> which
is introduced to deal with physical quantities. They always can be represented in the following way:</p>
<div class="highlight-python"><div class="highlight"><pre><span></span>&lt;property name&gt; &lt;value&gt; +- &lt;estimated error&gt; &lt;unit&gt;; SP: &lt;demand&gt;; &lt;description&gt;
</pre></div>
</div>
</li>
</ol>
<p>Not all of these values are needed to be given and depending on which are given, the representation in the <tt class="docutils literal"><span class="pre">MusrRootv</span> <span class="pre">file</span> <span class="pre">will</span> <span class="pre">be</span> <span class="pre">different</span> <span class="pre">(handled</span> <span class="pre">by</span> <span class="pre">``TMusrRunHeader</span></tt>). Examples are given in the comment column of the table above. For details see <a class="reference internal" href="#musr-run-physical-quantity"><em>TMusrRunPhysicalQuantity - Possible Representations</em></a>.</p>
<p>A mock-up <tt class="docutils literal"><span class="pre">TBrowser</span></tt> print-out would look like the one shown in the following figure. You might notice, that at the end of each entry you find a <tt class="docutils literal"><span class="pre">-&#64;X</span></tt>, where <tt class="docutils literal"><span class="pre">X</span></tt> is a number. This is an encoding of the internal type of the entry and is the price to be payed not using derived types. The next section will explain this in much more detail.</p>
<img alt="_images/MusrRoot-RunInfo.png" src="_images/MusrRoot-RunInfo.png" />
<p><tt class="docutils literal"><span class="pre">TMusrRunHeader</span></tt> mock up. The red shaded entries are of type <tt class="docutils literal"><span class="pre">TMusrRunPhysicalQuantity</span></tt></p>
</div>
</div>
</div>
<div class="section" id="tmusrrunheader-concept">
<span id="musr-run-header-concept"></span><h2>TMusrRunHeader Concept<a class="headerlink" href="#tmusrrunheader-concept" title="Permalink to this headline"></a></h2>
<p>The different μSR instruments need different information to be written into the data file (next to the most important ones: the histograms). The above defined properties are the <em>minimal number of required</em> ones. There are different possible approaches to deal with it on the implementation level.</p>
<ul class="simple">
<li>A base class dealing with <em>minimal</em> required standard is defined. Afterwards for each instrument a class
is derived which is extending the base class to the needs of the instrument.</li>
<li>The base class is defined in a more abstract way, and some external, text-based description is given which defines the details of the instrument.</li>
</ul>
<p>Even though the first approach is very clean, it would mean a lot of maintenance work. The 2nd approach is slightly more demanding for the handling class (<tt class="docutils literal"><span class="pre">TMusrRunHeader</span></tt> and helper classes), but having the advantage of easy maintainability and expandability. The idea is that all header information can be classified into 7 groups (see previous and following section(s))</p>
<ol class="arabic simple">
<li>Strings, represented by <tt class="docutils literal"><span class="pre">TString</span></tt></li>
<li>Integers, represented by <tt class="docutils literal"><span class="pre">Int_t</span></tt></li>
<li>Floating point numbers, represented by <tt class="docutils literal"><span class="pre">Double_t</span></tt></li>
<li>Physical quantities, represented by <a class="reference internal" href="#musr-run-physical-quantity"><em>TMusrRunPhysicalQuantity - Possible Representations</em></a></li>
<li>Collection of strings, represented by <tt class="docutils literal"><span class="pre">TStringVector</span></tt></li>
<li>Collection of integers, represented by <tt class="docutils literal"><span class="pre">TIntVector</span></tt></li>
<li>Collection of floating point numbers, represented by <tt class="docutils literal"><span class="pre">TDoubleVector</span></tt></li>
</ol>
<p>These properties can be collected by themselves in form of vectors. This way any needed information can be written into the ROOT file. The class <tt class="docutils literal"><span class="pre">TMusrRunHeader</span></tt> is implementing this run header concept. In following section code snippets will be discussed, showing how this is used on level of the <tt class="docutils literal"><span class="pre">MIDAS</span></tt> analyzer, <tt class="docutils literal"><span class="pre">musrfit</span></tt> reader routine, and <tt class="docutils literal"><span class="pre">any2many</span></tt> conversion routines. The section <a class="reference internal" href="#musr-root-validation"><em>Validation</em></a> will discuss how to validate <tt class="docutils literal"><span class="pre">MusrRoot</span></tt> files.</p>
<div class="section" id="user-interface-for-musrroot-run-header">
<h3>User Interface for MusrRoot Run Header<a class="headerlink" href="#user-interface-for-musrroot-run-header" title="Permalink to this headline"></a></h3>
<p>There are two things needed to deal with the <tt class="docutils literal"><span class="pre">MusrRoot</span></tt> run header, namely writing it and reading it. I will start with the writing as will be done in the <tt class="docutils literal"><span class="pre">MIDAS</span></tt> analyzer.</p>
<div class="section" id="writing-a-musrroot-run-header">
<h4>Writing a MusrRoot Run Header<a class="headerlink" href="#writing-a-musrroot-run-header" title="Permalink to this headline"></a></h4>
<p>An example program <tt class="docutils literal"><span class="pre">write_musrRoot_runHeader</span></tt> which is writing a full run header is part of the <tt class="docutils literal"><span class="pre">musrfit</span></tt> package. Here I will concentrate just on the most essential parts. First one needs an instance of <tt class="docutils literal"><span class="pre">TMusrRunHeader</span></tt></p>
<div class="highlight-c++"><div class="highlight"><pre><span></span><span class="n">TMusrRunHeader</span> <span class="o">*</span><span class="n">header</span> <span class="o">=</span> <span class="k">new</span> <span class="n">TMusrRunHeader</span><span class="p">();</span>
<span class="n">TMusrRunPhysicalQuantity</span> <span class="n">prop</span><span class="p">;</span>
</pre></div>
</div>
<p><tt class="docutils literal"><span class="pre">header</span></tt> is the instance of <tt class="docutils literal"><span class="pre">TMusrRunHeader</span></tt>. <tt class="docutils literal"><span class="pre">prop</span></tt> is an instance of <tt class="docutils literal"><span class="pre">TMusrRunPhysicalQuantity</span></tt> which will be needed further down in the description. In the next step some run header entries will be added</p>
<div class="highlight-c++"><div class="highlight"><pre><span></span><span class="n">header</span><span class="o">-&gt;</span><span class="n">Set</span><span class="p">(</span><span class="s">&quot;RunInfo/File Name&quot;</span><span class="p">,</span> <span class="s">&quot;deltat_tdc_gps_2871.root&quot;</span><span class="p">);</span>
<span class="n">header</span><span class="o">-&gt;</span><span class="n">Set</span><span class="p">(</span><span class="s">&quot;RunInfo/Run Title&quot;</span><span class="p">,</span> <span class="s">&quot;here comes the run title&quot;</span><span class="p">);</span>
<span class="n">header</span><span class="o">-&gt;</span><span class="n">Set</span><span class="p">(</span><span class="s">&quot;RunInfo/Run Number&quot;</span><span class="p">,</span> <span class="mi">2871</span><span class="p">);</span>
</pre></div>
</div>
<p>Adding information is done via the multiple overloaded <tt class="docutils literal"><span class="pre">Set(&lt;pathName&gt;,&lt;value&gt;)</span></tt> method. Here <tt class="docutils literal"><span class="pre">&lt;pathName&gt;</span></tt> is a string representing the &#8220;path&#8221; like representation in the <tt class="docutils literal"><span class="pre">MusrRoot</span></tt> file structure, followed by the &#8220;value&#8221; to be set, <em>e.g.</em> &#8220;=File Name=&#8221;. <tt class="docutils literal"><span class="pre">&lt;value&gt;</span></tt> can be any of the types listed at the beginning of <a class="reference internal" href="#musr-run-header-concept"><em>Sec. TMusrRunHeader Concept</em></a>. Here a few examples how to set <tt class="docutils literal"><span class="pre">TMusrRunPhysicalQuantity</span></tt>.</p>
<div class="highlight-c++"><div class="highlight"><pre><span></span><span class="n">prop</span><span class="p">.</span><span class="n">Set</span><span class="p">(</span><span class="s">&quot;Sample Temperature&quot;</span><span class="p">,</span> <span class="mf">3.2</span><span class="p">,</span> <span class="mf">3.21</span><span class="p">,</span> <span class="mf">0.05</span><span class="p">,</span> <span class="s">&quot;K&quot;</span><span class="p">,</span> <span class="s">&quot;CF1&quot;</span><span class="p">);</span>
<span class="n">header</span><span class="o">-&gt;</span><span class="n">Set</span><span class="p">(</span><span class="s">&quot;RunInfo/Sample Temperature&quot;</span><span class="p">,</span> <span class="n">prop</span><span class="p">);</span>
<span class="n">prop</span><span class="p">.</span><span class="n">Set</span><span class="p">(</span><span class="s">&quot;Time Resolution&quot;</span><span class="p">,</span> <span class="mf">0.1953125</span><span class="p">,</span> <span class="s">&quot;ns&quot;</span><span class="p">,</span> <span class="s">&quot;TDC 9999&quot;</span><span class="p">);</span>
<span class="n">header</span><span class="o">-&gt;</span><span class="n">Set</span><span class="p">(</span><span class="s">&quot;RunInfo/Time Resolution&quot;</span><span class="p">,</span> <span class="n">prop</span><span class="p">);</span>
<span class="n">prop</span><span class="p">.</span><span class="n">Set</span><span class="p">(</span><span class="s">&quot;CF3&quot;</span><span class="p">,</span> <span class="n">MRH_UNDEFINED</span><span class="p">,</span> <span class="mf">3.27</span><span class="p">,</span> <span class="mf">0.09</span><span class="p">,</span> <span class="s">&quot;K&quot;</span><span class="p">,</span> <span class="s">&quot;strange temperature&quot;</span><span class="p">);</span>
<span class="n">header</span><span class="o">-&gt;</span><span class="n">Set</span><span class="p">(</span><span class="s">&quot;SampleEnvironmentInfo/CF3&quot;</span><span class="p">,</span> <span class="n">prop</span><span class="p">);</span>
</pre></div>
</div>
<p>Here <tt class="docutils literal"><span class="pre">TMusrRunPhysicalQuantity</span></tt> objects are fed via the use of the overloaded set-method. For details see <a class="reference internal" href="#musr-run-physical-quantity"><em>TMusrRunPhysicalQuantity - Possible Representations</em></a>.</p>
<p>To set some property within &#8220;sub-sub-directories&#8221; it would like this:</p>
<div class="highlight-c++"><div class="highlight"><pre><span></span><span class="n">header</span><span class="o">-&gt;</span><span class="n">Set</span><span class="p">(</span><span class="s">&quot;DetectorInfo/Detector001/Time Zero Bin&quot;</span><span class="p">,</span> <span class="mf">3419.0</span><span class="p">);</span>
</pre></div>
</div>
<p>To write the whole run header into a file would look something like this:</p>
<div class="highlight-c++"><div class="highlight"><pre><span></span><span class="n">TFile</span> <span class="o">*</span><span class="n">f</span> <span class="o">=</span> <span class="k">new</span> <span class="n">TFile</span><span class="p">(</span><span class="n">fileName</span><span class="p">,</span> <span class="s">&quot;RECREATE&quot;</span><span class="p">,</span> <span class="s">&quot;write_musrRoot_runHeader&quot;</span><span class="p">);</span>
<span class="k">if</span> <span class="p">(</span><span class="n">f</span><span class="o">-&gt;</span><span class="n">IsZombie</span><span class="p">())</span> <span class="p">{</span>
<span class="k">delete</span> <span class="n">f</span><span class="p">;</span>
<span class="k">return</span> <span class="o">-</span><span class="mi">1</span><span class="p">;</span>
<span class="p">}</span>
<span class="c1">// create the needed TFolder object</span>
<span class="n">TFolder</span> <span class="o">*</span><span class="n">runHeader</span> <span class="o">=</span> <span class="k">new</span> <span class="n">TFolder</span><span class="p">(</span><span class="s">&quot;RunHeader&quot;</span><span class="p">,</span> <span class="s">&quot;MusrRoot Run Header Info&quot;</span><span class="p">);</span>
<span class="c1">// create the &quot;directory&quot; structure</span>
<span class="k">if</span> <span class="p">(</span><span class="n">header</span><span class="o">-&gt;</span><span class="n">FillFolder</span><span class="p">(</span><span class="n">runHeader</span><span class="p">))</span> <span class="p">{</span>
<span class="n">runHeader</span><span class="o">-&gt;</span><span class="n">Write</span><span class="p">();</span> <span class="c1">// write run header to file</span>
<span class="p">}</span>
<span class="n">f</span><span class="o">-&gt;</span><span class="n">Close</span><span class="p">();</span>
</pre></div>
</div>
</div>
<div class="section" id="reading-a-musrroot-run-header">
<h4>Reading a MusrRoot Run Header<a class="headerlink" href="#reading-a-musrroot-run-header" title="Permalink to this headline"></a></h4>
<p>The following code snippet shows how the extract the full run header from the <tt class="docutils literal"><span class="pre">MusrRoot</span></tt> file.</p>
<div class="highlight-c++"><div class="highlight"><pre><span></span><span class="n">TFile</span> <span class="o">*</span><span class="n">f</span> <span class="o">=</span> <span class="k">new</span> <span class="n">TFile</span><span class="p">(</span><span class="n">fileName</span><span class="p">,</span> <span class="s">&quot;READ&quot;</span><span class="p">,</span> <span class="s">&quot;read_musrRoot_runHeader&quot;</span><span class="p">);</span>
<span class="k">if</span> <span class="p">(</span><span class="n">f</span><span class="o">-&gt;</span><span class="n">IsZombie</span><span class="p">())</span> <span class="p">{</span>
<span class="k">delete</span> <span class="n">f</span><span class="p">;</span>
<span class="k">return</span> <span class="o">-</span><span class="mi">1</span><span class="p">;</span>
<span class="p">}</span>
<span class="n">TFolder</span> <span class="o">*</span><span class="n">runHeader</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
<span class="n">f</span><span class="o">-&gt;</span><span class="n">GetObject</span><span class="p">(</span><span class="s">&quot;RunHeader&quot;</span><span class="p">,</span> <span class="n">runHeader</span><span class="p">);</span>
<span class="k">if</span> <span class="p">(</span><span class="n">runHeader</span> <span class="o">==</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span>
<span class="n">cerr</span> <span class="o">&lt;&lt;</span> <span class="n">endl</span> <span class="o">&lt;&lt;</span> <span class="s">&quot;&gt;&gt; **ERROR** Couldn&#39;t get top folder RunHeader&quot;</span><span class="p">;</span>
<span class="n">closeFile</span><span class="p">(</span><span class="n">f</span><span class="p">);</span>
<span class="k">return</span> <span class="o">-</span><span class="mi">1</span><span class="p">;</span>
<span class="p">}</span>
<span class="n">TMusrRunHeader</span> <span class="o">*</span><span class="n">header</span> <span class="o">=</span> <span class="k">new</span> <span class="n">TMusrRunHeader</span><span class="p">(</span><span class="n">fileName</span><span class="p">);</span>
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="n">header</span><span class="o">-&gt;</span><span class="n">ExtractAll</span><span class="p">(</span><span class="n">runHeader</span><span class="p">))</span> <span class="p">{</span>
<span class="n">cerr</span> <span class="o">&lt;&lt;</span> <span class="n">endl</span> <span class="o">&lt;&lt;</span> <span class="s">&quot;&gt;&gt; **ERROR** couldn&#39;t extract all RunHeader information&quot;</span><span class="p">;</span>
<span class="n">closeFile</span><span class="p">(</span><span class="n">f</span><span class="p">);</span>
<span class="k">return</span> <span class="o">-</span><span class="mi">1</span><span class="p">;</span>
<span class="p">}</span>
<span class="n">f</span><span class="o">-&gt;</span><span class="n">Close</span><span class="p">();</span>
<span class="k">delete</span> <span class="n">f</span><span class="p">;</span>
</pre></div>
</div>
<p>The routine <tt class="docutils literal"><span class="pre">ExtractAll(TFolder</span> <span class="pre">*runHeader)</span></tt> decodes all the <tt class="docutils literal"><span class="pre">TObjString</span></tt> objects and fills internal data structures. This means when reading a MusrRoot -file the above handling is always needed. After the <tt class="docutils literal"><span class="pre">ExtractAll</span></tt> call, parameters can be extracted via the getter routines available. For instance to read the Run Number, the code would look like</p>
<div class="highlight-c++"><div class="highlight"><pre><span></span><span class="n">Bool_t</span> <span class="n">ok</span><span class="p">;</span>
<span class="n">Int_t</span> <span class="n">ival</span><span class="p">;</span>
<span class="n">header</span><span class="o">-&gt;</span><span class="n">Get</span><span class="p">(</span><span class="s">&quot;RunInfo/Run Number&quot;</span><span class="p">,</span> <span class="n">ival</span><span class="p">,</span> <span class="n">ok</span><span class="p">);</span>
<span class="k">if</span> <span class="p">(</span><span class="n">ok</span><span class="p">)</span>
<span class="n">cout</span> <span class="o">&lt;&lt;</span> <span class="n">endl</span> <span class="o">&lt;&lt;</span> <span class="s">&quot;Run Number: &quot;</span> <span class="o">&lt;&lt;</span> <span class="n">ival</span><span class="p">;</span>
<span class="k">else</span>
<span class="n">cout</span> <span class="o">&lt;&lt;</span> <span class="n">endl</span> <span class="o">&lt;&lt;</span> <span class="s">&quot;**ERROR** Couldn&#39;t obtain the &#39;Run Number&#39;.&quot;</span><span class="p">;</span>
</pre></div>
</div>
<p>Reading a <tt class="docutils literal"><span class="pre">TMusrRunPhysicalQuantity</span></tt> object, <em>e.g.</em> the sample temperature looks like this</p>
<div class="highlight-c++"><div class="highlight"><pre><span></span><span class="n">TMusrRunPhysicalQuantity</span> <span class="n">prop</span><span class="p">;</span>
<span class="n">header</span><span class="o">-&gt;</span><span class="n">Get</span><span class="p">(</span><span class="s">&quot;RunInfo/Sample Temperature&quot;</span><span class="p">,</span> <span class="n">prop</span><span class="p">,</span> <span class="n">ok</span><span class="p">);</span>
<span class="k">if</span> <span class="p">(</span><span class="n">ok</span><span class="p">)</span> <span class="p">{</span>
<span class="n">cout</span> <span class="o">&lt;&lt;</span> <span class="n">endl</span> <span class="o">&lt;&lt;</span> <span class="s">&quot;Sample Temperature: &quot;</span> <span class="o">&lt;&lt;</span> <span class="n">prop</span><span class="p">.</span><span class="n">GetValue</span><span class="p">()</span> <span class="o">&lt;&lt;</span> <span class="s">&quot; +- &quot;</span><span class="p">;</span>
<span class="n">cout</span> <span class="o">&lt;&lt;</span> <span class="n">prop</span><span class="p">.</span><span class="n">GetError</span><span class="p">()</span> <span class="o">&lt;&lt;</span> <span class="s">&quot; &quot;</span> <span class="o">&lt;&lt;</span> <span class="n">prop</span><span class="p">.</span><span class="n">GetUnit</span><span class="p">().</span><span class="n">Data</span><span class="p">();</span>
<span class="n">cout</span> <span class="o">&lt;&lt;</span> <span class="s">&quot;; SP: &quot;</span> <span class="o">&lt;&lt;</span> <span class="n">prop</span><span class="p">.</span><span class="n">GetDemand</span><span class="p">()</span> <span class="o">&lt;&lt;</span> <span class="s">&quot;; &quot;</span> <span class="o">&lt;&lt;</span> <span class="n">prop</span><span class="p">.</span><span class="n">GetDescription</span><span class="p">().</span><span class="n">Data</span><span class="p">();</span>
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
<span class="n">cout</span> <span class="o">&lt;&lt;</span> <span class="n">endl</span> <span class="o">&lt;&lt;</span> <span class="s">&quot;**ERROR** Couldn&#39;t obtain the &#39;Sample Temperature&#39;.&quot;</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="validation-of-a-musrroot-file">
<span id="musr-root-validation"></span><span id="index-2"></span><h3>Validation of a MusrRoot File<a class="headerlink" href="#validation-of-a-musrroot-file" title="Permalink to this headline"></a></h3>
<p>Since <tt class="docutils literal"><span class="pre">MusrRoot</span></tt> is an open and extensible file format a mechanism is needed to validate that a given file is indeed holding the minimum of required entries. To check this the following scheme is implemented in the program <tt class="docutils literal"><span class="pre">musrRootValidation</span></tt>:</p>
<img alt="_images/MusrRootValidationScheme.png" src="_images/MusrRootValidationScheme.png" />
<p><tt class="docutils literal"><span class="pre">MusrRoot</span></tt> validation scheme</p>
<p>In the following this validation scheme will be discussed as it is implemented in <tt class="docutils literal"><span class="pre">musrRootValidation</span></tt>:</p>
<ol class="arabic simple">
<li>It is checked if the given file name is a <tt class="docutils literal"><span class="pre">TFile</span></tt></li>
<li>The file structure is recursively parsed and mapped into an temporary XML file. XML is used
since there are ample of parser and validation frameworks at hand. For details check any decent
book about XML. Here the <tt class="docutils literal"><span class="pre">libxml2</span></tt> is used, because also ROOT is requiring it.</li>
<li>In a next step the XML file (holding the structure of the supposed <tt class="docutils literal"><span class="pre">MusrRoot</span></tt> file is validated
against a XML schema. The minimum of required entries is described by <tt class="docutils literal"><span class="pre">MusrRoot.xsd</span></tt> which is
part of <tt class="docutils literal"><span class="pre">musrfit</span></tt> but also available from the PSI/LMU web-page.</li>
<li>If the schema validation is successful additional semantic checks (like is the number of decay
histograms the same as the number of detector entries, etc.) will be preformed.</li>
</ol>
<p>This validation scheme is useful for people which define instrument specific extensions of the base <tt class="docutils literal"><span class="pre">MusrRoot</span></tt>, as for instance the LEM instrument at PSI. It is also useful for people writing file converters in order to cross check if the generated file is valid.</p>
</div>
</div>
<div class="section" id="runinfo-required">
<span id="run-info-required"></span><h2>RunInfo (Required)<a class="headerlink" href="#runinfo-required" title="Permalink to this headline"></a></h2>
<table border="1" class="docutils">
<colgroup>
<col width="17%" />
<col width="19%" />
<col width="64%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Name</th>
<th class="head">Internal Type</th>
<th class="head">Comment</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>Version</td>
<td><tt class="docutils literal"><span class="pre">TString</span></tt></td>
<td>GIT version of <tt class="docutils literal"><span class="pre">TMusrRunHeader</span></tt></td>
</tr>
<tr class="row-odd"><td>Generic Validator URL</td>
<td><tt class="docutils literal"><span class="pre">TString</span></tt></td>
<td>URL of the generic <tt class="docutils literal"><span class="pre">MusrRoot</span></tt> validation xsd-file.
<em>e.g.</em> <a class="reference external" href="http://lmu.web.psi.ch/facilities/software/MusrRoot/Validation/MusrRoot.xsd">http://lmu.web.psi.ch/facilities/software/MusrRoot/Validation/MusrRoot.xsd</a></td>
</tr>
<tr class="row-even"><td>Specific Validator URL</td>
<td><tt class="docutils literal"><span class="pre">TString</span></tt></td>
<td>URL of the instrument specific validation xsd-file.
<em>e.g.</em> for LEM: <a class="reference external" href="http://lmu.web.psi.ch/facilities/software/MusrRoot/Validation/MusrRootLEM.xsd">http://lmu.web.psi.ch/facilities/software/MusrRoot/Validation/MusrRootLEM.xsd</a></td>
</tr>
<tr class="row-odd"><td>Generator</td>
<td><tt class="docutils literal"><span class="pre">TString</span></tt></td>
<td>Program which wrote the <tt class="docutils literal"><span class="pre">MusrRoot</span></tt> file, <em>e.g.</em> <tt class="docutils literal"><span class="pre">nemu_analyzer</span></tt></td>
</tr>
<tr class="row-even"><td>File Name</td>
<td><tt class="docutils literal"><span class="pre">TString</span></tt></td>
<td>File name of the <tt class="docutils literal"><span class="pre">MusrRoot</span></tt> file, <em>e.g.</em> <tt class="docutils literal"><span class="pre">deltat_tdc_gps_4295.root</span></tt></td>
</tr>
<tr class="row-odd"><td>Run Title</td>
<td><tt class="docutils literal"><span class="pre">TString</span></tt></td>
<td>&nbsp;</td>
</tr>
<tr class="row-even"><td>Run Number</td>
<td><tt class="docutils literal"><span class="pre">Int_t</span></tt></td>
<td>&nbsp;</td>
</tr>
<tr class="row-odd"><td>Run Start Time</td>
<td><tt class="docutils literal"><span class="pre">TString</span></tt></td>
<td>ISO 8601 date time</td>
</tr>
<tr class="row-even"><td>Run Stop Time</td>
<td><tt class="docutils literal"><span class="pre">TString</span></tt></td>
<td>ISO 8601 date time</td>
</tr>
<tr class="row-odd"><td>Run Duration</td>
<td><tt class="docutils literal"><span class="pre">TMusrRunPhysicalQuantity</span></tt></td>
<td>run duration in sec</td>
</tr>
<tr class="row-even"><td>Laboratory</td>
<td><tt class="docutils literal"><span class="pre">TString</span></tt></td>
<td><em>e.g.</em> PSI</td>
</tr>
<tr class="row-odd"><td>Instrument</td>
<td><tt class="docutils literal"><span class="pre">TString</span></tt></td>
<td><em>e.g.</em> GPS</td>
</tr>
<tr class="row-even"><td>Muon Beam Momentum</td>
<td><tt class="docutils literal"><span class="pre">TMusrRunPhysicalQuantity</span></tt></td>
<td><em>e.g.</em> 28.1 MeV/c</td>
</tr>
<tr class="row-odd"><td>Muon Species</td>
<td><tt class="docutils literal"><span class="pre">TString</span></tt></td>
<td>poitive or negative muon</td>
</tr>
<tr class="row-even"><td>Muon Source</td>
<td><tt class="docutils literal"><span class="pre">TString</span></tt></td>
<td><em>e.g.</em> &#8220;Target E - Low Energy Muons&#8221; or &#8220;Target M&#8221; ...</td>
</tr>
<tr class="row-odd"><td>Setup</td>
<td><tt class="docutils literal"><span class="pre">TString</span></tt></td>
<td>&nbsp;</td>
</tr>
<tr class="row-even"><td>Comment</td>
<td><tt class="docutils literal"><span class="pre">TString</span></tt></td>
<td>&nbsp;</td>
</tr>
<tr class="row-odd"><td>Sample Name</td>
<td><tt class="docutils literal"><span class="pre">TString</span></tt></td>
<td>&nbsp;</td>
</tr>
<tr class="row-even"><td>Sample Temperature</td>
<td><tt class="docutils literal"><span class="pre">TMusrRunPhysicalQuantity</span></tt></td>
<td><em>e.g.</em> 3.21 +- 0.05 K; SP: 3.2; CF1</td>
</tr>
<tr class="row-odd"><td>Sample Magnetic Field</td>
<td><tt class="docutils literal"><span class="pre">TMusrRunPhysicalQuantity</span></tt></td>
<td><em>e.g.</em> 350.002 +- 0.005 G; SP: 350; WEW</td>
</tr>
<tr class="row-even"><td>No of Histos</td>
<td><tt class="docutils literal"><span class="pre">Int_t</span></tt></td>
<td>&nbsp;</td>
</tr>
<tr class="row-odd"><td>Time Resolution</td>
<td><tt class="docutils literal"><span class="pre">TMusrRunPhysicalQuantity</span></tt></td>
<td><em>e.g.</em> 0.1953125 ns</td>
</tr>
<tr class="row-even"><td>RedGreen Offsets</td>
<td><tt class="docutils literal"><span class="pre">TIntVector</span></tt></td>
<td><em>e.g.</em> 0; 20</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="detectorinfo-required">
<span id="detector-info-required"></span><h2>DetectorInfo (Required)<a class="headerlink" href="#detectorinfo-required" title="Permalink to this headline"></a></h2>
<p>The <tt class="docutils literal"><span class="pre">DetectorInfo</span></tt> is organized in a sub-tree like</p>
<div class="highlight-python"><div class="highlight"><pre><span></span>DetectorInfo ---|
|- Detector001
|- Detector002
...
</pre></div>
</div>
<p>For each histogram in the <tt class="docutils literal"><span class="pre">histos/DecayAnaModule</span></tt> corresponds detector entry here.</p>
<p>The numbering of the detectors has to correspond the its histogram, <em>e.g.</em> <tt class="docutils literal"><span class="pre">hDecay023</span> <span class="pre">&lt;=&gt;</span> <span class="pre">Detector023</span></tt>, <em>i.e.</em> potentially discontinuous to show red / green breaks.</p>
<p><tt class="docutils literal"><span class="pre">Detector&lt;XXX&gt;</span></tt> has the elements</p>
<table border="1" class="docutils">
<colgroup>
<col width="22%" />
<col width="25%" />
<col width="53%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Name</th>
<th class="head">Internal Type</th>
<th class="head">Comment</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>Name</td>
<td><tt class="docutils literal"><span class="pre">TString</span></tt></td>
<td>detector name, <em>e.g.</em> Left-NPP</td>
</tr>
<tr class="row-odd"><td>Histo Number</td>
<td><tt class="docutils literal"><span class="pre">Int_t</span></tt></td>
<td>histogram number. This number corresponds to the histogram
number in the <tt class="docutils literal"><span class="pre">histos/DecayAnaModule</span></tt> sub-tree.</td>
</tr>
<tr class="row-even"><td>Histo Length</td>
<td><tt class="docutils literal"><span class="pre">Int_t</span></tt></td>
<td>length of the histogram (in bins)</td>
</tr>
<tr class="row-odd"><td>Time Zero Bin</td>
<td><tt class="docutils literal"><span class="pre">Double_t</span></tt></td>
<td>The type is <tt class="docutils literal"><span class="pre">Double_t</span></tt> since for the high-field spectrometer
at PSI an <tt class="docutils literal"><span class="pre">Int_t</span></tt> representation would be not good enough.</td>
</tr>
<tr class="row-even"><td>First Good Bin</td>
<td><tt class="docutils literal"><span class="pre">Int_t</span></tt></td>
<td>&nbsp;</td>
</tr>
<tr class="row-odd"><td>Last Good Bin</td>
<td><tt class="docutils literal"><span class="pre">Int_t</span></tt></td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="sampleenvironmentinfo-required">
<span id="sample-environment-info-required"></span><h2>SampleEnvironmentInfo (Required)<a class="headerlink" href="#sampleenvironmentinfo-required" title="Permalink to this headline"></a></h2>
<p>Here only a single entry is required, namely</p>
<table border="1" class="docutils">
<colgroup>
<col width="24%" />
<col width="27%" />
<col width="49%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Name</th>
<th class="head">Internal Type</th>
<th class="head">Comment</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>Cryo</td>
<td><tt class="docutils literal"><span class="pre">TString</span></tt></td>
<td>name of the used cryostat/oven, <em>e.g.</em> <tt class="docutils literal"><span class="pre">Konti-2</span></tt></td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="magneticfieldenvironmentinfo-required">
<span id="magnetic-field-environment-info-required"></span><h2>MagneticFieldEnvironmentInfo (Required)<a class="headerlink" href="#magneticfieldenvironmentinfo-required" title="Permalink to this headline"></a></h2>
<p>Here only a single entry is required, namely</p>
<table border="1" class="docutils">
<colgroup>
<col width="23%" />
<col width="25%" />
<col width="52%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Name</th>
<th class="head">Internal Type</th>
<th class="head">Comment</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>Magnet Name</td>
<td><tt class="docutils literal"><span class="pre">TString</span></tt></td>
<td>name of the used magnet, <em>e.g.</em> <tt class="docutils literal"><span class="pre">WEW</span></tt>.
In case of ZF measurements, there might be an entry like ZF.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="beamlineinfo-required">
<span id="beamline-info-required"></span><h2>BeamlineInfo (Required)<a class="headerlink" href="#beamlineinfo-required" title="Permalink to this headline"></a></h2>
<p>Here only a single entry is required, namely</p>
<table border="1" class="docutils">
<colgroup>
<col width="24%" />
<col width="27%" />
<col width="49%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Name</th>
<th class="head">Internal Type</th>
<th class="head">Comment</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>Name</td>
<td><tt class="docutils literal"><span class="pre">TString</span></tt></td>
<td>name of the beamline, <em>e.g.</em> <tt class="docutils literal"><span class="pre">piM3.2</span></tt></td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="exhaustive-musrroot-tree-including-everything-required">
<h2>Exhaustive MusrRoot Tree Including Everything Required<a class="headerlink" href="#exhaustive-musrroot-tree-including-everything-required" title="Permalink to this headline"></a></h2>
<p>Here it is assumed that there are hypothetical <em>red / green data</em> with electric field on/off and light on/off,
and hence 4 data sets per detector, and 8 detectors of the instrument: <tt class="docutils literal"><span class="pre">left/forward</span></tt>, <tt class="docutils literal"><span class="pre">top/forward</span></tt>, <tt class="docutils literal"><span class="pre">right/forward</span></tt>,
<tt class="docutils literal"><span class="pre">bottom/forward</span></tt>, <tt class="docutils literal"><span class="pre">left/backward</span></tt>, <tt class="docutils literal"><span class="pre">top/backward</span></tt>, <tt class="docutils literal"><span class="pre">right/backward</span></tt>, <tt class="docutils literal"><span class="pre">bottom/backward</span></tt>. To show the whole
tree structure, it will be split in the representation afterwards, but keep in mind: this will be all part of a
single <tt class="docutils literal"><span class="pre">MusrRoot</span></tt> file. I will add comments in the tree structure by the symbol <tt class="docutils literal"><span class="pre">#</span></tt>. Lets start with the μSR data histograms:</p>
<div class="highlight-python"><div class="highlight"><pre><span></span>histos -|
|- DecayAnaModule -|
|- hDecay001 # left/forward, electric field off, light off
|- hDecay002 # top/forward, electric field off, light off
|- hDecay003 # right/forward, electric field off, light off
|- hDecay004 # bottom/forward, electric field off, light off
...
|- hDecay007 # right/backward, electric field off, light off
|- hDecay008 # bottom/backward, electric field off, light off
|- hDecay011 # left/forward, electric field on, light off
|- hDecay012 # top/forward, electric field on, light off
|- hDecay013 # right/forward, electric field on, light off
|- hDecay014 # bottom/forward, electric field on, light off
...
|- hDecay017 # right/backward, electric field on, light off
|- hDecay018 # bottom/backward, electric field on, light off
|- hDecay021 # left/forward, electric field off, light on
|- hDecay022 # top/forward, electric field off, light on
|- hDecay023 # right/forward, electric field off, light on
|- hDecay024 # bottom/forward, electric field off, light on
...
|- hDecay027 # right/backward, electric field off, light on
|- hDecay028 # bottom/backward, electric field off, light on
|- hDecay031 # left/forward, electric field on, light on
|- hDecay032 # top/forward, electric field on, light on
|- hDecay033 # right/forward, electric field on, light on
|- hDecay034 # bottom/forward, electric field on, light on
...
|- hDecay037 # right/backward, electric field on, light on
|- hDecay038 # bottom/backward, electric field on, light on
...
</pre></div>
</div>
<p><em>Comments</em>: as can be seen the histograms are continuous numbered until there is a red / green mode switch where
the histogram number &#8220;jumps&#8221; (<em>e.g.</em> from <tt class="docutils literal"><span class="pre">008</span></tt> to <tt class="docutils literal"><span class="pre">011</span></tt>). In order to fill in the different red / green
histograms an offset is added (here 10, 20, and 30).</p>
<p>Next the whole <tt class="docutils literal"><span class="pre">RunHeader</span></tt>. Here the information will be grouped in different folders collecting related information,
like general run info, detector info, sample and magnetic field environment info, beamline info, etc.</p>
<div class="highlight-python"><div class="highlight"><pre><span></span>RunInfo:
000 - Version: $Id: TMusrRunHeader.cpp 5092 2012-03-13 07:47:00Z nemu $ -@0
001 - Generic Validator URL: http://lmu.web.psi.ch/facilities/software/MusrRoot/Validation/MusrRoot.xsd -@0
002 - Specific Validator URL: http://lmu.web.psi.ch/facilities/software/MusrRoot/Validation/MusrRootLEM.xsd -@0
003 - Generator: nemu_analyzer -@0
004 - File Name: lem12_his_0234.root -@0
005 - Run Title: here comes the run title -@0
006 - Run Number: 234 -@1
007 - Run Start Time: 2012-04-19 14:25:22 -@0
008 - Run Stop Time: 2012-04-19 19:13:47 -@0
009 - Run Duration: 17305 sec -@3
010 - Laboratory: PSI -@0
011 - Instrument: LEM -@0
012 - Muon Beam Momentum: 28.1 MeV/c -@3
013 - Muon Species: positive muon -@0
014 - Muon Source: target E -@0
015 - Setup: a very special setup -@0
016 - Comment: nothing more to be said -@0
017 - Sample Name: the best ever -@0
018 - Sample Temperature: 3.21 +- 0.05 K; SP: 3.2 -@3
019 - Sample Magnetic Field: 350.002 +- 0.005 G; SP: 350 -@3
020 - No of Histos: 8 -@1
021 - Time Resolution: 0.1953125 ns; TDC 9999 -@3
022 - RedGreen Offsets: 0; 10; 20; 30
DetectorInfo:
Detector001:
023 - Name: Left/Forward - electric field off, light off -@0
024 - Histo Number: 1 -@1
025 - Histo Length: 66661 -@1
026 - Time Zero Bin: 3419.000000 -@2
027 - First Good Bin: 3419 -@1
028 - Last Good Bin: 66661 -@1
Detector002:
029 - Name: Top/Forward - electric field off, light off -@0
030 - Histo Number: 2 -@1
031 - Histo Length: 66661 -@1
032 - Time Zero Bin: 3419.000000 -@2
033 - First Good Bin: 3419 -@1
034 - Last Good Bin: 66661 -@1
...
Detector038:
213 - Name: Bottom/Backward - electric field on, light on -@0
214 - Histo Number: 38 -@1
215 - Histo Length: 66661 -@1
216 - Time Zero Bin: 3419.000000 -@2
217 - First Good Bin: 3419 -@1
218 - Last Good Bin: 66661 -@1
SampleEnvironmentInfo:
219 - Cryo: Konti-1 -@0
220 - Insert: X123 -@0
221 - Orientation: c-axis perp spin, perp field. spin perp field -@0
MagneticFieldEnvironmentInfo:
222 - Magnet Name: WEW -@0
223 - Current: 17.34 A -@3
BeamlineInfo:
224 - Name: muE4 -@0
ScalerInfo:
225 - Ip: 12332123 -@1
RunSummary:
0000 - Wed Oct 5 01:30:37 2011 Run 2856 started.
0001 - Wed Oct 5 02:02:51 2011 Run 2856 stopped.
0002 -
0003 - LCO, T=170.02(K), wTF ~30(G)/5.18(A), Tr/Sa=15.02/8.50(kV), E=5.63(keV), LEDb off, BP off
0004 - =========================================================================================
0005 -
0006 - #BUC---- B e g i n of User Comment ------ Do not edit this line
0007 - #EUC---- E n d of User Comment ------ Do not edit this line
0008 -
0009 - ====================== E v e n t definition =========================
0010 -
0011 - Events:
0012 - Event_0: (BC)-MCP1-(e+); Event_1:( BC)-TD-MCP2-(e+); Event_2: LEmuSR, (BC)-TD-e
...
</pre></div>
</div>
<p><em>Comment</em>: the last sub-tree <tt class="docutils literal"><span class="pre">RunSummary</span></tt> is not following <tt class="docutils literal"><span class="pre">TMusrRunHeader</span></tt> rule <tt class="docutils literal"><span class="pre">&lt;number&gt;</span> <span class="pre">-</span> <span class="pre">&lt;label&gt;:</span> <span class="pre">&lt;value&gt;</span> <span class="pre">-&#64;&lt;type&gt;</span></tt>.
It is added in the instrument analyzer directly by other means than the <tt class="docutils literal"><span class="pre">TMusrRunHeader::Set</span></tt>-method. This is no problem!
Since <tt class="docutils literal"><span class="pre">RunSummary</span></tt> is not part of the required <tt class="docutils literal"><span class="pre">MusrRoot</span></tt>-file. One is quite free in adding any ROOT based information here.</p>
</div>
<div class="section" id="tmusrrunphysicalquantity-possible-representations">
<span id="musr-run-physical-quantity"></span><span id="index-3"></span><h2>TMusrRunPhysicalQuantity - Possible Representations<a class="headerlink" href="#tmusrrunphysicalquantity-possible-representations" title="Permalink to this headline"></a></h2>
<p>A physical property can be described as</p>
<div class="highlight-python"><div class="highlight"><pre><span></span>&lt;property name&gt;: &lt;value&gt; +- &lt;estimated error&gt; &lt;unit&gt;; SP: &lt;demand&gt;; &lt;description&gt;
</pre></div>
</div>
<p>where <tt class="docutils literal"><span class="pre">&lt;property</span> <span class="pre">name&gt;</span></tt> is the name of the quantity, <em>e.g.</em> Sample Temperature, <tt class="docutils literal"><span class="pre">&lt;value&gt;</span></tt> the value
of the quantity, <tt class="docutils literal"><span class="pre">&lt;estimated</span> <span class="pre">error&gt;</span></tt> the error estimate, <em>e.g.</em> the standard deviation, <tt class="docutils literal"><span class="pre">&lt;unit&gt;</span></tt> the unit,
<em>e.g.</em> K, <tt class="docutils literal"><span class="pre">&lt;demand&gt;</span></tt> a demand value, <em>e.g.</em> the set point of the temperature. <tt class="docutils literal"><span class="pre">&lt;description&gt;</span></tt> is a
possible additional comment for this quantity.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Not <em>all</em> of these quantities are always needed. The list of handled combination are given
hereafter together with the <tt class="docutils literal"><span class="pre">C++</span></tt> code snipped how to set it. It is assumed that <tt class="docutils literal"><span class="pre">TMusrRunPhysicalQuantity</span> <span class="pre">prop;</span></tt>
is somewhere defined.</p>
</div>
<p><strong>Possibility 1</strong></p>
<div class="highlight-python"><div class="highlight"><pre><span></span>&lt;property name&gt;: &lt;value&gt; &lt;unit&gt; [; &lt;description&gt;]
</pre></div>
</div>
<p>Code snippet:</p>
<div class="highlight-c++"><div class="highlight"><pre><span></span><span class="n">prop</span><span class="p">.</span><span class="n">Set</span><span class="p">(</span><span class="s">&quot;Muon Beam Momentum&quot;</span><span class="p">,</span> <span class="mf">28.1</span><span class="p">,</span> <span class="s">&quot;MeV/c&quot;</span><span class="p">);</span>
<span class="n">header</span><span class="o">-&gt;</span><span class="n">Set</span><span class="p">(</span><span class="s">&quot;RunInfo/Muon Beam Momentum&quot;</span><span class="p">,</span> <span class="n">prop</span><span class="p">);</span>
<span class="n">prop</span><span class="p">.</span><span class="n">Set</span><span class="p">(</span><span class="s">&quot;Time Resolution&quot;</span><span class="p">,</span> <span class="mf">0.1953125</span><span class="p">,</span> <span class="s">&quot;ns&quot;</span><span class="p">,</span> <span class="s">&quot;TDC 9999&quot;</span><span class="p">);</span>
<span class="n">header</span><span class="o">-&gt;</span><span class="n">Set</span><span class="p">(</span><span class="s">&quot;RunInfo/Time Resolution&quot;</span><span class="p">,</span> <span class="n">prop</span><span class="p">);</span>
</pre></div>
</div>
<p>Result in the <tt class="docutils literal"><span class="pre">RunHeader/RunInfo</span></tt>:</p>
<div class="highlight-python"><div class="highlight"><pre><span></span>011 - Muon Beam Momentum: 28.1 MeV/c -@3
013 - Time Resolution: 0.1953125 ns; TDC 9999 -@3
</pre></div>
</div>
<p>The number on front of the token (<em>e.g.</em> <tt class="docutils literal"><span class="pre">011</span></tt> in front of Muon Beam Momentum) will depend on the position where
the entry has been added. The last token, <tt class="docutils literal"><span class="pre">-&#64;3</span></tt>, is the encoding of the type: here <tt class="docutils literal"><span class="pre">TMusrRunPhysicalQuantity</span></tt>.</p>
<p><strong>Possibility 2</strong></p>
<div class="highlight-python"><div class="highlight"><pre><span></span>&lt;property name&gt;: &lt;val&gt; +- &lt;err&gt; &lt;unit&gt;[; &lt;description&gt;]
</pre></div>
</div>
<p>Code snippet:</p>
<div class="highlight-c++"><div class="highlight"><pre><span></span><span class="n">prop</span><span class="p">.</span><span class="n">Set</span><span class="p">(</span><span class="s">&quot;CF3&quot;</span><span class="p">,</span> <span class="n">MRH_UNDEFINED</span><span class="p">,</span> <span class="mf">3.27</span><span class="p">,</span> <span class="mf">0.09</span><span class="p">,</span> <span class="s">&quot;K&quot;</span><span class="p">,</span> <span class="s">&quot;strange temperature&quot;</span><span class="p">);</span>
<span class="n">header</span><span class="o">-&gt;</span><span class="n">Set</span><span class="p">(</span><span class="s">&quot;SampleEnvironmentInfo/CF3&quot;</span><span class="p">,</span> <span class="n">prop</span><span class="p">);</span>
</pre></div>
</div>
<p>Result in the <tt class="docutils literal"><span class="pre">RunHeader/SampleEnvironmentInfo</span></tt>:</p>
<div class="highlight-python"><div class="highlight"><pre><span></span>033 - CF3: 3.27 +- 0.09 K; strange temperature -@3
</pre></div>
</div>
<p><strong>Possibility 3</strong></p>
<div class="highlight-python"><div class="highlight"><pre><span></span>&lt;property name&gt;: &lt;val&gt; &lt;unit&gt;; SP: &lt;demand&gt;[; &lt;description&gt;]
</pre></div>
</div>
<p>Code snippet:</p>
<div class="highlight-c++"><div class="highlight"><pre><span></span><span class="n">prop</span><span class="p">.</span><span class="n">Set</span><span class="p">(</span><span class="s">&quot;CF4&quot;</span><span class="p">,</span> <span class="mf">3.25</span><span class="p">,</span> <span class="mf">3.28</span><span class="p">,</span> <span class="s">&quot;K&quot;</span><span class="p">);</span>
<span class="n">header</span><span class="o">-&gt;</span><span class="n">Set</span><span class="p">(</span><span class="s">&quot;SampleEnvironmentInfo/CF4&quot;</span><span class="p">,</span> <span class="n">prop</span><span class="p">);</span>
<span class="n">prop</span><span class="p">.</span><span class="n">Set</span><span class="p">(</span><span class="s">&quot;CF5&quot;</span><span class="p">,</span> <span class="mf">3.26</span><span class="p">,</span> <span class="mf">3.29</span><span class="p">,</span> <span class="s">&quot;K&quot;</span><span class="p">,</span> <span class="s">&quot;another strange temperature&quot;</span><span class="p">);</span>
<span class="n">header</span><span class="o">-&gt;</span><span class="n">Set</span><span class="p">(</span><span class="s">&quot;SampleEnvironmentInfo/CF5&quot;</span><span class="p">,</span> <span class="n">prop</span><span class="p">);</span>
</pre></div>
</div>
<p>Result in the <tt class="docutils literal"><span class="pre">RunHeader/SampleEnvironmentInfo</span></tt>:</p>
<div class="highlight-python"><div class="highlight"><pre><span></span>034 - CF4: 3.28 K; SP: 3.25 -@3
035 - CF5: 3.29 K; SP: 3.26; another strange temperature -@3
</pre></div>
</div>
<p><strong>Possibility 4</strong></p>
<div class="highlight-python"><div class="highlight"><pre><span></span>&lt;property name&gt;: &lt;value&gt; +- &lt;estimated error&gt; &lt;unit&gt;; SP: &lt;demand&gt;; &lt;description&gt;
</pre></div>
</div>
<p>Code snippet:</p>
<div class="highlight-c++"><div class="highlight"><pre><span></span><span class="n">prop</span><span class="p">.</span><span class="n">Set</span><span class="p">(</span><span class="s">&quot;Sample Magnetic Field&quot;</span><span class="p">,</span> <span class="mf">350.0</span><span class="p">,</span> <span class="mf">350.002</span><span class="p">,</span> <span class="mf">0.005</span><span class="p">,</span> <span class="s">&quot;G&quot;</span><span class="p">,</span> <span class="s">&quot;WXY&quot;</span><span class="p">);</span>
<span class="n">header</span><span class="o">-&gt;</span><span class="n">Set</span><span class="p">(</span><span class="s">&quot;RunInfo/Sample Magnetic Field&quot;</span><span class="p">,</span> <span class="n">prop</span><span class="p">);</span>
</pre></div>
</div>
<p>Result in the <tt class="docutils literal"><span class="pre">RunHeader/SampleEnvironmentInfo</span></tt>:</p>
<div class="highlight-python"><div class="highlight"><pre><span></span>017 - Sample Magnetic Field: 350.002 +- 0.005 G; SP: 350.0; WXY -@3
</pre></div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h3><a href="index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">MusrRoot - an Extensible Open File Format for μSR</a><ul>
<li><a class="reference internal" href="#some-basics-concerning-root-files">Some Basics Concerning ROOT Files</a></li>
<li><a class="reference internal" href="#id1">MusrRoot an Extensible Open File Format for μSR</a><ul>
<li><a class="reference internal" href="#run-information-contained-in-runheader">Run Information Contained in <tt class="docutils literal"><span class="pre">RunHeader</span></tt></a><ul>
<li><a class="reference internal" href="#runinfo-overview"><tt class="docutils literal"><span class="pre">RunInfo</span></tt> Overview</a></li>
</ul>
</li>
</ul>
</li>
<li><a class="reference internal" href="#tmusrrunheader-concept">TMusrRunHeader Concept</a><ul>
<li><a class="reference internal" href="#user-interface-for-musrroot-run-header">User Interface for MusrRoot Run Header</a><ul>
<li><a class="reference internal" href="#writing-a-musrroot-run-header">Writing a MusrRoot Run Header</a></li>
<li><a class="reference internal" href="#reading-a-musrroot-run-header">Reading a MusrRoot Run Header</a></li>
</ul>
</li>
<li><a class="reference internal" href="#validation-of-a-musrroot-file">Validation of a MusrRoot File</a></li>
</ul>
</li>
<li><a class="reference internal" href="#runinfo-required">RunInfo (Required)</a></li>
<li><a class="reference internal" href="#detectorinfo-required">DetectorInfo (Required)</a></li>
<li><a class="reference internal" href="#sampleenvironmentinfo-required">SampleEnvironmentInfo (Required)</a></li>
<li><a class="reference internal" href="#magneticfieldenvironmentinfo-required">MagneticFieldEnvironmentInfo (Required)</a></li>
<li><a class="reference internal" href="#beamlineinfo-required">BeamlineInfo (Required)</a></li>
<li><a class="reference internal" href="#exhaustive-musrroot-tree-including-everything-required">Exhaustive MusrRoot Tree Including Everything Required</a></li>
<li><a class="reference internal" href="#tmusrrunphysicalquantity-possible-representations">TMusrRunPhysicalQuantity - Possible Representations</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="any2many.html"
title="previous chapter">any2many - a Universal μSR-file-format converter</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="acknowledgement.html"
title="next chapter">Acknowledgements</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/musr-root.txt"
rel="nofollow">Show Source</a></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="acknowledgement.html" title="Acknowledgements"
>next</a> |</li>
<li class="right" >
<a href="any2many.html" title="any2many - a Universal μSR-file-format converter"
>previous</a> |</li>
<li><a href="index.html">musrfit 1.7.1 documentation</a> &raquo;</li>
</ul>
</div>
<div class="footer">
&copy; Copyright 2021, Andreas Suter.
Last updated on Apr 09, 2021.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.3.
</div>
</body>
</html>