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());
112 fListOfHistos = new TList();
113 fHistos = new AliJetHistos();
114 fHistos->AddHistosToList(fListOfHistos);
116 // Add the JetFinderInformation to the Outputlist
117 AliJetHeader *fH = fJetFinder->GetHeader();
119 // Compose a characteristic output name
120 // with the name of the output branch
122 if(fNonStdBranch.Length()==0) {
123 fH->SetName("AliJetHeader_jets");
126 fH->SetName(Form("AliJetHeader_%s",fNonStdBranch.Data()));
129 OutputTree()->GetUserInfo()->Add(fH);
132 //----------------------------------------------------------------
133 void AliAnalysisTaskJets::Init()
136 if (fDebug > 1) printf("AnalysisTaskJets::Init() \n");
138 // Call configuration file
139 if (fConfigFile.Length()) {
140 gROOT->LoadMacro(fConfigFile);
141 fJetFinder = (AliJetFinder*) gInterpreter->ProcessLine("ConfigJetAnalysis()");
143 AliJetReaderHeader *header = (AliJetReaderHeader*)fJetFinder->GetReader()->GetReaderHeader();
144 fOpt = header->GetDetector();
146 // Initialise Jet Analysis
147 if(fOpt == 0) fJetFinder->Init();
148 else fJetFinder->InitTask(fChain); // V2
150 // Write header information to local file
151 fJetFinder->WriteHeaders();
154 //----------------------------------------------------------------
155 void AliAnalysisTaskJets::UserExec(Option_t */*option*/)
157 // Execute analysis for current event
159 // Fill control histos
160 TClonesArray* jarray = 0;
162 if(fNonStdBranch.Length()==0) {
163 jarray = AODEvent()->GetJets();
166 jarray = dynamic_cast<TClonesArray*>(AODEvent()->FindListObject(fNonStdBranch.Data()));
167 jarray->Delete(); // this is our responsibility, clear before filling again
170 fJetFinder->GetReader()->SetInputEvent(InputEvent(), AODEvent(), MCEvent());
171 if(fOpt==0) fJetFinder->ProcessEvent();
172 else fJetFinder->ProcessEvent2(); // V2
174 // Fill control histos
175 fHistos->FillHistos(jarray);
178 PostData(1, fListOfHistos);
182 //*************************************************************
184 void AliAnalysisTaskJets::Terminate(Option_t */*option*/)
186 // Terminate analysis
188 if (fDebug > 1) printf("AnalysisJets: Terminate() \n");
189 // if (fJetFinder) fJetFinder->FinishRun();