]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - RAW/AliRawReaderChain.cxx
Coverity fix (an obsolete constructor removed)
[u/mrichter/AliRoot.git] / RAW / AliRawReaderChain.cxx
index 17e59f54b0e521213ee467fca3fe1e637d5e4109..4663bd625864107bacaeb26015c2578335cfd442 100644 (file)
 #include <TSystem.h>
 #include <TFile.h>
 #include <TKey.h>
+#include <TGrid.h>
+#include <TGridResult.h>
 
 #include "AliRawReaderChain.h"
-#include "AliRawEvent.h"
+#include "AliRawVEvent.h"
 
 ClassImp(AliRawReaderChain)
 
@@ -173,7 +175,10 @@ AliRawReaderChain::AliRawReaderChain(TChain *chain) :
 // create raw-reader objects which takes as an input a root chain
 // from a root file collection
 
-  if (!fChain) fIsValid = kFALSE;
+  if (!fChain) {
+    fIsValid = kFALSE;
+    return;
+  }
 
   fChain->SetBranchStatus("*",1);
   fChain->SetBranchAddress("rawevent",&fEvent,&fBranch);
@@ -186,7 +191,10 @@ AliRawReaderChain::AliRawReaderChain(TEntryList *elist) :
 // create raw-reader objects which takes as an input a root chain
 // from a root file collection
 
-  if (!elist) fIsValid = kFALSE;
+  if (!elist) {
+    fIsValid = kFALSE;
+    return;
+  }
 
   fChain = new TChain("RAW");
 
@@ -202,6 +210,48 @@ AliRawReaderChain::AliRawReaderChain(TEntryList *elist) :
   fChain->SetBranchAddress("rawevent",&fEvent,&fBranch);
 }
 
+AliRawReaderChain::AliRawReaderChain(Int_t runNumber) :
+  AliRawReaderRoot(),
+  fChain(NULL)
+{
+// create raw-reader objects which takes as an input a root chain
+// with the raw-data files for a given run
+// It queries alien FC in order to do that and therefore
+// it needs alien API to be enabled
+
+  if (runNumber <= 0) {
+    Error("AliRawReaderChain","Bad run number:%d",runNumber);
+    fIsValid = kFALSE;
+  }
+
+  if (!gGrid) TGrid::Connect("alien://");
+  if (!gGrid) {
+    fIsValid = kFALSE;
+    return;
+  }
+
+  TGridResult *res = gGrid->Query("/alice/data",Form("%09d/raw/*%09d*0.root",runNumber,runNumber));
+  Int_t nFiles = res->GetEntries();
+  if (!nFiles) {
+    Error("AliRawReaderChain","No raw-data files found for run %d",runNumber);
+    fIsValid = kFALSE;
+    delete res;
+    return;
+  }
+
+  fChain = new TChain("RAW");
+  for (Int_t i = 0; i < nFiles; i++) {
+    TString filename = res->GetKey(i, "turl");
+    if(filename == "") continue;
+    fChain->Add(filename.Data());
+  }
+  delete res;
+
+  fChain->SetBranchStatus("*",1);
+  fChain->SetBranchAddress("rawevent",&fEvent,&fBranch);
+}
+
+
 AliRawReaderChain::AliRawReaderChain(const AliRawReaderChain& rawReader) :
   AliRawReaderRoot(rawReader),
   fChain(rawReader.fChain)
@@ -237,12 +287,14 @@ Bool_t AliRawReaderChain::NextEvent()
 
   do {
     delete fEvent;
-    fEvent = new AliRawEvent;
+    fEvent = NULL;
+    fEventHeader = NULL;
     Long64_t treeEntry = fChain->LoadTree(fEventIndex+1);
     if (!fBranch)
       return kFALSE;
     if (fBranch->GetEntry(treeEntry) <= 0)
       return kFALSE;
+    fEventHeader = fEvent->GetHeader();
     fEventIndex++;
   } while (!IsEventSelected());
   fEventNumber++;
@@ -255,7 +307,8 @@ Bool_t AliRawReaderChain::RewindEvents()
 
   fEventIndex = -1;
   delete fEvent;
-  fEvent = new AliRawEvent;
+  fEvent = NULL;
+  fEventHeader = NULL;
   fEventNumber = -1;
   return Reset();
 }
@@ -269,12 +322,14 @@ Bool_t  AliRawReaderChain::GotoEvent(Int_t event)
   if (!fChain || !fChain->GetListOfFiles()->GetEntriesFast()) return kFALSE;
 
   delete fEvent;
-  fEvent = new AliRawEvent;
+  fEvent = NULL;
+  fEventHeader = NULL;
   Long64_t treeEntry = fChain->LoadTree(event);
    if (!fBranch)
     return kFALSE;
   if (fBranch->GetEntry(treeEntry) <= 0)
     return kFALSE;
+  fEventHeader = fEvent->GetHeader();
   fEventIndex = event;
   fEventNumber++;
   return Reset();