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 "AliAODJetEventBackground.h"
36 #include "AliAODHandler.h"
37 #include "AliMCEventHandler.h"
38 #include "AliESDInputHandler.h"
39 #include "AliMCEvent.h"
43 ClassImp(AliAnalysisTaskJets)
45 ////////////////////////////////////////////////////////////////////////
47 AliAnalysisTaskJets::AliAnalysisTaskJets():
49 fConfigFile("ConfigJetAnalysis.C"),
57 // Default constructor
60 AliAnalysisTaskJets::AliAnalysisTaskJets(const char* name):
61 AliAnalysisTaskSE(name),
62 fConfigFile("ConfigJetAnalysis.C"),
70 // Default constructor
71 DefineOutput(1, TList::Class());
74 AliAnalysisTaskJets::AliAnalysisTaskJets(const char* name, TChain* chain):
75 AliAnalysisTaskSE(name),
76 fConfigFile("ConfigJetAnalysis.C"),
84 // Default constructor
85 DefineOutput(1, TList::Class());
88 //----------------------------------------------------------------
89 void AliAnalysisTaskJets::UserCreateOutputObjects()
91 // Create the output container
93 if (fDebug > 1) printf("AnalysisTaskJets::CreateOutPutData() \n");
95 if(fNonStdBranch.Length()==0)
97 // Connec default AOD to jet finder
98 // create a new branch for the background
99 if(!AODEvent()->FindListObject(AliAODJetEventBackground::StdBranchName())){
100 AliAODJetEventBackground* evBkg = new AliAODJetEventBackground();
101 evBkg->SetName(AliAODJetEventBackground::StdBranchName());
102 AddAODBranch("AliAODJetEventBackground",&evBkg);
104 fJetFinder->ConnectAOD(AODEvent());
108 // Create a new branch for jets...
109 // how is this reset? -> cleared in the UserExec....
110 // Can this be handled by the framework?
111 TClonesArray *tca = new TClonesArray("AliAODJet", 0);
112 tca->SetName(fNonStdBranch);
113 AddAODBranch("TClonesArray",&tca);
114 if(!AODEvent()->FindListObject(Form("%s_%s",AliAODJetEventBackground::StdBranchName(),fNonStdBranch.Data()))){
115 AliAODJetEventBackground* evBkg = new AliAODJetEventBackground();
116 evBkg->SetName(Form("%s_%s",AliAODJetEventBackground::StdBranchName(),fNonStdBranch.Data()));
117 AddAODBranch("AliAODJetEventBackground",&evBkg);
119 fJetFinder->ConnectAODNonStd(AODEvent(), fNonStdBranch.Data());
125 fListOfHistos = new TList();
126 fHistos = new AliJetHistos();
127 fHistos->AddHistosToList(fListOfHistos);
129 // Add the JetFinderInformation to the Outputlist
130 AliJetHeader *fH = fJetFinder->GetHeader();
132 // Compose a characteristic output name
133 // with the name of the output branch
135 if(fNonStdBranch.Length()==0) {
136 fH->SetName("AliJetHeader_jets");
139 fH->SetName(Form("AliJetHeader_%s",fNonStdBranch.Data()));
142 OutputTree()->GetUserInfo()->Add(fH);
145 //----------------------------------------------------------------
146 void AliAnalysisTaskJets::Init()
149 if (fDebug > 1) printf("AnalysisTaskJets::Init() \n");
151 // Call configuration file
152 if (fConfigFile.Length()) {
153 gROOT->LoadMacro(fConfigFile);
154 fJetFinder = (AliJetFinder*) gInterpreter->ProcessLine("ConfigJetAnalysis()");
156 AliJetReaderHeader *header = (AliJetReaderHeader*)fJetFinder->GetReader()->GetReaderHeader();
157 fOpt = header->GetDetector();
159 // Initialise Jet Analysis
160 if(fOpt == 0) fJetFinder->Init();
161 else fJetFinder->InitTask(fChain); // V2
163 // Write header information to local file
164 fJetFinder->WriteHeaders();
167 //----------------------------------------------------------------
168 void AliAnalysisTaskJets::UserExec(Option_t */*option*/)
170 // Execute analysis for current event
172 // Fill control histos
173 TClonesArray* jarray = 0;
174 AliAODJetEventBackground* evBkg;
176 if(fNonStdBranch.Length()==0) {
177 jarray = AODEvent()->GetJets();
178 evBkg = (AliAODJetEventBackground*)(AODEvent()->FindListObject(AliAODJetEventBackground::StdBranchName()));
182 jarray = dynamic_cast<TClonesArray*>(AODEvent()->FindListObject(fNonStdBranch.Data()));
183 jarray->Delete(); // this is our responsibility, clear before filling again
184 evBkg = (AliAODJetEventBackground*)(AODEvent()->FindListObject(Form("%s_%s",AliAODJetEventBackground::StdBranchName(),fNonStdBranch.Data())));
187 if (dynamic_cast<AliAODEvent*>(InputEvent()) != 0) {
188 fJetFinder->GetReader()->SetInputEvent(InputEvent(), InputEvent(), MCEvent());
190 fJetFinder->GetReader()->SetInputEvent(InputEvent(), AODEvent(), MCEvent());
195 if(fOpt==0) fJetFinder->ProcessEvent();
196 else fJetFinder->ProcessEvent2(); // V2
198 // Fill control histos
199 fHistos->FillHistos(jarray);
202 PostData(1, fListOfHistos);
206 //*************************************************************
208 void AliAnalysisTaskJets::Terminate(Option_t */*option*/)
210 // Terminate analysis
212 if (fDebug > 1) printf("AnalysisJets: Terminate() \n");
213 // if (fJetFinder) fJetFinder->FinishRun();