]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ANALYSIS/AliEventPoolLoop.cxx
including new Salvatore's patch
[u/mrichter/AliRoot.git] / ANALYSIS / AliEventPoolLoop.cxx
index f16128b59fc15b2e8a99aad1063e44f7f304c518..b4d6b54d3835fadda4135cb95b6a8abf86bb533e 100644 (file)
@@ -24,6 +24,9 @@
 
 
 #include "AliEventPoolLoop.h"
+#include <TChain.h>
+#include <TFile.h>
+#include <TObjArray.h>
 
 ClassImp(AliEventPoolLoop)
 
@@ -33,7 +36,8 @@ ClassImp(AliEventPoolLoop)
 AliEventPoolLoop::AliEventPoolLoop():
     AliVEventPool(),
     fMaxIterations(0),
-    fNIteration(0)
+    fNIteration(1),
+    fChainClone(0)
 {
   // Default constructor
 }
@@ -41,7 +45,8 @@ AliEventPoolLoop::AliEventPoolLoop():
 AliEventPoolLoop::AliEventPoolLoop(Int_t nit):
     AliVEventPool(),
     fMaxIterations(nit),
-    fNIteration(0)
+    fNIteration(1),
+    fChainClone(0)
 {
   // Default constructor
 }
@@ -49,7 +54,8 @@ AliEventPoolLoop::AliEventPoolLoop(Int_t nit):
 AliEventPoolLoop::AliEventPoolLoop(const char* name, const char* title):
     AliVEventPool(name, title),
     fMaxIterations(0),
-    fNIteration(0)
+    fNIteration(1),
+    fChainClone(0)
 {
   // Constructor
 }
@@ -58,7 +64,8 @@ AliEventPoolLoop::AliEventPoolLoop(const char* name, const char* title):
 AliEventPoolLoop::AliEventPoolLoop(const AliEventPoolLoop& obj):
     AliVEventPool(obj),
     fMaxIterations(obj.fMaxIterations),
-    fNIteration(obj.fNIteration)
+    fNIteration(obj.fNIteration),
+    fChainClone(0)
 {
     // Copy constructor
 }
@@ -78,17 +85,34 @@ void AliEventPoolLoop::Init()
 // Initialisation
 
     fMaxIterations = 0;
-    fNIteration    = 0;
+    fNIteration    = 1;
 }
 
 TChain* AliEventPoolLoop::GetNextChain()
 {
-    //
-    if (fNIteration >= fMaxIterations) {
+    // Get the next chain
+    if (fNIteration > fMaxIterations) {
        return (0);
     } else {
        fNIteration++;
-       return fChain;
+       /*
+       if (fChainClone) {
+         fChainClone->Reset();
+         new (fChainClone) TChain(fChain->GetName());
+       } else {
+         fChainClone = new TChain(fChain->GetName());
+       }
+       TObjArray* files = fChain->GetListOfFiles();
+       Int_t n = files->GetEntriesFast();
+       for (Int_t i = 0; i < n; i++) {
+         TFile* file = (TFile*) (files->At(i));
+         fChainClone->AddFile(file->GetTitle());
+         printf("Adding %s %s %s\n", fChainClone->GetName(), file->GetName(), file->GetTitle());
+
+       }
+       */
+       fChainClone = (TChain*) (fChain->Clone());
+       return fChainClone;
     }
 }