Change of getter in AliAnalysisManager
[u/mrichter/AliRoot.git] / JETAN / AliAnalysisTaskJets.cxx
index 5ec6b6ad51db8becb339c5415a7592058726ae11..3e718ed1a704d20448619fd8360dc7078feb66a8 100644 (file)
 #include <TSystem.h>
 #include <TInterpreter.h>
 #include <TChain.h>
+#include <TFile.h>
 #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)
 
@@ -32,7 +39,9 @@ AliAnalysisTaskJets::AliAnalysisTaskJets():
     fJetFinder(0x0),
     fChain(0x0),
     fESD(0x0),
-    fTreeJ(0x0)
+    fAOD(0x0),
+    fTreeA(0x0),
+    fHisto(0x0)
 {
   // Default constructor
 }
@@ -43,17 +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
-    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()
@@ -66,27 +90,34 @@ void AliAnalysisTaskJets::Init()
     fJetFinder = (AliJetFinder*) gInterpreter->ProcessLine("ConfigJetAnalysis()");
     // Initialise Jet Analysis
     fJetFinder->Init();
+    // Write header information to local file
+    fJetFinder->WriteHeaders();
 }
 
 void AliAnalysisTaskJets::ConnectInputData(Option_t */*option*/)
 {
 // Connect the input data
-//
     if (fDebug > 1) printf("AnalysisTaskJets::ConnectInputData() \n");
-    
     fChain = (TChain*)GetInputData(0);
-    fJetFinder->ConnectTree(fChain);
-    fJetFinder->WriteHeaders();
+    fESD = new AliESDEvent();
+    fESD->ReadFromTree(fChain);
+    fJetFinder->ConnectTree(fChain, fESD);
 }
 
 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);
+    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*/)
@@ -94,7 +125,6 @@ void AliAnalysisTaskJets::Terminate(Option_t */*option*/)
 // Terminate analysis
 //
     if (fDebug > 1) printf("AnalysisJets: Terminate() \n");
-   
-    if (fJetFinder) fJetFinder->FinishRun();
+    // if (fJetFinder) fJetFinder->FinishRun();
 }