]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ANALYSIS/AliEventBuffer.cxx
- ESDfilter moved from PWG0base to ANALYSISalice
[u/mrichter/AliRoot.git] / ANALYSIS / AliEventBuffer.cxx
1 #include "AliEventBuffer.h"
2
3 ClassImp(AliEventBuffer)
4
5 //______________________________________________________
6 ////////////////////////////////////////////////////////
7 //
8 // class AliEventBuffer
9 //
10 // FIFO type event buffer
11 //
12 // Piotr.Skowronski@cern.ch
13 //
14 ////////////////////////////////////////////////////////
15
16 AliEventBuffer::AliEventBuffer():
17  fSize(-1),fEvents(),fIter(&fEvents)
18 {
19   //ctor
20 }
21 /***********************************************************/
22
23 AliEventBuffer::AliEventBuffer(Int_t size):
24  fSize(size),fEvents(),fIter(&fEvents)
25 {
26   //ctor
27 }
28 /***********************************************************/
29
30 AliEventBuffer::~AliEventBuffer()
31 {
32   //dtor -- TList::IsOwner(1) does not work - Valgrind says that there is mem leak
33   //take care owerseves
34   if (fEvents.IsOwner())
35    { 
36      AliAOD* e=0x0;
37      while (( e=RemoveLast() )) delete e;
38    }
39 }
40 /***********************************************************/
41
42 void AliEventBuffer::Reset()
43 {
44   //Resets the queue
45   if (fEvents.IsOwner())
46    { 
47      AliAOD* e=0x0;
48      while (( e=RemoveLast() )) delete e;
49    }
50   else
51    {
52      fEvents.RemoveAll();
53    } 
54 }
55 /***********************************************************/
56
57 AliAOD* AliEventBuffer::Push(AliAOD* event)
58 {
59   //adds a new event, and returns old of do not fit in size
60   if (fSize == 0) return event;
61   
62   AliAOD* ret = 0x0;
63   
64   if (fSize == fEvents.GetSize()) 
65     ret = dynamic_cast<AliAOD*>(fEvents.Remove(fEvents.Last()));
66   if (event) fEvents.AddFirst(event);
67   return ret;
68 }
69