Pass execution mode to event handler.
[u/mrichter/AliRoot.git] / JETAN / AliAnalysisTaskJets.cxx
CommitLineData
e5b96aa0 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16#include <TROOT.h>
17#include <TSystem.h>
18#include <TInterpreter.h>
19#include <TChain.h>
76c48857 20#include <TFile.h>
e5b96aa0 21#include <TH1.h>
22
23#include "AliAnalysisTaskJets.h"
1d27ecd2 24#include "AliAnalysisManager.h"
e5b96aa0 25#include "AliJetFinder.h"
26#include "AliESD.h"
1d27ecd2 27#include "AliAODEvent.h"
28#include "AliAODHandler.h"
29
e5b96aa0 30
31ClassImp(AliAnalysisTaskJets)
32
33////////////////////////////////////////////////////////////////////////
34
19e6695b 35AliAnalysisTaskJets::AliAnalysisTaskJets():
36 fDebug(0),
37 fJetFinder(0x0),
38 fChain(0x0),
eaabc21f 39 fESD(0x0),
1d27ecd2 40 fAOD(0x0),
41 fTreeA(0x0)
19e6695b 42{
43 // Default constructor
44}
45
e5b96aa0 46AliAnalysisTaskJets::AliAnalysisTaskJets(const char* name):
47 AliAnalysisTask(name, "AnalysisTaskJets"),
68093d75 48 fDebug(0),
e5b96aa0 49 fJetFinder(0x0),
50 fChain(0x0),
eaabc21f 51 fESD(0x0),
1d27ecd2 52 fAOD(0x0),
53 fTreeA(0x0)
e5b96aa0 54{
55 // Default constructor
56 DefineInput (0, TChain::Class());
eaabc21f 57 DefineOutput(0, TTree::Class());
58}
59
60void AliAnalysisTaskJets::CreateOutputObjects()
61{
62// Create the output container
76c48857 63 OpenFile(0);
1d27ecd2 64 AliAODHandler* handler = (AliAODHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetEventHandler());
65
66 fAOD = handler->GetAOD();
67 fTreeA = handler->GetTree();
68 fJetFinder->ConnectAOD(fAOD);
e5b96aa0 69}
70
19e6695b 71void AliAnalysisTaskJets::Init()
e5b96aa0 72{
19e6695b 73 // Initialization
74 if (fDebug > 1) printf("AnalysisTaskJets::Init() \n");
eaabc21f 75
e5b96aa0 76 // Call configuration file
77 gROOT->LoadMacro("ConfigJetAnalysis.C");
78 fJetFinder = (AliJetFinder*) gInterpreter->ProcessLine("ConfigJetAnalysis()");
79 // Initialise Jet Analysis
80 fJetFinder->Init();
76c48857 81 // Write header information to local file
82 fJetFinder->WriteHeaders();
19e6695b 83}
84
85void AliAnalysisTaskJets::ConnectInputData(Option_t */*option*/)
86{
87// Connect the input data
88//
89 if (fDebug > 1) printf("AnalysisTaskJets::ConnectInputData() \n");
76c48857 90 fChain = (TChain*)GetInputData(0);
f3f3617d 91
76c48857 92 char ** address = (char **)GetBranchAddress(0, "ESD");
f3f3617d 93 if (address) {
76c48857 94
95// Branch has been already connected
f3f3617d 96 fESD = (AliESD*)(*address);
97 }
98 else {
76c48857 99// First task taking the branch enables it
f3f3617d 100 fESD = new AliESD();
76c48857 101 SetBranchAddress(0, "ESD", &fESD);
f3f3617d 102 }
76c48857 103
f3f3617d 104 fJetFinder->ConnectTree(fChain, fESD);
e5b96aa0 105}
106
107void AliAnalysisTaskJets::Exec(Option_t */*option*/)
108{
109// Execute analysis for current event
110//
111 Long64_t ientry = fChain->GetReadEntry();
76c48857 112 if (fDebug > 1) printf("Analysing event # %5d\n", (Int_t) ientry);
e5b96aa0 113 fJetFinder->ProcessEvent(ientry);
1d27ecd2 114 PostData(0, fTreeA);
e5b96aa0 115}
116
117void AliAnalysisTaskJets::Terminate(Option_t */*option*/)
118{
119// Terminate analysis
120//
19e6695b 121 if (fDebug > 1) printf("AnalysisJets: Terminate() \n");
76c48857 122 // if (fJetFinder) fJetFinder->FinishRun();
e5b96aa0 123}
124