Chapter 62. Transformer

Sometimes it's useful to perform some cmoputations on an NSCLDAQ event file and append data to parts of the event. Transformer provides the ability to add an arbitrary extension to fragments of event built data. It is a parallel program that runs on top of the communication framework we've been describing.

The program consists of an input stage, a set of parallel workers that can add extension to event fragments, a sorter that resorts the ouptut of the workers back into time stamp ordered events. The pipeline of input workers sorting and output are parallel processes as is each worker.

Transformer allows you to write the code needed to compute the extension for any single event fragment. This code does not have to be MPI or thread-aware though it must be thread-safe. This code is built into a shared library which is loaded by Transformer at run time.

The remainder of this chapter

  1. Describes what your shared library must provide.

  2. Describes how to build your shared library.

NoteNOTE:
 

The Transformer man page in 1daq desribes how to run the program. CBuiltRingItemExtender's manpage describes the interfes needed by Transfomer.

62.1. User shared libraries for Transformer

The Transformer uses a set of parallel workers to compute the actual extension. The workers receive blocks of events an parcel them off to instances of a CBuiltRingItemExtender. Each of those instances walks the event fragments in the event providing the fragment's ring item to user code embedded in a concrete subclass of CBuiltRingItemExtender::CRingItemExtender. The user code must implement the following methods:

virtual iovec operator()(pRingItem item);

Takes the ring item of an event fragment as input and computes the extension for that event fragment. The return value is an iovec See the writev(2) man page for a description of that struct.

If the length of the extension returned is zero, no extension will be added.

Refer to DataFormat.h(3daq) for information about the pRingItem data type.

virtual void free(iovec& extension);

Since all extension data must remain valid until the entire event has been formatted, you may find that you need to use dynamic memory to hold your extensions. After an event has been formatted and sent to the sorter, this method is called once for each fragment passing in the iovec as extension that was returned by operator(). This method is expected to free any dynamic data that was created to hold that extension data.

In addition to a concrete extension class, your shared library must provide a factory method the Transforme uses to create instances of your class. Each worker gets its own class instance.