1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 #include <Riostream.h>
20 #include <TInterpreter.h>
25 #include "AliAnalysisTaskJets.h"
26 #include "AliAnalysisManager.h"
27 #include "AliJetFinder.h"
28 #include "AliJetHeader.h"
29 #include "AliJetReader.h"
30 #include "AliJetReaderHeader.h"
31 #include "AliJetHistos.h"
32 #include "AliESDEvent.h"
34 #include "AliAODEvent.h"
35 #include "AliAODHandler.h"
36 #include "AliMCEventHandler.h"
37 #include "AliESDInputHandler.h"
38 #include "AliMCEvent.h"
42 ClassImp(AliAnalysisTaskJets)
44 ////////////////////////////////////////////////////////////////////////
46 AliAnalysisTaskJets::AliAnalysisTaskJets():
48 fConfigFile("ConfigJetAnalysis.C"),
56 // Default constructor
59 AliAnalysisTaskJets::AliAnalysisTaskJets(const char* name):
60 AliAnalysisTaskSE(name),
61 fConfigFile("ConfigJetAnalysis.C"),
69 // Default constructor
70 DefineOutput(1, TList::Class());
73 AliAnalysisTaskJets::AliAnalysisTaskJets(const char* name, TChain* chain):
74 AliAnalysisTaskSE(name),
75 fConfigFile("ConfigJetAnalysis.C"),
83 // Default constructor
84 DefineOutput(1, TList::Class());
87 //----------------------------------------------------------------
88 void AliAnalysisTaskJets::UserCreateOutputObjects()
90 // Create the output container
92 if (fDebug > 1) printf("AnalysisTaskJets::CreateOutPutData() \n");
94 if(fNonStdBranch.Length()==0)
96 // Connec default AOD to jet finder
97 fJetFinder->ConnectAOD(AODEvent());
101 // Create a new branch for jets...
102 // how is this reset? -> cleared in the UserExec....
103 // Can this be handled by the framework?
104 TClonesArray *tca = new TClonesArray("AliAODJet", 0);
105 tca->SetName(fNonStdBranch);
106 AddAODBranch("TClonesArray",&tca);
107 fJetFinder->ConnectAODNonStd(AODEvent(), fNonStdBranch.Data());
109 AliAODJetEventBackground* evBkg = fJetFinder->GetEventBackground();
110 if (evBkg) AddAODBranch("AliAODJetEventBackground",&evBkg);
114 fListOfHistos = new TList();
115 fHistos = new AliJetHistos();
116 fHistos->AddHistosToList(fListOfHistos);
118 // Add the JetFinderInformation to the Outputlist
119 AliJetHeader *fH = fJetFinder->GetHeader();
121 // Compose a characteristic output name
122 // with the name of the output branch
124 if(fNonStdBranch.Length()==0) {
125 fH->SetName("AliJetHeader_jets");
128 fH->SetName(Form("AliJetHeader_%s",fNonStdBranch.Data()));
131 OutputTree()->GetUserInfo()->Add(fH);
134 //----------------------------------------------------------------
135 void AliAnalysisTaskJets::Init()
138 if (fDebug > 1) printf("AnalysisTaskJets::Init() \n");
140 // Call configuration file
141 if (fConfigFile.Length()) {
142 gROOT->LoadMacro(fConfigFile);
143 fJetFinder = (AliJetFinder*) gInterpreter->ProcessLine("ConfigJetAnalysis()");
145 AliJetReaderHeader *header = (AliJetReaderHeader*)fJetFinder->GetReader()->GetReaderHeader();
146 fOpt = header->GetDetector();
148 // Initialise Jet Analysis
149 if(fOpt == 0) fJetFinder->Init();
150 else fJetFinder->InitTask(fChain); // V2
152 // Write header information to local file
153 fJetFinder->WriteHeaders();
156 //----------------------------------------------------------------
157 void AliAnalysisTaskJets::UserExec(Option_t */*option*/)
159 // Execute analysis for current event
161 // Fill control histos
162 TClonesArray* jarray = 0;
164 if(fNonStdBranch.Length()==0) {
165 jarray = AODEvent()->GetJets();
168 jarray = dynamic_cast<TClonesArray*>(AODEvent()->FindListObject(fNonStdBranch.Data()));
169 jarray->Delete(); // this is our responsibility, clear before filling again
171 if (dynamic_cast<AliAODEvent*>(InputEvent()) != 0) {
172 fJetFinder->GetReader()->SetInputEvent(InputEvent(), InputEvent(), MCEvent());
174 fJetFinder->GetReader()->SetInputEvent(InputEvent(), AODEvent(), MCEvent());
179 if(fOpt==0) fJetFinder->ProcessEvent();
180 else fJetFinder->ProcessEvent2(); // V2
182 // Fill control histos
183 fHistos->FillHistos(jarray);
186 PostData(1, fListOfHistos);
190 //*************************************************************
192 void AliAnalysisTaskJets::Terminate(Option_t */*option*/)
194 // Terminate analysis
196 if (fDebug > 1) printf("AnalysisJets: Terminate() \n");
197 // if (fJetFinder) fJetFinder->FinishRun();