Error in <TStreamerInfo::Build>: valarray<float>, discarding: float* __begin_, no [dimension]
Error in <TStreamerInfo::Build>: valarray<float>, discarding: float* __end_, no [dimension]
Invalid data type for FITS Data I/O
libc++abi.dylib: terminating with uncaught exception of type CCfits::FITSUtil::UnrecognizedType
but I could set it in another way
t1->Branch("a", &a[0], "a[4]/F");
Is it a safe way to do these things?
Is there a better way?
The I/O currently does not support std::valarray per se. If you can not use std::array and if your valarray is indeed of fixed size, then your alternative is a good choice (as long as the branch is created after the valarray has been set to the correct size).
$> go get go-hep.org/x/hep/groot/cmd/root-ls
$> root-ls -t ./simple.root
=== [./simple.root] ===
version: 60600
TTree tree fake data (entries=4)
one "one/I" TBranch
two "two/F" TBranch
three "three/C" TBranch
$> go get go-hep.org/x/hep/groot/cmd/root-dump
$> root-dump ./simple.root
>>> file[./simple.root]
key[000]: tree;1 "fake data" (TTree)
[000][one]: 1
[000][two]: 1.1
[000][three]: uno
[001][one]: 2
[001][two]: 2.2
[001][three]: dos
[002][one]: 3
[002][two]: 3.3
[002][three]: tres
[003][one]: 4
[003][two]: 4.4
[003][three]: quatro
$> go get go-hep.org/x/hep/cmd/root2fits
$> root2fits -h
root2fits converts the content of a ROOT tree to a FITS (binary) table.
Usage: root2fits [OPTIONS] -f input.root
Example:
$> root2fits -f ./input.root -t tree
Options:
-f string
path to input ROOT file name
-o string
path to output FITS file name (default "output.fits")
-t string
name of the ROOT tree to convert
$> root2fits -t tree -f ./simple.root
$> go get github.com/astrogo/fitsio/cmd/go-fitsio-listhead
$> go-fitsio-listhead ./output.fits
Header listing for HDU #0:
SIMPLE = true / file does conform to FITS standard
BITPIX = 8 / number of bits per data pixel
NAXIS = 0 / number of data axes
NAXIS1 = 0 / length of data axis 1
NAXIS2 = 0 / length of data axis 2
END
Header listing for HDU #1:
XTENSION= BINTABLE / table extension
BITPIX = 8 / number of bits per data pixel
NAXIS = 2 / number of data axes
NAXIS1 = 15 / length of data axis 1
NAXIS2 = 4 / length of data axis 2
PCOUNT = 0 / heap area size (bytes)
GCOUNT = 1 / one data group
TFIELDS = 3 / number of fields in each row
TTYPE1 = one / label for column 1
TFORM1 = J / data format for column 1
TSCAL1 = 0 / scaling offset for column 1
TZERO1 = 0 / zero value for column 1
TBCOL1 = 1 /
TTYPE2 = two / label for column 2
TFORM2 = E / data format for column 2
TSCAL2 = 0 / scaling offset for column 2
TZERO2 = 0 / zero value for column 2
TBCOL2 = 5 /
TTYPE3 = three / label for column 3
TFORM3 = 7A / data format for column 3
TSCAL3 = 0 / scaling offset for column 3
TZERO3 = 0 / zero value for column 3
TBCOL3 = 9 /
EXTNAME = tree / name of this table extension
THEAP = 0 / gap size (bytes)
END
$> go get github.com/astrogo/fitsio/cmd/go-fitsio-tablist
$> go-fitsio-tablist ./output.fits
== 00000/00004 =================================================================
one | 1
two | 1.1
three | uno
== 00001/00004 =================================================================
one | 2
two | 2.2
three | dos
== 00002/00004 =================================================================
one | 3
two | 3.3
three | tres
== 00003/00004 =================================================================
one | 4
two | 4.4
three | quatro