Standard connection to ESD in chain.
[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>
20#include <TH1.h>
21
22#include "AliAnalysisTaskJets.h"
23#include "AliJetFinder.h"
24#include "AliESD.h"
25
26ClassImp(AliAnalysisTaskJets)
27
28////////////////////////////////////////////////////////////////////////
29
19e6695b 30AliAnalysisTaskJets::AliAnalysisTaskJets():
31 fDebug(0),
32 fJetFinder(0x0),
33 fChain(0x0),
eaabc21f 34 fESD(0x0),
35 fTreeJ(0x0)
19e6695b 36{
37 // Default constructor
38}
39
e5b96aa0 40AliAnalysisTaskJets::AliAnalysisTaskJets(const char* name):
41 AliAnalysisTask(name, "AnalysisTaskJets"),
68093d75 42 fDebug(0),
e5b96aa0 43 fJetFinder(0x0),
44 fChain(0x0),
eaabc21f 45 fESD(0x0),
46 fTreeJ(0x0)
e5b96aa0 47{
48 // Default constructor
49 DefineInput (0, TChain::Class());
eaabc21f 50 DefineOutput(0, TTree::Class());
51}
52
53void AliAnalysisTaskJets::CreateOutputObjects()
54{
55// Create the output container
56 fTreeJ = fJetFinder->MakeTreeJ("TreeJ");
e5b96aa0 57}
58
19e6695b 59void AliAnalysisTaskJets::Init()
e5b96aa0 60{
19e6695b 61 // Initialization
62 if (fDebug > 1) printf("AnalysisTaskJets::Init() \n");
eaabc21f 63
e5b96aa0 64 // Call configuration file
65 gROOT->LoadMacro("ConfigJetAnalysis.C");
66 fJetFinder = (AliJetFinder*) gInterpreter->ProcessLine("ConfigJetAnalysis()");
67 // Initialise Jet Analysis
68 fJetFinder->Init();
19e6695b 69}
70
71void AliAnalysisTaskJets::ConnectInputData(Option_t */*option*/)
72{
73// Connect the input data
74//
75 if (fDebug > 1) printf("AnalysisTaskJets::ConnectInputData() \n");
f3f3617d 76 char ** address = (char **)GetBranchAddress(0, "ESD");
77
78 if (address) {
79 fESD = (AliESD*)(*address);
80 }
81 else {
82 fESD = new AliESD();
83 SetBranchAddress(0, "ESD", &fESD); // first task taking the branch enables it
84 }
e5b96aa0 85 fChain = (TChain*)GetInputData(0);
f3f3617d 86 fJetFinder->ConnectTree(fChain, fESD);
e5b96aa0 87 fJetFinder->WriteHeaders();
88}
89
90void AliAnalysisTaskJets::Exec(Option_t */*option*/)
91{
92// Execute analysis for current event
93//
94 Long64_t ientry = fChain->GetReadEntry();
eaabc21f 95 if (fDebug > 1) printf("Analysing event # %5d \n", (Int_t) ientry);
e5b96aa0 96 fJetFinder->ProcessEvent(ientry);
eaabc21f 97 PostData(0, fTreeJ);
e5b96aa0 98}
99
100void AliAnalysisTaskJets::Terminate(Option_t */*option*/)
101{
102// Terminate analysis
103//
19e6695b 104 if (fDebug > 1) printf("AnalysisJets: Terminate() \n");
eaabc21f 105
68093d75 106 if (fJetFinder) fJetFinder->FinishRun();
e5b96aa0 107}
108