last fit iteration removed, because it used non-accurate selection of tracks.
[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();
48d5b578 50 cout << "getting async block list"<<endl;
cc87822c 51 TList * aList = fHomer->GetAsyncBlockList();
52 fAsyncList = aList;
30e7579c 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}
8676f4b1 60
30e7579c 61///___________________________________________________________________________
62void AliEveEventBufferHomer::AddToBuffer(TObject * event) {
63 cout << "Add to buffer"<<endl;
64 if(!event) return;
65 fBIndex[kTop] = CalculateNext(fBIndex[kTop]);
66 TList * list = dynamic_cast<TList*>(fEventBuffer->At(fBIndex[kTop]));
67 if(list) {
68 list->Clear();
69 list->AddAll(dynamic_cast<TList*>(event));
70 }
71}
72
8676f4b1 73
30e7579c 74
75///______________________________________________________________________
76void AliEveEventBufferHomer::Initialize() {
77 //Add TList pointers to the buffer array
b088c0a1 78
79 //Create TLists in all of buffer
30e7579c 80 for(Int_t i = 0; i < fBufferSize; i++) {
81 TList * list = new TList();
82 list->SetOwner(kTRUE);
83 fEventBuffer->AddAt(list, i);
84 }
85
b088c0a1 86 //Create the async list
87 fAsyncList = new TList();
88 fAsyncList->SetOwner(kTRUE);
30e7579c 89
90 Int_t iResult = fHomer->Initialize();
91 if(iResult) {
92 cout << "Error Initializing HOMER!!!"<<endl;
93 return;
94 }
95
96
97 fHomer->SetRetryCount(1,15);
98 fHomer->SetBlockOwner(kFALSE);
99 fHomer->StartEveSourceListLoop();
100}
101
102
103///______________________________________________________________________
104void AliEveEventBufferHomer::ConnectToSource () {
105
106 fHomer->SetRetryCount(200, 15);
107 fHomer->ReConnectHOMER();
108}
109
110///_____________________________________________________________________
cc87822c 111void AliEveEventBufferHomer::WriteToFile(Int_t runnumber){
30e7579c 112
cc87822c 113 TFile * file = TFile::Open(Form("%d_0x%016X_ESD.root", runnumber, GetEventId()), "RECREATE");
114 fEventBuffer->At(fBIndex[kCurrent])->Write("blockList", TObject::kSingleKey);
30e7579c 115 file->Close();
116
117 if(fAsyncList) {
cc87822c 118 TFile * afile = TFile::Open(Form("%d_0x%016X_Async.root", runnumber, GetEventId()), "RECREATE");
30e7579c 119 fAsyncList->Write("blockList", TObject::kSingleKey);
120 afile->Close();
121 }
122}