Fixing warnings
[u/mrichter/AliRoot.git] / EVE / EveHLT / AliEveEventBufferHomer.cxx
... / ...
CommitLineData
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///____________________________________________________________
39ULong64_t AliEveEventBufferHomer::GetEventIdFromSource() {
40 ///see header file for documentation
41 return fHomer->GetEventID();
42}
43
44///______________________________________________________________________
45TObject * AliEveEventBufferHomer::GetEventFromSource() {
46 //see header file for documentation
47 if(fHomer) {
48 cout << "calling nexthomerevent"<<endl;
49 TList * blockList = fHomer->NextHOMEREvent();
50 cout << "getting async block list"<<endl;
51 TList * aList = fHomer->GetAsyncBlockList();
52 fAsyncList = aList;
53 if(blockList) return dynamic_cast<TObject*>(blockList);
54 else return NULL;
55 }
56
57 cout << "AliEveEventBufferHomer::GetEventFromSource() : fHomer is null pointer!!"<<endl;
58 return NULL;
59}
60
61///___________________________________________________________________________
62void AliEveEventBufferHomer::AddToBuffer(TObject * event) {
63 cout << "AliEveEventBufferHomer::Add to buffer"<<endl;
64 if(!event) {
65 cout << "event is NULL pointer, return" << endl;
66 return;
67 }
68
69
70 TList * listIn = dynamic_cast<TList*>(event);
71 if(!(listIn->GetSize() > 0)) {
72 cout << "AliEveEventBufferHomer::AddToBuffer(): List Is empty, not added to buffer!"<<endl;
73 return;
74 }
75
76 fBIndex[kTop] = CalculateNext(fBIndex[kTop]);
77 TList * list = dynamic_cast<TList*>(fEventBuffer->At(fBIndex[kTop]));
78 if(list) {
79 list->Delete();
80 list->AddAll(dynamic_cast<TList*>(event));
81 }
82}
83
84
85
86///______________________________________________________________________
87void AliEveEventBufferHomer::Initialize() {
88 //Add TList pointers to the buffer array
89
90 //Create TLists in all of buffer
91 for(Int_t i = 0; i < fBufferSize; i++) {
92 TList * list = new TList();
93 list->SetOwner(kTRUE);
94 fEventBuffer->AddAt(list, i);
95 }
96
97 //Create the async list
98 fAsyncList = new TList();
99 fAsyncList->SetOwner(kTRUE);
100
101 Int_t iResult = fHomer->Initialize();
102 if(iResult) {
103 cout << "Error Initializing HOMER!!!"<<endl;
104 return;
105 }
106
107
108 fHomer->SetRetryCount(1,15);
109 fHomer->SetBlockOwner(kFALSE);
110 //fHomer->StartEveSourceListLoop();
111}
112
113
114///______________________________________________________________________
115void AliEveEventBufferHomer::ConnectToSource () {
116
117 fHomer->SetRetryCount(200, 15);
118 fHomer->ReConnectHOMER();
119}
120
121///_____________________________________________________________________
122void AliEveEventBufferHomer::WriteToFile(Int_t runnumber){
123
124 TFile * file = TFile::Open(Form("Run_%d_0x%016LX_ESD.root", runnumber, GetEventId()), "RECREATE");
125 fEventBuffer->At(fBIndex[kCurrent])->Write("blockList", TObject::kSingleKey);
126 file->Close();
127
128 if(fAsyncList) {
129 TFile * afile = TFile::Open(Form("Run_%d_0x%016LX_Async.root", runnumber, GetEventId()), "RECREATE");
130 fAsyncList->Write("blockList", TObject::kSingleKey);
131 //aFile-
132 afile->Close();
133 }
134}