JAPAn
Just Another Parity Analyzer
Loading...
Searching...
No Matches
Coda3EventDecoder::TBOBJ Class Reference

#include <Coda3EventDecoder.h>

Public Member Functions

 TBOBJ ()
 
void Clear ()
 
uint32_t Fill (const uint32_t *evbuffer, uint32_t blkSize, uint32_t tsroc)
 
bool withTimeStamp () const
 
bool withRunInfo () const
 
bool withTriggerBits () const
 

Data Fields

uint32_t blksize
 
uint16_t tag
 
uint16_t nrocs
 
uint32_t len
 
uint32_t tsrocLen
 
uint64_t evtNum
 
uint64_t runInfo
 
const uint32_t * start
 
const uint64_t * evTS
 
const uint16_t * evType
 
const uint32_t * TSROC
 

Detailed Description

Definition at line 102 of file Coda3EventDecoder.h.

Constructor & Destructor Documentation

◆ TBOBJ()

Coda3EventDecoder::TBOBJ::TBOBJ ( )
inline

Member Function Documentation

◆ Clear()

void Coda3EventDecoder::TBOBJ::Clear ( )
inline

Definition at line 107 of file Coda3EventDecoder.h.

107{ memset(this, 0, sizeof(*this)); }

◆ Fill()

uint32_t Coda3EventDecoder::TBOBJ::Fill ( const uint32_t * evbuffer,
uint32_t blkSize,
uint32_t tsroc )

Definition at line 296 of file Coda3EventDecoder.cc.

298{
299 if( blkSize == 0 )
300 throw std::invalid_argument("CODA block size must be > 0");
301 start = evbuffer;
302 blksize = blkSize;
303 len = evbuffer[0] + 1;
304 tag = (evbuffer[1] & 0xffff0000) >> 16;
305 nrocs = evbuffer[1] & 0xff;
306
307 const uint32_t* p = evbuffer + 2;
308 // Segment 1:
309 // uint64_t event_number
310 // uint64_t run_info if withRunInfo
311 // uint64_t time_stamp[blkSize] if withTimeStamp
312 {
313 uint32_t slen = *p & 0xffff;
314 if( slen != 2*(1 + (withRunInfo() ? 1 : 0) + (withTimeStamp() ? blkSize : 0)))
315 throw coda_format_error("Invalid length for Trigger Bank seg 1");
316 const uint32_t *q = (p+1);
317 memcpy(&evtNum, q++, sizeof(evtNum)); // uint64_t
318 if (withTimeStamp()) {
319 evTS = reinterpret_cast<const uint64_t*>(++q); // uint64_t[blkSize]
320 q += 2*(blksize-1);
321 } else {
322 evTS = nullptr;
323 }
324 if (withRunInfo()) {
325 memcpy(&runInfo, q+=2, sizeof(runInfo)); // uint64_t
326 } else {
327 runInfo = 0;
328 }
329 p += slen + 1;
330 }
331 if( p-evbuffer >= len )
332 throw coda_format_error("Past end of bank after Trigger Bank seg 1");
333
334 // Segment 2:
335 // uint16_t event_type[blkSize]
336 // padded to next 32-bit boundary
337 {
338 uint32_t slen = *p & 0xffff;
339 if( slen != (blkSize-1)/2 + 1 )
340 throw coda_format_error("Invalid length for Trigger Bank seg 2");
341 evType = (const uint16_t*) (p + 1);
342 p += slen + 1;
343 }
344
345 // nroc ROC segments containing timestamps and optional
346 // data like trigger latch bits:
347 // struct {
348 // uint64_t roc_time_stamp; // Lower 48 bits only seem to be the time.
349 // uint32_t roc_trigger_bits; // Optional. Typically only in TSROC.
350 // } roc_segment[blkSize];
351 TSROC = nullptr;
352 tsrocLen = 0;
353 for( uint32_t i = 0; i < nrocs; ++i ) {
354 if( p-evbuffer >= len )
355 throw coda_format_error("Past end of bank while scanning trigger bank segments");
356 uint32_t slen = *p & 0xffff;
357 uint32_t rocnum = (*p & 0xff000000) >> 24;
358 // TODO:
359 // tsroc is the crate # of the TS
360 // This is filled with Podd's THaCrateMap class which we are not using
361 // tsroc is currently always 0
362 if( rocnum == tsroc ) {
363 TSROC = p + 1;
364 tsrocLen = slen;
365 break;
366 }
367 p += slen + 1;
368 }
369
370 return len;
371}

