Change of getter in AliAnalysisManager
[u/mrichter/AliRoot.git] / JETAN / AliAnalysisTaskJets.cxx
index 674cec0abcaab85d0404fea3a4b4daf137709772..3e718ed1a704d20448619fd8360dc7078feb66a8 100644 (file)
 #include "AliAnalysisTaskJets.h"
 #include "AliAnalysisManager.h"
 #include "AliJetFinder.h"
-#include "AliESD.h"
+#include "AliESDEvent.h"
 #include "AliAODEvent.h"
 #include "AliAODHandler.h"
+#include "AliMCEventHandler.h"
+#include "AliStack.h"
 
 
 ClassImp(AliAnalysisTaskJets)
@@ -65,7 +67,9 @@ void AliAnalysisTaskJets::CreateOutputObjects()
 // Create the output container
 //
 //  Default AOD
-    AliAODHandler* handler = (AliAODHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetEventHandler());
+    if (fDebug > 1) printf("AnalysisTaskJets::CreateOutPutData() \n");
+    AliAODHandler* handler = (AliAODHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
+    
     fAOD   = handler->GetAOD();
     fTreeA = handler->GetTree();
     fJetFinder->ConnectAOD(fAOD);
@@ -73,6 +77,7 @@ void AliAnalysisTaskJets::CreateOutputObjects()
 //  Histogram
     OpenFile(1);
     fHisto = new TH1F("fHisto", "Jet Et", 100, 0., 100.);
+    
 }
 
 void AliAnalysisTaskJets::Init()
@@ -92,22 +97,10 @@ void AliAnalysisTaskJets::Init()
 void AliAnalysisTaskJets::ConnectInputData(Option_t */*option*/)
 {
 // Connect the input data
-//
     if (fDebug > 1) printf("AnalysisTaskJets::ConnectInputData() \n");
     fChain = (TChain*)GetInputData(0);
-
-    char ** address = (char **)GetBranchAddress(0, "ESD");
-    if (address)     {
-       
-// Branch has been already connected
-       fESD = (AliESD*)(*address);
-    }
-    else     {
-// First task taking the branch enables it
-       fESD = new AliESD();
-       SetBranchAddress(0, "ESD", &fESD);
-    }
-    
+    fESD = new AliESDEvent();
+    fESD->ReadFromTree(fChain);
     fJetFinder->ConnectTree(fChain, fESD);
 }
 
@@ -115,6 +108,11 @@ void AliAnalysisTaskJets::Exec(Option_t */*option*/)
 {
 // Execute analysis for current event
 //
+    AliMCEventHandler*    mctruth = (AliMCEventHandler*) 
+       ((AliAnalysisManager::GetAnalysisManager())->GetMCtruthEventHandler());
+    AliStack* stack = mctruth->Stack();
+    printf("AliAnalysisTaskJets: Number of tracks %5d\n", stack->GetNtrack());
+
     Long64_t ientry = fChain->GetReadEntry();
     if (fDebug > 1) printf("Analysing event # %5d\n", (Int_t) ientry);
     fJetFinder->ProcessEvent(ientry);