]> git.uio.no Git - u/mrichter/AliRoot.git/blame - JETAN/AliAnalysisTaskJets.cxx
Add config for AOD, avoid fLego creation in gDirectory, added delete in dtor
[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"
9ff7671d 34#include "AliESDInputHandler.h"
7f7091b8 35#include "AliMCEvent.h"
691685d6 36#include "AliStack.h"
1d27ecd2 37
e5b96aa0 38
39ClassImp(AliAnalysisTaskJets)
40
41////////////////////////////////////////////////////////////////////////
42
19e6695b 43AliAnalysisTaskJets::AliAnalysisTaskJets():
ae24a5a1 44 AliAnalysisTaskSE(),
4aa71b6f 45 fConfigFile("ConfigJetAnalysis.C"),
46 fNonStdBranch(""),
47 fJetFinder(0x0),
48 fHistos(0x0),
49 fListOfHistos(0x0)
19e6695b 50{
51 // Default constructor
52}
53
e5b96aa0 54AliAnalysisTaskJets::AliAnalysisTaskJets(const char* name):
ae24a5a1 55 AliAnalysisTaskSE(name),
4aa71b6f 56 fConfigFile("ConfigJetAnalysis.C"),
57 fNonStdBranch(""),
e5b96aa0 58 fJetFinder(0x0),
22003a60 59 fHistos(0x0),
60 fListOfHistos(0x0)
e5b96aa0 61{
62 // Default constructor
22003a60 63 DefineOutput(1, TList::Class());
eaabc21f 64}
65
ae24a5a1 66void AliAnalysisTaskJets::UserCreateOutputObjects()
eaabc21f 67{
68// Create the output container
aa049fb2 69//
1b307662 70 if (fDebug > 1) printf("AnalysisTaskJets::CreateOutPutData() \n");
ae24a5a1 71
4aa71b6f 72
73 if(fNonStdBranch.Length()==0){
74 // Connec default AOD to jet finder
75 fJetFinder->ConnectAOD(AODEvent());
76 }
77 else{
78 // Create a new branch for jets...
79 // how is this is reset cleared in the UserExec....
80 // Can this be handled by the framework?
81 TClonesArray *tca = new TClonesArray("AliAODJet", 0);
82 tca->SetName(fNonStdBranch);
83 AddAODBranch("TClonesArray",&tca);
84 fJetFinder->ConnectAODNonStd(AODEvent(),fNonStdBranch.Data());
85 }
86 // Histograms
aa049fb2 87 OpenFile(1);
22003a60 88 fListOfHistos = new TList();
89 fHistos = new AliJetHistos();
90 fHistos->AddHistosToList(fListOfHistos);
4aa71b6f 91
e5b96aa0 92}
93
19e6695b 94void AliAnalysisTaskJets::Init()
e5b96aa0 95{
19e6695b 96 // Initialization
97 if (fDebug > 1) printf("AnalysisTaskJets::Init() \n");
eaabc21f 98
e5b96aa0 99 // Call configuration file
4aa71b6f 100 gROOT->LoadMacro(fConfigFile);
e5b96aa0 101 fJetFinder = (AliJetFinder*) gInterpreter->ProcessLine("ConfigJetAnalysis()");
102 // Initialise Jet Analysis
103 fJetFinder->Init();
76c48857 104 // Write header information to local file
105 fJetFinder->WriteHeaders();
19e6695b 106}
107
9ff7671d 108
85c7d469 109
e5b96aa0 110
ae24a5a1 111
112void AliAnalysisTaskJets::UserExec(Option_t */*option*/)
e5b96aa0 113{
4aa71b6f 114 // Execute analysis for current event
115 //
116
117
118 // Fill control histos
119 TClonesArray* jarray = 0;
120 if(fNonStdBranch.Length()==0){
121 jarray = AODEvent()->GetJets();
122 }
123 else{
124 jarray = dynamic_cast<TClonesArray*>(AODEvent()->FindListObject(fNonStdBranch.Data()));
125 jarray->Delete(); // this is our responsibility, clear before filling again
126 }
127
128 fJetFinder->GetReader()->SetInputEvent(InputEvent(), AODEvent(), MCEvent());
129 fJetFinder->ProcessEvent();
130
131 fHistos->FillHistos(jarray);
132 // Post the data
133 PostData(1, fListOfHistos);
e5b96aa0 134}
135
136void AliAnalysisTaskJets::Terminate(Option_t */*option*/)
137{
138// Terminate analysis
139//
19e6695b 140 if (fDebug > 1) printf("AnalysisJets: Terminate() \n");
9ff7671d 141// if (fJetFinder) fJetFinder->FinishRun();
e5b96aa0 142}
143