Added run number to frame
[u/mrichter/AliRoot.git] / EVE / EveHLT / AliEveEventBufferHomer.cxx
CommitLineData
30e7579c 1#if __GNUC__>= 3
2 using namespace std;
3#endif
4
5#include "AliEveEventBufferHomer.h"
6#include "AliEveHOMERManager.h"
7
8#include "TList.h"
9#include "TFile.h"
10
11#include <iostream>
12
13ClassImp(AliEveEventBufferHomer);
14
15///_______________________________________________________________________
16AliEveEventBufferHomer::AliEveEventBufferHomer() :
17 fHomer(NULL),
18 fEventNo(0),
19 fAsyncList(NULL)
20{
21 // see header file for class documentation
22 fHomer = new AliEveHOMERManager();
23 Initialize();
24
25}
26
27
28///____________________________________________________________________
29AliEveEventBufferHomer::~AliEveEventBufferHomer() {
30
31 if(fHomer)
32 delete fHomer;
33 fHomer = NULL;
34
35}
36
37
38
8676f4b1 39ULong64_t AliEveEventBufferHomer::GetEventIdFromSource() {
40 ///
41 return fHomer->GetEventID();
42}
30e7579c 43
44///______________________________________________________________________
45TObject * AliEveEventBufferHomer::GetEventFromSource() {
46 //see header file for documentation
47 if(fHomer) {
48 cout << "calling nexthomerevent"<<endl;
49 TList * blockList = fHomer->NextHOMEREvent();
8676f4b1 50
30e7579c 51 if(blockList) return dynamic_cast<TObject*>(blockList);
52 else return NULL;
53 }
54
55 cout << "AliEveEventBufferHomer::GetEventFromSource() : fHomer is null pointer!!"<<endl;
56 return NULL;
57}
8676f4b1 58
30e7579c 59///___________________________________________________________________________
60void AliEveEventBufferHomer::AddToBuffer(TObject * event) {
61 cout << "Add to buffer"<<endl;
62 if(!event) return;
63 fBIndex[kTop] = CalculateNext(fBIndex[kTop]);
64 TList * list = dynamic_cast<TList*>(fEventBuffer->At(fBIndex[kTop]));
65 if(list) {
66 list->Clear();
67 list->AddAll(dynamic_cast<TList*>(event));
68 }
69}
70
8676f4b1 71
30e7579c 72
73///______________________________________________________________________
74void AliEveEventBufferHomer::Initialize() {
75 //Add TList pointers to the buffer array
b088c0a1 76
77 //Create TLists in all of buffer
30e7579c 78 for(Int_t i = 0; i < fBufferSize; i++) {
79 TList * list = new TList();
80 list->SetOwner(kTRUE);
81 fEventBuffer->AddAt(list, i);
82 }
83
b088c0a1 84 //Create the async list
85 fAsyncList = new TList();
86 fAsyncList->SetOwner(kTRUE);
30e7579c 87
88 Int_t iResult = fHomer->Initialize();
89 if(iResult) {
90 cout << "Error Initializing HOMER!!!"<<endl;
91 return;
92 }
93
94
95 fHomer->SetRetryCount(1,15);
96 fHomer->SetBlockOwner(kFALSE);
97 fHomer->StartEveSourceListLoop();
98}
99
100
101///______________________________________________________________________
102void AliEveEventBufferHomer::ConnectToSource () {
103
104 fHomer->SetRetryCount(200, 15);
105 fHomer->ReConnectHOMER();
106}
107
108///_____________________________________________________________________
109void AliEveEventBufferHomer::WriteToFile(){
110
111 TFile * file = TFile::Open(Form("Event_0x%016X_ITS.root", 100), "RECREATE");
112 fEventBuffer->At(fBIndex[kTop])->Write("blockList", TObject::kSingleKey);
113 file->Close();
114
115 if(fAsyncList) {
116 TFile * afile = TFile::Open(Form("Event_0x%016X_Async.root", 100), "RECREATE");
117 fAsyncList->Write("blockList", TObject::kSingleKey);
118 afile->Close();
119 }
120}