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