CEventSegment

Name

CEventSegment -- Base class for all event segments.

Synopsis


#include <CEventSegment.h>
         

            class CEventSegment {
         

            
  virtual void initialize();
              virtual void clear();
              virtual void disable();
              virtual =0 size_t read(void* pBuffer, size_t maxwords);
	      virtual void onBegin();
	      virtual void onEnd();
	      virtual void onPause();
	      virtual void onResume();
	    
              virtual const bool isComposite();
            
              void reject();
              void rejectImmediately();
              void keep();
              const CEventSegment::AcceptState getAcceptState();
              void setTimestamp(uint64_t stamp);
              void setSourceId(uint32_tr id);
              uint32_t getSourceId();
                
        };
         

DESCRIPTION

Event segments are a logical unit of an experiment readout. CEventSegment is an abstract base class that provides default implementations for most of the interface for an event segment as well as a pure virtual function as an interface placeholder for the readout of the segment itself.

PUBLIC MEMBER FUNCTIONS

virtual void initialize();

This is called as the runs becomes active (begin or resume). It should be overidden by concrete classes to provide code that sets up the hardware used by the segment and makes it ready for data taking. The default implementation of this method is to do nothing.

virtual void clear();

Called to clear the data taking hardware just prior to releasing the busy and enabling gates. This happens prior to the initial enable of response to triggers as well as after each event is read. Default action is to do nothing.

virtual void disable();

Called to disable the electronics. The default does nothing.

virtual =0 size_t read(void* pBuffer, size_t maxwords);

This must be suplied by concrete classes for them to be concrete classes. This method is supposed to read out the electronics associated with the event segment and put it in pBuffer. At most maxwords words of data should be read.

virtual void onBegin();

This method is invoked when the begin run event has been sent out but before the readout program is responding to event triggers. The base class implementation is to do nothing, so this is an optional method.

virtual void onEnd();

This method is invoked after the trigger loop has stopped responding to triggers as the run is ending but before the end run event has been emitted. The base class method is to do nothing making this an optional method.

virtual void onPause();

This method is invoked after the trigger loop has stopped responding to triggers as the run is pausing, but before the pause run event has been emitted. The base class method does nothing making this an optional method.

virtual void onResume();

This method is invoked after a resume event has been emitted when a run is resuming but before the trigger thread has begun to poll for triggers. The base class method does nothing making this an optional method.

virtual const bool isComposite();

If the event segment contains other segments and those segments can be queried via the same interfaces supported by CCompoundEventSegment, this should return true false if not.

void reject();

This can be called from read to indicate the framework should not keep the event. The remainder of the event segments registered with the experiment are run unless a subsequent one calls rejectImmediately (see below).

void rejectImmediately();

This can be called from read to indicate the framework should not keep the event. Processing of event segments stops with the return from read if this is called.

void keep();

This is called by the framework to initalize the event segment accept state. It can also be called to change your mind about rejecting an event. If used in this manner, keep must be called within the same event segment that invoked reject or rejectimmediately.

const CEventSegment::AcceptState getAcceptState();

Returns the value of the accept state as set by the methods keep, reject and rejectImmdediately. See PUBLIC TYPES AND VARIABLES below for possible return values.

Normally this only needs to be called by the framework. Since each event segement has its own acceptance state, this cannot be used to determine if the event has been marked for rejection by another event segment.

void setTimestamp(uint64_t stamp);

This should be called from the read method of at least one event segmetn when Readout is a data source for event building. The method sets the event timestamp. If called more than once, the last call in the event readout specifies the time.

void setSourceId(uint32_tr id);

Called by an event segment to set the source id. Normally this is set at the command line via the --sourceid option.

uint32_t getSourceId();

Returns the experiment's source id.

PUBLIC TYPES AND VARIABLES

CEventSegment::AcceptState is an enum that describes how the event should be disposed of after the segment returns from read. This type can take the following values:

CEventSegment::keep

Indicates the event segment wants the framework to keep the event.

CEventSegement::reject

Indicates that the event segment wants the framework to reject the event but that the remainder of the event segments should keep running. This takes precedence over CEventSegment::keep

CEventSegment::rejectImmediately

Same meaning as CExperiment::reject except that this requests that no more event segments be run.