Next: Conclusion Up: The FARFALLA User GuideFARFALLA Previous: A complete example

Making Custom DSTs

The full procedure of what you need to do to make your own custom DSTs is explained in the FARFALLA Programming Reference Guide. There is also an example DREAM DUSER there which can be used to produce simple DST files. Here is an overview of the procedure though so you can have an idea of what is involved.

In general, what you do is use DREAM to do reconstructions(such as tracking and ERP reconstructions); then you call a DUSER routine written in C++ using FARFALLA. In your DUSER routine you call DREAM routines such as DSAGET to retrieve the information you need from the ZEBRA banks where DREAM has deposited them. You then put that information into FARFALLA nodes and trees and write them out to disk.

A small piece of a DUSER routine which fills part of the eventNode and writes it out to disk might look like this:



/* User event routine */
void duser_(int& ipass, int& itimes) {
  
  if (ipass  != 3 ) return;       // Only do this on pass 3
  if (itimes != 3 ) return;       // Only do this on the third call

.
. .....Code..... 
.
 
  int ierr;
  float ihead[20];
  dsaget_("RAW ",1,1,20,ihead[0],ierr); // Read in the online run header
  
  ev->run     = ihead[2];    // Set the run number 
  ev->event   = ihead[3];    // Set the event number

.
. .....Code......(add stuff to tree)
.

  ev->outputSubtree(outfile);     // Write the entire tree to disk
.
.
.
}

Two new things here are the underscores and ampersands in the definition of the DUSER function. These are artifacts of the fact that we are calling a C++ routine from FORTRAN. We explain this in more detail in the FARFALLA Programming Reference Guide.

This routine would be linked in with the DREAM libraries and run as a DREAM job. Then for every event a FARFALLA tree would be written to disk. Later you could read this ``DST'' file back in and process it.

The DUSER routine becomes longer if you wish to add other nodes to the tree. If you look in the FARFALLA Programming Reference Guide you will find some code that decodes the ERP hits and adds them as children to the eventNode.

An erpNode is used to hold the ERP information. You can also create new types of nodes for your particular needs if you want to make a custom DST. For example, someone working on the QTPs might like to make a QTP node.

The way to do this is to create a new node type which inherits from the basic class F_Node. So a simple example defining a qtpNode might look similar to this:


class qtpNode : public F_Node {

public:

  qtpNode() {type = "QTP ";}

  int chan;                      // QTP channel number
  int adc;                       // ADC value
  int tdc;                       // TDC value

};

Then in your DUSER you could do the following:


.
.  Make EventNode and Fill it..
.
.  Decode ERP info/Add ErpNode Children etc...
.
.  Decode the QTP information stick it into variables...
.
.

qtpNode *qtpBank;

F_addChild(ev,qtpBank);        // Make a qtpNode child for ev and make
                               // qtpBank point at it

qtpBank->chan = decoded_chan;  // Now we can put values into the QTP child
qtpBank->adc  = decoded_adc;    
qtpBank->tdc  = decoded_tdc;

ev->outputSubtree(outfile);   // Write the event to disk

The F_addChild() routine used here is similar to the F_getChild() routine except it is used to add children onto a FARFALLA tree.

The outputSubtree() command writes out the node and all of its children to the disk. You will notice that we choose to write:


ev->outputSubtree(outfile)

This causes the top event node and all of its children to be written out. If we had used qtpBank->outputSubtree(outfile) instead then only the qtpNode and its children would have been written out.

The full details of all the steps you need to take to make your own node types and write DST files are in the FARFALLA Programming Reference Guide.



Next: Conclusion Up: The FARFALLA User GuideFARFALLA Previous: A complete example


walter@
Wed Aug 10 11:42:05 PDT 1994