// // TMidasEvent.h // #ifndef TMIDASEVENT_H #define TMIDASEVENT_H #include "TMidasStructs.h" /// /// 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 /// /// MIDAS event class TMidasEvent { public: // houskeeping functions TMidasEvent(); ///< default constructor TMidasEvent(const TMidasEvent &); ///< copy constructor ~TMidasEvent(); ///< destructor TMidasEvent& operator=(const TMidasEvent &); ///< assignement operator void Clear(); ///< clear event for reuse void Copy(const TMidasEvent &); ///< copy helper void Print(const char* option = "") const; ///< show all event information // get event information uint16_t GetEventId() const; ///< return the event id uint16_t GetTriggerMask() const; ///< return the triger mask uint32_t GetSerialNumber() const; ///< return the serial number uint32_t GetTimeStamp() const; ///< return the time stamp (unix time in seconds) uint32_t GetDataSize() const; ///< return the event size // get data banks const char* GetBankList() const; ///< return a list of data banks int FindBank(const char* bankName, int* bankLength, int* bankType, void **bankPtr) const; int LocateBank(const void *unused, const char* bankName, void **bankPtr) const; bool IsBank32() const; ///< returns "true" if event uses bk_init32() banks bool IsBank32a() const; ///< returns "true" if event uses bk_init32a() banks int IterateBank(TMidas_BANK **, char **pdata) const; ///< iterate through 16-bit data banks int IterateBank32(TMidas_BANK32 **, char **pdata) const; ///< iterate through 32-bit data banks int IterateBank32a(TMidas_BANK32a **, char **pdata) const; ///< iterate through 32-bit data banks // helpers for event creation TMidas_EVENT_HEADER* GetEventHeader(); ///< return pointer to the event header char* GetData(); ///< return pointer to the data buffer void AllocateData(); ///< allocate data buffer using the existing event header void SetData(uint32_t dataSize, char* dataBuffer); ///< set an externally allocated data buffer int SetBankList(); ///< create the list of data banks, return number of banks bool IsGoodSize() const; ///< validate the event length void SwapBytesEventHeader(); ///< convert event header between little-endian (Linux-x86) and big endian (MacOS-PPC) int SwapBytes(bool); ///< convert event data between little-endian (Linux-x86) and big endian (MacOS-PPC) protected: TMidas_EVENT_HEADER fEventHeader; ///< event header char* fData; ///< event data buffer int fBanksN; ///< number of banks in this event char* fBankList; ///< list of bank names in this event bool fAllocatedByUs; ///< "true" if we own the data buffer }; class TMReaderInterface; class TMWriterInterface; // read and write functions bool TMReadEvent(TMReaderInterface* reader, TMidasEvent* event); bool TMWriteEvent(TMWriterInterface* writer, TMidasEvent* event); #endif // TMidasEvent.h