]>
Commit | Line | Data |
---|---|---|
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" |
bcec7a80 | 35 | #include "AliAODJetEventBackground.h" |
1d27ecd2 | 36 | #include "AliAODHandler.h" |
691685d6 | 37 | #include "AliMCEventHandler.h" |
9ff7671d | 38 | #include "AliESDInputHandler.h" |
7f7091b8 | 39 | #include "AliMCEvent.h" |
691685d6 | 40 | #include "AliStack.h" |
1d27ecd2 | 41 | |
e5b96aa0 | 42 | |
43 | ClassImp(AliAnalysisTaskJets) | |
44 | ||
45 | //////////////////////////////////////////////////////////////////////// | |
46 | ||
19e6695b | 47 | AliAnalysisTaskJets::AliAnalysisTaskJets(): |
8838ab7a | 48 | AliAnalysisTaskSE(), |
49 | fConfigFile("ConfigJetAnalysis.C"), | |
50 | fNonStdBranch(""), | |
931c23a1 | 51 | fNonStdFile(""), |
4aa71b6f | 52 | fJetFinder(0x0), |
53 | fHistos(0x0), | |
931c23a1 | 54 | fAODExtension(0x0), |
8838ab7a | 55 | fListOfHistos(0x0), |
56 | fChain(0x0), | |
57 | fOpt(0) | |
19e6695b | 58 | { |
59 | // Default constructor | |
60 | } | |
61 | ||
e5b96aa0 | 62 | AliAnalysisTaskJets::AliAnalysisTaskJets(const char* name): |
8838ab7a | 63 | AliAnalysisTaskSE(name), |
64 | fConfigFile("ConfigJetAnalysis.C"), | |
65 | fNonStdBranch(""), | |
931c23a1 | 66 | fNonStdFile(""), |
8838ab7a | 67 | fJetFinder(0x0), |
68 | fHistos(0x0), | |
931c23a1 | 69 | fAODExtension(0x0), |
8838ab7a | 70 | fListOfHistos(0x0), |
71 | fChain(0x0), | |
0f4a88df | 72 | fOpt(0), |
73 | fReadAODFromOutput(0) | |
e5b96aa0 | 74 | { |
75 | // Default constructor | |
8838ab7a | 76 | DefineOutput(1, TList::Class()); |
eaabc21f | 77 | } |
78 | ||
8838ab7a | 79 | AliAnalysisTaskJets::AliAnalysisTaskJets(const char* name, TChain* chain): |
80 | AliAnalysisTaskSE(name), | |
81 | fConfigFile("ConfigJetAnalysis.C"), | |
82 | fNonStdBranch(""), | |
931c23a1 | 83 | fNonStdFile(""), |
8838ab7a | 84 | fJetFinder(0x0), |
85 | fHistos(0x0), | |
931c23a1 | 86 | fAODExtension(0x0), |
8838ab7a | 87 | fListOfHistos(0x0), |
88 | fChain(chain), | |
0f4a88df | 89 | fOpt(0), |
90 | fReadAODFromOutput(0) | |
eaabc21f | 91 | { |
8838ab7a | 92 | // Default constructor |
93 | DefineOutput(1, TList::Class()); | |
94 | } | |
4aa71b6f | 95 | |
8838ab7a | 96 | //---------------------------------------------------------------- |
97 | void AliAnalysisTaskJets::UserCreateOutputObjects() | |
98 | { | |
99 | // Create the output container | |
100 | // | |
101 | if (fDebug > 1) printf("AnalysisTaskJets::CreateOutPutData() \n"); | |
931c23a1 | 102 | |
103 | // we already have a non standard output, need not to book a new file... | |
104 | if (!IsStandardAOD())fNonStdFile = ""; | |
105 | ||
8838ab7a | 106 | if(fNonStdBranch.Length()==0) |
107 | { | |
4aa71b6f | 108 | // Connec default AOD to jet finder |
bcec7a80 | 109 | // create a new branch for the background |
110 | if(!AODEvent()->FindListObject(AliAODJetEventBackground::StdBranchName())){ | |
111 | AliAODJetEventBackground* evBkg = new AliAODJetEventBackground(); | |
112 | evBkg->SetName(AliAODJetEventBackground::StdBranchName()); | |
113 | AddAODBranch("AliAODJetEventBackground",&evBkg); | |
114 | } | |
4aa71b6f | 115 | fJetFinder->ConnectAOD(AODEvent()); |
116 | } | |
8838ab7a | 117 | else |
118 | { | |
4aa71b6f | 119 | // Create a new branch for jets... |
8838ab7a | 120 | // how is this reset? -> cleared in the UserExec.... |
4aa71b6f | 121 | // Can this be handled by the framework? |
931c23a1 | 122 | // here we can also have the case that the brnaches are written to a separate file |
123 | ||
4aa71b6f | 124 | TClonesArray *tca = new TClonesArray("AliAODJet", 0); |
931c23a1 | 125 | tca->SetName(fNonStdBranch.Data()); |
126 | AddAODBranch("TClonesArray",&tca,fNonStdFile.Data()); | |
bcec7a80 | 127 | if(!AODEvent()->FindListObject(Form("%s_%s",AliAODJetEventBackground::StdBranchName(),fNonStdBranch.Data()))){ |
128 | AliAODJetEventBackground* evBkg = new AliAODJetEventBackground(); | |
129 | evBkg->SetName(Form("%s_%s",AliAODJetEventBackground::StdBranchName(),fNonStdBranch.Data())); | |
931c23a1 | 130 | AddAODBranch("AliAODJetEventBackground",&evBkg,fNonStdFile.Data()); |
131 | } | |
132 | ||
133 | if(fNonStdFile.Length()!=0){ | |
134 | // | |
135 | // case that we have an AOD extension we need to fetch the jets from the extended output | |
136 | // we identifay the extension aod event by looking for the branchname | |
137 | AliAODHandler *aodH = dynamic_cast<AliAODHandler*>(AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()); | |
138 | TObjArray* extArray = aodH->GetExtensions(); | |
139 | if (extArray) { | |
140 | TIter next(extArray); | |
141 | while ((fAODExtension=(AliAODExtension*)next())){ | |
142 | TObject *obj = fAODExtension->GetAOD()->FindListObject(fNonStdBranch.Data()); | |
8f9a4721 | 143 | if(fDebug>10){ |
144 | Printf("%s:%d Dumping..",(char*)__FILE__,__LINE__); | |
145 | fAODExtension->GetAOD()->Dump(); | |
146 | } | |
931c23a1 | 147 | if(obj){ |
148 | if(fDebug>1)Printf("AODExtension found for %s",fNonStdBranch.Data()); | |
149 | break; | |
150 | } | |
151 | fAODExtension = 0; | |
152 | } | |
153 | } | |
154 | if(fAODExtension)fJetFinder->ConnectAODNonStd(fAODExtension->GetAOD(), fNonStdBranch.Data()); | |
155 | } | |
156 | else{ | |
157 | fJetFinder->ConnectAODNonStd(AODEvent(), fNonStdBranch.Data()); | |
bcec7a80 | 158 | } |
8838ab7a | 159 | } |
bcec7a80 | 160 | |
952b368c | 161 | |
8838ab7a | 162 | // Histograms |
163 | OpenFile(1); | |
164 | fListOfHistos = new TList(); | |
165 | fHistos = new AliJetHistos(); | |
166 | fHistos->AddHistosToList(fListOfHistos); | |
167 | ||
168 | // Add the JetFinderInformation to the Outputlist | |
169 | AliJetHeader *fH = fJetFinder->GetHeader(); | |
170 | ||
171 | // Compose a characteristic output name | |
172 | // with the name of the output branch | |
173 | if(fH) { | |
174 | if(fNonStdBranch.Length()==0) { | |
175 | fH->SetName("AliJetHeader_jets"); | |
4aa71b6f | 176 | } |
8838ab7a | 177 | else { |
178 | fH->SetName(Form("AliJetHeader_%s",fNonStdBranch.Data())); | |
99c8d2ad | 179 | } |
8838ab7a | 180 | } |
931c23a1 | 181 | if(!fAODExtension)OutputTree()->GetUserInfo()->Add(fH); |
182 | else fAODExtension->GetTree()->GetUserInfo()->Add(fH); | |
e5b96aa0 | 183 | } |
184 | ||
8838ab7a | 185 | //---------------------------------------------------------------- |
19e6695b | 186 | void AliAnalysisTaskJets::Init() |
e5b96aa0 | 187 | { |
8838ab7a | 188 | // Initialization |
189 | if (fDebug > 1) printf("AnalysisTaskJets::Init() \n"); | |
190 | ||
191 | // Call configuration file | |
192 | if (fConfigFile.Length()) { | |
193 | gROOT->LoadMacro(fConfigFile); | |
194 | fJetFinder = (AliJetFinder*) gInterpreter->ProcessLine("ConfigJetAnalysis()"); | |
195 | } | |
196 | AliJetReaderHeader *header = (AliJetReaderHeader*)fJetFinder->GetReader()->GetReaderHeader(); | |
197 | fOpt = header->GetDetector(); | |
198 | ||
199 | // Initialise Jet Analysis | |
200 | if(fOpt == 0) fJetFinder->Init(); | |
201 | else fJetFinder->InitTask(fChain); // V2 | |
202 | ||
203 | // Write header information to local file | |
204 | fJetFinder->WriteHeaders(); | |
19e6695b | 205 | } |
206 | ||
931c23a1 | 207 | |
8838ab7a | 208 | //---------------------------------------------------------------- |
ae24a5a1 | 209 | void AliAnalysisTaskJets::UserExec(Option_t */*option*/) |
e5b96aa0 | 210 | { |
4aa71b6f | 211 | // Execute analysis for current event |
212 | // | |
4aa71b6f | 213 | // Fill control histos |
214 | TClonesArray* jarray = 0; | |
bcec7a80 | 215 | AliAODJetEventBackground* evBkg; |
8838ab7a | 216 | |
217 | if(fNonStdBranch.Length()==0) { | |
4aa71b6f | 218 | jarray = AODEvent()->GetJets(); |
bcec7a80 | 219 | evBkg = (AliAODJetEventBackground*)(AODEvent()->FindListObject(AliAODJetEventBackground::StdBranchName())); |
220 | evBkg->Reset(); | |
4aa71b6f | 221 | } |
8838ab7a | 222 | else { |
931c23a1 | 223 | jarray = (TClonesArray*)(AODEvent()->FindListObject(fNonStdBranch.Data())); |
224 | if(!jarray)jarray = (TClonesArray*)(fAODExtension->GetAOD()->FindListObject(fNonStdBranch.Data())); | |
4aa71b6f | 225 | jarray->Delete(); // this is our responsibility, clear before filling again |
bcec7a80 | 226 | evBkg = (AliAODJetEventBackground*)(AODEvent()->FindListObject(Form("%s_%s",AliAODJetEventBackground::StdBranchName(),fNonStdBranch.Data()))); |
931c23a1 | 227 | if(!evBkg) evBkg = (AliAODJetEventBackground*)(fAODExtension->GetAOD()->FindListObject(Form("%s_%s",AliAODJetEventBackground::StdBranchName(),fNonStdBranch.Data()))); |
bcec7a80 | 228 | evBkg->Reset(); |
4aa71b6f | 229 | } |
931c23a1 | 230 | |
0f4a88df | 231 | if (dynamic_cast<AliAODEvent*>(InputEvent()) != 0 && !fReadAODFromOutput) { |
232 | // AOD is input event..........................................V | |
c98859dd | 233 | fJetFinder->GetReader()->SetInputEvent(InputEvent(), InputEvent(), MCEvent()); |
234 | } else { | |
0f4a88df | 235 | // AOD is read from output ....................................V |
c98859dd | 236 | fJetFinder->GetReader()->SetInputEvent(InputEvent(), AODEvent(), MCEvent()); |
237 | } | |
238 | ||
239 | ||
4aa71b6f | 240 | |
8838ab7a | 241 | if(fOpt==0) fJetFinder->ProcessEvent(); |
242 | else fJetFinder->ProcessEvent2(); // V2 | |
243 | ||
244 | // Fill control histos | |
4aa71b6f | 245 | fHistos->FillHistos(jarray); |
8838ab7a | 246 | |
4aa71b6f | 247 | // Post the data |
248 | PostData(1, fListOfHistos); | |
931c23a1 | 249 | return; |
e5b96aa0 | 250 | } |
251 | ||
8838ab7a | 252 | |
253 | //************************************************************* | |
254 | ||
e5b96aa0 | 255 | void AliAnalysisTaskJets::Terminate(Option_t */*option*/) |
256 | { | |
257 | // Terminate analysis | |
258 | // | |
19e6695b | 259 | if (fDebug > 1) printf("AnalysisJets: Terminate() \n"); |
9ff7671d | 260 | // if (fJetFinder) fJetFinder->FinishRun(); |
e5b96aa0 | 261 | } |
262 |