///////////////////////////////////////////////////////////////////////////////
-#include "AliVertexGenFile.h"
-#include "AliHeader.h"
-#include "AliGenEventHeader.h"
+#include <TArrayF.h>
#include <TFile.h>
#include <TTree.h>
-#include <TArrayF.h>
+
+#include "AliVertexGenFile.h"
+#include "AliLog.h"
+#include "AliGenEventHeader.h"
+#include "AliHeader.h"
ClassImp(AliVertexGenFile)
TDirectory* dir = gDirectory;
fFile = TFile::Open(fileName);
- if (!fFile) {
- Error("AliVertexGenFile", "could not open file %s", fileName);
+ if (!fFile || !fFile->IsOpen()) {
+ AliError(Form("could not open file %s", fileName));
+ delete fFile;
+ fFile = NULL;
return;
}
fTree = (TTree*) fFile->Get("TE");
if (!fTree) {
- Error("AliVertexGenFile", "not header tree found in file %s", fileName);
+ AliError(Form("no header tree found in file %s", fileName));
dir->cd();
return;
}
{
// clean up
- fFile->Close();
+ if (fFile) fFile->Close();
delete fFile;
delete fHeader;
}
// get the vertex from the event header tree
Int_t entry = fEvent++ / fEventsPerEntry;
+ if (!fTree) {
+ AliError("no header tree");
+ return TVector3(0,0,0);
+ }
+
if (fTree->GetEntry(entry) <= 0) {
- Error("GetVertex", "error loading entry %d", entry);
+ AliError(Form("error loading entry %d", entry));
return TVector3(0,0,0);
}
if (!fHeader->GenEventHeader()) {
- Error("GetVertex", "no generator event header");
+ AliError("no generator event header");
return TVector3(0,0,0);
}