Subsections


21 Data output to tables and spreadsheets

21.1 HTable class

In some cases, instead of plotting the data, it is convenient to show the data in a form of a table. jHepWork provides excellent support for this. Use the HTable class:

>>> HTable(object)

where ``object'' is H1D, P1D or F1D class holding the data. After executing this statement, you will see a frame with a table populated with numbers (by the default, the numbers are nicely formatted in scientific format). Using this table, one can sort the data as well as search for a particular value. Note: it is impossible to modify the data in the table, as it was developed only for examining the data.

If you want the data to be shown as formatted string (java scientific format), use this constructor:

>>> HTable(object,1)

One one sets "0", the data will not be formatted.

One can call to HTable differently: if a data container is created, one can use "toTable()" method. For example, to display a H1D histogram, one can use either statements:

>>> HTable(h1)     # where h1 is H1D histogram, or use
>>> h1.toTable()   #

If "toTable()" is used with the argument "0" , the numbers will not be formatted to scientific format.

The HTable container can be filled by the standard java Vector class. You can run the example ``pdg_table.py'', which illustrates how to fill the Particle Data Group (PDG) table to a HTable frame for easy sorting and manipulation with particle data.

21.2 Spreadsheet. The SPsheet class

For more flexibility, one can export the data to a spreadsheet using the SPsheet class. In this case, the data can be modified and edited in a usual way:

To create an empty frame with a spreadsheet, use

>>> SPsheet()

If you want to build a spreadsheet using some data in containers such as P1D, H1D or F1D, use

>>> SPsheet(object)   # where object is class of type P1D, H1D or F1D