]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliVertexGenFile.cxx
readers updated (mini header -> data header)
[u/mrichter/AliRoot.git] / STEER / AliVertexGenFile.cxx
index b2020b45ae9be68a160aeaec46e4cc147899524a..f44023083f373542f6c6df428b7ef1b1be0f68ea 100644 (file)
@@ -65,13 +65,15 @@ AliVertexGenFile::AliVertexGenFile(const char* fileName,
   TDirectory* dir = gDirectory;
 
   fFile = TFile::Open(fileName);
-  if (!fFile) {
+  if (!fFile || !fFile->IsOpen()) {
     Error("AliVertexGenFile", "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);
+    Error("AliVertexGenFile", "no header tree found in file %s", fileName);
     dir->cd();
     return;
   }
@@ -86,7 +88,7 @@ AliVertexGenFile::~AliVertexGenFile()
 {
 // clean up
 
-  fFile->Close();
+  if (fFile) fFile->Close();
   delete fFile;
   delete fHeader;
 }
@@ -98,6 +100,11 @@ TVector3 AliVertexGenFile::GetVertex()
 // get the vertex from the event header tree
 
   Int_t entry = fEvent++ / fEventsPerEntry;
+  if (!fTree) {
+    Error("GetVertex", "no header tree");
+    return TVector3(0,0,0);
+  }
+
   if (fTree->GetEntry(entry) <= 0) {
     Error("GetVertex", "error loading entry %d", entry);
     return TVector3(0,0,0);