]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ANALYSIS/AliAnalysisTask.cxx
Init() added to interface.
[u/mrichter/AliRoot.git] / ANALYSIS / AliAnalysisTask.cxx
CommitLineData
d3106602 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// Author: Andrei Gheata, 31/05/2006
18
19//==============================================================================
20// AliAnalysysTask - Class representing a basic analysis task. Any
21// user-defined task should derive from it and implement the Exec() virtual
22// method.
23//==============================================================================
24//
25// A specific user analysis task have to derive from this class. The list of
26// specific input and output slots have to be defined in the derived class ctor:
27//
28// UserTask::UserTask(name, title)
29// {
30// DefineInput(0, TTree::Class());
31// DefineInput(1, TH1::Class());
32// ...
33// DefineOutput(0, TTree::Class());
34// DefineOutput(1, MyObject::Class());
35// ...
36// }
37//
38// An existing data contaner (AliAnalysisDataContainer) can be connected to the
39// input/output slots of an analysis task. Containers should not be defined and
40// connected by the derived analysis task, but from the level of AliAnalysisManager:
41//
42// AliAnalysisManager::ConnectInput(AliAnalysisTask *task, Int_t islot,
43// AliAnalysisDataContainer *cont)
44// AliAnalysisManager::ConnectOutput(AliAnalysisTask *task, Int_t islot,
45// AliAnalysisDataContainer *cont)
46// To connect a slot to a data container, the data types declared by both must
47// match.
327eaf46 48//
c52c2132 49// The method ConnectInputData() has to be overloaded by the derived class in order to
50// set the branch address or connect to a branch address in case the input
51// slots are connected to trees.
327eaf46 52// Example:
c52c2132 53// MyAnalysisTask::ConnectInputData(Option_t *)
327eaf46 54// {
c52c2132 55// // One should first check if the branch address was taken by some other task
56// char ** address = (char **)GetBranchAddress(0, "ESD");
57// if (address) {
58// fESD = (AliESD*)(*address);
59// } else {
60// fESD = new AliESD();
61// SetBranchAddress(0, "ESD", &fESD);
62// }
63// }
64//
9b33830a 65// The method LocalInit() may be implemented to call locally (on the client)
66// all initialization methods of the class. It is not mandatory and was created
67// in order to minimize the complexity and readability of the analysis macro.
68// DO NOT create in this method the histigrams or task output objects that will
69// go in the task output containers. Use CreateOutputObjects for that.
70//
71// The method CreateOutputObjects() has to be implemented an will contain the
c52c2132 72// objects that should be created only once per session (e.g. output
73// histograms)
74//
75// void MyAnalysisTask::CreateOutputObjects()
76//{
77 // create histograms
78// fhPt = new TH1F("fhPt","This is the Pt distribution",15,0.1,3.1);
79// fhPt->SetStats(kTRUE);
80// fhPt->GetXaxis()->SetTitle("P_{T} [GeV]");
81// fhPt->GetYaxis()->SetTitle("#frac{dN}{dP_{T}}");
82// fhPt->GetXaxis()->SetTitleColor(1);
83// fhPt->SetMarkerStyle(kFullCircle);
327eaf46 84// }
85//
86// The method Terminate() will be called by the framework once at the end of
c52c2132 87// data processing. Overload this if needed. DO NOT ASSUME that the pointers
88// to histograms defined in CreateOutputObjects() are valid, since this is
89// not true in case of PROOF. Restore the pointer values like:
90//
91//void MyAnalysisTask::Terminate(Option_t *)
92//{
93// fhPt = (TH1F*)GetOutputData(0);
94// ...
95//}
96
327eaf46 97//
d3106602 98//==============================================================================
99
0b28fd57 100#include <Riostream.h>
c5a87c56 101#include <TFile.h>
c52c2132 102#include <TClass.h>
b1310ef5 103#include <TTree.h>
d3106602 104
d3106602 105#include "AliAnalysisTask.h"
106#include "AliAnalysisDataSlot.h"
107#include "AliAnalysisDataContainer.h"
c5a87c56 108#include "AliAnalysisManager.h"
d3106602 109
110ClassImp(AliAnalysisTask)
111
112//______________________________________________________________________________
113AliAnalysisTask::AliAnalysisTask()
37a26056 114 :fReady(kFALSE),
327eaf46 115 fInitialized(kFALSE),
37a26056 116 fNinputs(0),
117 fNoutputs(0),
118 fOutputReady(NULL),
119 fPublishedData(NULL),
120 fInputs(NULL),
121 fOutputs(NULL)
d3106602 122{
123// Default constructor.
d3106602 124}
125
126//______________________________________________________________________________
127AliAnalysisTask::AliAnalysisTask(const char *name, const char *title)
37a26056 128 :TTask(name,title),
129 fReady(kFALSE),
327eaf46 130 fInitialized(kFALSE),
37a26056 131 fNinputs(0),
132 fNoutputs(0),
133 fOutputReady(NULL),
134 fPublishedData(NULL),
135 fInputs(NULL),
136 fOutputs(NULL)
d3106602 137{
37a26056 138// Constructor.
d3106602 139 fInputs = new TObjArray(2);
140 fOutputs = new TObjArray(2);
141}
142
143//______________________________________________________________________________
144AliAnalysisTask::AliAnalysisTask(const AliAnalysisTask &task)
37a26056 145 :TTask(task),
146 fReady(task.fReady),
327eaf46 147 fInitialized(task.fInitialized),
37a26056 148 fNinputs(task.fNinputs),
149 fNoutputs(task.fNoutputs),
150 fOutputReady(NULL),
151 fPublishedData(NULL),
152 fInputs(NULL),
153 fOutputs(NULL)
d3106602 154{
155// Copy ctor.
d3106602 156 fInputs = new TObjArray((fNinputs)?fNinputs:2);
157 fOutputs = new TObjArray((fNoutputs)?fNoutputs:2);
158 fPublishedData = 0;
159 Int_t i;
160 for (i=0; i<fNinputs; i++) fInputs->AddAt(task.GetInputSlot(i),i);
161 fOutputReady = new Bool_t[(fNoutputs)?fNoutputs:2];
162 for (i=0; i<fNoutputs; i++) {
163 fOutputReady[i] = IsOutputReady(i);
164 fOutputs->AddAt(task.GetOutputSlot(i),i);
165 }
166}
167
168//______________________________________________________________________________
169AliAnalysisTask::~AliAnalysisTask()
170{
171// Dtor.
c52c2132 172 if (fTasks) fTasks->Clear();
d3106602 173 if (fInputs) {fInputs->Delete(); delete fInputs;}
174 if (fOutputs) {fOutputs->Delete(); delete fOutputs;}
175}
176
177//______________________________________________________________________________
178AliAnalysisTask& AliAnalysisTask::operator=(const AliAnalysisTask& task)
179{
180// Assignment
37a26056 181 if (&task == this) return *this;
182 TTask::operator=(task);
183 fReady = task.IsReady();
327eaf46 184 fInitialized = task.IsInitialized();
37a26056 185 fNinputs = task.GetNinputs();
186 fNoutputs = task.GetNoutputs();
187 fInputs = new TObjArray((fNinputs)?fNinputs:2);
188 fOutputs = new TObjArray((fNoutputs)?fNoutputs:2);
189 fPublishedData = 0;
190 Int_t i;
191 for (i=0; i<fNinputs; i++) fInputs->AddAt(new AliAnalysisDataSlot(*task.GetInputSlot(i)),i);
192 fOutputReady = new Bool_t[(fNoutputs)?fNoutputs:2];
193 for (i=0; i<fNoutputs; i++) {
194 fOutputReady[i] = IsOutputReady(i);
195 fOutputs->AddAt(new AliAnalysisDataSlot(*task.GetOutputSlot(i)),i);
196 }
d3106602 197 return *this;
198}
199
200//______________________________________________________________________________
201Bool_t AliAnalysisTask::AreSlotsConnected()
202{
203// Check if all input/output slots are connected. If this is the case fReady=true
204 fReady = kFALSE;
205 if (!fNinputs || !fNoutputs) return kFALSE;
206 Int_t i;
207 AliAnalysisDataSlot *slot;
208 for (i=0; i<fNinputs; i++) {
209 slot = (AliAnalysisDataSlot*)fInputs->At(i);
210 if (!slot) {
c52c2132 211 Error("AreSlotsConnected", "Input slot %d of task %s not defined !",i,GetName());
d3106602 212 return kFALSE;
213 }
214 if (!slot->IsConnected()) return kFALSE;
215 }
216 for (i=0; i<fNoutputs; i++) {
217 slot = (AliAnalysisDataSlot*)fOutputs->At(i);
218 if (!slot) {
c52c2132 219 Error("AreSlotsConnected", "Output slot %d of task %s not defined !",i,GetName());
d3106602 220 return kFALSE;
221 }
222 if (!slot->IsConnected()) return kFALSE;
223 }
224 fReady = kTRUE;
225 return kTRUE;
226}
227
228//______________________________________________________________________________
327eaf46 229void AliAnalysisTask::CheckNotify(Bool_t init)
d3106602 230{
231// Check if data is available from all inputs. Change the status of the task
232// accordingly. This method is called automatically for all tasks connected
233// to a container where the data was published.
327eaf46 234 if (init) fInitialized = kFALSE;
b1310ef5 235 Bool_t single_shot = IsPostEventLoop();
efd53803 236 AliAnalysisDataContainer *cinput;
d3106602 237 for (Int_t islot=0; islot<fNinputs; islot++) {
efd53803 238 cinput = GetInputSlot(islot)->GetContainer();
b1310ef5 239 if (!cinput->GetData() || (single_shot && !cinput->IsPostEventLoop())) {
d3106602 240 SetActive(kFALSE);
241 return;
242 }
243 }
244 SetActive(kTRUE);
327eaf46 245 if (fInitialized) return;
246 TDirectory *cursav = gDirectory;
c52c2132 247 ConnectInputData();
327eaf46 248 if (cursav) cursav->cd();
249 fInitialized = kTRUE;
d3106602 250}
251
252//______________________________________________________________________________
253Bool_t AliAnalysisTask::ConnectInput(Int_t islot, AliAnalysisDataContainer *cont)
254{
255// Connect an input slot to a data container.
256 AliAnalysisDataSlot *input = GetInputSlot(islot);
257 if (!input) {
c52c2132 258 Error("ConnectInput","Input slot %i not defined for analysis task %s", islot, GetName());
d3106602 259 return kFALSE;
260 }
261 // Check type matching
262 if (!input->GetType()->InheritsFrom(cont->GetType())) {
c52c2132 263 Error("ConnectInput","Data type %s for input %i of task %s not matching container %s of type %s",input->GetType()->GetName(), islot, GetName(), cont->GetName(), cont->GetType()->GetName());
d3106602 264 return kFALSE;
265 }
266 // Connect the slot to the container as input
267 if (!input->ConnectContainer(cont)) return kFALSE;
268 // Add this to the list of container consumers
269 cont->AddConsumer(this, islot);
270 AreSlotsConnected();
271 return kTRUE;
272}
273
274//______________________________________________________________________________
275Bool_t AliAnalysisTask::ConnectOutput(Int_t islot, AliAnalysisDataContainer *cont)
276{
277// Connect an output slot to a data container.
278 AliAnalysisDataSlot *output = GetOutputSlot(islot);
279 if (!output) {
c52c2132 280 Error("ConnectOutput","Output slot %i not defined for analysis task %s", islot, GetName());
d3106602 281 return kFALSE;
282 }
283 // Check type matching
284 if (!output->GetType()->InheritsFrom(cont->GetType())) {
c52c2132 285 Error("ConnectOutput","Data type %s for output %i of task %s not matching container %s of type %s",output->GetType()->GetName(), islot, GetName(), cont->GetName(), cont->GetType()->GetName());
d3106602 286 return kFALSE;
287 }
288 // Connect the slot to the container as output
289 if (!output->ConnectContainer(cont)) return kFALSE;
b1310ef5 290 // Set event loop type the same as for the task
291 cont->SetPostEventLoop(IsPostEventLoop());
d3106602 292 // Declare this as the data producer
293 cont->SetProducer(this, islot);
294 AreSlotsConnected();
295 return kTRUE;
296}
297
298//______________________________________________________________________________
299void AliAnalysisTask::DefineInput(Int_t islot, TClass *type)
300{
301// Define an input slot and its type.
302 AliAnalysisDataSlot *input = new AliAnalysisDataSlot(type, this);
303 if (fNinputs<islot+1) fNinputs = islot+1;
6ae18197 304 fInputs->AddAtAndExpand(input, islot);
d3106602 305}
306
307//______________________________________________________________________________
308void AliAnalysisTask::DefineOutput(Int_t islot, TClass *type)
309{
310// Define an output slot and its type.
d3106602 311 AliAnalysisDataSlot *output = new AliAnalysisDataSlot(type, this);
312 if (fNoutputs<islot+1) {
313 fNoutputs = islot+1;
314 if (fOutputReady) delete [] fOutputReady;
315 fOutputReady = new Bool_t[fNoutputs];
316 memset(fOutputReady, 0, fNoutputs*sizeof(Bool_t));
317 }
6ae18197 318 fOutputs->AddAtAndExpand(output, islot);
d3106602 319}
320
321//______________________________________________________________________________
322TClass *AliAnalysisTask::GetInputType(Int_t islot) const
323{
324// Retreive type of a given input slot.
325 AliAnalysisDataSlot *input = GetInputSlot(islot);
326 if (!input) {
c52c2132 327 Error("GetInputType","Input slot %d not defined for analysis task %s", islot, GetName());
d3106602 328 return NULL;
329 }
330 return (input->GetType());
331}
332
333//______________________________________________________________________________
334TClass *AliAnalysisTask::GetOutputType(Int_t islot) const
335{
336// Retreive type of a given output slot.
337 AliAnalysisDataSlot *output = GetOutputSlot(islot);
338 if (!output) {
c52c2132 339 Error("GetOutputType","Output slot %d not defined for analysis task %s", islot, GetName());
d3106602 340 return NULL;
341 }
342 return (output->GetType());
343}
344
345//______________________________________________________________________________
346TObject *AliAnalysisTask::GetInputData(Int_t islot) const
347{
348// Retreive input data for a slot if ready. Normally called by Exec() and
349// the object has to be statically cast to the appropriate type.
350 AliAnalysisDataSlot *input = GetInputSlot(islot);
351 if (!input) {
c52c2132 352 Error("GetInputData","Input slot %d not defined for analysis task %s", islot, GetName());
d3106602 353 return NULL;
354 }
355 return (input->GetData());
356}
357
c52c2132 358//______________________________________________________________________________
359TObject *AliAnalysisTask::GetOutputData(Int_t islot) const
360{
361// Retreive output data for a slot. Normally called in UserTask::Terminate to
362// get a valid pointer to data even in case of Proof.
363 AliAnalysisDataSlot *output = GetOutputSlot(islot);
364 if (!output) {
365 Error("GetOutputData","Input slot %d not defined for analysis task %s", islot, GetName());
366 return NULL;
367 }
368 return (output->GetData());
369}
370
327eaf46 371//______________________________________________________________________________
372char *AliAnalysisTask::GetBranchAddress(Int_t islot, const char *branch) const
373{
374// Check if a branch with a given name from the specified input is connected
375// to some address. Call this in Init() before trying to call SetBranchAddress()
376// since the adress may be set by other task.
377 return (char *)GetInputSlot(islot)->GetBranchAddress(branch);
378}
379
380//______________________________________________________________________________
381Bool_t AliAnalysisTask::SetBranchAddress(Int_t islot, const char *branch, void *address) const
382{
383// Connect an object address to a branch of the specified input.
384 return GetInputSlot(islot)->SetBranchAddress(branch, address);
385}
386
b1310ef5 387//______________________________________________________________________________
388void AliAnalysisTask::EnableBranch(Int_t islot, const char *bname) const
389{
390// Call this in ConnectInputData() to enable only the branches needed by this
391// task. "*" will enable everything.
392 AliAnalysisDataSlot *input = GetInputSlot(islot);
393 if (!input || !input->GetType()->InheritsFrom(TTree::Class())) {
394 Error("EnableBranch", "Wrong slot type #%d for task %s: not TTree-derived type", islot, GetName());
395 return;
396 }
397 TTree *tree = (TTree*)input->GetData();
398 if (!strcmp(bname, "*")) {
399 tree->SetBranchStatus("*",1);
400 return;
401 }
402 AliAnalysisDataSlot::EnableBranch(bname, tree);
403}
8508e09f 404
405//______________________________________________________________________________
8d7d3b59 406void AliAnalysisTask::FinishTaskOutput()
8508e09f 407{
8d7d3b59 408// Optional method that is called in SlaveTerminate phase.
409// Used for calling aditional methods just after the last event was processed ON
410// THE WORKING NODE. The call is made also in local case.
411// Do NOT delete output objects here since they will have to be sent for
412// merging in PROOF mode - use class destructor for cleanup.
8508e09f 413}
b1310ef5 414
327eaf46 415//______________________________________________________________________________
c52c2132 416void AliAnalysisTask::ConnectInputData(Option_t *)
327eaf46 417{
c52c2132 418// Overload and connect your branches here.
327eaf46 419}
420
9b33830a 421//______________________________________________________________________________
422void AliAnalysisTask::LocalInit()
423{
424// The method LocalInit() may be implemented to call locally (on the client)
425// all initialization methods of the class. It is not mandatory and was created
426// in order to minimize the complexity and readability of the analysis macro.
427// DO NOT create in this method the histigrams or task output objects that will
428// go in the task output containers. Use CreateOutputObjects for that.
429}
430
327eaf46 431//______________________________________________________________________________
c52c2132 432void AliAnalysisTask::CreateOutputObjects()
327eaf46 433{
981f2614 434// Called once per task either in PROOF or local mode. Overload to put some
435// task initialization and/or create your output objects here.
436}
437
c5a87c56 438//______________________________________________________________________________
13ef3bb0 439TFile *AliAnalysisTask::OpenFile(Int_t iout, Option_t *option) const
c5a87c56 440{
441// This method has to be called INSIDE the user redefined CreateOutputObjects
442// method, before creating each object corresponding to the output containers
443// that are to be written to a file. This need to be done in general for the big output
444// objects that may not fit memory during processing.
445// - 'option' is the file opening option.
446//=========================================================================
447// NOTE !: The method call will be ignored in PROOF mode, in which case the
448// results have to be streamed back to the client and written just before Terminate()
449//=========================================================================
450//
451// Example:
452// void MyAnaTask::CreateOutputObjects() {
453// OpenFile(0); // Will open the file for the object to be written at output #0
454// fAOD = new TTree("AOD for D0toKPi");
455// OpenFile(1);
456// now some histos that should go in the file of the second output container
457// fHist1 = new TH1F("my quality check hist1",...);
458// fHist2 = new TH2F("my quality check hist2",...);
459// }
460
13ef3bb0 461 if (iout<0 || iout>=fNoutputs) {
462 Error("OpenFile", "No output slot for task %s with index %d", GetName(), iout);
463 return NULL;
464 }
465 // We allow file opening also on the slaves (AG)
8d7d3b59 466 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
c5a87c56 467 AliAnalysisDataContainer *cont = GetOutputSlot(iout)->GetContainer();
13ef3bb0 468 TFile *f = NULL;
8d7d3b59 469 if (!strlen(cont->GetFileName())) {
470 Error("OpenFile", "No file name specified for container %s", cont->GetName());
471 return f;
472 }
473 if (mgr->GetAnalysisType()==AliAnalysisManager::kProofAnalysis && cont->IsSpecialOutput())
474 f = mgr->OpenProofFile(cont->GetFileName(),option);
475 else
476 f = new TFile(cont->GetFileName(), option);
477 if (f && !f->IsZombie()) {
478 cont->SetFile(f);
479 return f;
480 }
481 cont->SetFile(NULL);
13ef3bb0 482 return NULL;
c5a87c56 483}
484
981f2614 485//______________________________________________________________________________
486Bool_t AliAnalysisTask::Notify()
487{
488// Overload this IF you need to treat input file change.
489 return kTRUE;
327eaf46 490}
491
aee5ee44 492//______________________________________________________________________________
493Bool_t AliAnalysisTask::NotifyBinChange()
494{
495// Overload this IF you need to treat bin change in event mixing.
496 return kTRUE;
497}
498
327eaf46 499//______________________________________________________________________________
c52c2132 500void AliAnalysisTask::Terminate(Option_t *)
327eaf46 501{
c52c2132 502// Method called by the framework at the end of data processing.
503}
327eaf46 504
d3106602 505//______________________________________________________________________________
506Bool_t AliAnalysisTask::PostData(Int_t iout, TObject *data, Option_t *option)
507{
508// Post output data for a given ouput slot in the corresponding data container.
509// Published data becomes owned by the data container.
510// If option is specified, the container connected to the output slot must have
511// an associated file name defined. The option represents the method to open the file.
512 fPublishedData = 0;
513 AliAnalysisDataSlot *output = GetOutputSlot(iout);
514 if (!output) {
c52c2132 515 Error("PostData","Output slot %i not defined for analysis task %s", iout, GetName());
d3106602 516 return kFALSE;
517 }
518 if (!output->IsConnected()) {
c52c2132 519 Error("PostData","Output slot %i of analysis task %s not connected to any data container", iout, GetName());
d3106602 520 return kFALSE;
521 }
522 if (!fOutputReady) {
523 fOutputReady = new Bool_t[fNoutputs];
524 memset(fOutputReady, 0, fNoutputs*sizeof(Bool_t));
525 }
526 fOutputReady[iout] = kTRUE;
527 fPublishedData = data;
528 return (output->GetContainer()->SetData(data, option));
529}
530
531//______________________________________________________________________________
532void AliAnalysisTask::SetUsed(Bool_t flag)
533{
534// Set 'used' flag recursively to task and all daughter tasks.
535 if (TestBit(kTaskUsed)==flag) return;
536 TObject::SetBit(kTaskUsed,flag);
537 Int_t nd = fTasks->GetSize();
538 AliAnalysisTask *task;
539 for (Int_t i=0; i<nd; i++) {
540 task = (AliAnalysisTask*)fTasks->At(i);
541 task->SetUsed(flag);
542 }
543}
544
545//______________________________________________________________________________
546Bool_t AliAnalysisTask::CheckCircularDeps()
547{
548// Check for illegal circular dependencies, e.g. a daughter task should not have
549// a hierarchical parent as subtask.
550 if (IsChecked()) return kTRUE;
551 SetChecked();
552 TList *tasks = GetListOfTasks();
553 Int_t ntasks = tasks->GetSize();
554 AliAnalysisTask *task;
555 for (Int_t i=0; i<ntasks; i++) {
556 task = (AliAnalysisTask*)tasks->At(i);
557 if (task->CheckCircularDeps()) return kTRUE;
558 }
559 SetChecked(kFALSE);
560 return kFALSE;
561}
562
563//______________________________________________________________________________
564void AliAnalysisTask::PrintTask(Option_t *option, Int_t indent) const
565{
566// Print task info.
567 AliAnalysisTask *thistask = (AliAnalysisTask*)this;
568 TString opt(option);
569 opt.ToLower();
570 Bool_t dep = (opt.Contains("dep"))?kTRUE:kFALSE;
571 TString ind;
572 Int_t islot;
573 AliAnalysisDataContainer *cont;
574 for (Int_t i=0; i<indent; i++) ind += " ";
575 if (!dep || (dep && IsChecked())) {
b1310ef5 576 printf("%s\n", Form("%stask: %s ACTIVE=%i POST_LOOP=%i", ind.Data(), GetName(),IsActive(),IsPostEventLoop()));
d3106602 577 if (dep) thistask->SetChecked(kFALSE);
578 else {
579 for (islot=0; islot<fNinputs; islot++) {
580 printf("%s", Form("%s INPUT #%i: %s <- ",ind.Data(),islot, GetInputType(islot)->GetName()));
581 cont = GetInputSlot(islot)->GetContainer();
582 if (cont) printf(" [%s]\n", cont->GetName());
583 else printf(" [NO CONTAINER]\n");
584 }
585 for (islot=0; islot<fNoutputs; islot++) {
586 printf("%s", Form("%s OUTPUT #%i: %s -> ",ind.Data(),islot, GetOutputType(islot)->GetName()));
587 cont = GetOutputSlot(islot)->GetContainer();
588 if (cont) printf(" [%s]\n", cont->GetName());
589 else printf(" [NO CONTAINER]\n");
590 }
591 }
592 }
593 PrintContainers(option, indent+3);
594}
595
596//______________________________________________________________________________
597void AliAnalysisTask::PrintContainers(Option_t *option, Int_t indent) const
598{
599// Print containers info.
600 AliAnalysisDataContainer *cont;
601 TString ind;
602 for (Int_t i=0; i<indent; i++) ind += " ";
603 Int_t islot;
604 for (islot=0; islot<fNoutputs; islot++) {
605 cont = GetOutputSlot(islot)->GetContainer();
efd53803 606 if (cont) cont->PrintContainer(option, indent);
d3106602 607 }
608}
efd53803 609
610//______________________________________________________________________________
b1310ef5 611void AliAnalysisTask::SetPostEventLoop(Bool_t flag)
efd53803 612{
b1310ef5 613// Set the task execution mode - run after event loop or not. All output
efd53803 614// containers of this task will get the same type.
b1310ef5 615 TObject::SetBit(kTaskPostEventLoop,flag);
efd53803 616 AliAnalysisDataContainer *cont;
617 Int_t islot;
618 for (islot=0; islot<fNoutputs; islot++) {
619 cont = GetOutputSlot(islot)->GetContainer();
b1310ef5 620 if (cont) cont->SetPostEventLoop(flag);
efd53803 621 }
622}
623