]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/EveHLT/AliEveEventBufferHomer.cxx
Added event id to frame
[u/mrichter/AliRoot.git] / EVE / EveHLT / AliEveEventBufferHomer.cxx
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
13 ClassImp(AliEveEventBufferHomer);
14
15 ///_______________________________________________________________________
16 AliEveEventBufferHomer::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 ///____________________________________________________________________
29 AliEveEventBufferHomer::~AliEveEventBufferHomer() {
30   
31   if(fHomer)
32     delete fHomer;
33   fHomer = NULL;
34
35 }
36
37
38
39 ULong64_t AliEveEventBufferHomer::GetEventIdFromSource() {
40   ///
41   return fHomer->GetEventID();
42 }
43
44 ///______________________________________________________________________
45 TObject * AliEveEventBufferHomer::GetEventFromSource() {
46   //see header file for documentation
47   if(fHomer) {
48     cout << "calling nexthomerevent"<<endl;
49     TList * blockList = fHomer->NextHOMEREvent();
50     
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 }
58
59 ///___________________________________________________________________________
60 void 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
71 // ///___________________________________________________________________________
72 // void AliEveEventBufferHomer::AddToBuffer(TObject * event, ULong64_t eventId ) {
73 //   cout << "Add to buffer"<<endl;
74 //   if(!event) return;
75 //   fBIndex[kTop] = CalculateNext(fBIndex[kTop]);
76 //   TList * list = dynamic_cast<TList*>(fEventBuffer->At(fBIndex[kTop]));
77 //   if(list) {
78 //     list->Clear();
79 //     list->AddAll(dynamic_cast<TList*>(event));
80 //     fEventId[fBIndex[kTop]] = eventId;  
81 //   }
82 // }
83
84
85 ///______________________________________________________________________
86 void AliEveEventBufferHomer::Initialize() {
87   //Add TList pointers to the buffer array
88
89   //Create TLists in all of buffer
90   for(Int_t i = 0; i < fBufferSize; i++) {
91     TList * list = new TList();
92     list->SetOwner(kTRUE);
93     fEventBuffer->AddAt(list, i);
94   }
95
96   //Create the async list
97   fAsyncList = new TList();
98   fAsyncList->SetOwner(kTRUE);
99
100   Int_t iResult = fHomer->Initialize();
101   if(iResult) {
102     cout << "Error Initializing HOMER!!!"<<endl;
103     return;
104   }
105
106
107   fHomer->SetRetryCount(1,15);
108   fHomer->SetBlockOwner(kFALSE);
109   fHomer->StartEveSourceListLoop();
110 }
111
112
113 ///______________________________________________________________________
114 void AliEveEventBufferHomer::ConnectToSource () {
115
116   fHomer->SetRetryCount(200, 15);
117   fHomer->ReConnectHOMER();
118 }
119
120 ///_____________________________________________________________________
121 void AliEveEventBufferHomer::WriteToFile(){
122
123   TFile * file = TFile::Open(Form("Event_0x%016X_ITS.root", 100), "RECREATE"); 
124   fEventBuffer->At(fBIndex[kTop])->Write("blockList", TObject::kSingleKey);
125   file->Close();
126   
127   if(fAsyncList) {
128     TFile * afile = TFile::Open(Form("Event_0x%016X_Async.root", 100), "RECREATE"); 
129     fAsyncList->Write("blockList", TObject::kSingleKey);
130     afile->Close();
131   }
132 }