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