Appendix B. User written triggers

The readout framework has explicity support for user written triggers. This appendix will describe that support and provide a simple example.

A trigger is a class/object that is polled to determine if a condition has occured. Two triggers are registered by the application programmer. An event trigger, which determines when the read method of the event segments are invoked, and a scaler trigger, which determines when scalers get read/cleared.

Closely associated with triggers are Busy objects which allow the computer to report when it is not able to accept a new trigger. Busy objects are only used with the event trigger.

All triggers are required to extend the CEventTrigger (event in this case means that some external event occured not that a physics event of interest has been detected). The CEventTrigger provides the following public interface to clients:

setup

Called as the run is starting. This allows the trigger code to do any hardware setup required to initialize the trigger. If not declared/implemented, the base class provides a no-op default implementation.

teardown

Called as a run is halting (pausing as well as ending). This allows for the trigger class to do any required shutdown of the trigger hardware. If not declared/implemented, the base class provides a no-op default implementation.

operator()

This is called when the framework is able to accept a trigger. The method is expected to return true if a trigger is present, and false if not. The method should not poll. That is the function of the framework. The method should determine, as quicly as possible the state of the trigger and return the appropriate value. This method is mandatory and is pure virtual in the base class.

Without comment I supply a trigger class that can trigger the DAQ when a CAEN V775/782/792/865 module shows data present.

Example B-1. CAEN data ready trigger header


#ifndef __CEVENTTRIGGER_H
#include <CEventTrigger.h>
#endif

class CAENcard;        /* Forward class definition */

/*!
  This class is a trigger class that will indicate a trigger if a specific
  CAEN32 module has data.
*/

class CCAENRdyTrigger : public CEventTrigger
{
private:
  CAENcard*   m_pModule;

public:
  CCAENRdyTrigger(CAENcard* pSegment);

  virtual bool operator()();    // Only method we need to implement.
};
            

Example B-2. CAEN data ready trigger implementation


#include <config.h>
#include "CCAENRdyTrigger.h"
#include <CAENcard.h>



CCAENRdyTrigger::CCAENRdyTrigger(CCAENCard* pSegment) :
  m_pModule(pSegment)
{}

bool
CCAENRdyTrigger::operator()()
{
  return m_pModule->dataPresent();
}                
            

Note that by hooking the command bus for a set of these modules together, you coudl use gdataPresent as the trigger conditions and then the trigger would be true if any of the modules had data.