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