00001 // 00002 // TMidasEvent.h 00003 // 00004 00005 #ifndef TMIDASEVENT_H 00006 #define TMIDASEVENT_H 00007 00008 #include "TMidasStructs.h" 00009 00010 /// 00011 /// C++ class representing one midas event. 00012 /// 00013 /// Objects of this class are created by reading 00014 /// midas events from a file, by reading 00015 /// them from a midas shared memory buffer or by 00016 /// receiving them through the mserver 00017 /// 00018 00019 /// MIDAS event 00020 00021 class TMidasEvent 00022 { 00023 public: 00024 00025 // houskeeping functions 00026 00027 TMidasEvent(); ///< default constructor 00028 TMidasEvent(const TMidasEvent &); ///< copy constructor 00029 ~TMidasEvent(); ///< destructor 00030 TMidasEvent& operator=(const TMidasEvent &); ///< assignement operator 00031 void Clear(); ///< clear event for reuse 00032 void Copy(const TMidasEvent &); ///< copy helper 00033 void Print(const char* option = "") const; ///< show all event information 00034 00035 // get event information 00036 00037 uint16_t GetEventId() const; ///< return the event id 00038 uint16_t GetTriggerMask() const; ///< return the triger mask 00039 uint32_t GetSerialNumber() const; ///< return the serial number 00040 uint32_t GetTimeStamp() const; ///< return the time stamp (unix time in seconds) 00041 uint32_t GetDataSize() const; ///< return the event size 00042 00043 // get data banks 00044 00045 const char* GetBankList() const; ///< return a list of data banks 00046 int FindBank(const char* bankName, int* bankLength, int* bankType, void **bankPtr) const; 00047 int LocateBank(const void *unused, const char* bankName, void **bankPtr) const; 00048 00049 bool IsBank32() const; ///< returns "true" if event uses 32-bit banks 00050 int IterateBank(TMidas_BANK **, char **pdata) const; ///< iterate through 16-bit data banks 00051 int IterateBank32(TMidas_BANK32 **, char **pdata) const; ///< iterate through 32-bit data banks 00052 00053 // helpers for event creation 00054 00055 TMidas_EVENT_HEADER* GetEventHeader(); ///< return pointer to the event header 00056 char* GetData(); ///< return pointer to the data buffer 00057 00058 void AllocateData(); ///< allocate data buffer using the existing event header 00059 void SetData(uint32_t dataSize, char* dataBuffer); ///< set an externally allocated data buffer 00060 00061 int SetBankList(); ///< create the list of data banks, return number of banks 00062 bool IsGoodSize() const; ///< validate the event length 00063 00064 void SwapBytesEventHeader(); ///< convert event header between little-endian (Linux-x86) and big endian (MacOS-PPC) 00065 int SwapBytes(bool); ///< convert event data between little-endian (Linux-x86) and big endian (MacOS-PPC) 00066 00067 protected: 00068 00069 TMidas_EVENT_HEADER fEventHeader; ///< event header 00070 char* fData; ///< event data buffer 00071 int fBanksN; ///< number of banks in this event 00072 char* fBankList; ///< list of bank names in this event 00073 bool fAllocatedByUs; ///< "true" if we own the data buffer 00074 }; 00075 00076 #endif // TMidasEvent.h