Read a g4tools HDF5 file


After installation of a binary kit, you start gopaw with:

    UNIX> <install_path>/gopaw/<version>/bin/gopaw  # UNIX here is for Linux and macOS.
 on Windows:
     DOS> <install_path>\gopaw\<version>\bin\gopaw.exe

Note that on Windows you must run from a DOS prompt (CMD.exe), it does not work from a cygwin prompt.

A distribution comes with examples to play with under the res/gopaw/examples directory. The below instructions are based on data files (for example data_B4.hdf5) found under this directory. The best is to have a local copy of this directory and work on that.

    UNIX> cp -R <install_path>/gopaw/<version>/res/gopaw/examples .
 on Windows:
     DOS> xcopy /s /q /i <install_path>\gopaw\<version>\res\gopaw\examples examples

Read and plot an histogram

To see histograms in an HDF5 file produced by Geant4/g4tools:

    UNIX> cd examples/gopaw  # in this directory there is a data_B4.hdf5 file coming from the Geant4 B4 example.
 on Windows:
     DOS> cd examples\gopaw
 start gopaw:
      OS> <start gopaw> 

and from the gopaw prompt:

    GOPAW> h/file 1 data_B4.hdf5    | open an HDF5 file and attach it to unit 1.
    GOPAW> ldir                     | list objects in the file.
    directory : "default_histograms".
      object : "Eabs", class : "tools::histo::h1d".
      object : "Egap", class : "tools::histo::h1d".
      object : "Labs", class : "tools::histo::h1d".
      object : "Lgap", class : "tools::histo::h1d".
    directory : "default_ntuples".
      class : "tools::hdf5::store", name : "B4".
    GOPAW> cd //lun1/default_histograms
    GOPAW> h/plot Eabs    | plot the histogram Eabs found in the default_histograms directory.
    GOPAW> close 1
Egap.png

Work on an ntuple

To do a ntuple projection on an ntuple found in the data_B4.hdf5 file:

    GOPAW> h/file 1 data_B4.hdf5
    GOPAW> /f/units
     +----+------------------+-----------+
     | Lu | File name        | File type |
     +----+------------------+-----------+
     | 1  | data_B4.hdf5     | HDF5_FILE |
     +----+------------------+-----------+
    GOPAW> ldir
    ...
    GOPAW> cd //lun1/default_ntuples
    GOPAW> n/print B4
    ********************************************************
    * NTUPLE NAME= B4 ENTRIES= 1000 TITLE= 
    ********************************************************
    *  Var numb  *   Name    *    Lower     *    Upper     *
    ********************************************************
    *     1      * Eabs      * 1.80103      * 32.4403      *
    *     2      * Egap      * 0            * 16.2602      *
    *     3      * Labs      * 7.99212      * 171.515      *
    *     4      * Lgap      * 0            * 82.1058      *
    ********************************************************
    GOPAW> n/plot rg_rbw.rgauss
    GOPAW> zone 2 2
    GOPAW> exec root_def  | CERN-ROOT style.
    GOPAW> n/plot B4.Eabs
    GOPAW> n/plot B4.Labs
    GOPAW> n/plot B4.Eabs%Labs
B4_ntuple.png
    GOPAW> close 1
    GOPAW> quit
      Exiting from gopaw.

You can have a look at the B4.kumac file:

macro B4
* Copyright (C) 2018, Guy Barrand. All rights reserved.
* See the file gopaw.license for terms.
exec alldef
zone 2 3
opt stat
*////////////////////////////////////////
*////////////////////////////////////////
*////////////////////////////////////////
h/file 1 data_B4.hdf5   | file coming from Geant4.
ldir 
cd //lun1/default_histograms
h/plot Eabs
h/plot Egap
h/plot Labs
h/plot Lgap
close 1
*////////////////////////////////////////
*/// ntuple : ///////////////////////////
*////////////////////////////////////////
h/file 1 data_B4.hdf5
ldir //
ldir
cd //lun1/default_ntuples
n/print B4
n/plot B4.Eabs%Labs
n/plot B4.Egap%Lgap
close 1
*////////////////////////////////////////
*////////////////////////////////////////
*////////////////////////////////////////
return

and execute it:

    GOPAW> exec B4
out_gopaw_B4.png

Note that you may have done also :

    UNIX> <install_path>/gopaw/<version>/bin/gopaw B4.kumac
 on Windows:
     DOS> <install_path>\gopaw\<version>\bin\gopaw.exe B4.kumac