]> git.uio.no Git - u/mrichter/AliRoot.git/blob - JETAN/AliAnalysisTaskJets.cxx
Interfaced to AliAODJet and AliAODHandler.
[u/mrichter/AliRoot.git] / JETAN / AliAnalysisTaskJets.cxx
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 <TFile.h>
21 #include <TH1.h>
22
23 #include "AliAnalysisTaskJets.h"
24 #include "AliAnalysisManager.h"
25 #include "AliJetFinder.h"
26 #include "AliESD.h"
27 #include "AliAODEvent.h"
28 #include "AliAODHandler.h"
29
30
31 ClassImp(AliAnalysisTaskJets)
32
33 ////////////////////////////////////////////////////////////////////////
34
35 AliAnalysisTaskJets::AliAnalysisTaskJets():
36     fDebug(0),
37     fJetFinder(0x0),
38     fChain(0x0),
39     fESD(0x0),
40     fAOD(0x0),
41     fTreeA(0x0)
42 {
43   // Default constructor
44 }
45
46 AliAnalysisTaskJets::AliAnalysisTaskJets(const char* name):
47     AliAnalysisTask(name, "AnalysisTaskJets"),
48     fDebug(0),
49     fJetFinder(0x0),
50     fChain(0x0),
51     fESD(0x0),
52     fAOD(0x0),
53     fTreeA(0x0)
54 {
55   // Default constructor
56     DefineInput (0, TChain::Class());
57     DefineOutput(0, TTree::Class());
58 }
59
60 void AliAnalysisTaskJets::CreateOutputObjects()
61 {
62 // Create the output container
63     OpenFile(0);
64     AliAODHandler* handler = (AliAODHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetEventHandler());
65     
66     fAOD   = handler->GetAOD();
67     fTreeA = handler->GetTree();
68     fJetFinder->ConnectAOD(fAOD);
69 }
70
71 void AliAnalysisTaskJets::Init()
72 {
73     // Initialization
74     if (fDebug > 1) printf("AnalysisTaskJets::Init() \n");
75
76     // Call configuration file
77     gROOT->LoadMacro("ConfigJetAnalysis.C");
78     fJetFinder = (AliJetFinder*) gInterpreter->ProcessLine("ConfigJetAnalysis()");
79     // Initialise Jet Analysis
80     fJetFinder->Init();
81     // Write header information to local file
82     fJetFinder->WriteHeaders();
83 }
84
85 void AliAnalysisTaskJets::ConnectInputData(Option_t */*option*/)
86 {
87 // Connect the input data
88 //
89     if (fDebug > 1) printf("AnalysisTaskJets::ConnectInputData() \n");
90     fChain = (TChain*)GetInputData(0);
91
92     char ** address = (char **)GetBranchAddress(0, "ESD");
93     if (address)     {
94         
95 // Branch has been already connected
96         fESD = (AliESD*)(*address);
97     }
98     else     {
99 // First task taking the branch enables it
100         fESD = new AliESD();
101         SetBranchAddress(0, "ESD", &fESD);
102     }
103     
104     fJetFinder->ConnectTree(fChain, fESD);
105 }
106
107 void AliAnalysisTaskJets::Exec(Option_t */*option*/)
108 {
109 // Execute analysis for current event
110 //
111     Long64_t ientry = fChain->GetReadEntry();
112     if (fDebug > 1) printf("Analysing event # %5d\n", (Int_t) ientry);
113     fJetFinder->ProcessEvent(ientry);
114     PostData(0, fTreeA);
115 }
116
117 void AliAnalysisTaskJets::Terminate(Option_t */*option*/)
118 {
119 // Terminate analysis
120 //
121     if (fDebug > 1) printf("AnalysisJets: Terminate() \n");
122     // if (fJetFinder) fJetFinder->FinishRun();
123 }
124