Corrections for reconnection of event in case of event mixing.
authormorsch <morsch@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 3 Sep 2010 21:20:02 +0000 (21:20 +0000)
committermorsch <morsch@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 3 Sep 2010 21:20:02 +0000 (21:20 +0000)
ANALYSIS/AliMultiEventInputHandler.cxx
ANALYSIS/AliMultiEventInputHandler.h
STEER/AliAODEvent.cxx
STEER/AliESDEvent.cxx

index aec7d51..4ff7c8a 100644 (file)
@@ -29,6 +29,8 @@
 #include "AliLog.h"
 #include <TObjArray.h>
 #include <TTree.h>
+#include <TList.h>
+#include <TEntryList.h>
 
 
 ClassImp(AliMultiEventInputHandler)
@@ -40,6 +42,8 @@ AliMultiEventInputHandler::AliMultiEventInputHandler() :
     fNBuffered(0),
     fIndex(0),
     fCurrentBin(0),
+    fCurrentEvt(0),
+    fInit(0),
     fEventPool(0),
     fEventBuffer(0)
 {
@@ -54,6 +58,8 @@ AliMultiEventInputHandler::AliMultiEventInputHandler(Int_t size, Int_t format) :
     fNBuffered(0),
     fIndex(0),
     fCurrentBin(0),
+    fCurrentEvt(0),
+    fInit(0),
     fEventPool(0),
     fEventBuffer(0)
 {
@@ -68,6 +74,8 @@ AliMultiEventInputHandler::AliMultiEventInputHandler(const char* name, const cha
     fNBuffered(0),
     fIndex(0),
     fCurrentBin(0),
+    fCurrentEvt(0),
+    fInit(0),
     fEventPool(0),
     fEventBuffer(0)
 {
@@ -99,6 +107,8 @@ Bool_t AliMultiEventInputHandler::Init(TTree* tree, Option_t* /*opt*/)
     
 
     fTree = tree;
+    fInit = 1;
+    
     if (!fTree) return kFALSE;
     for (Int_t i = 0; i < fBufferSize; i++) 
        fEventBuffer[i]->Clear();
@@ -111,18 +121,16 @@ Bool_t AliMultiEventInputHandler::Init(TTree* tree, Option_t* /*opt*/)
 Bool_t AliMultiEventInputHandler::Notify(const char */*path*/)
 {
     // Connect to new tree
-
-       
-    static Bool_t first = kTRUE;
-    
-    
-    if (first) {
-       fEventBuffer[0]->ReadFromTree(fTree, "");
-       first = kFALSE;
-    } else {
+    TList* connectedList = (TList*) (fTree->GetUserInfo()->FindObject("AODObjectsConnectedToTree"));   
+    if (connectedList && !fInit) {
        fEventBuffer[0]->ReadFromTree(fTree, "reconnect");
+    } else {
+       if (fInit) fEventBuffer[0]->ReadFromTree(fTree, "");
     }
     
+    fCurrentEvt = 0;
+    fInit = 0;
     
     return (kTRUE);
 }
@@ -148,11 +156,29 @@ Bool_t AliMultiEventInputHandler::FinishEvent()
     fIndex %= fBufferSize;
     AliInfo(Form("Connecting buffer entry %5d", fIndex));
     fEventBuffer[fIndex]->Clear();
+    fCurrentEvt++;
+    if (fEventBuffer[fIndex]->GetList() && fCurrentEvt > (fBufferSize - 1))
+       fEventBuffer[fIndex]->GetList()->Delete();
+
     fEventBuffer[fIndex]->ReadFromTree(fTree, "reconnect");
 
     fNBuffered++;
     if (fNBuffered > fBufferSize) fNBuffered = fBufferSize;
 
+    Int_t nmax = fTree->GetEntries();
+    if (fTree->GetEntryList()) {
+       nmax = (fTree->GetEntryList()->GetN());
+    } else {
+       if (fTree->GetTree()) nmax = fTree->GetTree()->GetEntries();
+    }
+    
+    if (fCurrentEvt == nmax)
+    {
+       for (Int_t i = 0; i < fBufferSize; i++) {
+           fEventBuffer[i]->Clear();
+       }
+    }
+    
     return (kTRUE);
 }
 
index ac8d491..baaaee6 100644 (file)
@@ -49,6 +49,8 @@ class AliMultiEventInputHandler : public AliInputEventHandler {
     Int_t          fNBuffered;    // Number of events actually buffered
     Int_t          fIndex;        // Pointer to most recent event
     Int_t          fCurrentBin;   // Current bin from the pool
+    Int_t          fCurrentEvt;   // Current event
+    Bool_t         fInit;         // Current event
     AliVEventPool* fEventPool;    // Pointer to the pool
     AliVEvent**    fEventBuffer;  //! The event buffer
     ClassDef(AliMultiEventInputHandler, 1);
index b8816c6..350f99f 100644 (file)
@@ -527,15 +527,15 @@ void AliAODEvent::ReadFromTree(TTree *tree, Option_t* opt /*= ""*/)
     TList* connectedList = (TList*) (tree->GetUserInfo()->FindObject("AODObjectsConnectedToTree"));
     if (connectedList && (strcmp(opt, "reconnect"))) {
         // If connected use the connected list of objects
-      fAODObjects->Delete();
-      fAODObjects = connectedList;
-      GetStdContent(); 
-      fConnected = kTRUE;
-      return;
+       fAODObjects->Delete();
+       fAODObjects = connectedList;
+       GetStdContent(); 
+       fConnected = kTRUE;
+       return;
     } 
       // Connect to tree
       // prevent a memory leak when reading back the TList
-      // if (!(strcmp(opt, "reconnect"))) fAODObjects->Delete();
+//      if (!(strcmp(opt, "reconnect"))) fAODObjects->Delete();
     
       // create a new TList from the UserInfo TList... 
       // copy constructor does not work...
index 7f5af67..5951b71 100644 (file)
@@ -1349,7 +1349,7 @@ void AliESDEvent::ReadFromTree(TTree *tree, Option_t* opt){
 
     // Connect to tree
     // prevent a memory leak when reading back the TList
-    if (!(strcmp(opt, "reconnect"))) fESDObjects->Delete();
+    // if (!(strcmp(opt, "reconnect"))) fESDObjects->Delete();
     
     if(!fUseOwnList){
       // create a new TList from the UserInfo TList...