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