This chapter describes functions for creating and manipulating
ntuples, sets of values associated with events. The ntuples
are stored in files. Their values can be extracted in any combination
and booked in a histogram using a selection function.
The values to be stored are held in a user-defined data structure, and
an ntuple is created associating this data structure with a file. The
values are then written to the file (normally inside a loop) using
the ntuple functions described below.
A histogram can be created from ntuple data by providing a selection
function and a value function. The selection function specifies whether
an event should be included in the subset to be analyzed or not. The value
function computes the entry to be added to the histogram for each
event.
All the ntuple functions are defined in the header file
gsl_ntuple.h.
Ntuples are manipulated using the gsl_ntuple struct. This struct
contains information on the file where the ntuple data is stored, a
pointer to the current ntuple data row and the size of the user-defined
ntuple data struct:
This function creates a new write-only ntuple file filename for
ntuples of size size and returns a pointer to the newly created
ntuple struct. Any existing file with the same name is truncated to
zero length and overwritten. A pointer to memory for the current ntuple
row ntuple_data must be supplied—this is used to copy ntuples
in and out of the file.
This function opens an existing ntuple file filename for reading
and returns a pointer to a corresponding ntuple struct. The ntuples in
the file must have size size. A pointer to memory for the current
ntuple row ntuple_data must be supplied—this is used to copy
ntuples in and out of the file.
Once an ntuple has been created its contents can be histogrammed in
various ways using the function gsl_ntuple_project(). Two
user-defined functions must be provided, a function to select events and
a function to compute scalar values. The selection function and the
value function both accept the ntuple row as a first argument and other
parameters as a second argument.
This function updates the histogram h from the ntuple ntuple
using the functions value_func and select_func. For each
ntuple row where the selection function select_func is non-zero the
corresponding value of that row is computed using the function
value_func and added to the histogram. Those ntuple rows where
select_func returns zero are ignored. New entries are added to
the histogram, so subsequent calls can be used to accumulate further
data in the same histogram.
The following example programs demonstrate the use of ntuples in
managing a large dataset. The first program creates a set of 10,000
simulated “events”, each with 3 associated values
System Message: WARNING/2 ((x,y,z))
latex exited with error
[stderr]
kpathsea: Running mktexfmt latex.fmt
mktexfmt: mktexfmt is using the following fmtutil.cnf files (in precedence order):
mktexfmt: /usr/share/texmf-dist/web2c/fmtutil.cnf
mktexfmt: mktexfmt is using the following fmtutil.cnf file for writing changes:
mktexfmt: /usr/src/.texlive2019/texmf-config/web2c/fmtutil.cnf
mktexfmt [INFO]: writing formats under /usr/src/.texlive2019/texmf-var/web2c
mktexfmt [INFO]: --- remaking latex with pdftex
mktexfmt: running `pdftex -ini -jobname=latex -progname=latex -translate-file=cp227.tcx *latex.ini' ...
This is pdfTeX, Version 3.14159265-2.6-1.40.20 (TeX Live 2019/Mageia) (INITEX)
restricted \write18 enabled.
(/usr/share/texmf-dist/web2c/cp227.tcx)
entering extended mode
(/usr/share/texmf-dist/tex/latex/latexconfig/latex.ini
(/usr/share/texmf-dist/tex/generic/config/pdftexconfig.tex)
(/usr/share/texmf-dist/tex/latex/base/latex.ltx
(/usr/share/texmf-dist/tex/latex/base/texsys.cfg)
./texsys.aux found
\@currdir set to: ./.
Assuming \openin and \input
have the same search path.
Defining UNIX/DOS style filename parser.
catcodes, registers, parameters,
LaTeX2e <2018-12-01>
hacks, control, par, spacing, files, font encodings, lengths,
====================================
Local config file fonttext.cfg used
====================================
(/usr/share/texmf-dist/tex/latex/base/fonttext.cfg
(/usr/share/texmf-dist/tex/latex/base/fonttext.ltx
=== Don't modify this file, use a .cfg file instead ===
(/usr/share/texmf-dist/tex/latex/base/omlenc.def)
(/usr/share/texmf-dist/tex/latex/base/t1enc.def)
(/usr/share/texmf-dist/tex/latex/base/ot1enc.def)
(/usr/share/texmf-dist/tex/latex/base/omsenc.def)
(/usr/share/texmf-dist/tex/latex/base/t1cmr.fd)
(/usr/share/texmf-dist/tex/latex/base/ot1cmr.fd)
(/usr/share/texmf-dist/tex/latex/base/ot1cmss.fd)
(/usr/share/texmf-dist/tex/latex/base/ot1cmtt.fd)))
====================================
Local config file fontmath.cfg used
====================================
(/usr/share/texmf-dist/tex/latex/base/fontmath.cfg
(/usr/share/texmf-dist/tex/latex/base/fontmath.ltx
=== Don't modify this file, use a .cfg file instead ===
(/usr/share/texmf-dist/tex/latex/base/omlcmm.fd)
(/usr/share/texmf-dist/tex/latex/base/omscmsy.fd)
(/usr/share/texmf-dist/tex/latex/base/omxcmex.fd)
(/usr/share/texmf-dist/tex/latex/base/ucmr.fd)))
====================================
Local config file preload.cfg used
=====================================
(/usr/share/texmf-dist/tex/latex/base/preload.cfg
(/usr/share/texmf-dist/tex/latex/base/preload.ltx)) page nos., x-ref,
environments, center, verbatim, math definitions, boxes, title, sectioning,
contents, floats, footnotes, index, bibliography, output,
===========================================
Local configuration file hyphen.cfg used
===========================================
(/usr/share/texmf-dist/tex/generic/babel/hyphen.cfg
(/usr/share/texmf-dist/tex/generic/babel/switch.def)
(/usr/share/texmf-dist/tex/generic/hyphen/hyphen.tex)
(/usr/share/texmf-dist/tex/generic/hyphen/dumyhyph.tex)
(/usr/share/texmf-dist/tex/generic/hyphen/zerohyph.tex)
(/usr/share/texmf-dist/tex/generic/dehyph-exptl/dehypht-x-2019-04-04.tex
dehyph-exptl: using an 8-bit TeX engine.
(/usr/share/texmf-dist/tex/generic/dehyph-exptl/dehypht-x-2019-04-04.pat
German Hyphenation Patterns (Traditional Orthography) `dehypht-x' 2019-04-04 (W
L))) (/usr/share/texmf-dist/tex/generic/dehyph-exptl/dehyphn-x-2019-04-04.tex
dehyph-exptl: using an 8-bit TeX engine.
(/usr/share/texmf-dist/tex/generic/dehyph-exptl/dehyphn-x-2019-04-04.pat
German Hyphenation Patterns (Reformed Orthography, 2006) `dehyphn-x' 2019-04-04
(WL))) (/usr/share/texmf-dist/tex/generic/hyph-utf8/loadhyph/loadhyph-af.tex
EC Afrikaans hyphenation patterns
(/usr/share/texmf-dist/tex/generic/hyph-utf8/conversions/conv-utf8-ec.tex)
(/usr/share/texmf-dist/tex/generic/hyph-utf8/patterns/tex/hyph-af.tex))
(/usr/share/texmf-dist/tex/generic/hyph-utf8/loadhyph/loadhyph-grc.tex
Hyphenation patterns for Ancient Greek
(/usr/share/texmf-dist/tex/generic/hyphen/grahyph5.tex
Hyphenation patterns for Ancient Greek))
(/usr/share/texmf-dist/tex/generic/hyphen/ibyhyph.tex
Greek hyphenation patterns for Ibycus encoding, v3.0)
(/usr/share/texmf-dist/tex/generic/hyphen/zerohyph.tex)
(/usr/share/texmf-dist/tex/generic/hyph-utf8/loadhyph/loadhyph-hy.tex
No Armenian hyphenation patterns - only for Unicode engines)
(/usr/share/texmf-dist/tex/generic/hyph-utf8/loadhyph/loadhyph-eu.tex
EC Basque hyphenation patterns
(/usr/share/texmf-dist/tex/generic/hyph-utf8/conversions/conv-utf8-ec.tex)
(/usr/share/texmf-dist/tex/generic/hyph-utf8/patterns/tex/hyph-eu.tex))
(/usr/share/texmf-dist/tex/generic/hyph-utf8/loadhyph/loadhyph-be.tex
T2A Belarusian hyphenation patterns
(/usr/share/texmf-dist/tex/generic/hyph-utf8/conversions/conv-utf8-t2a.tex)
(/usr/share/texmf-dist/tex/generic/hyph-utf8/patterns/tex/hyph-be.tex))
(/usr/share/texmf-dist/tex/generic/hyph-utf8/loadhyph/loadhyph-bg.tex
T2A Bulgarian hyphenation patterns
(/usr/share/texmf-dist/tex/generic/hyph-utf8/conversions/conv-utf8-t2a.tex)
(/usr/share/texmf-dist/tex/generic/hyph-utf8/patterns/tex/hyph-bg.tex
Bulgarian hyphenation patterns (options: --safe-morphology --standalone-tex, ve
rsion 21 October 2017)))
(/usr/share/texmf-dist/tex/generic/hyph-utf8/loadhyph/loadhyph-ca.tex
EC Catalan hyphenation patterns
(/usr/share/texmf-dist/tex/generic/hyph-utf8/conversions/conv-utf8-ec.tex)
(/usr/share/texmf-dist/tex/generic/hyph-utf8/patterns/tex/hyph-ca.tex))
(/usr/share/texmf-dist/tex/generic/hyph-utf8/loadhyph/loadhyph-cu.tex
No Church Slavonic hyphenation patterns - only for Unicode engines)
(/usr/share/texmf-dist/tex/generic/hyph-utf8/loadhyph/loadhyph-cop.tex
Coptic hyphenation patterns
(/usr/share/texmf-dist/tex/generic/hyph-utf8/patterns/tex-8bit/copthyph.tex))
(/usr/share/texmf-dist/tex/generic/hyph-utf8/loadhyph/loadhyph-hr.tex
EC Croatian hyphenation patterns
(/usr/share/texmf-dist/tex/generic/hyph-utf8/conversions/conv-utf8-ec.tex)
(/usr/share/texmf-dist/tex/generic/hyph-utf8/patterns/tex/hyph-hr.tex))
(/usr/share/texmf-dist/tex/generic/hyph-utf8/loadhyph/loadhyph-cs.tex
EC Czech hyphenation patterns
(/usr/share/texmf-dist/tex/generic/hyph-utf8/conversions/conv-utf8-ec.tex)
(/usr/share/texmf-dist/tex/generic/hyph-utf8/patterns/tex/hyph-cs.tex))
(/usr/share/texmf-dist/tex/generic/hyph-utf8/loadhyph/loadhyph-da.tex
EC Danish hyphenation patterns
(/usr/share/texmf-dist/tex/generic/hyph-utf8/conversions/conv-utf8-ec.tex)
(/usr/share/texmf-dist/tex/generic/hyph-utf8/patterns/tex/hyph-da.tex))
(/usr/share/texmf-dist/tex/generic/hyph-utf8/loadhyph/loadhyph-nl.tex
EC Dutch hyphenation patterns
(/usr/share/texmf-dist/tex/generic/hyph-utf8/conversions/conv-utf8-ec.tex)
(/usr/share/texmf-dist/tex/generic/hyph-utf8/patterns/tex/hyph-nl.tex))
(/usr/share/texmf-dist/tex/generic/hyph-utf8/loadhyph/loadhyph-en-gb.tex
ASCII Hyphenation patterns for British English
(/usr/share/texmf-dist/tex/generic/hyph-utf8/patterns/tex/hyph-en-gb.tex))
(/usr/share/texmf-dist/tex/generic/hyph-utf8/loadhyph/loadhyph-en-us.tex
ASCII Hyphenation patterns for American English
(/usr/share/texmf-dist/tex/generic/hyph-utf8/patterns/tex/hyph-en-us.tex))
(/usr/share/texmf-dist/tex/generic/hyph-utf8/loadhyph/loadhyph-eo.tex
IL3 Esperanto hyphenation patterns
(/usr/share/texmf-dist/tex/generic/hyph-utf8/conversions/conv-utf8-il3.tex)
(/usr/share/texmf-dist/tex/generic/hyph-utf8/patterns/tex/hyph-eo.tex))
(/usr/share/texmf-dist/tex/generic/hyph-utf8/loadhyph/loadhyph-et.tex
EC Estonian hyphenation patterns
(/usr/share/texmf-dist/tex/generic/hyph-utf8/conversions/conv-utf8-ec.tex)
(/usr/share/texmf-dist/tex/generic/hyph-utf8/patterns/tex/hyph-et.tex))
(/usr/share/texmf-dist/tex/generic/hyph-utf8/loadhyph/loadhyph-mul-ethi.tex
No Pan-Ethiopic hyphenation patterns - only for Unicode engines)
(/usr/share/texmf-dist/tex/generic/hyphen/zerohyph.tex)
(/usr/share/texmf-dist/tex/generic/hyph-utf8/loadhyph/loadhyph-fi.tex
EC Finnish hyphenation patterns
(/usr/share/texmf-dist/tex/generic/hyph-utf8/conversions/conv-utf8-ec.tex)
(/usr/share/texmf-dist/tex/generic/hyph-utf8/patterns/tex/hyph-fi.tex))
(/usr/share/texmf-dist/tex/generic/hyph-utf8/loadhyph/loadhyph-fr.tex
EC French hyphenation patterns
(/usr/share/texmf-dist/tex/generic/hyph-utf8/conversions/conv-utf8-ec.tex)
(/usr/share/texmf-dist/tex/generic/hyph-utf8/patterns/tex/hyph-fr.tex))
(/usr/share/texmf-dist/tex/generic/hyph-utf8/loadhyph/loadhyph-fur.tex
EC Friulan hyphenation patterns
(/usr/share/texmf-dist/tex/generic/hyph-utf8/conversions/conv-utf8-ec.tex)
(/usr/share/texmf-dist/tex/generic/hyph-utf8/patterns/tex/hyph-fur.tex))
(/usr/share/texmf-dist/tex/generic/hyph-utf8/loadhyph/loadhyph-gl.tex
EC Galician hyphenation patterns
(/usr/share/texmf-dist/tex/generic/hyph-utf8/conversions/conv-utf8-ec.tex)
(/usr/share/texmf-dist/tex/generic/hyph-utf8/patterns/tex/hyph-gl.tex))
(/usr/share/texmf-dist/tex/generic/hyph-utf8/loadhyph/loadhyph-ka.tex
T8M Georgian hyphenation patterns
(/usr/share/texmf-dist/tex/generic/hyph-utf8/conversions/conv-utf8-t8m.tex)
(/usr/share/texmf-dist/tex/generic/hyph-utf8/patterns/tex/hyph-ka.tex))
(/usr/share/texmf-dist/tex/generic/hyph-utf8/loadhyph/loadhyph-de-1901.tex
EC German hyphenation patterns (traditional orthography)
! I can't find file `dehypht.tex'.
l.29 \input dehypht.tex
(Press Enter to retry, or Control-D to exit)
Please type another input file name:
! Emergency stop.
l.29 \input dehypht.tex
No pages of output.
Transcript written on latex.log.
mktexfmt [ERROR]: running `pdftex -ini -jobname=latex -progname=latex -translate-file=cp227.tcx *latex.ini >&2 </dev/null' return status 1
mktexfmt [ERROR]: return error due to options --strict
mktexfmt [INFO]: Disabled formats: 6
mktexfmt [INFO]: Not selected formats: 44
mktexfmt [INFO]: Failed to build: 1 (pdftex/latex)
mktexfmt [INFO]: Total formats: 51
mktexfmt [INFO]: exiting with status 1
[stdout]
This is pdfTeX, Version 3.14159265-2.6-1.40.20 (TeX Live 2019/Mageia) (preloaded format=latex)
restricted \write18 enabled.
I can't find the format file `latex.fmt'!
. These
are generated from a Gaussian distribution with unit variance, for
demonstration purposes, and written to the ntuple file test.dat.