]> git.uio.no Git - u/mrichter/AliRoot.git/blame - JETAN/AliAnalysisTaskJets.cxx
Variable shadowing corrected.
[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$ */
8838ab7a 17#include <Riostream.h>
e5b96aa0 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"
99c8d2ad 28#include "AliJetHeader.h"
8838ab7a 29#include "AliJetReader.h"
30#include "AliJetReaderHeader.h"
22003a60 31#include "AliJetHistos.h"
1b307662 32#include "AliESDEvent.h"
7f7091b8 33#include "AliESD.h"
1d27ecd2 34#include "AliAODEvent.h"
35#include "AliAODHandler.h"
691685d6 36#include "AliMCEventHandler.h"
9ff7671d 37#include "AliESDInputHandler.h"
7f7091b8 38#include "AliMCEvent.h"
691685d6 39#include "AliStack.h"
1d27ecd2 40
e5b96aa0 41
42ClassImp(AliAnalysisTaskJets)
43
44////////////////////////////////////////////////////////////////////////
45
19e6695b 46AliAnalysisTaskJets::AliAnalysisTaskJets():
8838ab7a 47 AliAnalysisTaskSE(),
48 fConfigFile("ConfigJetAnalysis.C"),
49 fNonStdBranch(""),
4aa71b6f 50 fJetFinder(0x0),
51 fHistos(0x0),
8838ab7a 52 fListOfHistos(0x0),
53 fChain(0x0),
54 fOpt(0)
19e6695b 55{
56 // Default constructor
57}
58
e5b96aa0 59AliAnalysisTaskJets::AliAnalysisTaskJets(const char* name):
8838ab7a 60 AliAnalysisTaskSE(name),
61 fConfigFile("ConfigJetAnalysis.C"),
62 fNonStdBranch(""),
63 fJetFinder(0x0),
64 fHistos(0x0),
65 fListOfHistos(0x0),
66 fChain(0x0),
67 fOpt(0)
e5b96aa0 68{
69 // Default constructor
8838ab7a 70 DefineOutput(1, TList::Class());
eaabc21f 71}
72
8838ab7a 73AliAnalysisTaskJets::AliAnalysisTaskJets(const char* name, TChain* chain):
74 AliAnalysisTaskSE(name),
75 fConfigFile("ConfigJetAnalysis.C"),
76 fNonStdBranch(""),
77 fJetFinder(0x0),
78 fHistos(0x0),
79 fListOfHistos(0x0),
80 fChain(chain),
81 fOpt(0)
eaabc21f 82{
8838ab7a 83 // Default constructor
84 DefineOutput(1, TList::Class());
85}
4aa71b6f 86
8838ab7a 87//----------------------------------------------------------------
88void AliAnalysisTaskJets::UserCreateOutputObjects()
89{
90 // Create the output container
91 //
92 if (fDebug > 1) printf("AnalysisTaskJets::CreateOutPutData() \n");
93
94 if(fNonStdBranch.Length()==0)
95 {
4aa71b6f 96 // Connec default AOD to jet finder
97 fJetFinder->ConnectAOD(AODEvent());
98 }
8838ab7a 99 else
100 {
4aa71b6f 101 // Create a new branch for jets...
8838ab7a 102 // how is this reset? -> cleared in the UserExec....
4aa71b6f 103 // Can this be handled by the framework?
104 TClonesArray *tca = new TClonesArray("AliAODJet", 0);
105 tca->SetName(fNonStdBranch);
106 AddAODBranch("TClonesArray",&tca);
8838ab7a 107 fJetFinder->ConnectAODNonStd(AODEvent(), fNonStdBranch.Data());
108 }
109
110 // Histograms
111 OpenFile(1);
112 fListOfHistos = new TList();
113 fHistos = new AliJetHistos();
114 fHistos->AddHistosToList(fListOfHistos);
115
116 // Add the JetFinderInformation to the Outputlist
117 AliJetHeader *fH = fJetFinder->GetHeader();
118
119 // Compose a characteristic output name
120 // with the name of the output branch
121 if(fH) {
122 if(fNonStdBranch.Length()==0) {
123 fH->SetName("AliJetHeader_jets");
4aa71b6f 124 }
8838ab7a 125 else {
126 fH->SetName(Form("AliJetHeader_%s",fNonStdBranch.Data()));
99c8d2ad 127 }
8838ab7a 128 }
129 OutputTree()->GetUserInfo()->Add(fH);
e5b96aa0 130}
131
8838ab7a 132//----------------------------------------------------------------
19e6695b 133void AliAnalysisTaskJets::Init()
e5b96aa0 134{
8838ab7a 135 // Initialization
136 if (fDebug > 1) printf("AnalysisTaskJets::Init() \n");
137
138 // Call configuration file
139 if (fConfigFile.Length()) {
140 gROOT->LoadMacro(fConfigFile);
141 fJetFinder = (AliJetFinder*) gInterpreter->ProcessLine("ConfigJetAnalysis()");
142 }
143 AliJetReaderHeader *header = (AliJetReaderHeader*)fJetFinder->GetReader()->GetReaderHeader();
144 fOpt = header->GetDetector();
145
146 // Initialise Jet Analysis
147 if(fOpt == 0) fJetFinder->Init();
148 else fJetFinder->InitTask(fChain); // V2
149
150 // Write header information to local file
151 fJetFinder->WriteHeaders();
19e6695b 152}
153
8838ab7a 154//----------------------------------------------------------------
ae24a5a1 155void AliAnalysisTaskJets::UserExec(Option_t */*option*/)
e5b96aa0 156{
4aa71b6f 157 // Execute analysis for current event
158 //
4aa71b6f 159 // Fill control histos
160 TClonesArray* jarray = 0;
8838ab7a 161
162 if(fNonStdBranch.Length()==0) {
4aa71b6f 163 jarray = AODEvent()->GetJets();
164 }
8838ab7a 165 else {
166 jarray = dynamic_cast<TClonesArray*>(AODEvent()->FindListObject(fNonStdBranch.Data()));
4aa71b6f 167 jarray->Delete(); // this is our responsibility, clear before filling again
168 }
169
170 fJetFinder->GetReader()->SetInputEvent(InputEvent(), AODEvent(), MCEvent());
8838ab7a 171 if(fOpt==0) fJetFinder->ProcessEvent();
172 else fJetFinder->ProcessEvent2(); // V2
173
174 // Fill control histos
4aa71b6f 175 fHistos->FillHistos(jarray);
8838ab7a 176
4aa71b6f 177 // Post the data
178 PostData(1, fListOfHistos);
e5b96aa0 179}
180
8838ab7a 181
182//*************************************************************
183
e5b96aa0 184void AliAnalysisTaskJets::Terminate(Option_t */*option*/)
185{
186// Terminate analysis
187//
19e6695b 188 if (fDebug > 1) printf("AnalysisJets: Terminate() \n");
9ff7671d 189// if (fJetFinder) fJetFinder->FinishRun();
e5b96aa0 190}
191