Sign of L1phase changed
[u/mrichter/AliRoot.git] / ANALYSIS / AliAnalysisTaskSE.cxx
CommitLineData
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"
90a9a634 29
5232d0de 30#include "AliESDEvent.h"
620ad672 31#include "AliESDfriend.h"
5232d0de 32#include "AliESD.h"
33#include "AliAODEvent.h"
3f2431c4 34#include "AliAODHeader.h"
c185e0db 35#include "AliAODTracklets.h"
5a922844 36#include "AliAODCaloCells.h"
113bc2bd 37#include "AliAODMCParticle.h"
5232d0de 38#include "AliVEvent.h"
39#include "AliAODHandler.h"
3f2431c4 40#include "AliAODInputHandler.h"
5232d0de 41#include "AliMCEventHandler.h"
42#include "AliInputEventHandler.h"
620ad672 43#include "AliESDInputHandler.h"
5232d0de 44#include "AliMCEvent.h"
45#include "AliStack.h"
4d0a82af 46#include "AliLog.h"
866d8d78 47#include "AliAODDimuon.h"
5232d0de 48
49
50ClassImp(AliAnalysisTaskSE)
51
52////////////////////////////////////////////////////////////////////////
90a9a634 53AliAODHeader* AliAnalysisTaskSE::fgAODHeader = NULL;
54TClonesArray* AliAnalysisTaskSE::fgAODTracks = NULL;
55TClonesArray* AliAnalysisTaskSE::fgAODVertices = NULL;
56TClonesArray* AliAnalysisTaskSE::fgAODV0s = NULL;
57TClonesArray* AliAnalysisTaskSE::fgAODPMDClusters = NULL;
58TClonesArray* AliAnalysisTaskSE::fgAODJets = NULL;
59TClonesArray* AliAnalysisTaskSE::fgAODFMDClusters = NULL;
60TClonesArray* AliAnalysisTaskSE::fgAODCaloClusters = NULL;
61TClonesArray* AliAnalysisTaskSE::fgAODMCParticles = NULL;
62AliAODTracklets* AliAnalysisTaskSE::fgAODTracklets = NULL;
63AliAODCaloCells* AliAnalysisTaskSE::fgAODEmcalCells = NULL;
64AliAODCaloCells* AliAnalysisTaskSE::fgAODPhosCells = NULL;
866d8d78 65TClonesArray* AliAnalysisTaskSE::fgAODDimuons = NULL;
5232d0de 66
67AliAnalysisTaskSE::AliAnalysisTaskSE():
68 AliAnalysisTask(),
69 fDebug(0),
80d13558 70 fEntry(0),
5232d0de 71 fInputEvent(0x0),
620ad672 72 fESDfriend(0x0),
80d13558 73 fInputHandler(0x0),
5232d0de 74 fOutputAOD(0x0),
75 fMCEvent(0x0),
9a587f77 76 fTreeA(0x0),
77 fCurrentRunNumber(-1),
90a9a634 78 fHistosQA(0x0),
0c6c629b 79 fOfflineTriggerMask(0)
5232d0de 80{
81 // Default constructor
82}
83
84AliAnalysisTaskSE::AliAnalysisTaskSE(const char* name):
85 AliAnalysisTask(name, "AnalysisTaskSE"),
86 fDebug(0),
80d13558 87 fEntry(0),
5232d0de 88 fInputEvent(0x0),
620ad672 89 fESDfriend(0x0),
80d13558 90 fInputHandler(0x0),
5232d0de 91 fOutputAOD(0x0),
92 fMCEvent(0x0),
1ec2c8dc 93 fTreeA(0x0),
94 fCurrentRunNumber(-1),
90a9a634 95 fHistosQA(0x0),
0c6c629b 96 fOfflineTriggerMask(0)
5232d0de 97{
98 // Default constructor
99 DefineInput (0, TChain::Class());
100 DefineOutput(0, TTree::Class());
101}
102
26f071d8 103AliAnalysisTaskSE::AliAnalysisTaskSE(const AliAnalysisTaskSE& obj):
104 AliAnalysisTask(obj),
105 fDebug(0),
80d13558 106 fEntry(0),
26f071d8 107 fInputEvent(0x0),
620ad672 108 fESDfriend(0x0),
80d13558 109 fInputHandler(0x0),
26f071d8 110 fOutputAOD(0x0),
111 fMCEvent(0x0),
1ec2c8dc 112 fTreeA(0x0),
113 fCurrentRunNumber(-1),
90a9a634 114 fHistosQA(0x0),
0c6c629b 115 fOfflineTriggerMask(0)
26f071d8 116{
117// Copy constructor
1ec2c8dc 118 fDebug = obj.fDebug;
119 fEntry = obj.fEntry;
120 fInputEvent = obj.fInputEvent;
620ad672 121 fESDfriend = obj.fESDfriend;
1ec2c8dc 122 fInputHandler = obj.fInputHandler;
123 fOutputAOD = obj.fOutputAOD;
124 fMCEvent = obj.fMCEvent;
125 fTreeA = obj.fTreeA;
126 fCurrentRunNumber = obj.fCurrentRunNumber;
127 fHistosQA = obj.fHistosQA;
90a9a634 128
26f071d8 129}
130
131
132AliAnalysisTaskSE& AliAnalysisTaskSE::operator=(const AliAnalysisTaskSE& other)
133{
134// Assignment
135 AliAnalysisTask::operator=(other);
1ec2c8dc 136 fDebug = other.fDebug;
137 fEntry = other.fEntry;
138 fInputEvent = other.fInputEvent;
620ad672 139 fESDfriend = other.fESDfriend;
1ec2c8dc 140 fInputHandler = other.fInputHandler;
141 fOutputAOD = other.fOutputAOD;
142 fMCEvent = other.fMCEvent;
143 fTreeA = other.fTreeA;
144 fCurrentRunNumber = other.fCurrentRunNumber;
145 fHistosQA = other.fHistosQA;
0c6c629b 146 fOfflineTriggerMask = other.fOfflineTriggerMask;
26f071d8 147 return *this;
148}
5232d0de 149
150
151void AliAnalysisTaskSE::ConnectInputData(Option_t* /*option*/)
152{
153// Connect the input data
154 if (fDebug > 1) printf("AnalysisTaskSE::ConnectInputData() \n");
155//
156// ESD
157//
f0b15803 158 fInputHandler = (AliInputEventHandler*)
259b7a8a 159 ((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
5232d0de 160//
161// Monte Carlo
162//
163 AliMCEventHandler* mcH = 0;
164 mcH = (AliMCEventHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetMCtruthEventHandler());
04a79fa0 165 if (mcH) {
166 fMCEvent = mcH->MCEvent();
167 }
259b7a8a 168
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 }
5232d0de 180}
181
182void AliAnalysisTaskSE::CreateOutputObjects()
183{
184// Create the output container
185//
186// Default AOD
187 if (fDebug > 1) printf("AnalysisTaskSE::CreateOutPutData() \n");
188
b9531017 189 AliAODHandler* handler = dynamic_cast<AliAODHandler*>
259b7a8a 190 ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
5232d0de 191
5a922844 192 Bool_t merging = kFALSE;
193 AliAODInputHandler* aodIH = static_cast<AliAODInputHandler*>((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
194 if (aodIH) {
195 if (aodIH->GetMergeEvents()) merging = kTRUE;
196 }
197
90a9a634 198
c185e0db 199 // Check if AOD replication has been required
200
3b9a675c 201 if (handler) {
202 fOutputAOD = handler->GetAOD();
203 fTreeA = handler->GetTree();
d7c65b93 204 if (fOutputAOD && !(handler->IsStandard())) {
c185e0db 205 if ((handler->NeedsHeaderReplication()) && !(fgAODHeader))
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
266 fgAODEmcalCells = new AliAODCaloCells();
267 fgAODEmcalCells->SetName("emcalCells");
268 handler->AddBranch("AliAODCaloCells", &fgAODEmcalCells);
269
270 fgAODPhosCells = new AliAODCaloCells();
271 fgAODPhosCells->SetName("phosCells");
272 handler->AddBranch("AliAODCaloCells", &fgAODPhosCells);
c185e0db 273 }
113bc2bd 274 if ((handler->NeedsMCParticlesBranchReplication() || merging) && !(fgAODMCParticles))
275 {
276 if (fDebug > 1) AliInfo("Replicating MCParticles branch\n");
277 fgAODMCParticles = new TClonesArray("AliAODMCParticle",500);
278 fgAODMCParticles->SetName("mcparticles");
279 handler->AddBranch("TClonesArray", &fgAODMCParticles);
280 }
866d8d78 281 if ((handler->NeedsDimuonsBranchReplication() || merging) && !(fgAODDimuons))
282 {
283 if (fDebug > 1) AliInfo("Replicating dimuon branch\n");
284 fgAODDimuons = new TClonesArray("AliAODDimuon",0);
285 fgAODDimuons->SetName("dimuons");
286 handler->AddBranch("TClonesArray", &fgAODDimuons);
287 }
288
5a922844 289 // cache the pointerd in the AODEvent
290 fOutputAOD->GetStdContent();
3f2431c4 291 }
3b9a675c 292 }
5232d0de 293 UserCreateOutputObjects();
294}
295
296void AliAnalysisTaskSE::Exec(Option_t* option)
297{
298//
299// Exec analysis of one event
27704f6c 300 if ( fDebug >= 10)
301 printf("Task is active %5d\n", IsActive());
8f6e7d10 302
259b7a8a 303 if (fDebug > 1) AliInfo("AliAnalysisTaskSE::Exec() \n");
fdda6b64 304//
b9531017 305 AliAODHandler* handler = dynamic_cast<AliAODHandler*>
fdda6b64 306 ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
b9531017 307
fdda6b64 308 AliAODInputHandler* aodH = dynamic_cast<AliAODInputHandler*>(fInputHandler);
309//
5b173801 310// Was event selected ? If no event selection mechanism, the event SHOULD be selected (AG)
311 UInt_t isSelected = AliVEvent::kAny;
312 if( fInputHandler && fInputHandler->GetEventSelection()) {
313 // Get the actual offline trigger mask for the event
314 isSelected = fInputHandler->IsEventSelected();
315 // If the task had a selection AND it with the event mask (i.e. event interesting for the task if at least one matching trigger)
316 if (fOfflineTriggerMask) isSelected &= fOfflineTriggerMask;
04a79fa0 317 }
5b173801 318// Functionality below moved in the filter tasks (AG)
319// if (handler) handler->SetFillAOD(isSelected);
9b98c4df 320
80ce1b4e 321 if( fInputHandler ) {
322 fEntry = fInputHandler->GetReadEntry();
323 fESDfriend = ((AliESDInputHandler*)fInputHandler)->GetESDfriend();
324 }
325
bf666461 326
39b02a2e 327// Notify the change of run number
276b8751 328 if (InputEvent() && (InputEvent()->GetRunNumber() != fCurrentRunNumber)) {
39b02a2e 329 fCurrentRunNumber = InputEvent()->GetRunNumber();
330 NotifyRun();
331 }
04a79fa0 332
259b7a8a 333 else if( fMCEvent )
334 fEntry = fMCEvent->Header()->GetEvent();
4d0a82af 335 if ( !((Entry()-1)%100) && fDebug > 0)
259b7a8a 336 AliInfo(Form("%s ----> Processing event # %lld", CurrentFileName(), Entry()));
3f2431c4 337
fdda6b64 338
339
c185e0db 340
341 if (handler && aodH) {
04a79fa0 342 fMCEvent = aodH->MCEvent();
5a922844 343 Bool_t merging = aodH->GetMergeEvents();
04a79fa0 344
c185e0db 345 if (!(handler->IsStandard()) && !(handler->AODIsReplicated())) {
346 if ((handler->NeedsHeaderReplication()) && (fgAODHeader))
347 {
61d5496b 348 // copy the contents by assigment
349 *fgAODHeader = *(dynamic_cast<AliAODHeader*>(InputEvent()->GetHeader()));
daa81fe5 350 }
5a922844 351 if ((handler->NeedsTracksBranchReplication() || merging) && (fgAODTracks))
c185e0db 352 {
353 TClonesArray* tracks = (dynamic_cast<AliAODEvent*>(InputEvent()))->GetTracks();
354 new (fgAODTracks) TClonesArray(*tracks);
355 }
417ab5ac 356 if ((handler->NeedsVerticesBranchReplication() || merging) && (fgAODVertices))
c185e0db 357 {
358 TClonesArray* vertices = (dynamic_cast<AliAODEvent*>(InputEvent()))->GetVertices();
359 new (fgAODVertices) TClonesArray(*vertices);
360 }
361 if ((handler->NeedsV0sBranchReplication()) && (fgAODV0s))
362 {
113bc2bd 363 TClonesArray* v0s = (dynamic_cast<AliAODEvent*>(InputEvent()))->GetV0s();
364 new (fgAODV0s) TClonesArray(*v0s);
c185e0db 365 }
366 if ((handler->NeedsTrackletsBranchReplication()) && (fgAODTracklets))
367 {
61d5496b 368 *fgAODTracklets = *(dynamic_cast<AliAODEvent*>(InputEvent()))->GetTracklets();
c185e0db 369 }
370 if ((handler->NeedsPMDClustersBranchReplication()) && (fgAODPMDClusters))
371 {
113bc2bd 372 TClonesArray* pmdClusters = (dynamic_cast<AliAODEvent*>(InputEvent()))->GetPmdClusters();
373 new (fgAODPMDClusters) TClonesArray(*pmdClusters);
c185e0db 374 }
5a922844 375 if ((handler->NeedsJetsBranchReplication() || merging) && (fgAODJets))
c185e0db 376 {
113bc2bd 377 TClonesArray* jets = (dynamic_cast<AliAODEvent*>(InputEvent()))->GetJets();
378 new (fgAODJets) TClonesArray(*jets);
c185e0db 379 }
380 if ((handler->NeedsFMDClustersBranchReplication()) && (fgAODFMDClusters))
381 {
113bc2bd 382 TClonesArray* fmdClusters = (dynamic_cast<AliAODEvent*>(InputEvent()))->GetFmdClusters();
383 new (fgAODFMDClusters) TClonesArray(*fmdClusters);
c185e0db 384 }
5a922844 385 if ((handler->NeedsCaloClustersBranchReplication() || merging) && (fgAODCaloClusters))
c185e0db 386 {
113bc2bd 387 TClonesArray* caloClusters = (dynamic_cast<AliAODEvent*>(InputEvent()))->GetCaloClusters();
388 new (fgAODCaloClusters) TClonesArray(*caloClusters);
389 }
390
391 if ((handler->NeedsMCParticlesBranchReplication() || merging) && (fgAODMCParticles))
392 {
393 TClonesArray* mcParticles = (TClonesArray*) ((dynamic_cast<AliAODEvent*>(InputEvent()))->FindListObject("mcparticles"));
394 new (fgAODMCParticles) TClonesArray(*mcParticles);
c185e0db 395 }
866d8d78 396
397 if ((handler->NeedsDimuonsBranchReplication() || merging) && (fgAODDimuons))
398 {
8f6e7d10 399 fgAODDimuons->Clear();
400 TClonesArray& dimuons = *fgAODDimuons;
401 TClonesArray& tracksnew = *fgAODTracks;
402
403 Int_t nMuonTrack[10];
404 for(Int_t imuon = 0; imuon < 10; imuon++) nMuonTrack[imuon] = 0;
405 Int_t nMuons=0;
406 for(Int_t ii=0; ii < fgAODTracks->GetEntries(); ii++){
407 AliAODTrack *track = (AliAODTrack*) fgAODTracks->At(ii);
408 if(track->IsMuonTrack()) {
409 nMuonTrack[nMuons]= ii;
410 nMuons++;
411 }
412 }
413 Int_t jDimuons=0;
414 if(nMuons >= 2){
415 for(Int_t i = 0; i < nMuons; i++){
416 Int_t index0 = nMuonTrack[i];
417 for(Int_t j = i+1; j < nMuons; j++){
418 Int_t index1 = nMuonTrack[j];
8f6e7d10 419 tracksnew.At(index0)->ResetBit(kIsReferenced);
420 tracksnew.At(index0)->SetUniqueID(0);
421 tracksnew.At(index1)->ResetBit(kIsReferenced);
422 tracksnew.At(index1)->SetUniqueID(0);
423 new(dimuons[jDimuons++]) AliAODDimuon(tracksnew.At(index0),tracksnew.At(index1));
424 }
425 }
426 }
866d8d78 427 }
8f6e7d10 428
5a922844 429 // Additional merging if needed
430 if (merging) {
113bc2bd 431 // mcParticles
432 TClonesArray* mcparticles = (TClonesArray*) ((aodH->GetEventToMerge())->FindListObject("mcparticles"));
433 Int_t npart = mcparticles->GetEntries();
434 Int_t nc = fgAODMCParticles->GetEntries();
435 Int_t nc0 = nc;
436
437 for (Int_t i = 0; i < npart; i++) {
438 AliAODMCParticle* particle = (AliAODMCParticle*) mcparticles->At(i);
c8de791b 439 new((*fgAODMCParticles)[nc++]) AliAODMCParticle(*particle);
113bc2bd 440 }
441
5a922844 442 // tracks
443 TClonesArray* tracks = aodH->GetEventToMerge()->GetTracks();
444 Int_t ntr = tracks->GetEntries();
113bc2bd 445 nc = fgAODTracks->GetEntries();
5a922844 446 for (Int_t i = 0; i < ntr; i++) {
447 AliAODTrack* track = (AliAODTrack*) tracks->At(i);
448 AliAODTrack* newtrack = new((*fgAODTracks)[nc++]) AliAODTrack(*track);
113bc2bd 449 newtrack->SetLabel(newtrack->GetLabel() + nc0);
5a922844 450 }
c8de791b 451
452 for (Int_t i = 0; i < nc; i++)
453 {
454 AliAODTrack* track = (AliAODTrack*) fgAODTracks->At(i);
455 track->ResetBit(kIsReferenced);
456 track->SetUniqueID(0);
457 }
458
459
5a922844 460 // clusters
461 TClonesArray* clusters = aodH->GetEventToMerge()->GetCaloClusters();
462 Int_t ncl = clusters->GetEntries();
463 nc = fgAODCaloClusters->GetEntries();
464 for (Int_t i = 0; i < ncl; i++) {
465 AliAODCaloCluster* cluster = (AliAODCaloCluster*) clusters->At(i);
c8de791b 466 new((*fgAODCaloClusters)[nc++]) AliAODCaloCluster(*cluster);
5a922844 467 }
468 // cells
469 AliAODCaloCells* cellsA = aodH->GetEventToMerge()->GetEMCALCells();
470 Int_t ncells = cellsA->GetNumberOfCells();
471 nc = fgAODEmcalCells->GetNumberOfCells();
472
473 for (Int_t i = 0; i < ncells; i++) {
474 Int_t cn = cellsA->GetCellNumber(i);
475 Int_t pos = fgAODEmcalCells->GetCellPosition(cn);
476 if (pos >= 0) {
477 Double_t amp = cellsA->GetAmplitude(i) + fgAODEmcalCells->GetAmplitude(pos);
478 fgAODEmcalCells->SetCell(pos, cn, amp);
479 } else {
480 Double_t amp = cellsA->GetAmplitude(i);
481 fgAODEmcalCells->SetCell(nc++, cn, amp);
482 fgAODEmcalCells->Sort();
483 }
484 }
113bc2bd 485
486
487 } // merging
c185e0db 488
5a922844 489 handler->SetAODIsReplicated();
3f2431c4 490 }
491 }
492
4d0a82af 493// Call the user analysis
67d77d71 494 AliMCEventHandler* mcH = 0;
495 mcH = (AliMCEventHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetMCtruthEventHandler());
496
497 if (!mcH) {
5b173801 498 if (isSelected)
67d77d71 499 UserExec(option);
500 } else {
5b173801 501 if (isSelected && (mcH->InitOk()))
67d77d71 502 UserExec(option);
503 }
90a9a634 504
505// Added protection in case the derived task is not an AOD producer.
60a04972 506 AliAnalysisDataSlot *out0 = GetOutputSlot(0);
507 if (out0 && out0->IsConnected()) PostData(0, fTreeA);
5232d0de 508}
509
4d0a82af 510const char* AliAnalysisTaskSE::CurrentFileName()
511{
512// Returns the current file name
259b7a8a 513 if( fInputHandler )
514 return fInputHandler->GetTree()->GetCurrentFile()->GetName();
515 else if( fMCEvent )
516 return ((AliMCEventHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetMCtruthEventHandler()))->TreeK()->GetCurrentFile()->GetName();
8803dcb1 517 else return "";
4d0a82af 518}
5232d0de 519
3cee83d7 520void AliAnalysisTaskSE::AddAODBranch(const char* cname, void* addobj, const char *fname)
164e94ff 521{
522 // Add a new branch to the aod tree
b9531017 523 AliAODHandler* handler = dynamic_cast<AliAODHandler*>
164e94ff 524 ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
525 if (handler) {
3cee83d7 526 handler->AddBranch(cname, addobj, fname);
164e94ff 527 }
528}
3cee83d7 529
530Bool_t AliAnalysisTaskSE::IsStandardAOD() const
531{
532// Check if the output AOD handler is configured for standard or delta AOD.
533// Users should first check that AODEvent() returns non-null.
b9531017 534 AliAODHandler* handler = dynamic_cast<AliAODHandler*>
3cee83d7 535 ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
536 if (!handler) {
537 Error("IsStandardAOD", "No AOD handler. Please use AODEvent() to check this first");
538 return kTRUE;
539 }
540 return handler->IsStandard();
541}
1ec2c8dc 542
543Bool_t AliAnalysisTaskSE::Notify()
544{
9a587f77 545 return (UserNotify());
1ec2c8dc 546}
547
548