NSCL DDAS  12.1-001
Support for XIA DDAS at FRIB
Classes | Public Member Functions | List of all members
CMyEventSegment Class Reference

Derived class for DDAS event segments. More...

#include <CMyEventSegment.h>

Inheritance diagram for CMyEventSegment:
Inheritance graph
[legend]
Collaboration diagram for CMyEventSegment:
Collaboration graph
[legend]

Public Member Functions

 CMyEventSegment (CMyTrigger *trig, CExperiment &exp)
 Construct from trigger object and experiment. More...
 
 CMyEventSegment ()
 Default constructor. More...
 
 ~CMyEventSegment ()
 Destructor. More...
 
virtual void initialize ()
 Initialize the modules recording data in this segment. More...
 
virtual size_t read (void *rBuffer, size_t maxwords)
 Read data from the modules following a valid trigger. More...
 
virtual void disable ()
 Nothing to disable. More...
 
virtual void clear ()
 Nothing to clear. More...
 
virtual void onBegin ()
 Manage run start operation. More...
 
virtual void onResume ()
 Manage run resume operation. More...
 
virtual void onEnd (CExperiment *pExperiment)
 Just return. Sorting is offloaded into its own process. More...
 
size_t GetNumberOfModules ()
 Get the number of modules in the crate. More...
 
int GetCrateID () const
 Get the crate ID value from the configuration. More...
 
void synchronize ()
 Perform clock synchronization. More...
 
void boot (DAQ::DDAS::SystemBooter::BootType=DAQ::DDAS::SystemBooter::FullBoot)
 Load firmware and boot the modules. More...
 
std::pair< size_t, size_t > getStatistics ()
 Get the cumulative and current run statistics. More...
 

Detailed Description

Derived class for DDAS event segments.

The event segment reads out a logical chunk of an experiment. In the DDAS case, data from a single crate (single source ID). An experiment may consist of multiple crates arranged in a CCompoundEventSegment container.

Constructor & Destructor Documentation

◆ CMyEventSegment() [1/2]

CMyEventSegment::CMyEventSegment ( CMyTrigger trig,
CExperiment &  exp 
)

Construct from trigger object and experiment.

Parameters
trigPointer to the DDAS trigger.
expReference to the experiment the event segment comes from.

Initialize the system, load the configuration and expected event lengths from the cfgPixie16.txt and modevtlen.txt files, boot the system and initialize the trigger.

In FRIBDAQ 12.0+, the external clock readout is merged into the standard readout framework. The constructor determines whether or not the external clock is enabled for each module the by checking the value of the corresponding bit in the Pixie CSRA register in that module's channel 0.

Failure to properly construct an event segment occurs if:

  • The CSRA register cannot be read from channel 0 on any of the modules.
  • An custom external timestamp clock calibration is <= 0.
  • There are a mix of external and internal clocks enabled on the same crate.

    Todo:
    (ASC 1/25/24): The assumption that the external timestamp bit for channel 0 is the same as the rest of the module allows some obviously bad configurations to be accepted. This may be a QtScope issue too: users should be prevented from enabling the external timestamp on a subset of channels if the readout code doesn't support it.

◆ CMyEventSegment() [2/2]

CMyEventSegment::CMyEventSegment ( )

Default constructor.

Note
For unit testing purposes only!

◆ ~CMyEventSegment()

CMyEventSegment::~CMyEventSegment ( )

Destructor.

Member Function Documentation

◆ boot()

Load firmware and boot the modules.

Parameters
typeThe boot type (boot mask) passed to the system booter (default = SystemBooter::FullBoot).
Exceptions
CDDASExceptionIf the system is initialized and fails to exit before attempting to boot again.

◆ clear()

void CMyEventSegment::clear ( )
virtual

Nothing to clear.

◆ disable()

void CMyEventSegment::disable ( )
virtual

Nothing to disable.

◆ GetCrateID()

int CMyEventSegment::GetCrateID ( ) const

Get the crate ID value from the configuration.

Returns
The crate ID.

◆ GetNumberOfModules()

size_t CMyEventSegment::GetNumberOfModules ( )
inline

Get the number of modules in the crate.

Returns
Number of modules.

◆ getStatistics()

std::pair<size_t, size_t> CMyEventSegment::getStatistics ( )
inline

Get the cumulative and current run statistics.

Returns
Cumulative and current run stats as a std::pair.

◆ initialize()

void CMyEventSegment::initialize ( )
virtual

Initialize the modules recording data in this segment.

Initialize unless there is an INFINITY_CLOCK environment variable with the value "YES" or the firmware has been loaded recently (no system exit).

Note
This is not threadsafe as C++ does not require getenv to be thread-safe.
Todo:
(ASC 1/25/24): An old comment from (I bet) RF: "paging through the global **environ is probably thread-safe however I'm pretty sure at this point in time there's no other thread doing a getenv()."

◆ onBegin()

void CMyEventSegment::onBegin ( )
virtual

Manage run start operation.

Begin the list mode run with NEW_RUN (= 1) run mode. If the start fails, display the return value of Pixie16StartListModeRun() and the error code text.

◆ onEnd()

void CMyEventSegment::onEnd ( CExperiment *  pExperiment)
virtual

Just return. Sorting is offloaded into its own process.

◆ onResume()

void CMyEventSegment::onResume ( )
virtual

Manage run resume operation.

Resume the list mode run with RESUME_RUN (= 0) run mode. If the resume fails, display the return value of Pixie16StartListModeRun and the error code text.

◆ read()

size_t CMyEventSegment::read ( void *  rBuffer,
size_t  maxBytes 
)
virtual

Read data from the modules following a valid trigger.

Parameters
[in,out]rBufferRead data into this buffer.
[in]maxBytesMax bytes of data we can stuff in the buffer.
Returns
Number of 16-bit words in the ring item body.

Pixie has triggered. There are greater than EXTFIFO_READ_THRESH words in the output FIFO of a particular Pixie module. Read out all modules.

This loop finds the first module that has at least one event in it since the trigger fired. We read the minimum of all complete events and the number of complete events that fit in that buffer (note that ) each buffer will also contain the module type word. Note as well that modules count words in uint32_t's but maxBytes is in uint16_t's.

◆ synchronize()

void CMyEventSegment::synchronize ( )

Perform clock synchronization.

Exceptions
CDDASExceptionIf we fail to talk properly to the module while setting the clock synchronization parameters.

More or less straight from the XIA Pixie SDK docs: configure the system to run synchronously through the backplane by setting Pixie module parameters. Synchronous running means that the last module ready to take data starts the run in all modules and the first module to end the run stops the run in all modules (SYNCH_WAIT = 1). In synchronous mode, all run timers are cleared at the start of a new run (IN_SYNCH = 0). Once the run has started, IN_SYNCH is automatically set to 1.

Removed from initialize() so that this can be called via a command. See the CSyncCommand class for details.


The documentation for this class was generated from the following files: