Project

General

Profile

Receiving Data from Artdaq

The sbndqm repository provides an interface to receive events from artdaq. This interface allows users to write online analysis code as the usual art classes (e.g. Producers, Analyzers, Filters) and run them as an online monitoring process by just changing the input source to the larsoft process.

The code to do this is the “TransferInput_source” module and is located in the TransferInput/ sub-directory. This code was copied from artdaq version 3.03.01. Hopefully, in the near future this code will be moved from artdaq into art so that it can be more properly maintained. But for now, this will work as a stopgap solution.

Artdaq is split up into a number of sub-processes that each manage their own set of tasks. The process whose job it is to send data to online monitoring processes is called the “Dispatcher”. In order to run an online monitoring process with an instance of artdaq, you’ll need to make sure that the Dispatcher is set to run.

From there, you can run an online monitoring process on the same server as the dispatcher (using the Shmem transfer module) or on a different server (using the PortTransfer transfer module -- NOTE: I have not yet ported this module into sbndqm, so currently you cannot do this).

An example of the fhicl configuration is at dqmAnalyis/example/run_example_daq_interface.fcl. A run-through of that fhicl configuration is also included below. Note that to run the code as an online monitoring process, we only have to set the “source” block of the fhicl configuration.

source:
{
  module_type: TransferInput

  # The timeout shouldn't be much smaller than the period between events, otherwise
  # there's a spew of timeout messages
  timeoutInUsecs: 10000000

  commanderPluginType: xmlrpc
  dispatcherHost: localhost
  dispatcherPort: 7166

  transfer_plugin: {

     unique_label: "ExampleOnlineMonitor" 
      transferPluginType: Shmem
      shm_key: 0x40471453
      max_fragment_size_words: 2097152
      first_event_builder_rank: 0
          source_rank: 5
          destination_rank: 6
  }

  dispatcher_config: {
    unique_label: "ExampleOnlineMonitor" 
    path: [ out ]
    physics: {}
    outputs: {
      out: {
        module_type: TransferOutput
        transfer_plugin: {

           unique_label: "ExampleOnlineMonitor" 
            transferPluginType: Shmem

            shm_key: 0x40471453

            max_fragment_size_words: 2097152
              first_event_builder_rank: 0
              destination_rank: 6
        }
      }
    }
  }
}

This block includes a lot of configuration -- I will be talking about the important parts and the pieces you may want to change yourself.

First, “module_type” sets the type of input source we want -- in this case “TransferInput”. This module lets you specify a timeout with “timeoutinUsecs”. The module is configured to send a warning message each time it has not seen an event for the duration of the specified timeout. You’ll want to set it to something larger than the expected time in between events from the DAQ. You will need to specify the host and the port of the dispatcher with “dispatcherHost” and “dispatcherPort”. Make sure that the port you specify here matches the port that the Dispatcher is configured to run on (this is usually specified in the boot.txt file in artdaq).

In the “transfer_plugin” block, you’ll specify how the Dispatcher sends data to the online monitoring process. In this case, since we are running the online analysis code on the same server as the dispatcher, we can use the “Shmem” or “Shared Memory” transfer module. For this module, you have to specify a key for a linux shared memory instance. Note that this key must be unique across the whole server -- make sure that no other processes use the same key. You also specify a unique_label to register with the Dispatcher. As implied by the configuration name, this label must be unique for all online monitoring processes connecting to the dispatcher. Finally, you also must specify the max fragment size for the shared memory segment. This configuration name is a bit of a misnomer -- it specifies the max size of the art::Event object that will be sent by the dispatcher. You should hopefully be able to estimate the size for your instance of artdaq. There is also some other configuration that I am not sure about myself. If anyone wants to fill in more, that would be awesome.

Finally, there is a “dispatcher_config” block. This mostly has some configuration that must match what was in the “transfer_plugin” block. You must re-specify the unique_label, and then include the transfer_plugin block again for the dispatcher. However, note that this time the module type is “TransferOut” (the Dispatcher is transferring data “Out” and the online monitoring process is transferring data “In”). Again, if anyone wants to fill in documentation on the missing parts, please do.