]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EVE/EveHLT/AliEveEventBuffer.h
Prepare for the new TPC layout
[u/mrichter/AliRoot.git] / EVE / EveHLT / AliEveEventBuffer.h
CommitLineData
30e7579c 1// $Id$
2
30e7579c 3/* This file is property of and copyright by the ALICE HLT Project *
4 * ALICE Experiment at CERN, All rights reserved. *
5 * See cxx source for full Copyright notice
6 */
7
8/** @file AliEveEventBuffer.h
9 @author Svein Lindal
10 @date
973e8d95 11 @brief Event buffer for HOMER
30e7579c 12*/
13
14
973e8d95 15#ifndef ALIEVEEVENTBUFFER_H
16#define ALIEVEEVENTBUFFER_H
17
18
19
20#include "TObject.h"
21#include "TMutex.h"
22
30e7579c 23class TObjArray;
30e7579c 24class TTimer;
25class TThread;
973e8d95 26class TTimer;
27
30e7579c 28
29class AliEveEventBuffer : public TObject{
30
31public:
32
33 /** default constructor */
34 AliEveEventBuffer();
35
36 /** destructor */
37 virtual ~AliEveEventBuffer();
38
39 void SetBufferSize(Int_t bs) { fBufferSize = bs;}
973e8d95 40
30e7579c 41 TObject * NextEvent();
42 TObject * Back();
43 TObject * Fwd();
44
45 void StartBufferMonitor();
46 void StopBufferMonitor();
47 //Needed for Homer buffer
48 virtual void ConnectToSource() = 0;
49 //Check if more events are needed in buffer
50 void MonitorBuffer();
51
52 static void * BufferThread(void * buffer);
cc87822c 53 virtual void WriteToFile(Int_t runnumber) = 0;
30e7579c 54
239fdf4e 55 void CreateBufferThread();
56
8676f4b1 57 ULong64_t GetEventId() const { return fEventId[fBIndex[kCurrent]]; }
cc87822c 58 void SetEventId(ULong64_t eventId) { fEventId[fBIndex[kCurrent]] = eventId;}
239fdf4e 59
765675f2 60 Int_t LockMutex() { return fMutex->TryLock();}
61 Int_t UnLockMutex() { return fMutex->UnLock();}
62
63
30e7579c 64protected:
65
66 enum fBufferIndex {
67 kCurrent,
68 kLast,
69 kTop,
70 kSize
71 };
72
73
973e8d95 74 Int_t fBufferSize;//Size of event buffer
75 Int_t fPreBuffer;//How many events should be prefetched
76 TObjArray * fEventBuffer; //TClonesArray containing the stored events
77 TObject * fCurrentEvent; //Pointer to current event
78 Int_t fBIndex[kSize]; //Event buffer indexes
30e7579c 79
30e7579c 80
81
82 //Add event to buffer
83 virtual void AddToBuffer(TObject * event);
30e7579c 84 virtual TObject * GetEventFromSource() = 0;
8676f4b1 85 virtual ULong64_t GetEventIdFromSource() { return 0;}
86
30e7579c 87
88 void FetchEvent();
89
90
91 //Calculate buffer index stuff
973e8d95 92 Int_t CalculateDifference(Int_t top, Int_t low) const;
93 Int_t CalculatePrevious(Int_t current) const;
94 Int_t CalculateNext(Int_t current) const;
30e7579c 95
30e7579c 96
b088c0a1 97 void SetBufferMonStarted(Bool_t started) {fBufferMonStarted = started;}
98 Bool_t GetBufferMonStarted () const { return fBufferMonStarted;}
30e7579c 99
100private:
101
102 /** copy constructor prohibited */
103 AliEveEventBuffer(const AliEveEventBuffer&);
104
105 /** assignment operator prohibited */
106 AliEveEventBuffer& operator=(const AliEveEventBuffer&);
107
239fdf4e 108
30e7579c 109
110 TObject * GetNextUnSeen();
111
112 void PrintIndeces();
113 void PrintBuffer();
114
973e8d95 115 TTimer * fTimer;//Timer to loop over buffer monitor
30e7579c 116
30e7579c 117 //Current event id
973e8d95 118 ULong64_t * fEventId;//Event id
30e7579c 119
973e8d95 120 Bool_t fBufferMonStarted;//Has buffer monitor loop started?
b088c0a1 121
973e8d95 122 TThread * fThread; //Thread pointer
123 TMutex * fMutex;//Mutex
30e7579c 124
125 ClassDef(AliEveEventBuffer, 0); // Manage connections to HLT data-sources.
126};
127
128#endif