lcls2
C++ API: public headers of xtcdata, psalg, psdaq and psana
Loading...
Searching...
No Matches
Drp::CubeTebReceiver Class Reference

TebReceiver that accumulates the detector raw data (Detector::rawDef()) into bins chosen by the Cube trigger results, using nCubeWorkers worker threads; the full cube is recorded at EndRun and single bins are recorded or monitored as the results request (per the file comment). More...

#include <CubeTebReceiver.hh>

Inherits Drp::TebReceiver.

Public Member Functions

 CubeTebReceiver (const Parameters &, DrpBase &)
 Construct the TebReceiver base and the per-buffer result copies, with one initialization flag and one semaphore per cube worker.
 
void finalize ()
 Thread body (named drp/CubeTebProc): for each completed result in order, take the matching index from the worker output queue (aborting on a mismatch), monitor and record the requested bins, free the transition and pebble buffers, and zero the flushed bins (or mark the whole cube for reinitialization).
 
- Public Member Functions inherited from Drp::TebReceiver
 TebReceiver (const Parameters &, DrpBase &)
 Construct the base, keep the MEB contributor of drp, and create the file writer and the small-data writer with buffers of the larger of the pebble buffer size and para.maxTrSize (the file writer uses direct I/O per getDioFlag(para)).
 
virtual FileWriterBase & fileWriter () override
 Return the BufferedFileWriterMT member that records events.
 
virtual SmdWriterBase & smdWriter () override
 Return the SmdWriter member used for the small-data output.
 
- Public Member Functions inherited from Drp::TebReceiverBase
 TebReceiverBase (const Parameters &, DrpBase &)
 Construct the EbCtrbInBase from the TEB parameters of the DRP, keep references to the DRP and its pool, and allocate a buffer of para.maxTrSize bytes for the Configure datagram.
 
virtual ~TebReceiverBase ()
 Does nothing; empty body.
 
void resetCounters (bool all)
 Reset the EbCtrbInBase counters, the damage count and histogram and the latency; with all true, also reset the expected next buffer index so that index 0 is expected.
 
int connect (const std::shared_ptr< Pds::MetricExporter >)
 Register metrics (if the exporter is non-null), remember the node ID on the timing-system DRP (detType ts), and connect to the TEBs with EbCtrbInBase::connect().
 
void unconfigure ()
 Close the files (in case BeginRun failed), then call EbCtrbInBase::unconfigure().
 
std::string openFiles (const RunInfo &runInfo)
 If runInfo.runNumber is non-zero, create the directories and open the data file outputDir/instrument/experiment/xtc/RUN.xtc2 and the small-data file RUN.smd.xtc2 in its smalldata subdirectory (RUN is experiment-rNNNN-sNNN-c000), sending a file report message for each.
 
bool advanceChunkId ()
 If no chunk change is pending, increment the chunk ID in the file parameters, mark a change pending and return true; otherwise return false.
 
std::string reopenFiles ()
 Close the current data file and open the data file for the new chunk (name from FileParameters::runName()), sending a file report message and clearing the pending flag on success.
 
std::string closeFiles ()
 If writing, clear the writing flag and close the small-data and data files.
 
uint64_t chunkSize () const
 Return the number of bytes recorded since the current chunk started.
 
void chunkRequestSet ()
 Set the chunk-request flag.
 
void chunkReset ()
 Clear the chunk offset, the chunk-request flag and the pending flag left from a previous run.
 
void offsetReset ()
 Set the recorded byte offset to 0.
 
void offsetAppend (size_t size)
 Add size to the recorded byte offset.
 
bool writing () const
 Return true while files are open for recording (from a successful openFiles() until closeFiles()).
 
const FileParameters & fileParameters () const
 Return the file parameters cached by openFiles(); valid only after a successful openFiles().
 
- Public Member Functions inherited from Pds::Eb::EbCtrbInBase
 EbCtrbInBase (const TebCtrbParams &)
 Keep a reference to the parameters and create the server transport from prms.verbose and prms.kwargs.
 
