/** @file CbmDaqBuffer.h ** @author Volker Friese ** @date 17 July 2012 **/ #ifndef CBMDAQBUFFER_H #define CBMDAQBUFFER_H 1 #include #include #include #include "CbmDefs.h" #include "CbmDigi.h" #include "CbmMatch.h" /** @class CbmDaqBuffer ** @author Volker Friese ** @date 20 July 2012 ** @brief Buffer class for CBM raw data. Used by CbmDaq. ** ** The CbmDaqBuffer stores and sorts (w.r.t. time) CBM raw data ** (currently: CbmDigi and the associated match) transiently. ** Data can be send to the buffer by the method InsertData. ** They can be retrieved by GetNextData, which delivers a ** time-ordered sequence of raw data objects for each detector. **/ class CbmDaqBuffer { public: /** Data typedef **/ typedef std::pair Data; /** @brief Default constructor **/ CbmDaqBuffer(); /** @brief Copy constructor forbidden **/ CbmDaqBuffer(const CbmDaqBuffer&) = delete; /** Assignment operator forbidden **/ CbmDaqBuffer& operator=(const CbmDaqBuffer&) = delete; /** @brief Destructor **/ ~CbmDaqBuffer(); /** @brief Time of first data for all detectors ** @return time of first data [ns] **/ Double_t GetFirstTime() const; /** @brief Time of first data for a given detector ** @param iDet detector type (e.g. kSTS) ** @return time of first data [ns] */ Double_t GetFirstTime(Int_t iDet) const; /** @brief Time of last data for all detectors ** @return time of last data [ns] **/ Double_t GetLastTime() const; /** @brief Time of last data for a given detector ** @param iDet detector type (e.g. kSTS) ** @return time of last data [ns] */ Double_t GetLastTime(Int_t iDet) const; /** @brief Pointer to next raw data object for a given detector ** @param iDet detector type (ECbmModuleId) ** @return pointer to raw data object ** ** The ownership of the returned objects is passed to the caller. **/ Data GetNextData(Int_t iDet); /** @brief Pointer to next raw data object for a given detector ** up to given time ** @param iDet detector type (e.g. kSTS) ** @param time maximal time [ns] ** @return pointer to raw data object ** ** If the argument time is negative, no time limit is set. ** ** The ownership of the returned objects is passed to the caller. **/ Data GetNextData(Int_t iDet, Double_t time); /** @brief Current buffer size ** @return number of objects in buffer */ Int_t GetSize() const; /** @brief Current buffer size for given detector ** @param det Detector system (e.g. kSTS) ** @return number of objects in buffer */ Int_t GetSize(Int_t det) const; /** @brief Insert digi and match objects into the buffer ** @param digi Unique pointer to digi object to be inserted ** @param match Unique pointer to match object to be inserted ** ** The match object contains the links of the digis to the MCPoints **/ void InsertData(up_CbmDigi digi, up_CbmMatch match = nullptr); /** @brief Insert digi into the buffer ** @param digi Pointer to digi object to be inserted ** ** Legacy: For use e.g. from unpackers **/ void InsertDigi(CbmDigi* digi); /** @brief Print buffer status **/ void PrintStatus() const; /** @brief Status string **/ std::string ToString() const; private: /** Buffer representation. Key is time. **/ std::multimap fData[kNofSystems]; }; #endif /* CBMDAQBUFFER_H */