ROOTANA
Loading...
Searching...
No Matches
TMidasEvent.h
Go to the documentation of this file.
1//
2// TMidasEvent.h
3//
4
5#ifndef TMIDASEVENT_H
6#define TMIDASEVENT_H
7
8#include "TMidasStructs.h"
9
10///
11/// C++ class representing one midas event.
12///
13/// Objects of this class are created by reading
14/// midas events from a file, by reading
15/// them from a midas shared memory buffer or by
16/// receiving them through the mserver
17///
18
19/// MIDAS event
20
22{
23 public:
24
25 // houskeeping functions
26
27 TMidasEvent(); ///< default constructor
28 TMidasEvent(const TMidasEvent &); ///< copy constructor
29 ~TMidasEvent(); ///< destructor
30 TMidasEvent& operator=(const TMidasEvent &); ///< assignement operator
31 void Clear(); ///< clear event for reuse
32 void Copy(const TMidasEvent &); ///< copy helper
33 void Print(const char* option = "") const; ///< show all event information
34
35 // get event information
36
37 uint16_t GetEventId() const; ///< return the event id
38 uint16_t GetTriggerMask() const; ///< return the triger mask
39 uint32_t GetSerialNumber() const; ///< return the serial number
40 uint32_t GetTimeStamp() const; ///< return the time stamp (unix time in seconds)
41 uint32_t GetDataSize() const; ///< return the event size
42
43 // get data banks
44
45 const char* GetBankList() const; ///< return a list of data banks
46 int FindBank(const char* bankName, int* bankLength, int* bankType, void **bankPtr) const;
47 int LocateBank(const void *unused, const char* bankName, void **bankPtr) const;
48
49 bool IsBank32() const; ///< returns "true" if event uses bk_init32() banks
50 bool IsBank32a() const; ///< returns "true" if event uses bk_init32a() banks
51 int IterateBank(TMidas_BANK **, char **pdata) const; ///< iterate through 16-bit data banks
52 int IterateBank32(TMidas_BANK32 **, char **pdata) const; ///< iterate through 32-bit data banks
53 int IterateBank32a(TMidas_BANK32a **, char **pdata) const; ///< iterate through 32-bit data banks
54
55 // helpers for event creation
56
57 TMidas_EVENT_HEADER* GetEventHeader(); ///< return pointer to the event header
58 char* GetData(); ///< return pointer to the data buffer
59
60 void AllocateData(); ///< allocate data buffer using the existing event header
61 void SetData(uint32_t dataSize, char* dataBuffer); ///< set an externally allocated data buffer
62
63 int SetBankList(); ///< create the list of data banks, return number of banks
64 bool IsGoodSize() const; ///< validate the event length
65
66 void SwapBytesEventHeader(); ///< convert event header between little-endian (Linux-x86) and big endian (MacOS-PPC)
67 int SwapBytes(bool); ///< convert event data between little-endian (Linux-x86) and big endian (MacOS-PPC)
68
69protected:
70
72 char* fData; ///< event data buffer
73 int fBanksN; ///< number of banks in this event
74 char* fBankList; ///< list of bank names in this event
75 bool fAllocatedByUs; ///< "true" if we own the data buffer
76};
77
80
81// read and write functions
82bool TMReadEvent(TMReaderInterface* reader, TMidasEvent* event);
83bool TMWriteEvent(TMWriterInterface* writer, TMidasEvent* event);
84
85#endif // TMidasEvent.h
bool TMWriteEvent(TMWriterInterface *writer, TMidasEvent *event)
bool TMReadEvent(TMReaderInterface *reader, TMidasEvent *event)
MIDAS event.
Definition TMidasEvent.h:22
int FindBank(const char *bankName, int *bankLength, int *bankType, void **bankPtr) const
int SwapBytes(bool)
convert event data between little-endian (Linux-x86) and big endian (MacOS-PPC)
bool IsBank32() const
returns "true" if event uses bk_init32() banks
int IterateBank32(TMidas_BANK32 **, char **pdata) const
iterate through 32-bit data banks
TMidas_EVENT_HEADER * GetEventHeader()
return pointer to the event header
void Clear()
clear event for reuse
uint32_t GetDataSize() const
return the event size
int fBanksN
number of banks in this event
Definition TMidasEvent.h:73
int SetBankList()
create the list of data banks, return number of banks
int IterateBank32a(TMidas_BANK32a **, char **pdata) const
iterate through 32-bit data banks
void AllocateData()
allocate data buffer using the existing event header
const char * GetBankList() const
return a list of data banks
int IterateBank(TMidas_BANK **, char **pdata) const
iterate through 16-bit data banks
uint16_t GetEventId() const
return the event id
int LocateBank(const void *unused, const char *bankName, void **bankPtr) const
bool IsBank32a() const
returns "true" if event uses bk_init32a() banks
uint32_t GetTimeStamp() const
return the time stamp (unix time in seconds)
TMidasEvent()
default constructor
TMidasEvent & operator=(const TMidasEvent &)
assignement operator
void SetData(uint32_t dataSize, char *dataBuffer)
set an externally allocated data buffer
bool fAllocatedByUs
"true" if we own the data buffer
Definition TMidasEvent.h:75
char * fData
event data buffer
Definition TMidasEvent.h:72
void Print(const char *option="") const
show all event information
~TMidasEvent()
destructor
uint32_t GetSerialNumber() const
return the serial number
uint16_t GetTriggerMask() const
return the triger mask
TMidas_EVENT_HEADER fEventHeader
event header
Definition TMidasEvent.h:71
bool IsGoodSize() const
validate the event length
void Copy(const TMidasEvent &)
copy helper
char * GetData()
return pointer to the data buffer
char * fBankList
list of bank names in this event
Definition TMidasEvent.h:74
void SwapBytesEventHeader()
convert event header between little-endian (Linux-x86) and big endian (MacOS-PPC)
32-bit data bank
16-bit data bank