-printf 's replaced.
[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"
1b307662 26#include "AliESDEvent.h"
1d27ecd2 27#include "AliAODEvent.h"
28#include "AliAODHandler.h"
691685d6 29#include "AliMCEventHandler.h"
30#include "AliStack.h"
1d27ecd2 31
e5b96aa0 32
33ClassImp(AliAnalysisTaskJets)
34
35////////////////////////////////////////////////////////////////////////
36
19e6695b 37AliAnalysisTaskJets::AliAnalysisTaskJets():
38 fDebug(0),
39 fJetFinder(0x0),
40 fChain(0x0),
eaabc21f 41 fESD(0x0),
1d27ecd2 42 fAOD(0x0),
aa049fb2 43 fTreeA(0x0),
44 fHisto(0x0)
19e6695b 45{
46 // Default constructor
47}
48
e5b96aa0 49AliAnalysisTaskJets::AliAnalysisTaskJets(const char* name):
50 AliAnalysisTask(name, "AnalysisTaskJets"),
68093d75 51 fDebug(0),
e5b96aa0 52 fJetFinder(0x0),
53 fChain(0x0),
eaabc21f 54 fESD(0x0),
1d27ecd2 55 fAOD(0x0),
aa049fb2 56 fTreeA(0x0),
57 fHisto(0x0)
e5b96aa0 58{
59 // Default constructor
60 DefineInput (0, TChain::Class());
eaabc21f 61 DefineOutput(0, TTree::Class());
aa049fb2 62 DefineOutput(1, TH1F::Class());
eaabc21f 63}
64
65void AliAnalysisTaskJets::CreateOutputObjects()
66{
67// Create the output container
aa049fb2 68//
69// Default AOD
1b307662 70 if (fDebug > 1) printf("AnalysisTaskJets::CreateOutPutData() \n");
691685d6 71 AliAODHandler* handler = (AliAODHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
72
1d27ecd2 73 fAOD = handler->GetAOD();
74 fTreeA = handler->GetTree();
75 fJetFinder->ConnectAOD(fAOD);
aa049fb2 76//
77// Histogram
78 OpenFile(1);
79 fHisto = new TH1F("fHisto", "Jet Et", 100, 0., 100.);
691685d6 80
e5b96aa0 81}
82
19e6695b 83void AliAnalysisTaskJets::Init()
e5b96aa0 84{
19e6695b 85 // Initialization
86 if (fDebug > 1) printf("AnalysisTaskJets::Init() \n");
eaabc21f 87
e5b96aa0 88 // Call configuration file
89 gROOT->LoadMacro("ConfigJetAnalysis.C");
90 fJetFinder = (AliJetFinder*) gInterpreter->ProcessLine("ConfigJetAnalysis()");
91 // Initialise Jet Analysis
92 fJetFinder->Init();
76c48857 93 // Write header information to local file
94 fJetFinder->WriteHeaders();
19e6695b 95}
96
97void AliAnalysisTaskJets::ConnectInputData(Option_t */*option*/)
98{
99// Connect the input data
19e6695b 100 if (fDebug > 1) printf("AnalysisTaskJets::ConnectInputData() \n");
76c48857 101 fChain = (TChain*)GetInputData(0);
1b307662 102 fESD = new AliESDEvent();
103 fESD->ReadFromTree(fChain);
f3f3617d 104 fJetFinder->ConnectTree(fChain, fESD);
e5b96aa0 105}
106
107void AliAnalysisTaskJets::Exec(Option_t */*option*/)
108{
109// Execute analysis for current event
110//
691685d6 111 AliMCEventHandler* mctruth = (AliMCEventHandler*)
112 ((AliAnalysisManager::GetAnalysisManager())->GetMCtruthEventHandler());
113 AliStack* stack = mctruth->Stack();
114 printf("AliAnalysisTaskJets: Number of tracks %5d\n", stack->GetNtrack());
115
e5b96aa0 116 Long64_t ientry = fChain->GetReadEntry();
76c48857 117 if (fDebug > 1) printf("Analysing event # %5d\n", (Int_t) ientry);
e5b96aa0 118 fJetFinder->ProcessEvent(ientry);
1d27ecd2 119 PostData(0, fTreeA);
aa049fb2 120 PostData(1, fHisto);
e5b96aa0 121}
122
123void AliAnalysisTaskJets::Terminate(Option_t */*option*/)
124{
125// Terminate analysis
126//
19e6695b 127 if (fDebug > 1) printf("AnalysisJets: Terminate() \n");
76c48857 128 // if (fJetFinder) fJetFinder->FinishRun();
e5b96aa0 129}
130