Moved to gain folder (Basanta)
[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),
aa049fb2 41 fTreeA(0x0),
42 fHisto(0x0)
19e6695b 43{
44 // Default constructor
45}
46
e5b96aa0 47AliAnalysisTaskJets::AliAnalysisTaskJets(const char* name):
48 AliAnalysisTask(name, "AnalysisTaskJets"),
68093d75 49 fDebug(0),
e5b96aa0 50 fJetFinder(0x0),
51 fChain(0x0),
eaabc21f 52 fESD(0x0),
1d27ecd2 53 fAOD(0x0),
aa049fb2 54 fTreeA(0x0),
55 fHisto(0x0)
e5b96aa0 56{
57 // Default constructor
58 DefineInput (0, TChain::Class());
eaabc21f 59 DefineOutput(0, TTree::Class());
aa049fb2 60 DefineOutput(1, TH1F::Class());
eaabc21f 61}
62
63void AliAnalysisTaskJets::CreateOutputObjects()
64{
65// Create the output container
aa049fb2 66//
67// Default AOD
1d27ecd2 68 AliAODHandler* handler = (AliAODHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetEventHandler());
1d27ecd2 69 fAOD = handler->GetAOD();
70 fTreeA = handler->GetTree();
71 fJetFinder->ConnectAOD(fAOD);
aa049fb2 72//
73// Histogram
74 OpenFile(1);
75 fHisto = new TH1F("fHisto", "Jet Et", 100, 0., 100.);
e5b96aa0 76}
77
19e6695b 78void AliAnalysisTaskJets::Init()
e5b96aa0 79{
19e6695b 80 // Initialization
81 if (fDebug > 1) printf("AnalysisTaskJets::Init() \n");
eaabc21f 82
e5b96aa0 83 // Call configuration file
84 gROOT->LoadMacro("ConfigJetAnalysis.C");
85 fJetFinder = (AliJetFinder*) gInterpreter->ProcessLine("ConfigJetAnalysis()");
86 // Initialise Jet Analysis
87 fJetFinder->Init();
76c48857 88 // Write header information to local file
89 fJetFinder->WriteHeaders();
19e6695b 90}
91
92void AliAnalysisTaskJets::ConnectInputData(Option_t */*option*/)
93{
94// Connect the input data
95//
96 if (fDebug > 1) printf("AnalysisTaskJets::ConnectInputData() \n");
76c48857 97 fChain = (TChain*)GetInputData(0);
f3f3617d 98
76c48857 99 char ** address = (char **)GetBranchAddress(0, "ESD");
f3f3617d 100 if (address) {
76c48857 101
102// Branch has been already connected
f3f3617d 103 fESD = (AliESD*)(*address);
104 }
105 else {
76c48857 106// First task taking the branch enables it
f3f3617d 107 fESD = new AliESD();
76c48857 108 SetBranchAddress(0, "ESD", &fESD);
f3f3617d 109 }
76c48857 110
f3f3617d 111 fJetFinder->ConnectTree(fChain, fESD);
e5b96aa0 112}
113
114void AliAnalysisTaskJets::Exec(Option_t */*option*/)
115{
116// Execute analysis for current event
117//
118 Long64_t ientry = fChain->GetReadEntry();
76c48857 119 if (fDebug > 1) printf("Analysing event # %5d\n", (Int_t) ientry);
e5b96aa0 120 fJetFinder->ProcessEvent(ientry);
1d27ecd2 121 PostData(0, fTreeA);
aa049fb2 122 PostData(1, fHisto);
e5b96aa0 123}
124
125void AliAnalysisTaskJets::Terminate(Option_t */*option*/)
126{
127// Terminate analysis
128//
19e6695b 129 if (fDebug > 1) printf("AnalysisJets: Terminate() \n");
76c48857 130 // if (fJetFinder) fJetFinder->FinishRun();
e5b96aa0 131}
132