References blksize, evtNum, evTS, evType, len, nrocs, runInfo, start, tag, TSROC, tsrocLen, withRunInfo(), and withTimeStamp().

+ Here is the call graph for this function:

◆ withRunInfo()

bool Coda3EventDecoder::TBOBJ::withRunInfo ( ) const
inline

Definition at line 110 of file Coda3EventDecoder.h.

110{ return (tag & 2) != 0; }

References tag.

Referenced by Fill().

+ Here is the caller graph for this function:

◆ withTimeStamp()

bool Coda3EventDecoder::TBOBJ::withTimeStamp ( ) const
inline

Definition at line 109 of file Coda3EventDecoder.h.

109{ return (tag & 1) != 0; }

References tag.

Referenced by Fill().

+ Here is the caller graph for this function:

◆ withTriggerBits()

bool Coda3EventDecoder::TBOBJ::withTriggerBits ( ) const
inline

Definition at line 111 of file Coda3EventDecoder.h.

111{ return (tsrocLen > 2*blksize);}

References blksize, and tsrocLen.

Field Documentation

◆ blksize

uint32_t Coda3EventDecoder::TBOBJ::blksize

Definition at line 113 of file Coda3EventDecoder.h.

Referenced by Fill(), TBOBJ(), and withTriggerBits().

◆ evtNum

uint64_t Coda3EventDecoder::TBOBJ::evtNum

Definition at line 118 of file Coda3EventDecoder.h.

Referenced by Fill(), and TBOBJ().

◆ evTS

const uint64_t* Coda3EventDecoder::TBOBJ::evTS

Definition at line 121 of file Coda3EventDecoder.h.

Referenced by Fill(), and TBOBJ().

◆ evType

const uint16_t* Coda3EventDecoder::TBOBJ::evType

Definition at line 122 of file Coda3EventDecoder.h.

Referenced by Fill(), and TBOBJ().

◆ len

uint32_t Coda3EventDecoder::TBOBJ::len

Definition at line 116 of file Coda3EventDecoder.h.

Referenced by Fill(), and TBOBJ().

◆ nrocs

uint16_t Coda3EventDecoder::TBOBJ::nrocs

Definition at line 115 of file Coda3EventDecoder.h.

Referenced by Fill(), and TBOBJ().

◆ runInfo

uint64_t Coda3EventDecoder::TBOBJ::runInfo

Definition at line 119 of file Coda3EventDecoder.h.

Referenced by Fill(), and TBOBJ().

◆ start

const uint32_t* Coda3EventDecoder::TBOBJ::start

Definition at line 120 of file Coda3EventDecoder.h.

Referenced by Fill(), and TBOBJ().

◆ tag

uint16_t Coda3EventDecoder::TBOBJ::tag

Definition at line 114 of file Coda3EventDecoder.h.

Referenced by Fill(), TBOBJ(), withRunInfo(), and withTimeStamp().

◆ TSROC

const uint32_t* Coda3EventDecoder::TBOBJ::TSROC

Definition at line 123 of file Coda3EventDecoder.h.

Referenced by Fill(), and TBOBJ().

◆ tsrocLen

uint32_t Coda3EventDecoder::TBOBJ::tsrocLen

Definition at line 117 of file Coda3EventDecoder.h.

Referenced by Fill(), TBOBJ(), and withTriggerBits().


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