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