]> git.uio.no Git - u/mrichter/AliRoot.git/blob - JETAN/AliAnalysisTaskJets.cxx
Double declaration removed.
[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 /* $Id$ */
17  
18 #include <TROOT.h>
19 #include <TSystem.h>
20 #include <TInterpreter.h>
21 #include <TChain.h>
22 #include <TFile.h>
23 #include <TList.h>
24
25 #include "AliAnalysisTaskJets.h"
26 #include "AliAnalysisManager.h"
27 #include "AliJetFinder.h"
28 #include "AliJetHistos.h"
29 #include "AliESDEvent.h"
30 #include "AliESD.h"
31 #include "AliAODEvent.h"
32 #include "AliAODHandler.h"
33 #include "AliMCEventHandler.h"
34 #include "AliESDInputHandler.h"
35 #include "AliMCEvent.h"
36 #include "AliStack.h"
37
38
39 ClassImp(AliAnalysisTaskJets)
40
41 ////////////////////////////////////////////////////////////////////////
42
43 AliAnalysisTaskJets::AliAnalysisTaskJets():
44     fDebug(0),
45     fJetFinder(0x0),
46     fTree(0x0),
47     fESD(0x0),
48     fAOD(0x0),
49     fTreeA(0x0),
50     fHistos(0x0),
51     fListOfHistos(0x0)
52 {
53   // Default constructor
54 }
55
56 AliAnalysisTaskJets::AliAnalysisTaskJets(const char* name):
57     AliAnalysisTask(name, "AnalysisTaskJets"),
58     fDebug(0),
59     fJetFinder(0x0),
60     fTree(0x0),
61     fESD(0x0),
62     fAOD(0x0),
63     fTreeA(0x0),
64     fHistos(0x0),
65     fListOfHistos(0x0)
66 {
67   // Default constructor
68     DefineInput (0, TChain::Class());
69     DefineOutput(0, TTree::Class());
70     DefineOutput(1, TList::Class());
71 }
72
73 void AliAnalysisTaskJets::CreateOutputObjects()
74 {
75 // Create the output container
76 //
77 //  Default AOD
78     if (fDebug > 1) printf("AnalysisTaskJets::CreateOutPutData() \n");
79     AliAODHandler* handler = (AliAODHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
80     
81     fAOD   = handler->GetAOD();
82     fTreeA = handler->GetTree();
83     fJetFinder->ConnectAOD(fAOD);
84 //
85 //  Histograms
86     OpenFile(1);
87     fListOfHistos = new TList();
88     fHistos       = new AliJetHistos();
89     fHistos->AddHistosToList(fListOfHistos);
90 }
91
92 void AliAnalysisTaskJets::Init()
93 {
94     // Initialization
95     if (fDebug > 1) printf("AnalysisTaskJets::Init() \n");
96
97     // Call configuration file
98     gROOT->LoadMacro("ConfigJetAnalysis.C");
99     fJetFinder = (AliJetFinder*) gInterpreter->ProcessLine("ConfigJetAnalysis()");
100     // Initialise Jet Analysis
101     fJetFinder->Init();
102     // Write header information to local file
103     fJetFinder->WriteHeaders();
104 }
105
106 void AliAnalysisTaskJets::ConnectInputData(Option_t */*option*/)
107 {
108 // Connect the input data
109     if (fDebug > 1) printf("AnalysisTaskJets::ConnectInputData() \n");
110     AliESDInputHandler* esdH = (AliESDInputHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
111     fESD = esdH->GetEvent();
112     fTree = esdH->GetTree();
113     
114     
115
116     AliMCEventHandler*    mcTruth = (AliMCEventHandler*) 
117         ((AliAnalysisManager::GetAnalysisManager())->GetMCtruthEventHandler());
118     
119     fJetFinder->GetReader()->SetInputEvent(fESD, fAOD, mcTruth);
120 }
121
122 void AliAnalysisTaskJets::Exec(Option_t */*option*/)
123 {
124 // Execute analysis for current event
125 //
126     AliMCEventHandler*    mctruth = (AliMCEventHandler*) 
127         ((AliAnalysisManager::GetAnalysisManager())->GetMCtruthEventHandler());
128     if (mctruth) {
129         AliStack* stack = mctruth->MCEvent()->Stack();
130         //printf("AliAnalysisTaskJets: Number of tracks on stack %5d\n", stack->GetNtrack());
131     }
132     
133     Long64_t ientry = fTree->GetReadEntry();
134     if (fDebug > 1) printf("Analysing event # %5d\n", (Int_t) ientry);
135     fJetFinder->ProcessEvent(ientry);
136
137     // Fill control histos
138     fHistos->FillHistos(fAOD->GetJets());
139     
140     // Post the data
141     PostData(0, fTreeA);
142     PostData(1, fListOfHistos);
143 }
144
145 void AliAnalysisTaskJets::Terminate(Option_t */*option*/)
146 {
147 // Terminate analysis
148 //
149     if (fDebug > 1) printf("AnalysisJets: Terminate() \n");
150 //    if (fJetFinder) fJetFinder->FinishRun();
151 }
152