Previous: Command line arguments
Up: Tutorial
Next: Access to data
Previous Page: Command line arguments
Next Page: Access to data

More Object Description Files

The objects misssing in the track_t definition are defined in another file: dspack_tut_2.d.

dspack_tut_2.d file

* 
*   ********************************************************************
*   *                                                                  *
*$$ *   dspack_tut_2.d  DSPACK tutorial - example 1                    *
*   *                                                                  *
*   ********************************************************************
*

DEFINE point_t S 1 ! define structure point_t, section 1 V3 pos ! position V3 d ! position errors .INT4 flags(2) point_t *next ! pointer to the next hit on track END DEFINE

DEFINE vertex_t S 1 ! define structure point_t, section 1 V3 pos ! position V3 d ! position errors .INT4 n_tracks ! number of tracks .INT4 flags(2) track_t *tracks ! pointer to tracks END DEFINE

We could read this file after reading the first one, but it is easier to use INCLUDE keyword to read all needed files .

dspack_tut_3.d file

* 
*   ********************************************************************
*   *                                                                  *
*$$ *   dspack_tut_3.d  DSPACK tutorial - example 1                    *
*   *                                                                  *
*   ********************************************************************
*
INCLUDE dspack_tut_1.d
INCLUDE dspack_tut_2.d

INCLUDE can be used at any place in the object description file. It is recursive, up to 10 levels are allowed. All constants defined using SET keyword are valid in all included files.

The example below reads all the definitions:

Using INCLUDE

examples> example_1 tut_file=dspack_tut_3.d
 dspackrc_2 file in $DSPACK_HOME/doc/tutorial
 *********************************
 * This is Example 1 (version 2) *
 *********************************
DSPACK 1.130,  5 Jul 1994
*
*   ********************************************************************
*   *                                                                  *
*$$ *   dspack_tut_3.d  DSPACK tutorial - example 1                    *
*   *                                                                  *
*   ********************************************************************
*
INCLUDE dspack_tut_1.d
*
*   ********************************************************************
*   *                                                                  *
*$$ *   dspack_tut_1.d  DSPACK tutorial - example 1                    *
*   *                                                                  *
*   ********************************************************************
*
DEFINE V3 R 0                       ! A template for three real numbers
    "X component" x
    "Y component" y
    "Z component" z
END DEFINE

DEFINE track_t S 1 ! define structure track_t, section 1 V3 start ! start position V3 p ! momentum V3 d ! position errors V3 dp ! momentum errors .REAL4 charge .REAL4 chisq .INT4 n_hits .INT4 flags(2) point_t *point_p ! pointer to first hit vertex_t *vertex_p ! pointer to vertex structure track_t *nextvt_p ! pointer to next vertex track END DEFINE INCLUDE dspack_tut_2.d * * ******************************************************************** * * * *$$ * dspack_tut_2.d DSPACK tutorial - example 1 * * * * * ******************************************************************** *

DEFINE point_t S 1 ! define structure point_t, section 1 V3 pos ! position V3 d ! position errors .INT4 flags(2) point_t *next ! pointer to the next hit on track END DEFINE

DEFINE vertex_t S 1 ! define structure point_t, section 1 V3 pos ! position V3 d ! position errors .INT4 n_tracks ! number of tracks .INT4 flags(2) track_t *tracks ! pointer to tracks END DEFINE dsdb> c dsdb> track_t Definition of data set: track_t (trac) ID: 19 Type: Structure Section: 1 Machine words: 20 Items: 11 1 start V3 2 p V3 3 d V3 4 dp V3 5 charge .REAL4 6 chisq .REAL4 7 n_hits .INT4 8 flags(2) .INT4 9 *point_p point_t 10 *vertex_p vertex_t 11 *nextvt_p track_t

typedef struct V3 { float x; float y; float z; }; typedef struct point_t { struct V3 pos; struct V3 d; int flags[2]; struct point_t *next; }; typedef struct vertex_t { struct V3 pos; struct V3 d; int n_tracks; int flags[2]; struct track_t *tracks; }; typedef struct track_t { struct V3 start; struct V3 p; struct V3 d; struct V3 dp; float charge; float chisq; int n_hits; int flags[2]; struct point_t *point_p; struct vertex_t *vertex_p; struct track_t *nextvt_p; }; dsdb> quit examples>

This deals succesfully with the warnings from previous examples. Also when we ask for the definition of track_t we get the definitions of the objects it needs for the definitions to be complete. This listing may be used to make C header files.

wwwd@na49
Fri Nov 4 01:54:15 MET 1994