virtual ~EbCtrbInBase ()
 Free the result region.
 
int resetCounters ()
 Reset the batch, event, missing, bypass and no-progress counters; returns 0.
 
int startConnection (std::string &port)
 Listen on prms.ifAddr:port for up to MAX_TEBS TEB connections with EbLfServer::listen(); an empty port is replaced by the bound ephemeral port.
 
int connect (const std::shared_ptr< MetricExporter >)
 Register metrics with the exporter (if non-null) and accept one link per builder in prms.builders with linksConnect().
 
int configure (unsigned numBuffers)
 Forget left-over inputs and deferred results, then for each TEB link receive the result region size, (re)allocate the shared result region if the size changed, and register it and send its description with EbLfSvrLink::setupMr().
 
void unconfigure ()
 Does nothing; empty body.
 
void disconnect ()
 Call unconfigure(), then disconnect and drop all links.
 
void shutdown ()
 Call disconnect(), then shut down the transport.
 
void receiver (TebContributor &, std::atomic< bool > &running)
 Thread body: pin to prms.core[1], name the thread drp/TEBreceiver and repeatedly wait (100 ms each) for result batches and match them with the pending inputs of ctrb, until running becomes false.
 

Protected Member Functions

virtual void complete (unsigned index, const Pds::Eb::ResultDgram &) override
 
- Protected Member Functions inherited from Drp::TebReceiver
virtual int setupMetrics (const std::shared_ptr< Pds::MetricExporter >, std::map< std::string, std::string > &labels) override
 
void _writeDgram (XtcData::Dgram *)
 
- Protected Member Functions inherited from Drp::TebReceiverBase
void process (const Pds::Eb::ResultDgram &, unsigned index) override
 Pure virtual: handle the result of one event; index is the buffer index of the matching input datagram.
 

Additional Inherited Members

- Static Public Attributes inherited from Drp::TebReceiverBase
static const uint64_t DefaultChunkThresh = 500ull * 1024ull * 1024ull * 1024ull
 Chunk threshold of 500 * 1024^3 bytes (500 GB per the comment): process() requests a new chunk when chunkSize() exceeds it, and DrpBase::enable() advances the chunk once chunkSize() exceeds half of it.
 
- Protected Attributes inherited from Drp::TebReceiver
Pds::Eb::MebContributor & m_mon
 
BufferedFileWriterMT m_fileWriter
 
SmdWriter m_smdWriter
 
const Parameters & m_para
 
- Protected Attributes inherited from Drp::TebReceiverBase
MemPool & m_pool
 
DrpBase & m_drp
 
unsigned m_tsId
 
ZmqSocket & m_inprocSend
 
bool m_chunkRequest
 
unsigned m_configureIndex
 
std::vector< uint8_t > m_configureBuffer
 
uint64_t m_evtSize
 
uint64_t m_latPid
 
int64_t m_latency
 

Detailed Description

TebReceiver that accumulates the detector raw data (Detector::rawDef()) into bins chosen by the Cube trigger results, using nCubeWorkers worker threads; the full cube is recorded at EndRun and single bins are recorded or monitored as the results request (per the file comment).

Constructor & Destructor Documentation

◆ CubeTebReceiver()

Drp::CubeTebReceiver::CubeTebReceiver ( const Parameters &  ,
DrpBase &   
)

Construct the TebReceiver base and the per-buffer result copies, with one initialization flag and one semaphore per cube worker.

Member Function Documentation

◆ complete()

virtual void Drp::CubeTebReceiver::complete ( unsigned  index,
const Pds::Eb::ResultDgram &   
)
overrideprotectedvirtual

Reimplemented from Drp::TebReceiver.

◆ finalize()

void Drp::CubeTebReceiver::finalize ( )

Thread body (named drp/CubeTebProc): for each completed result in order, take the matching index from the worker output queue (aborting on a mismatch), monitor and record the requested bins, free the transition and pebble buffers, and zero the flushed bins (or mark the whole cube for reinitialization).

Busy-waits while no new result is available; exits when terminating or a worker queue is shut down.


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