Change of getter in AliAnalysisManager
[u/mrichter/AliRoot.git] / JETAN / AliAnalysisTaskJets.cxx
index 7c12a94fff177c67e3e022f8684191f5d92ac071..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)
 
 ////////////////////////////////////////////////////////////////////////
 
+AliAnalysisTaskJets::AliAnalysisTaskJets():
+    fDebug(0),
+    fJetFinder(0x0),
+    fChain(0x0),
+    fESD(0x0),
+    fAOD(0x0),
+    fTreeA(0x0),
+    fHisto(0x0)
+{
+  // Default constructor
+}
+
 AliAnalysisTaskJets::AliAnalysisTaskJets(const char* name):
     AliAnalysisTask(name, "AnalysisTaskJets"),
     fDebug(0),
     fJetFinder(0x0),
     fChain(0x0),
-    fESD(0x0)
+    fESD(0x0),
+    fAOD(0x0),
+    fTreeA(0x0),
+    fHisto(0x0)
 {
   // Default constructor
     DefineInput (0, TChain::Class());
-    DefineOutput(0, TH1::Class());
+    DefineOutput(0, TTree::Class());
+    DefineOutput(1, TH1F::Class());
 }
 
-void AliAnalysisTaskJets::ConnectInputData(Option_t */*option*/)
+void AliAnalysisTaskJets::CreateOutputObjects()
 {
-// Initialisation
+// Create the output container
 //
-    if (fDebug > 1) printf("AnalysisJets::Init() \n");
+//  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()
+{
+    // Initialization
+    if (fDebug > 1) printf("AnalysisTaskJets::Init() \n");
 
     // Call configuration file
     gROOT->LoadMacro("ConfigJetAnalysis.C");
     fJetFinder = (AliJetFinder*) gInterpreter->ProcessLine("ConfigJetAnalysis()");
     // Initialise Jet Analysis
     fJetFinder->Init();
-    fChain = (TChain*)GetInputData(0);
-    fJetFinder->ConnectTree(fChain);
+    // 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);
+    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, fTreeA);
+    PostData(1, fHisto);
 }
 
 void AliAnalysisTaskJets::Terminate(Option_t */*option*/)
 {
 // Terminate analysis
 //
-    printf("AnalysisJets: Terminate() \n");
-    if (fJetFinder) fJetFinder->FinishRun();
+    if (fDebug > 1) printf("AnalysisJets: Terminate() \n");
+    // if (fJetFinder) fJetFinder->FinishRun();
 }