This application note shows how to create and register a custom trigger for a tailored production readout system. See docs.nscl.msu.edu click on User's Manual under "Production Readout System" for more information about the production readout system. Background: "Out of the box" the production readout system supports triggers on the CES CBD8210 INT2 input (--camac-trigger on command line), or the CAEN V262 I/O register (default). It is possible to override the default trigger selection with a user defined trigger module: Outline of procedure: - Write a class derived from CTrigger that implements the custom trigger requirement. - Register an instance of this class as the trigger used by the CExperiment object Detailed procedure: Examine carefully /usr/opt/daq/include/CTrigger.h This defines the interface that must be supported by trigger classes. You need to write two source files e.g. MyTrigger.h MyTrigger.cpp MyTrigger.h looks like: #include class MyTrigger : public CTrigger { private: public: // Constructors, destructors and other cannonical operations: MyTrigger (); //!< Default constructor. MyTrigger(const MyTrigger& rhs); //!< Copy constructor. ~ MyTrigger ( ) { } //!< Destructor. MyTrigger& operator= (const MyTrigger& rhs); //!< Assignment int operator==(const MyTrigger& rhs) const; //!< Comparison for equality. int operator!=(const MyTrigger& rhs) const { return !(operator==(rhs)); } // Selectors for class attributes: public: // Mutators: protected: // Class operations: public: virtual bool operator() () = 0; }; MyTrigger.cpp implements this class: o The constructor does whatever initialization is required. o The operator() checks the trigger condition to see if it is satisfied and returns true if it is. Since ProductionReadout is multithreaded, you may block within operator(), however you must periodically exit this funciton to allow the trigger thread to shutdown when the run is terminated. see the select(2) and poll(s) man pages for options on how to do this in some circumstances. In general, to improve the trigger response latency, operator() should poll. Modify Skeleton.cpp as follows: - Create an instance of MyTrigger - Register that instance with the experiment: Add: #include "MyTrigger.h" MyTrigger theTrigger; at e.g. global scope. Add the following line to the function CMyExperiment::SetupReadout(CExperiment& rExperiment): rExperiment.EstablishTrigger(&theTrigger); Compile and debug.