Change of getter in AliAnalysisManager
[u/mrichter/AliRoot.git] / JETAN / AliAnalysisTaskJets.cxx
index 8b1b75d9df1364c73e45bb4f1433e843d21a27c5..3e718ed1a704d20448619fd8360dc7078feb66a8 100644 (file)
 #include <TH1.h>
 
 #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)
 
@@ -33,7 +39,9 @@ AliAnalysisTaskJets::AliAnalysisTaskJets():
     fJetFinder(0x0),
     fChain(0x0),
     fESD(0x0),
-    fTreeJ(0x0)
+    fAOD(0x0),
+    fTreeA(0x0),
+    fHisto(0x0)
 {
   // Default constructor
 }
@@ -44,18 +52,32 @@ AliAnalysisTaskJets::AliAnalysisTaskJets(const char* name):
     fJetFinder(0x0),
     fChain(0x0),
     fESD(0x0),
-    fTreeJ(0x0)
+    fAOD(0x0),
+    fTreeA(0x0),
+    fHisto(0x0)
 {
   // Default constructor
     DefineInput (0, TChain::Class());
     DefineOutput(0, TTree::Class());
+    DefineOutput(1, TH1F::Class());
 }
 
 void AliAnalysisTaskJets::CreateOutputObjects()
 {
 // Create the output container
-    OpenFile(0);
-    fTreeJ = fJetFinder->MakeTreeJ("TreeJ");
+//
+//  Default AOD
+    if (fDebug > 1) printf("AnalysisTaskJets::CreateOutPutData() \n");
+    AliAODHandler* handler = (AliAODHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
+    
+    fAOD   = handler->GetAOD();
+    fTreeA = handler->GetTree();
+    fJetFinder->ConnectAOD(fAOD);
+//
+//  Histogram
+    OpenFile(1);
+    fHisto = new TH1F("fHisto", "Jet Et", 100, 0., 100.);
+    
 }
 
 void AliAnalysisTaskJets::Init()
@@ -75,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);
 }
 
@@ -98,10 +108,16 @@ 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);
-    PostData(0, fTreeJ);
+    PostData(0, fTreeA);
+    PostData(1, fHisto);
 }
 
 void AliAnalysisTaskJets::Terminate(Option_t */*option*/)