MIDAS event.
C++ class representing one midas event.
Objects of this class are created by reading midas events from a file, by reading them from a midas shared memory buffer or by receiving them through the mserver
Contains the information within a Midas Event. This usually includes a header, midas information such as timestamp bank id, etc. And the bank data. The bank data is usually the information supplied by either a scaler or the experimental DAQ system.
Definition at line 35 of file TMidasEvent.h.
Classes | |
struct | TMidas_BANK |
struct | TMidas_BANK32 |
struct | TMidas_BANK_HEADER |
Public Member Functions | |
TMidasEvent () | |
TMidasEvent (const TMidasEvent &) | |
~TMidasEvent () override | |
void | AllocateData () |
void | Clear (Option_t *opt="") override |
void | Copy (TObject &) const override |
int | FindBank (const char *name, int *bklen, int *bktype, void **pdata) const |
const char * | GetBankList () const |
char * | GetData () override |
uint32_t | GetDataSize () const override |
TMidas_EVENT_HEADER * | GetEventHeader () |
uint16_t | GetEventId () const |
uint32_t | GetSerialNumber () const |
uint32_t | GetTimeStamp () const override |
uint16_t | GetTriggerMask () const |
virtual int | GoodFrags () |
virtual void | IncrementGoodFrags () |
bool | IsBank32 () const |
bool | IsGoodSize () const |
int | IterateBank (TMidas_BANK **, char **pdata) const |
int | IterateBank32 (TMidas_BANK32 **, char **pdata) const |
int | LocateBank (const void *unused, const char *name, void **pdata) const |
TMidasEvent & | operator= (const TMidasEvent &) |
void | Print (const char *option="") const override |
int | SetBankList () |
void | SetData (uint32_t size, char *data) |
int | SwapBytes (bool) override |
void | SwapBytesEventHeader () |
Protected Attributes | |
bool | fAllocatedByUs |
char * | fBankList |
int | fBanksN |
char * | fData |
TMidas_EVENT_HEADER | fEventHeader |
int | fGoodFrags {0} |
#include <TMidasEvent.h>
TMidasEvent::TMidasEvent | ( | ) |
default constructor
Definition at line 23 of file TMidasEvent.cxx.
TMidasEvent::TMidasEvent | ( | const TMidasEvent & | rhs | ) |
|
override |
void TMidasEvent::AllocateData | ( | ) |
allocate data buffer using the existing event header
Definition at line 366 of file TMidasEvent.cxx.
References fAllocatedByUs, fData, TMidas_EVENT_HEADER::fDataSize, fEventHeader, and IsGoodSize().
Referenced by GetData().
|
override |
clear event for reuse
Definition at line 79 of file TMidasEvent.cxx.
References fAllocatedByUs, fBankList, fBanksN, fData, TMidas_EVENT_HEADER::fDataSize, fEventHeader, TMidas_EVENT_HEADER::fEventId, TRawEvent::fGoodFrags, TMidas_EVENT_HEADER::fSerialNumber, TMidas_EVENT_HEADER::fTimeStamp, and TMidas_EVENT_HEADER::fTriggerMask.
Referenced by operator=(), TMidasFile::Skip(), and ~TMidasEvent().
|
override |
copy helper
Definition at line 41 of file TMidasEvent.cxx.
References fAllocatedByUs, fBankList, fBanksN, fData, TMidas_EVENT_HEADER::fDataSize, and fEventHeader.
Referenced by operator=(), and TMidasEvent().
int TMidasEvent::FindBank | ( | const char * | name, |
int * | bklen, | ||
int * | bktype, | ||
void ** | pdata | ||
) | const |
Find a data bank.
[in] | name | Name of the data bank to look for. |
[out] | bklen | Number of array elements in this bank. |
[out] | bktype | Bank data type (MIDAS TID_xxx). |
[out] | pdata | Pointer to bank data, Returns nullptr if bank not found. |
Definition at line 192 of file TMidasEvent.cxx.
References fData, TMidasEvent::TMidas_BANK_HEADER::fDataSize, TMidasEvent::TMidas_BANK::fDataSize, TMidasEvent::TMidas_BANK32::fDataSize, TMidasEvent::TMidas_BANK_HEADER::fFlags, TMidasEvent::TMidas_BANK::fName, TMidasEvent::TMidas_BANK32::fName, TMidasEvent::TMidas_BANK::fType, TMidasEvent::TMidas_BANK32::fType, IterateBank32(), and TID_SIZE.
Referenced by LocateBank(), and Print().
const char * TMidasEvent::GetBankList | ( | ) | const |
|
overridevirtual |
return pointer to the data buffer
Reimplemented from TRawEvent.
Definition at line 141 of file TMidasEvent.cxx.
References AllocateData(), and fData.
|
overridevirtual |
return the event size
Reimplemented from TRawEvent.
Definition at line 136 of file TMidasEvent.cxx.
References TMidas_EVENT_HEADER::fDataSize, and fEventHeader.
Referenced by TMidasFile::Skip().
TMidas_EVENT_HEADER * TMidasEvent::GetEventHeader | ( | ) |
return pointer to the event header
Definition at line 151 of file TMidasEvent.cxx.
References fEventHeader.
Referenced by TMidasFile::Skip().
uint16_t TMidasEvent::GetEventId | ( | ) | const |
return the event id
Definition at line 116 of file TMidasEvent.cxx.
References fEventHeader, and TMidas_EVENT_HEADER::fEventId.
uint32_t TMidasEvent::GetSerialNumber | ( | ) | const |
return the serial number
Definition at line 126 of file TMidasEvent.cxx.
References fEventHeader, and TMidas_EVENT_HEADER::fSerialNumber.
|
overridevirtual |
return the time stamp (unix time in seconds)
Reimplemented from TRawEvent.
Definition at line 131 of file TMidasEvent.cxx.
References fEventHeader, and TMidas_EVENT_HEADER::fTimeStamp.
uint16_t TMidasEvent::GetTriggerMask | ( | ) | const |
return the triger mask
Definition at line 121 of file TMidasEvent.cxx.
References fEventHeader, and TMidas_EVENT_HEADER::fTriggerMask.
|
inlinevirtualinherited |
returns number of good fragments parsed
Definition at line 48 of file TRawEvent.h.
References TRawEvent::fGoodFrags.
|
inlinevirtualinherited |
increments the number of good fragments parsed
Definition at line 49 of file TRawEvent.h.
References TRawEvent::fGoodFrags.
bool TMidasEvent::IsBank32 | ( | ) | const |
returns "true" if event uses 32-bit banks
Definition at line 161 of file TMidasEvent.cxx.
References fData.
Referenced by SetBankList(), and SwapBytes().
bool TMidasEvent::IsGoodSize | ( | ) | const |
validate the event length
Definition at line 156 of file TMidasEvent.cxx.
References TMidas_EVENT_HEADER::fDataSize, and fEventHeader.
Referenced by AllocateData(), SetData(), and TMidasFile::Skip().
int TMidasEvent::IterateBank | ( | TMidas_BANK ** | pbk, |
char ** | pdata | ||
) | const |
iterate through 16-bit data banks
Iterates through banks inside an event. The function can be used to enumerate all banks of an event.
[in] | pbk | Pointer to the bank header, must be nullptr for the first call to this function. Returns nullptr if no more banks |
[in] | pdata | Pointer to data area of bank. Returns nullptr if no more banks |
Definition at line 429 of file TMidasEvent.cxx.
References fData, and TMidasEvent::TMidas_BANK::fDataSize.
Referenced by SetBankList().
int TMidasEvent::IterateBank32 | ( | TMidas_BANK32 ** | pbk, |
char ** | pdata | ||
) | const |
iterate through 32-bit data banks
See IterateBank()
Definition at line 458 of file TMidasEvent.cxx.
References fData, TMidasEvent::TMidas_BANK32::fDataSize, TMidasEvent::TMidas_BANK32::fType, and TID_MAX.
Referenced by FindBank(), and SetBankList().
int TMidasEvent::LocateBank | ( | const void * | unused, |
const char * | name, | ||
void ** | pdata | ||
) | const |
TMidasEvent & TMidasEvent::operator= | ( | const TMidasEvent & | rhs | ) |
|
override |
show all event information
Print data held in this class.
[in] | option | If 'a' (for "all") then the raw data will be printed out too. |
Definition at line 265 of file TMidasEvent.cxx.
References fBankList, fBanksN, fData, TMidas_EVENT_HEADER::fDataSize, fEventHeader, TMidas_EVENT_HEADER::fEventId, FindBank(), TMidas_EVENT_HEADER::fSerialNumber, TMidas_EVENT_HEADER::fTimeStamp, TMidas_EVENT_HEADER::fTriggerMask, hex(), and RESET_COLOR.
int TMidasEvent::SetBankList | ( | ) |
create the list of data banks, return number of banks
Definition at line 381 of file TMidasEvent.cxx.
References fBankList, fBanksN, fEventHeader, TMidas_EVENT_HEADER::fEventId, TMidasEvent::TMidas_BANK::fName, TMidasEvent::TMidas_BANK32::fName, IsBank32(), IterateBank(), and IterateBank32().
Referenced by TGRSIDataParser::Process().
void TMidasEvent::SetData | ( | uint32_t | size, |
char * | data | ||
) |
set an externally allocated data buffer
Definition at line 104 of file TMidasEvent.cxx.
References fAllocatedByUs, fData, TMidas_EVENT_HEADER::fDataSize, fEventHeader, IsGoodSize(), and SwapBytes().
|
overridevirtual |
convert event data between little-endian (Linux-x86) and big endian (MacOS-PPC)
Reimplemented from TRawEvent.
Definition at line 549 of file TMidasEvent.cxx.
References DWORD_SWAP, fData, TMidas_EVENT_HEADER::fDataSize, TMidasEvent::TMidas_BANK_HEADER::fDataSize, TMidasEvent::TMidas_BANK::fDataSize, TMidasEvent::TMidas_BANK32::fDataSize, fEventHeader, TMidasEvent::TMidas_BANK_HEADER::fFlags, TMidasEvent::TMidas_BANK::fType, TMidasEvent::TMidas_BANK32::fType, IsBank32(), QWORD_SWAP, and WORD_SWAP.
Referenced by SetData().
void TMidasEvent::SwapBytesEventHeader | ( | ) |
convert event header between little-endian (Linux-x86) and big endian (MacOS-PPC)
Definition at line 539 of file TMidasEvent.cxx.
References DWORD_SWAP, TMidas_EVENT_HEADER::fDataSize, fEventHeader, TMidas_EVENT_HEADER::fEventId, TMidas_EVENT_HEADER::fSerialNumber, TMidas_EVENT_HEADER::fTimeStamp, TMidas_EVENT_HEADER::fTriggerMask, and WORD_SWAP.
Referenced by TMidasFile::Skip().
|
protected |
"true" if we own the data buffer
Definition at line 86 of file TMidasEvent.h.
Referenced by AllocateData(), Clear(), Copy(), and SetData().
|
protected |
list of bank names in this event
Definition at line 85 of file TMidasEvent.h.
Referenced by Clear(), Copy(), GetBankList(), Print(), and SetBankList().
|
protected |
number of banks in this event
Definition at line 84 of file TMidasEvent.h.
Referenced by Clear(), Copy(), Print(), and SetBankList().
|
protected |
event data buffer
Definition at line 83 of file TMidasEvent.h.
Referenced by AllocateData(), Clear(), Copy(), FindBank(), GetData(), IsBank32(), IterateBank(), IterateBank32(), Print(), SetData(), and SwapBytes().
|
protected |
event header
Definition at line 82 of file TMidasEvent.h.
Referenced by AllocateData(), Clear(), Copy(), GetDataSize(), GetEventHeader(), GetEventId(), GetSerialNumber(), GetTimeStamp(), GetTriggerMask(), IsGoodSize(), Print(), SetBankList(), SetData(), SwapBytes(), and SwapBytesEventHeader().
|
protectedinherited |
number of good fragments parsed
Definition at line 52 of file TRawEvent.h.
Referenced by Clear(), TRawEvent::GoodFrags(), and TRawEvent::IncrementGoodFrags().