]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliESDInputHandler.cxx
Typo fixed + warnings removed.
[u/mrichter/AliRoot.git] / STEER / AliESDInputHandler.cxx
index 815aa394203ab9ccaf0dd81e1e21988a1777e68e..d2ab9338d029a98147b563c9dbd71b1575fbf985 100644 (file)
 
 ClassImp(AliESDInputHandler)
 
+static Option_t *gESDDataType = "ESD";
+
 //______________________________________________________________________________
 AliESDInputHandler::AliESDInputHandler() :
   AliInputEventHandler(),
   fEvent(0x0),
-  fBranches(""),
-  fBranchesOn(""),
   fAnalysisType(0),
+  fNEvents(0),
+  fHLTEvent(0x0),
+  fHLTTree(0x0),
+  fUseHLT(kFALSE),
   fUseTags(kFALSE),
   fChainT(0),
   fTreeT(0),
@@ -63,8 +67,8 @@ AliESDInputHandler::~AliESDInputHandler()
 
 //______________________________________________________________________________
 AliESDInputHandler::AliESDInputHandler(const char* name, const char* title):
-    AliInputEventHandler(name, title), fEvent(0x0), fBranches(""), fBranchesOn(""), fAnalysisType(0),
-     fUseTags(kFALSE), fChainT(0), fTreeT(0), fRunTag(0)
+    AliInputEventHandler(name, title), fEvent(0x0), fAnalysisType(0),
+     fNEvents(0),  fHLTEvent(0x0), fHLTTree(0x0), fUseHLT(kFALSE), fUseTags(kFALSE), fChainT(0), fTreeT(0), fRunTag(0)
 {
     // Constructor
 }
@@ -76,21 +80,21 @@ Bool_t AliESDInputHandler::Init(TTree* tree,  Option_t* opt)
     fTree         = tree;
     
     if (!fTree) return kFALSE;
+    fTree->GetEntry(0);
+    
     // Get pointer to ESD event
     SwitchOffBranches();
     SwitchOnBranches();
     
-    if (fEvent) {
-      delete fEvent;
-      fEvent = 0;
-    }
-    fEvent = new AliESDEvent();
-
+    if (!fEvent) fEvent = new AliESDEvent();
     fEvent->ReadFromTree(fTree);
+    fNEvents = fTree->GetEntries();
+
+
     return kTRUE;
 }
 
-Bool_t AliESDInputHandler::BeginEvent(Long64_t /*entry*/)
+Bool_t AliESDInputHandler::BeginEvent(Long64_t entry)
 {
     // Copy from old to new format if necessary
   AliESD* old = ((AliESDEvent*) fEvent)->GetAliESDOld();
@@ -98,6 +102,11 @@ Bool_t AliESDInputHandler::BeginEvent(Long64_t /*entry*/)
        ((AliESDEvent*)fEvent)->CopyFromOldESD();
        old->Reset();
   }
+
+  if (fHLTTree) {
+      fHLTTree->GetEntry(entry);
+  }
+  
   return kTRUE;
 }
 
@@ -113,20 +122,31 @@ Bool_t AliESDInputHandler::Notify(const char* path)
     // Notify a directory change
     AliInfo(Form("Directory change %s \n", path));
     //
+    if (fUseHLT) {
+       // Get HLTesdTree from current file
+       TTree* cTree = fTree;
+       if (fTree->GetTree()) cTree = fTree->GetTree();
+       TFile* cFile = cTree->GetCurrentFile();
+       cFile->GetObject("HLTesdTree", fHLTTree);
+       
+       if (fHLTTree) {
+         if (!fHLTEvent) fHLTEvent = new AliESDEvent();
+         fHLTEvent->ReadFromTree(fHLTTree);
+       }
+    }
+
     if (!fUseTags) return (kTRUE);
     
     Bool_t zip = kFALSE;
     
     TString fileName(path);
     if(fileName.Contains("#AliESDs.root")){
-       fileName.ReplaceAll("#AliESDs.root", "");
        zip = kTRUE;
     } 
     else if (fileName.Contains("AliESDs.root")){
        fileName.ReplaceAll("AliESDs.root", "");
     }
     else if(fileName.Contains("#AliAOD.root")){
-       fileName.ReplaceAll("#AliAOD.root", "");
        zip = kTRUE;
     }
     else if(fileName.Contains("AliAOD.root")){
@@ -134,7 +154,6 @@ Bool_t AliESDInputHandler::Notify(const char* path)
     }
     else if(fileName.Contains("#galice.root")){
        // For running with galice and kinematics alone...
-       fileName.ReplaceAll("#galice.root", "");
        zip = kTRUE;
     }
     else if(fileName.Contains("galice.root")){
@@ -149,7 +168,7 @@ Bool_t AliESDInputHandler::Notify(const char* path)
     }
     
     printf("AliESDInputHandler::Notify() Path: %s\n", pathName.Data());
-    
+
     if (fRunTag) {
        fRunTag->Clear();
     } else {
@@ -157,7 +176,7 @@ Bool_t AliESDInputHandler::Notify(const char* path)
     }
     
     delete fTreeT; fTreeT = 0;
-
+    
     if (fChainT) {
        delete fChainT;
        fChainT = 0;
@@ -173,7 +192,7 @@ Bool_t AliESDInputHandler::Notify(const char* path)
     const char* name = 0x0;
     TString tagFilename;
     if (zip) {
-       TFile* file = TFile::Open(fileName.Data());
+       TFile* file = fTree->GetCurrentFile();
        TArchiveFile* arch = file->GetArchive();
        TObjArray* arr = arch->GetMembers();
        TIter next(arr);
@@ -206,31 +225,9 @@ Bool_t AliESDInputHandler::Notify(const char* path)
 }
 
 
-void AliESDInputHandler::SwitchOffBranches() const {
-  //
-  // Switch of branches on user request
-    TObjArray * tokens = fBranches.Tokenize(" ");
-    Int_t ntok = tokens->GetEntries();
-    for (Int_t i = 0; i < ntok; i++)  {
-       TString str = ((TObjString*) tokens->At(i))->GetString();
-       if (str.Length() == 0)
-           continue;
-       fTree->SetBranchStatus(Form("%s%s%s","*", str.Data(), "*"), 0);
-       AliInfo(Form("Branch %s switched off \n", str.Data()));
-    }
-}
 
-void AliESDInputHandler::SwitchOnBranches() const {
-  //
-  // Switch of branches on user request
-  TObjArray * tokens = fBranchesOn.Tokenize(" ");
-  Int_t ntok = tokens->GetEntries();
-
-  for (Int_t i = 0; i < ntok; i++)  {
-      TString str = ((TObjString*) tokens->At(i))->GetString();
-      if (str.Length() == 0)
-         continue;
-      fTree->SetBranchStatus(Form("%s%s%s","*", str.Data(), "*"), 1);
-      AliInfo(Form("Branch %s switched on \n", str.Data()));
-  }
+Option_t *AliESDInputHandler::GetDataType() const
+{
+// Returns handled data type.
+   return gESDDataType;
 }