/** @file CbmMCBuffer.h ** @author Volker Friese ** @date 8 February 2012 **/ #ifndef CBMMCBUFFER_H #define CBMMCBUFFER_H 1 #define NDET 20 #include "CbmMCPointBuffer.h" #include "CbmMvdPoint.h" #include "CbmStsPoint.h" #include "CbmRichPoint.h" #include "CbmMuchPoint.h" #include "CbmTrdPoint.h" #include "CbmTofPoint.h" #include "CbmEcalPoint.h" #include "CbmZdcPoint.h" class TClonesArray; using namespace std; /** @class CbmMCBuffer ** @author Volker Friese ** @date 8 February 2012 ** @brief CBM task class for generating a time-based stream of MCPoints ** ** This class reads transport data (MCPoints) event-by-event into buffers. ** For each event, a start time is generated according to the specified ** interaction rate and beam profile, and the absolute time (since run start) ** is calculated for each MCPoint. The MCPoints are sorted w.r.t. absolute ** time within the buffers. ** ** In each event, the buffered points can be retrieved by the method ** CbmMCPoint* GetNextPoint(DetectorId det). The tasks using the buffered ** points should call this method until it returns a NULL pointer. ** ** The task guarantuees that the points retrieved in this manner are sorted ** with respect to time. It will thus release all points with abolute time ** before the current event start time. ** ** The buffered MCPoints are transient. When used, they will be marked ** and removed from the buffer at the end of the input event. **/ class CbmMCBuffer { public: /** Destructor **/ ~CbmMCBuffer(); /** Clear ** Removes all used points from the buffers **/ void Clear(); /** Get singleton instance **/ static CbmMCBuffer* Instance(); /** Fill buffer ** @param points Pointer to TClonesArray with FairMCPoints ** @param det Detector System (e.g. kSTS) ** @param eventId ID of current event ** @param eventTime Start time of event [ns] ** @value Number of copied points ** ** The FairMCPoints in the given TClonesArray are copied to the CbmMCBuffer. ** The event start time is added to the MCPoint time, the event ID is set. **/ Int_t Fill(TClonesArray* points, DetectorId det, Int_t eventId, Double_t eventTime); Int_t Fill(TClonesArray* points, Int_t det, Int_t eventId, Double_t eventTime); /** Current time ** @value Start time of last event read into the buffer [ns] **/ Double_t GetTime() const { return fTime; } /** Current event ID ** @value ID of last event read into the buffer **/ Int_t GetEventId() const { return fEventId; } /** Current size ** @value Current buffer size [MB] **/ Double_t GetSize() const; /** Get next MCPoint from buffer ** @param det DetectorId (e.g. kSTS) ** @value point Pointer to MCPoint ** ** Returns a pointer to the next (w.r.t. absolute time) MCPoint ** of the respective detector in its buffer. ** Points are released up to the start time of the last event read ** After that, a NULL pointer is returned. ** After retrieval, the MCPoint is removed from the buffer. **/ const FairMCPoint* GetNextPoint(DetectorId det); /** Screen output ** Reports the current buffer sizes. **/ void Print(); private: /** MCPoint buffers **/ CbmMCPointBuffer fMvdBuffer; CbmMCPointBuffer fStsBuffer; CbmMCPointBuffer fRichBuffer; CbmMCPointBuffer fMuchBuffer; CbmMCPointBuffer fTrdBuffer; CbmMCPointBuffer fTofBuffer; CbmMCPointBuffer fEcalBuffer; CbmMCPointBuffer fZdcBuffer; /** Start time of last event read into the buffer **/ Double_t fTime; /** ID of last event read into the buffer **/ Int_t fEventId; /** Pointer to singleton instance **/ static CbmMCBuffer* fgInstance; /** Default constructor ** Declared private to prevent instantiation. **/ CbmMCBuffer(); /** Copy constructor. Defined private to prevent usage. **/ CbmMCBuffer(const CbmMCBuffer&); /** Assignment operator. Defined private to prevent usage. **/ CbmMCBuffer& operator=(const CbmMCBuffer&); }; #endif