Chapter 4. CFileDrivenParameterMapper

While you can hard-code parameter unpacking, and sometimes it pays to do so, you can use a prebuilt CFileDrivenParameterMapper or CCalibratedFileDrivenParameterMapper object to unpack DDAS hits from either of the top level unpackers. This unpacker takes a description file which defines how to map your DDAS channels (crate/slot/channel triplets) into parameters.

CFileDrivenParameterMapper simply unpacks raw parameters. CCalibratedFileDrivenParameterMapper provides the additional functionality of created quadratically calibrated raw parameters.

As a bonus, objects of these classes even create tree parameters for each of the parameters described in its configuration file. You can use this, in conjunction with the fact that tree parameters with the same name map to the same underlying parameters to communicate between your raw DDAS unpacker and subsequent event processors or unpackers.

4.1. The CFileDrivenParameterMapper

The constructor of the CFileDrivenParameterMapper looks like this:

CFileDrivenParameterMapper(const char* configFile);

Where configFile is the path to a configuration file for the parameter mapper. The configuration file provides a mapping between DDAS channel triplets and parameter names. In addition metadata about the channel must be provided.

The configuration file is a text file that can consist of a series any of the following line types:

Empty line

Ignored.

Line whose first character is #

Ignored. Use this to comment your configuration file.

Channel definition

These lines contain five fields. In order there are four integers and a string. Spaces are not allowed in the string.

The first three fields are the channel triplet, in order, the crate number, the slot number and the channel number within that crate/slot pair. The fourth field is the number of bits of resolution for the digitizer channel described. The last field is the name of the parameter to which the DPP energy from this channel should be unpacked into.

Here's a sample channel definition line:


    1 2 0 16 some.channel.name
                        

This line specifies that energy from channel number 0 of slot 2 in crate 1 is 16 bits wide and should be unpacked into some.channel.name

When CFileDrivenParameterMapper objects are constructed, the configuration file is read and for eeach channel definition line, a tree parameter is created with the specified name and the specified number of bits. When the object's mapToParameters method is invoked, this mapping is used to drive the interpretation of the hits parameter.

During unpacking, if a channel is encountered that does not have a channel definition, an std::string exception is thrown and, in general, the processing of that event is aborted. Failures to parse the configuration file also result in std::string exceptions.

Here's a sample use of the CFileDrivenParameterMapper class in the context of MySpecTclApp::CreateAnalysisPipeline. We are processing event built data.


    std::set<uint32_t>  ddasIds = {1, 2, 3};   // Allowed DDAS source ids (crates).
    ...
    MySpecTclApp::CreateAnalysisPipeline(CAnalyzer& rAnalyzer)
    {
        try {
            CFileDrivenParameterMapper* pMapper =
                new CFileDrivenParameterMapper("/user/fox/crate_1/crate1.parameters");
        }
        catch (std::string msg) {
            std::cerr << msg << std::endl;
            exit(EXIT_FAILURE);
        }
        RegisterEventProcessor(*(new DAQ::DDAS::CDDASBuiltUnpacker(ddasIds, *pMapper)));
    }
            

Note the use of the try/catch block to output any errors parsing the configuration file prior to exiting.