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