Application note: Writing a custom trigger for classic readout. Disclaimer: The code in this application note should be taken as a guide rather than complete debugged code. Background: Three objects interact to make Readout work when the run is in progress: 1. An object of type CTrigger polls the trigger device and indicates when a trigger has fired. 2. An object of type CBusy.h is invoked to describe when the computer is busy or free. 3. An object of type CReader is invoked to - control the flow of trigger checking and busy management. - To read events. - To read scalers. Approach: - Implement our own new class inheriting from CTrigger. - Register the new trigger object with the active state. - Replace the trigge object with our own trigger. Implementation Details: Examine carefully the header: /usr/opt/daq/include/Trigger.h This header defines the interface the Active state of the readout expects for a trigger object. Build a header for your own trigger class (mytrigger.h) mytrigger.h should look like: class CMyTrigger : public CTrigger { //< whatever private data, constructors etc. you will need> // Implementation of the trigger module: public: virtual void Initialize(); //!< Initialize the class. virtual void Enable(); //!< Enable the trigger hardware. virtual void Disable(); //!< Disable the trigger hardware. virtual bool Check(); //!< Check for a trigger. virtual void Clear(); //!< Clear existing trigger. }; Implement the class to meet your requirements. All of the virtual functions must be implemented since they are pure virtual in the base class. (Just use empty function bodies if you don't need to do anything). For Check you must return: true - If a trigger is present. false - If a trigger is not present. The Check function is polled so don't block inside it as that will make the command and timing interfaces dead for the duration of whatever blocking call you use. Modify your skeleton.cpp to register this trigger as follows: - Add #includes for Active.h and StateMachine.h - add at global scope: extern StateMachine* gpStateMachine; - Instantiate your trigger: Add: ... CMyTrigger myTrigger; //<----- Add this line. void initevt () ... - Register your trigger with Active. .. initevt () { ... Active* pActive = (Active*)gpStateMachine->GetCurrentStatePtr(); pActive->SetTrigger(&myTrigger); ... }