Lesson 4: A more realistic example: Several Classes, RCP Files

For an example that looks a bit more like the code you will see (and write) in D0, take a look at

In this example the test1 class is used to represent energy objects (e.g. calorimeter cells), which are collected in the test2 class (e.g. clusters). Cells can be added to a cluster using the addCell method. CalcET() returns the Et of a cluster, NCells() returns the number of cells in a cluster. Note that cells below a certain energy threshold are suppressed - since this threshold is a parameter that you might want to modify from time to time, it is read in from a file ( test2.rcp) when constructing the class.
This rcp-file is expected in the rcp directory of your package (create a directory rcp in t67/example/).
To add test2 to your example package, copy the source files, the include as well as the rcp file and add test2 to the COMPONENTS file in the src directory (you should add this below test1 so that test1 is tested before test2). You will also have to add the name of the rcp library to your LIBDEPS file:

rcp

Now you should be ready to compile and test:

<d0mino> gmake example.test

Hopefully both tests run successfully. You can take a look at ok.out for test2 to check if the test produced the expected results:

<d0mino> more tmp/$BFARCH/example/ctest/test2/ok.out

should give you something like this:

Testing test2:
 total ET 53 (should be 53)
 number of cells 2 (should be 2)
Component test returned status 0