Fixing warnings
[u/mrichter/AliRoot.git] / EVE / EveHLT / AliEveEventBufferOffline.cxx
CommitLineData
30e7579c 1#if __GNUC__>= 3
2 using namespace std;
3#endif
4
5#include "AliEveEventBufferOffline.h"
6
7#include "AliESDEvent.h"
52033dc6 8#include "AliEveEventBufferOffline.h"
9#include "AliEveEventBuffer.h"
30e7579c 10
11#include "TTimer.h"
12#include "TFile.h"
13#include "TTree.h"
14#include <iostream>
15
16ClassImp(AliEveEventBufferOffline);
17
18///_______________________________________________________________________
19AliEveEventBufferOffline::AliEveEventBufferOffline() :
20 fFile(NULL),
21 fNEntries(0),
22 fEventNo(0),
23 fEvent(NULL),
24 fTree(NULL)
25{
26 // see header file for class documentation
27 //Not Allowed
28}
29
30///_______________________________________________________________________
31AliEveEventBufferOffline::AliEveEventBufferOffline(TString filename) :
32 fFile(NULL),
33 fNEntries(0),
34 fEventNo(0),
35 fEvent(NULL),
36 fTree(NULL)
37{
38
39 fEvent = new AliESDEvent();
40
41 cout <<"opening file " << filename << " what?" <<endl;
42 fFile = TFile::Open(filename, "READ");
43 if(!fFile) {
44 cout << "Couldn't open file, crashing hard! Soon?"<<endl;
45 return;
46 }
47
b088c0a1 48 fTree = dynamic_cast<TTree *>(fFile->Get("HLTesdTree"));
30e7579c 49 cout << "File has " << fNEntries << "events" << endl;
50 fNEntries = fTree->GetEntries();
51 fEvent->ReadFromTree(fTree);
52
53}
54
55
56
57
58///____________________________________________________________________
59AliEveEventBufferOffline::~AliEveEventBufferOffline() {
60
61 if(fFile)
62 delete fFile;
63 fFile = NULL;
64
65 if(fTree)
66 delete fTree;
67 fTree = NULL;
68
69 if(fEvent)
70 delete fEvent;
71 fEvent = NULL;
72
73}
74
75
76///______________________________________________________________________
77TObject * AliEveEventBufferOffline::GetEventFromSource() {
78 //see header file for documentation
79 if(fTree) {
80 fTree->GetEntry(fEventNo++);
81 if(fEventNo == fNEntries)
82 fEventNo = 0;
83 } else {
84 cout << "Tree not found, probably bad file!!"<<endl;
85 return NULL;
86 }
87
88 //Copy event into new event (must be deleted when no longer needed in list!!
239fdf4e 89 //AliESDEvent * event = new AliESDEvent();
90 //fEvent->Copy(*event);
91 //cout << event->GetNumberOfCaloClusters() << endl;
30e7579c 92
239fdf4e 93 if (fEvent) {
94 return dynamic_cast<TObject*>(fEvent);
30e7579c 95 } else {
96 cout << "error getting event" << endl;
97 return NULL;
98 }
99}
100
101///___________________________________________________________________
102void AliEveEventBufferOffline::ConnectToSource() {
103 //Needed for homer version
104 // see header file for class documentation
105 return;
106}
107
108
109///_____________________________________________________________________
cc87822c 110void AliEveEventBufferOffline::WriteToFile(Int_t runnumber){
30e7579c 111 //Inherited from AliEveEventBuffer
7cd10272 112 TFile * file = TFile::Open(Form("%d_0x%016LX_ESD.root", runnumber, GetEventId()), "RECREATE");
cc87822c 113 fEventBuffer->At(fBIndex[kCurrent])->Write("blockList", TObject::kSingleKey);
30e7579c 114 file->Close();
115}