]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - RAW/AliRawReaderChain.cxx
Adding functionality to visualize result for defferent setttings (Marian)
[u/mrichter/AliRoot.git] / RAW / AliRawReaderChain.cxx
index bb774b1261a541fd0e74d0070c17ca31bac75173..0739551e8f036d1d239688be350b0bf158a9ce72 100644 (file)
@@ -53,14 +53,12 @@ AliRawReaderChain::AliRawReaderChain(const char* listFileName) :
   fChain = new TChain("RAW");
   if (!fChain->AddFileInfoList((TCollection*)(collection.GetList()))) {
     Error("AliRawReaderChain","Bad file list in collection, the chain is empty");
+    fIsValid = kFALSE;
     return;
   }
 
-  fChain->SetBranchStatus("*",0);
-  fChain->SetBranchStatus("rawevent",1);
-
-  fEvent = new AliRawEvent;
-  fChain->SetBranchAddress("rawevent", &fEvent);
+  fChain->SetBranchStatus("*",1);
+  fChain->SetBranchAddress("rawevent",&fEvent,&fBranch);
 }
 
 AliRawReaderChain::AliRawReaderChain(TFileCollection *collection) :
@@ -73,14 +71,25 @@ AliRawReaderChain::AliRawReaderChain(TFileCollection *collection) :
   fChain = new TChain("RAW");
   if (!fChain->AddFileInfoList((TCollection*)(collection->GetList()))) {
     Error("AliRawReaderChain","Bad file list in collection, the chain is empty");
+    fIsValid = kFALSE;
     return;
   }
 
-  fChain->SetBranchStatus("*",0);
-  fChain->SetBranchStatus("rawevent",1);
+  fChain->SetBranchStatus("*",1);
+  fChain->SetBranchAddress("rawevent",&fEvent,&fBranch);
+}
 
-  fEvent = new AliRawEvent;
-  fChain->SetBranchAddress("rawevent", &fEvent);
+AliRawReaderChain::AliRawReaderChain(TChain *chain) :
+  AliRawReaderRoot(),
+  fChain(chain)
+{
+// create raw-reader objects which takes as an input a root chain
+// from a root file collection
+
+  if (!fChain) fIsValid = kFALSE;
+
+  fChain->SetBranchStatus("*",1);
+  fChain->SetBranchAddress("rawevent",&fEvent,&fBranch);
 }
 
 AliRawReaderChain::AliRawReaderChain(const AliRawReaderChain& rawReader) :
@@ -119,7 +128,10 @@ Bool_t AliRawReaderChain::NextEvent()
   do {
     delete fEvent;
     fEvent = new AliRawEvent;
-    if (fChain->GetEntry(fEventIndex+1) <= 0)
+    Long64_t treeEntry = fChain->LoadTree(fEventIndex+1);
+    if (!fBranch)
+      return kFALSE;
+    if (fBranch->GetEntry(treeEntry) <= 0)
       return kFALSE;
     fEventIndex++;
   } while (!IsEventSelected());
@@ -137,3 +149,33 @@ Bool_t AliRawReaderChain::RewindEvents()
   fEventNumber = -1;
   return Reset();
 }
+
+Bool_t  AliRawReaderChain::GotoEvent(Int_t event)
+{
+  // go to a particular event
+  // Uses the absolute event index inside the
+  // chain with raw data
+
+  if (!fChain || !fChain->GetListOfFiles()->GetEntriesFast()) return kFALSE;
+
+  delete fEvent;
+  fEvent = new AliRawEvent;
+  Long64_t treeEntry = fChain->LoadTree(event);
+   if (!fBranch)
+    return kFALSE;
+  if (fBranch->GetEntry(treeEntry) <= 0)
+    return kFALSE;
+  fEventIndex = event;
+  fEventNumber++;
+  return Reset();
+}
+
+Int_t AliRawReaderChain::GetNumberOfEvents() const
+{
+  // Get the total number of events in the chain
+  // of raw-data files
+
+  if (!fChain) return -1;
+
+  return fChain->GetEntries();
+}