]>
Commit | Line | Data |
---|---|---|
5232d0de | 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 | **************************************************************************/ | |
15 | ||
16 | /* $Id$ */ | |
17 | ||
18 | #include <TROOT.h> | |
19 | #include <TSystem.h> | |
20 | #include <TInterpreter.h> | |
21 | #include <TChain.h> | |
22 | #include <TFile.h> | |
23 | #include <TList.h> | |
24 | ||
25 | #include "AliAnalysisTaskSE.h" | |
26 | #include "AliAnalysisManager.h" | |
90a9a634 | 27 | #include "AliAnalysisCuts.h" |
60a04972 | 28 | #include "AliAnalysisDataSlot.h" |
4747b4a7 | 29 | #include "AliAnalysisDataContainer.h" |
90a9a634 | 30 | |
5232d0de | 31 | #include "AliESDEvent.h" |
620ad672 | 32 | #include "AliESDfriend.h" |
5232d0de | 33 | #include "AliESD.h" |
34 | #include "AliAODEvent.h" | |
3f2431c4 | 35 | #include "AliAODHeader.h" |
c185e0db | 36 | #include "AliAODTracklets.h" |
5a922844 | 37 | #include "AliAODCaloCells.h" |
113bc2bd | 38 | #include "AliAODMCParticle.h" |
5232d0de | 39 | #include "AliVEvent.h" |
40 | #include "AliAODHandler.h" | |
3f2431c4 | 41 | #include "AliAODInputHandler.h" |
5232d0de | 42 | #include "AliMCEventHandler.h" |
43 | #include "AliInputEventHandler.h" | |
2da1d158 | 44 | #include "AliMultiInputEventHandler.h" |
620ad672 | 45 | #include "AliESDInputHandler.h" |
5232d0de | 46 | #include "AliMCEvent.h" |
47 | #include "AliStack.h" | |
4d0a82af | 48 | #include "AliLog.h" |
866d8d78 | 49 | #include "AliAODDimuon.h" |
5232d0de | 50 | |
51 | ||
52 | ClassImp(AliAnalysisTaskSE) | |
53 | ||
54 | //////////////////////////////////////////////////////////////////////// | |
90a9a634 | 55 | AliAODHeader* AliAnalysisTaskSE::fgAODHeader = NULL; |
56 | TClonesArray* AliAnalysisTaskSE::fgAODTracks = NULL; | |
57 | TClonesArray* AliAnalysisTaskSE::fgAODVertices = NULL; | |
58 | TClonesArray* AliAnalysisTaskSE::fgAODV0s = NULL; | |
59 | TClonesArray* AliAnalysisTaskSE::fgAODPMDClusters = NULL; | |
60 | TClonesArray* AliAnalysisTaskSE::fgAODJets = NULL; | |
61 | TClonesArray* AliAnalysisTaskSE::fgAODFMDClusters = NULL; | |
62 | TClonesArray* AliAnalysisTaskSE::fgAODCaloClusters = NULL; | |
63 | TClonesArray* AliAnalysisTaskSE::fgAODMCParticles = NULL; | |
64 | AliAODTracklets* AliAnalysisTaskSE::fgAODTracklets = NULL; | |
65 | AliAODCaloCells* AliAnalysisTaskSE::fgAODEmcalCells = NULL; | |
66 | AliAODCaloCells* AliAnalysisTaskSE::fgAODPhosCells = NULL; | |
866d8d78 | 67 | TClonesArray* AliAnalysisTaskSE::fgAODDimuons = NULL; |
5232d0de | 68 | |
69 | AliAnalysisTaskSE::AliAnalysisTaskSE(): | |
70 | AliAnalysisTask(), | |
71 | fDebug(0), | |
80d13558 | 72 | fEntry(0), |
5232d0de | 73 | fInputEvent(0x0), |
620ad672 | 74 | fESDfriend(0x0), |
80d13558 | 75 | fInputHandler(0x0), |
5232d0de | 76 | fOutputAOD(0x0), |
77 | fMCEvent(0x0), | |
9a587f77 | 78 | fTreeA(0x0), |
79 | fCurrentRunNumber(-1), | |
90a9a634 | 80 | fHistosQA(0x0), |
2da1d158 | 81 | fOfflineTriggerMask(0), |
82 | fMultiInputHandler(0), | |
83 | fMCEventHandler(0) | |
5232d0de | 84 | { |
85 | // Default constructor | |
86 | } | |
87 | ||
88 | AliAnalysisTaskSE::AliAnalysisTaskSE(const char* name): | |
89 | AliAnalysisTask(name, "AnalysisTaskSE"), | |
90 | fDebug(0), | |
80d13558 | 91 | fEntry(0), |
5232d0de | 92 | fInputEvent(0x0), |
620ad672 | 93 | fESDfriend(0x0), |
80d13558 | 94 | fInputHandler(0x0), |
5232d0de | 95 | fOutputAOD(0x0), |
96 | fMCEvent(0x0), | |
1ec2c8dc | 97 | fTreeA(0x0), |
98 | fCurrentRunNumber(-1), | |
90a9a634 | 99 | fHistosQA(0x0), |
2da1d158 | 100 | fOfflineTriggerMask(0), |
101 | fMultiInputHandler(0), | |
102 | fMCEventHandler(0) | |
5232d0de | 103 | { |
104 | // Default constructor | |
105 | DefineInput (0, TChain::Class()); | |
106 | DefineOutput(0, TTree::Class()); | |
107 | } | |
108 | ||
26f071d8 | 109 | AliAnalysisTaskSE::AliAnalysisTaskSE(const AliAnalysisTaskSE& obj): |
110 | AliAnalysisTask(obj), | |
111 | fDebug(0), | |
80d13558 | 112 | fEntry(0), |
26f071d8 | 113 | fInputEvent(0x0), |
620ad672 | 114 | fESDfriend(0x0), |
80d13558 | 115 | fInputHandler(0x0), |
26f071d8 | 116 | fOutputAOD(0x0), |
117 | fMCEvent(0x0), | |
1ec2c8dc | 118 | fTreeA(0x0), |
119 | fCurrentRunNumber(-1), | |
90a9a634 | 120 | fHistosQA(0x0), |
2da1d158 | 121 | fOfflineTriggerMask(0), |
122 | fMultiInputHandler(obj.fMultiInputHandler), | |
123 | fMCEventHandler(obj.fMCEventHandler) | |
26f071d8 | 124 | { |
125 | // Copy constructor | |
1ec2c8dc | 126 | fDebug = obj.fDebug; |
127 | fEntry = obj.fEntry; | |
128 | fInputEvent = obj.fInputEvent; | |
620ad672 | 129 | fESDfriend = obj.fESDfriend; |
1ec2c8dc | 130 | fInputHandler = obj.fInputHandler; |
131 | fOutputAOD = obj.fOutputAOD; | |
132 | fMCEvent = obj.fMCEvent; | |
133 | fTreeA = obj.fTreeA; | |
134 | fCurrentRunNumber = obj.fCurrentRunNumber; | |
135 | fHistosQA = obj.fHistosQA; | |
90a9a634 | 136 | |
26f071d8 | 137 | } |
138 | ||
139 | ||
140 | AliAnalysisTaskSE& AliAnalysisTaskSE::operator=(const AliAnalysisTaskSE& other) | |
141 | { | |
142 | // Assignment | |
143 | AliAnalysisTask::operator=(other); | |
1ec2c8dc | 144 | fDebug = other.fDebug; |
145 | fEntry = other.fEntry; | |
146 | fInputEvent = other.fInputEvent; | |
620ad672 | 147 | fESDfriend = other.fESDfriend; |
1ec2c8dc | 148 | fInputHandler = other.fInputHandler; |
149 | fOutputAOD = other.fOutputAOD; | |
150 | fMCEvent = other.fMCEvent; | |
151 | fTreeA = other.fTreeA; | |
152 | fCurrentRunNumber = other.fCurrentRunNumber; | |
153 | fHistosQA = other.fHistosQA; | |
0c6c629b | 154 | fOfflineTriggerMask = other.fOfflineTriggerMask; |
2da1d158 | 155 | fMultiInputHandler = other.fMultiInputHandler; |
156 | fMCEventHandler = other.fMCEventHandler; | |
26f071d8 | 157 | return *this; |
158 | } | |
5232d0de | 159 | |
4747b4a7 | 160 | //______________________________________________________________________________ |
5232d0de | 161 | void AliAnalysisTaskSE::ConnectInputData(Option_t* /*option*/) |
162 | { | |
163 | // Connect the input data | |
164 | if (fDebug > 1) printf("AnalysisTaskSE::ConnectInputData() \n"); | |
2da1d158 | 165 | |
166 | // Connect input handlers (multi input handler is handled) | |
93dca4c6 | 167 | ConnectMultiHandler(); |
168 | ||
259b7a8a | 169 | if (fInputHandler) { |
620ad672 | 170 | if ((fInputHandler->GetTree())->GetBranch("ESDfriend.")) |
171 | fESDfriend = ((AliESDInputHandler*)fInputHandler)->GetESDfriend(); | |
172 | ||
173 | fInputEvent = fInputHandler->GetEvent(); | |
259b7a8a | 174 | } else if( fMCEvent ) { |
175 | AliWarning("No Input Event Handler connected, only MC Truth Event Handler") ; | |
176 | } else { | |
177 | AliError("No Input Event Handler connected") ; | |
178 | return ; | |
179 | } | |
2da1d158 | 180 | // Disconnect multi handler |
181 | DisconnectMultiHandler(); | |
5232d0de | 182 | } |
183 | ||
184 | void AliAnalysisTaskSE::CreateOutputObjects() | |
185 | { | |
186 | // Create the output container | |
187 | // | |
188 | // Default AOD | |
189 | if (fDebug > 1) printf("AnalysisTaskSE::CreateOutPutData() \n"); | |
190 | ||
b9531017 | 191 | AliAODHandler* handler = dynamic_cast<AliAODHandler*> |
259b7a8a | 192 | ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler()); |
5232d0de | 193 | |
5a922844 | 194 | Bool_t merging = kFALSE; |
195 | AliAODInputHandler* aodIH = static_cast<AliAODInputHandler*>((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler()); | |
196 | if (aodIH) { | |
197 | if (aodIH->GetMergeEvents()) merging = kTRUE; | |
198 | } | |
90a9a634 | 199 | |
c185e0db | 200 | // Check if AOD replication has been required |
3b9a675c | 201 | if (handler) { |
202 | fOutputAOD = handler->GetAOD(); | |
203 | fTreeA = handler->GetTree(); | |
d7c65b93 | 204 | if (fOutputAOD && !(handler->IsStandard())) { |
abf59beb | 205 | if ((handler->NeedsHeaderReplication() || merging) && !(fgAODHeader)) |
c185e0db | 206 | { |
87022830 | 207 | if (fDebug > 1) AliInfo("Replicating header"); |
208 | fgAODHeader = new AliAODHeader; | |
209 | handler->AddBranch("AliAODHeader", &fgAODHeader); | |
c185e0db | 210 | } |
5a922844 | 211 | if ((handler->NeedsTracksBranchReplication() || merging) && !(fgAODTracks)) |
c185e0db | 212 | { |
213 | if (fDebug > 1) AliInfo("Replicating track branch\n"); | |
214 | fgAODTracks = new TClonesArray("AliAODTrack",500); | |
87022830 | 215 | fgAODTracks->SetName("tracks"); |
c185e0db | 216 | handler->AddBranch("TClonesArray", &fgAODTracks); |
217 | } | |
4dd8a1c8 | 218 | if ((handler->NeedsVerticesBranchReplication() || merging) && !(fgAODVertices)) |
c185e0db | 219 | { |
220 | if (fDebug > 1) AliInfo("Replicating vertices branch\n"); | |
221 | fgAODVertices = new TClonesArray("AliAODVertex",500); | |
87022830 | 222 | fgAODVertices->SetName("vertices"); |
c185e0db | 223 | handler->AddBranch("TClonesArray", &fgAODVertices); |
224 | } | |
225 | if ((handler->NeedsV0sBranchReplication()) && !(fgAODV0s)) | |
226 | { | |
227 | if (fDebug > 1) AliInfo("Replicating V0s branch\n"); | |
228 | fgAODV0s = new TClonesArray("AliAODv0",500); | |
87022830 | 229 | fgAODV0s->SetName("v0s"); |
c185e0db | 230 | handler->AddBranch("TClonesArray", &fgAODV0s); |
231 | } | |
232 | if ((handler->NeedsTrackletsBranchReplication()) && !(fgAODTracklets)) | |
233 | { | |
234 | if (fDebug > 1) AliInfo("Replicating Tracklets branch\n"); | |
87022830 | 235 | fgAODTracklets = new AliAODTracklets("tracklets","tracklets"); |
c185e0db | 236 | handler->AddBranch("AliAODTracklets", &fgAODTracklets); |
237 | } | |
238 | if ((handler->NeedsPMDClustersBranchReplication()) && !(fgAODPMDClusters)) | |
239 | { | |
240 | if (fDebug > 1) AliInfo("Replicating PMDClusters branch\n"); | |
241 | fgAODPMDClusters = new TClonesArray("AliAODPmdCluster",500); | |
87022830 | 242 | fgAODPMDClusters->SetName("pmdClusters"); |
c185e0db | 243 | handler->AddBranch("TClonesArray", &fgAODPMDClusters); |
244 | } | |
5a922844 | 245 | if ((handler->NeedsJetsBranchReplication() || merging) && !(fgAODJets)) |
c185e0db | 246 | { |
247 | if (fDebug > 1) AliInfo("Replicating Jets branch\n"); | |
248 | fgAODJets = new TClonesArray("AliAODJet",500); | |
87022830 | 249 | fgAODJets->SetName("jets"); |
c185e0db | 250 | handler->AddBranch("TClonesArray", &fgAODJets); |
251 | } | |
252 | if ((handler->NeedsFMDClustersBranchReplication()) && !(fgAODFMDClusters)) | |
253 | { | |
254 | AliInfo("Replicating FMDClusters branch\n"); | |
255 | fgAODFMDClusters = new TClonesArray("AliAODFmdCluster",500); | |
87022830 | 256 | fgAODFMDClusters->SetName("fmdClusters"); |
c185e0db | 257 | handler->AddBranch("TClonesArray", &fgAODFMDClusters); |
258 | } | |
5a922844 | 259 | if ((handler->NeedsCaloClustersBranchReplication() || merging) && !(fgAODCaloClusters)) |
c185e0db | 260 | { |
261 | if (fDebug > 1) AliInfo("Replicating CaloClusters branch\n"); | |
262 | fgAODCaloClusters = new TClonesArray("AliAODCaloCluster",500); | |
87022830 | 263 | fgAODCaloClusters->SetName("caloClusters"); |
c185e0db | 264 | handler->AddBranch("TClonesArray", &fgAODCaloClusters); |
5a922844 | 265 | |
93dca4c6 | 266 | fgAODEmcalCells = new AliAODCaloCells("emcalCells","emcalCells",AliVCaloCells::kEMCALCell); |
5a922844 | 267 | handler->AddBranch("AliAODCaloCells", &fgAODEmcalCells); |
268 | ||
93dca4c6 | 269 | fgAODPhosCells = new AliAODCaloCells("phosCells","phosCells",AliVCaloCells::kPHOSCell); |
5a922844 | 270 | handler->AddBranch("AliAODCaloCells", &fgAODPhosCells); |
93dca4c6 | 271 | |
c185e0db | 272 | } |
113bc2bd | 273 | if ((handler->NeedsMCParticlesBranchReplication() || merging) && !(fgAODMCParticles)) |
274 | { | |
275 | if (fDebug > 1) AliInfo("Replicating MCParticles branch\n"); | |
276 | fgAODMCParticles = new TClonesArray("AliAODMCParticle",500); | |
277 | fgAODMCParticles->SetName("mcparticles"); | |
278 | handler->AddBranch("TClonesArray", &fgAODMCParticles); | |
279 | } | |
866d8d78 | 280 | if ((handler->NeedsDimuonsBranchReplication() || merging) && !(fgAODDimuons)) |
281 | { | |
282 | if (fDebug > 1) AliInfo("Replicating dimuon branch\n"); | |
283 | fgAODDimuons = new TClonesArray("AliAODDimuon",0); | |
284 | fgAODDimuons->SetName("dimuons"); | |
285 | handler->AddBranch("TClonesArray", &fgAODDimuons); | |
286 | } | |
287 | ||
5a922844 | 288 | // cache the pointerd in the AODEvent |
289 | fOutputAOD->GetStdContent(); | |
3f2431c4 | 290 | } |
3b9a675c | 291 | } |
cdf456b5 | 292 | ConnectMultiHandler(); |
5232d0de | 293 | UserCreateOutputObjects(); |
cdf456b5 | 294 | DisconnectMultiHandler(); |
5232d0de | 295 | } |
296 | ||
297 | void AliAnalysisTaskSE::Exec(Option_t* option) | |
298 | { | |
299 | // | |
300 | // Exec analysis of one event | |
2da1d158 | 301 | |
302 | ConnectMultiHandler(); | |
303 | ||
27704f6c | 304 | if ( fDebug >= 10) |
305 | printf("Task is active %5d\n", IsActive()); | |
8f6e7d10 | 306 | |
259b7a8a | 307 | if (fDebug > 1) AliInfo("AliAnalysisTaskSE::Exec() \n"); |
fdda6b64 | 308 | // |
b9531017 | 309 | AliAODHandler* handler = dynamic_cast<AliAODHandler*> |
fdda6b64 | 310 | ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler()); |
b9531017 | 311 | |
fdda6b64 | 312 | AliAODInputHandler* aodH = dynamic_cast<AliAODInputHandler*>(fInputHandler); |
313 | // | |
5b173801 | 314 | // Was event selected ? If no event selection mechanism, the event SHOULD be selected (AG) |
315 | UInt_t isSelected = AliVEvent::kAny; | |
61200abd | 316 | if( fInputHandler && (fInputHandler->GetEventSelection() || aodH)) { |
ca9cb319 | 317 | // Get the actual offline trigger mask for the event and AND it with the |
318 | // requested mask. If no mask requested select by default the event. | |
319 | if (fOfflineTriggerMask) | |
320 | isSelected = fOfflineTriggerMask & fInputHandler->IsEventSelected(); | |
04a79fa0 | 321 | } |
5b173801 | 322 | // Functionality below moved in the filter tasks (AG) |
323 | // if (handler) handler->SetFillAOD(isSelected); | |
9b98c4df | 324 | |
80ce1b4e | 325 | if( fInputHandler ) { |
326 | fEntry = fInputHandler->GetReadEntry(); | |
327 | fESDfriend = ((AliESDInputHandler*)fInputHandler)->GetESDfriend(); | |
328 | } | |
329 | ||
bf666461 | 330 | |
39b02a2e | 331 | // Notify the change of run number |
276b8751 | 332 | if (InputEvent() && (InputEvent()->GetRunNumber() != fCurrentRunNumber)) { |
39b02a2e | 333 | fCurrentRunNumber = InputEvent()->GetRunNumber(); |
334 | NotifyRun(); | |
335 | } | |
04a79fa0 | 336 | |
259b7a8a | 337 | else if( fMCEvent ) |
338 | fEntry = fMCEvent->Header()->GetEvent(); | |
4d0a82af | 339 | if ( !((Entry()-1)%100) && fDebug > 0) |
259b7a8a | 340 | AliInfo(Form("%s ----> Processing event # %lld", CurrentFileName(), Entry())); |
3f2431c4 | 341 | |
fdda6b64 | 342 | |
343 | ||
c185e0db | 344 | |
345 | if (handler && aodH) { | |
04a79fa0 | 346 | fMCEvent = aodH->MCEvent(); |
5a922844 | 347 | Bool_t merging = aodH->GetMergeEvents(); |
1fbe12d4 | 348 | |
349 | // Do not analyze merged events if last embedded file has less events than normal event, | |
350 | // skip analysis after last embeded event | |
351 | if(merging){ | |
352 | if(aodH->GetReadEntry() + aodH->GetMergeOffset() >= aodH->GetTreeToMerge()->GetEntriesFast()){ | |
353 | //printf("Skip Entry %lld, Offset %d, Tree Entries %d\n",aodH->GetReadEntry(),aodH->GetMergeOffset(), aodH->GetTreeToMerge()->GetEntries()); | |
354 | ||
355 | // Do I need to add the lines before the return? | |
356 | // Added protection in case the derived task is not an AOD producer. | |
357 | AliAnalysisDataSlot *out0 = GetOutputSlot(0); | |
358 | if (out0 && out0->IsConnected()) PostData(0, fTreeA); | |
359 | ||
360 | DisconnectMultiHandler(); | |
361 | ||
362 | return; | |
363 | } | |
364 | //else printf("MERGE Entry %lld, Offset %d, Tree Entries %d\n",aodH->GetReadEntry(),aodH->GetMergeOffset(), aodH->GetTreeToMerge()->GetEntries()); | |
365 | } | |
366 | ||
9daedfd1 | 367 | AliAODEvent* aod = dynamic_cast<AliAODEvent*>(InputEvent()); |
368 | ||
369 | if (aod && !(handler->IsStandard()) && !(handler->AODIsReplicated())) { | |
abf59beb | 370 | if ((handler->NeedsHeaderReplication() || merging) && (fgAODHeader)) |
c185e0db | 371 | { |
61d5496b | 372 | // copy the contents by assigment |
9daedfd1 | 373 | *fgAODHeader = *(aod->GetHeader()); |
daa81fe5 | 374 | } |
abf59beb | 375 | if ((handler->NeedsTracksBranchReplication() || (merging && aodH->GetMergeTracks())) && (fgAODTracks)) |
c185e0db | 376 | { |
9daedfd1 | 377 | TClonesArray* tracks = aod->GetTracks(); |
c185e0db | 378 | new (fgAODTracks) TClonesArray(*tracks); |
379 | } | |
417ab5ac | 380 | if ((handler->NeedsVerticesBranchReplication() || merging) && (fgAODVertices)) |
c185e0db | 381 | { |
9daedfd1 | 382 | TClonesArray* vertices = aod->GetVertices(); |
c185e0db | 383 | new (fgAODVertices) TClonesArray(*vertices); |
384 | } | |
385 | if ((handler->NeedsV0sBranchReplication()) && (fgAODV0s)) | |
386 | { | |
9daedfd1 | 387 | TClonesArray* v0s = aod->GetV0s(); |
113bc2bd | 388 | new (fgAODV0s) TClonesArray(*v0s); |
c185e0db | 389 | } |
390 | if ((handler->NeedsTrackletsBranchReplication()) && (fgAODTracklets)) | |
391 | { | |
9daedfd1 | 392 | *fgAODTracklets = *aod->GetTracklets(); |
c185e0db | 393 | } |
394 | if ((handler->NeedsPMDClustersBranchReplication()) && (fgAODPMDClusters)) | |
395 | { | |
9daedfd1 | 396 | TClonesArray* pmdClusters = aod->GetPmdClusters(); |
113bc2bd | 397 | new (fgAODPMDClusters) TClonesArray(*pmdClusters); |
c185e0db | 398 | } |
abf59beb | 399 | if ((handler->NeedsJetsBranchReplication() || (merging &&aodH->GetMergeTracks())) && (fgAODJets)) |
c185e0db | 400 | { |
9daedfd1 | 401 | TClonesArray* jets = aod->GetJets(); |
113bc2bd | 402 | new (fgAODJets) TClonesArray(*jets); |
c185e0db | 403 | } |
404 | if ((handler->NeedsFMDClustersBranchReplication()) && (fgAODFMDClusters)) | |
405 | { | |
9daedfd1 | 406 | TClonesArray* fmdClusters = aod->GetFmdClusters(); |
113bc2bd | 407 | new (fgAODFMDClusters) TClonesArray(*fmdClusters); |
c185e0db | 408 | } |
abf59beb | 409 | if ((handler->NeedsCaloClustersBranchReplication() || |
410 | (merging && (aodH->GetMergeEMCALClusters() || aodH->GetMergePHOSClusters()))) | |
411 | && (fgAODCaloClusters)) | |
c185e0db | 412 | { |
9daedfd1 | 413 | TClonesArray* caloClusters = aod->GetCaloClusters(); |
113bc2bd | 414 | new (fgAODCaloClusters) TClonesArray(*caloClusters); |
415 | } | |
416 | ||
417 | if ((handler->NeedsMCParticlesBranchReplication() || merging) && (fgAODMCParticles)) | |
418 | { | |
9daedfd1 | 419 | TClonesArray* mcParticles = (TClonesArray*) (aod->FindListObject("mcparticles")); |
93dca4c6 | 420 | if( mcParticles ) |
421 | new (fgAODMCParticles) TClonesArray(*mcParticles); | |
c185e0db | 422 | } |
866d8d78 | 423 | |
abf59beb | 424 | if ((handler->NeedsDimuonsBranchReplication() || (merging && aodH->GetMergeTracks())) && (fgAODDimuons)) |
866d8d78 | 425 | { |
8f6e7d10 | 426 | fgAODDimuons->Clear(); |
427 | TClonesArray& dimuons = *fgAODDimuons; | |
428 | TClonesArray& tracksnew = *fgAODTracks; | |
429 | ||
397081d5 | 430 | Int_t nMuonTrack[100]; |
431 | for(Int_t imuon = 0; imuon < 100; imuon++) nMuonTrack[imuon] = 0; | |
8f6e7d10 | 432 | Int_t nMuons=0; |
433 | for(Int_t ii=0; ii < fgAODTracks->GetEntries(); ii++){ | |
434 | AliAODTrack *track = (AliAODTrack*) fgAODTracks->At(ii); | |
435 | if(track->IsMuonTrack()) { | |
436 | nMuonTrack[nMuons]= ii; | |
437 | nMuons++; | |
438 | } | |
439 | } | |
440 | Int_t jDimuons=0; | |
441 | if(nMuons >= 2){ | |
442 | for(Int_t i = 0; i < nMuons; i++){ | |
443 | Int_t index0 = nMuonTrack[i]; | |
444 | for(Int_t j = i+1; j < nMuons; j++){ | |
445 | Int_t index1 = nMuonTrack[j]; | |
8f6e7d10 | 446 | tracksnew.At(index0)->ResetBit(kIsReferenced); |
447 | tracksnew.At(index0)->SetUniqueID(0); | |
448 | tracksnew.At(index1)->ResetBit(kIsReferenced); | |
449 | tracksnew.At(index1)->SetUniqueID(0); | |
450 | new(dimuons[jDimuons++]) AliAODDimuon(tracksnew.At(index0),tracksnew.At(index1)); | |
451 | } | |
452 | } | |
453 | } | |
866d8d78 | 454 | } |
5a922844 | 455 | // Additional merging if needed |
456 | if (merging) { | |
93dca4c6 | 457 | Int_t nc; |
458 | ||
113bc2bd | 459 | // mcParticles |
460 | TClonesArray* mcparticles = (TClonesArray*) ((aodH->GetEventToMerge())->FindListObject("mcparticles")); | |
93dca4c6 | 461 | if( mcparticles ){ |
462 | Int_t npart = mcparticles->GetEntries(); | |
463 | nc = fgAODMCParticles->GetEntries(); | |
464 | ||
465 | for (Int_t i = 0; i < npart; i++) { | |
113bc2bd | 466 | AliAODMCParticle* particle = (AliAODMCParticle*) mcparticles->At(i); |
c8de791b | 467 | new((*fgAODMCParticles)[nc++]) AliAODMCParticle(*particle); |
93dca4c6 | 468 | } |
113bc2bd | 469 | } |
93dca4c6 | 470 | |
5a922844 | 471 | // tracks |
472 | TClonesArray* tracks = aodH->GetEventToMerge()->GetTracks(); | |
abf59beb | 473 | if(tracks && aodH->GetMergeTracks()){ |
93dca4c6 | 474 | Int_t ntr = tracks->GetEntries(); |
475 | nc = fgAODTracks->GetEntries(); | |
476 | for (Int_t i = 0; i < ntr; i++) { | |
5a922844 | 477 | AliAODTrack* track = (AliAODTrack*) tracks->At(i); |
478 | AliAODTrack* newtrack = new((*fgAODTracks)[nc++]) AliAODTrack(*track); | |
93dca4c6 | 479 | newtrack->SetLabel(newtrack->GetLabel() + fgAODMCParticles->GetEntries()); |
480 | } | |
481 | ||
482 | for (Int_t i = 0; i < nc; i++) | |
483 | { | |
484 | AliAODTrack* track = (AliAODTrack*) fgAODTracks->At(i); | |
485 | track->ResetBit(kIsReferenced); | |
486 | track->SetUniqueID(0); | |
487 | } | |
c8de791b | 488 | } |
489 | ||
5a922844 | 490 | // clusters |
491 | TClonesArray* clusters = aodH->GetEventToMerge()->GetCaloClusters(); | |
abf59beb | 492 | if( clusters && (aodH->GetMergeEMCALClusters() || aodH->GetMergePHOSClusters())) { |
93dca4c6 | 493 | Int_t ncl = clusters->GetEntries(); |
494 | nc = fgAODCaloClusters->GetEntries(); | |
495 | for (Int_t i = 0; i < ncl; i++) { | |
5a922844 | 496 | AliAODCaloCluster* cluster = (AliAODCaloCluster*) clusters->At(i); |
abf59beb | 497 | if(cluster->IsEMCAL() && !aodH->GetMergeEMCALClusters() ) continue; |
498 | if(cluster->IsPHOS() && !aodH->GetMergePHOSClusters() ) continue; | |
c8de791b | 499 | new((*fgAODCaloClusters)[nc++]) AliAODCaloCluster(*cluster); |
93dca4c6 | 500 | } |
501 | } | |
502 | ||
503 | // EMCAL cells | |
504 | //*fgAODEmcalCells = *(aod->GetEMCALCells()); // This will be valid after 10.Mar.2011. | |
abf59beb | 505 | if(aodH->GetMergeEMCALCells()) { |
506 | AliAODCaloCells* copycells = aod->GetEMCALCells(); | |
507 | fgAODEmcalCells->CreateContainer(copycells->GetNumberOfCells()); | |
508 | nc = copycells->GetNumberOfCells(); | |
d8e47d0b | 509 | while( nc-- ){ fgAODEmcalCells->SetCell(nc,copycells->GetCellNumber(nc),copycells->GetAmplitude(nc)); } |
510 | ||
abf59beb | 511 | AliAODCaloCells* cellsA = aodH->GetEventToMerge()->GetEMCALCells(); |
512 | if( cellsA ){ | |
513 | Int_t ncells = cellsA->GetNumberOfCells(); | |
514 | nc = fgAODEmcalCells->GetNumberOfCells(); | |
515 | for (Int_t i = 0; i < ncells; i++) { | |
516 | Int_t cn = cellsA->GetCellNumber(i); | |
517 | Int_t pos = fgAODEmcalCells->GetCellPosition(cn); | |
518 | if (pos >= 0) { | |
519 | Double_t amp = cellsA->GetAmplitude(i) + fgAODEmcalCells->GetAmplitude(pos); | |
520 | fgAODEmcalCells->SetCell(pos, cn, amp); | |
521 | } else { | |
522 | AliAODCaloCells* copycells1 = new AliAODCaloCells(*fgAODEmcalCells); | |
523 | fgAODEmcalCells->CreateContainer(nc+1); | |
524 | Int_t nn = copycells1->GetNumberOfCells(); | |
525 | while( nn-- ){ fgAODEmcalCells->SetCell(nn,copycells1->GetCellNumber(nn),copycells1->GetAmplitude(nn)); } | |
526 | fgAODEmcalCells->SetCell(nc++,cn,cellsA->GetAmplitude(i)); | |
527 | delete copycells1; | |
528 | } | |
529 | } | |
530 | fgAODEmcalCells->Sort(); | |
5a922844 | 531 | } |
abf59beb | 532 | } // merge emcal cells |
533 | ||
113bc2bd | 534 | |
93dca4c6 | 535 | // PHOS cells |
536 | //*fgAODPhosCells = *(aod->GetPHOSCells()); // This will be valid after 10.Mar.2011. | |
abf59beb | 537 | if(aodH->GetMergePHOSCells()) { |
538 | AliAODCaloCells* copycells = aod->GetPHOSCells(); | |
539 | fgAODPhosCells->CreateContainer(copycells->GetNumberOfCells()); | |
540 | nc = copycells->GetNumberOfCells(); | |
541 | while( nc-- ){ fgAODPhosCells->SetCell(nc,copycells->GetCellNumber(nc),copycells->GetAmplitude(nc)); } | |
542 | AliAODCaloCells* cellsP = aodH->GetEventToMerge()->GetPHOSCells(); | |
543 | if( cellsP ){ | |
544 | Int_t ncellsP = cellsP->GetNumberOfCells(); | |
545 | nc = fgAODPhosCells->GetNumberOfCells(); | |
546 | ||
547 | for (Int_t i = 0; i < ncellsP; i++) { | |
548 | Int_t cn = cellsP->GetCellNumber(i); | |
549 | Int_t pos = fgAODPhosCells->GetCellPosition(cn); | |
550 | if (pos >= 0) { | |
551 | Double_t amp = cellsP->GetAmplitude(i) + fgAODPhosCells->GetAmplitude(pos); | |
552 | fgAODPhosCells->SetCell(pos, cn, amp); | |
553 | } else { | |
554 | AliAODCaloCells* copycells1 = new AliAODCaloCells(*fgAODPhosCells); | |
555 | fgAODPhosCells->CreateContainer(nc+1); | |
556 | Int_t nn = copycells1->GetNumberOfCells(); | |
557 | while( nn-- ){ fgAODPhosCells->SetCell(nn,copycells1->GetCellNumber(nn),copycells1->GetAmplitude(nn)); } | |
558 | fgAODPhosCells->SetCell(nc++,cn,cellsP->GetAmplitude(i)); | |
559 | delete copycells1; | |
560 | } | |
561 | } | |
562 | fgAODPhosCells->Sort(); | |
93dca4c6 | 563 | } |
abf59beb | 564 | } // Merge PHOS Cells |
93dca4c6 | 565 | |
113bc2bd | 566 | } // merging |
c185e0db | 567 | |
5a922844 | 568 | handler->SetAODIsReplicated(); |
3f2431c4 | 569 | } |
570 | } | |
571 | ||
93dca4c6 | 572 | |
4d0a82af | 573 | // Call the user analysis |
2da1d158 | 574 | if (!fMCEventHandler) { |
5b173801 | 575 | if (isSelected) |
67d77d71 | 576 | UserExec(option); |
577 | } else { | |
2da1d158 | 578 | if (isSelected && (fMCEventHandler->InitOk())) |
67d77d71 | 579 | UserExec(option); |
580 | } | |
90a9a634 | 581 | |
582 | // Added protection in case the derived task is not an AOD producer. | |
60a04972 | 583 | AliAnalysisDataSlot *out0 = GetOutputSlot(0); |
584 | if (out0 && out0->IsConnected()) PostData(0, fTreeA); | |
93dca4c6 | 585 | |
2da1d158 | 586 | DisconnectMultiHandler(); |
5232d0de | 587 | } |
588 | ||
4d0a82af | 589 | const char* AliAnalysisTaskSE::CurrentFileName() |
590 | { | |
591 | // Returns the current file name | |
259b7a8a | 592 | if( fInputHandler ) |
593 | return fInputHandler->GetTree()->GetCurrentFile()->GetName(); | |
594 | else if( fMCEvent ) | |
595 | return ((AliMCEventHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetMCtruthEventHandler()))->TreeK()->GetCurrentFile()->GetName(); | |
8803dcb1 | 596 | else return ""; |
4d0a82af | 597 | } |
5232d0de | 598 | |
3cee83d7 | 599 | void AliAnalysisTaskSE::AddAODBranch(const char* cname, void* addobj, const char *fname) |
164e94ff | 600 | { |
601 | // Add a new branch to the aod tree | |
b9531017 | 602 | AliAODHandler* handler = dynamic_cast<AliAODHandler*> |
164e94ff | 603 | ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler()); |
604 | if (handler) { | |
3cee83d7 | 605 | handler->AddBranch(cname, addobj, fname); |
164e94ff | 606 | } |
607 | } | |
3cee83d7 | 608 | |
609 | Bool_t AliAnalysisTaskSE::IsStandardAOD() const | |
610 | { | |
611 | // Check if the output AOD handler is configured for standard or delta AOD. | |
612 | // Users should first check that AODEvent() returns non-null. | |
b9531017 | 613 | AliAODHandler* handler = dynamic_cast<AliAODHandler*> |
3cee83d7 | 614 | ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler()); |
615 | if (!handler) { | |
616 | Error("IsStandardAOD", "No AOD handler. Please use AODEvent() to check this first"); | |
617 | return kTRUE; | |
618 | } | |
619 | return handler->IsStandard(); | |
620 | } | |
1ec2c8dc | 621 | |
622 | Bool_t AliAnalysisTaskSE::Notify() | |
623 | { | |
9a587f77 | 624 | return (UserNotify()); |
1ec2c8dc | 625 | } |
626 | ||
cec9e119 | 627 | const AliEventTag *AliAnalysisTaskSE::EventTag() const |
628 | { | |
629 | // Returns tag for the current event, if any. The return value should always be checked by the user. | |
630 | if (!fInputHandler) { | |
631 | Error("EventTag", "Input handler not yet available. Call this in UserExec"); | |
632 | return NULL; | |
633 | } | |
634 | return fInputHandler->GetEventTag(); | |
635 | } | |
1ec2c8dc | 636 | |
cec9e119 | 637 | void AliAnalysisTaskSE::LoadBranches() const |
638 | { | |
639 | // Load all branches declared in fBranchNames data member of the parent class. | |
640 | // Should be called in UserExec. | |
641 | if (!fInputHandler) { | |
642 | Error("LoadBranches", "Input handler not available yet. Call this in UserExec"); | |
643 | return; | |
644 | } | |
645 | AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); | |
646 | if (mgr->GetAutoBranchLoading()) return; | |
647 | TString taskbranches; | |
648 | GetBranches(fInputHandler->GetDataType(), taskbranches); | |
649 | if (taskbranches.IsNull()) return; | |
650 | TObjArray *arr = taskbranches.Tokenize(","); | |
651 | TIter next(arr); | |
652 | TObject *obj; | |
653 | while ((obj=next())) mgr->LoadBranch(obj->GetName()); | |
654 | } | |
2da1d158 | 655 | |
656 | ||
657 | //_________________________________________________________________________________________________ | |
658 | void AliAnalysisTaskSE::ConnectMultiHandler() | |
659 | { | |
660 | // | |
661 | // Connect MultiHandler | |
662 | // | |
663 | fInputHandler = (AliInputEventHandler *)((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler()); | |
664 | fMultiInputHandler = dynamic_cast<AliMultiInputEventHandler *>(fInputHandler); | |
665 | if (fMultiInputHandler) { | |
2da1d158 | 666 | fInputHandler = dynamic_cast<AliInputEventHandler *>(fMultiInputHandler->GetFirstInputEventHandler()); |
667 | fMCEventHandler = dynamic_cast<AliMCEventHandler *>(fMultiInputHandler->GetFirstMCEventHandler()); | |
bae44bb7 | 668 | } else { |
669 | fMCEventHandler = dynamic_cast<AliMCEventHandler *>((AliAnalysisManager::GetAnalysisManager())->GetMCtruthEventHandler()); | |
2da1d158 | 670 | } |
671 | if (fMCEventHandler) fMCEvent = fMCEventHandler->MCEvent(); | |
672 | } | |
673 | ||
674 | //_________________________________________________________________________________________________ | |
675 | void AliAnalysisTaskSE::DisconnectMultiHandler() | |
676 | { | |
677 | // | |
678 | // Disconnect MultiHandler | |
679 | // | |
680 | if (fMultiInputHandler) fInputHandler = fMultiInputHandler; | |
681 | } |