]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliAODHandler.cxx
Improvement of AliACORDEv1 class
[u/mrichter/AliRoot.git] / STEER / AliAODHandler.cxx
index a4b3a1f695c0f6ffd62374679e2a0d6a74e477c3..cb7a5126ecf9d7bec834bb2c683d1fb21ae28119 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <TTree.h>
 #include <TFile.h>
+#include <TString.h>
 
 #include "AliAODHandler.h"
 #include "AliAODEvent.h"
@@ -33,10 +34,11 @@ ClassImp(AliAODHandler)
 AliAODHandler::AliAODHandler() :
     AliVEventHandler(),
     fIsStandard(kTRUE),
+    fNeedsHeaderReplication(kFALSE),
     fAODEvent(NULL),
     fTreeA(NULL),
     fFileA(NULL),
-    fName("")
+    fFileName("")
 {
   // default constructor
 }
@@ -45,10 +47,11 @@ AliAODHandler::AliAODHandler() :
 AliAODHandler::AliAODHandler(const char* name, const char* title):
     AliVEventHandler(name, title),
     fIsStandard(kTRUE),
+    fNeedsHeaderReplication(kFALSE),
     fAODEvent(NULL),
     fTreeA(NULL),
     fFileA(NULL),
-    fName("")
+    fFileName("")
 {
 }
 
@@ -62,11 +65,10 @@ AliAODHandler::~AliAODHandler()
     delete fFileA;
   }
   delete fTreeA;
-  delete fName;
  // destructor
 }
 
-
+//______________________________________________________________________________
 Bool_t AliAODHandler::Init(Option_t* opt)
 {
   // Initialize IO
@@ -78,14 +80,22 @@ Bool_t AliAODHandler::Init(Option_t* opt)
   }
   //
   // File opening according to execution mode
-  
-  if (!(strcmp(opt, "proof"))) {
+  TString option(opt);
+  option.ToLower();
+  if (option.Contains("proof")) {
     // proof
-    CreateTree(0);
+    if (option.Contains("special")) {
+       // File for tree already opened on slave -> merging via files
+       fFileA = gFile;
+       CreateTree(1);
+    } else {   
+       // Merging in memory
+       CreateTree(0);
+    }   
   } else {
     // local and grid
     TDirectory *owd = gDirectory;
-    fFileA = new TFile(fName, "RECREATE");
+    fFileA = new TFile(fFileName.Data(), "RECREATE");
     CreateTree(1);
     owd->cd();
   }
@@ -101,6 +111,7 @@ Bool_t AliAODHandler::FinishEvent()
     return kTRUE;
 }
 
+//______________________________________________________________________________
 Bool_t AliAODHandler::Terminate()
 {
     // Terminate 
@@ -108,6 +119,7 @@ Bool_t AliAODHandler::Terminate()
     return kTRUE;
 }
 
+//______________________________________________________________________________
 Bool_t AliAODHandler::TerminateIO()
 {
     // Terminate IO
@@ -118,7 +130,7 @@ Bool_t AliAODHandler::TerminateIO()
     return kTRUE;
 }
 
-
+//______________________________________________________________________________
 void AliAODHandler::CreateTree(Int_t flag)
 {
     // Creates the AOD Tree
@@ -127,19 +139,21 @@ void AliAODHandler::CreateTree(Int_t flag)
     if (flag == 0) fTreeA->SetDirectory(0);
 }
 
+//______________________________________________________________________________
 void AliAODHandler::FillTree()
 {
     // Fill the AOD Tree
     fTreeA->Fill();
 }
 
-
+//______________________________________________________________________________
 void AliAODHandler::AddAODtoTreeUserInfo()
 {
     // Add aod event to tree user info
     fTreeA->GetUserInfo()->Add(fAODEvent);
 }
 
+//______________________________________________________________________________
 void AliAODHandler::AddBranch(const char* cname, void* addobj)
 {
     // Add a new branch to the aod 
@@ -153,3 +167,17 @@ void AliAODHandler::AddBranch(const char* cname, void* addobj)
     fAODEvent->AddObject(obj);
     owd->cd();
 }
+
+//______________________________________________________________________________
+void AliAODHandler::SetOutputFileName(const char* fname)
+{
+// Set file name.
+   fFileName = fname;
+}
+
+//______________________________________________________________________________
+const char *AliAODHandler::GetOutputFileName()
+{
+// Get file name.
+   return fFileName.Data();
+}