Updated cut classes and macro for Sigma* analysis (M. Venaruzzo)
[u/mrichter/AliRoot.git] / PWGLF / RESONANCES / macros / lego_train / old / AddRsnAnalysisTask.C
1 #ifndef __CINT__
2 #include <TString.h>
3 #include <ANALYSIS/AliAnalysisManager.h>
4 #include <AliRsnAnalysisTask.h>
5 #include "AliRsnDaughterSelector.h"
6 #include "AliRsnMiniAnalysisTask.h"
7 #endif
8 AliAnalysisTaskSE *AddRsnAnalysisTask(TString format = "esd", Bool_t useMC = kFALSE,Bool_t isMixing = kFALSE,AliRsnInputHandler *rsnIH=0,TList *listRsn=0,TString postfix="")
9 {
10    // create manager
11    AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
12    if (!mgr) { Printf("Error [AddRsnAnalysisTask%s] : mgr is null !!!",postfix.Data()); return 0;}
13
14    // initialize task with all available slots, even if not all of them will be used:
15    AliAnalysisTaskSE *task = 0;
16
17    Bool_t valid;
18    Int_t isRsnMini = AliAnalysisManager::GetGlobalInt("rsnUseMiniPackage",valid);
19    Int_t isPhysSel = AliAnalysisManager::GetGlobalInt("rsnUsePhysSel",valid);
20    if (isRsnMini) {
21       postfix.Prepend("Mini");
22       AliRsnMiniAnalysisTask *taskRsnMini = new AliRsnMiniAnalysisTask(Form("Rsn%s",postfix.Data()),useMC);
23       Int_t refreshPrint = AliAnalysisManager::GetGlobalInt("rsnMixPrintRefresh",valid);
24       if (valid) taskRsnMini->SetMixPrintRefresh(refreshPrint);
25       task = (AliAnalysisTaskSE *) taskRsnMini;
26    }
27    else {
28       AliRsnAnalysisTask *taskRsn = new AliRsnAnalysisTask(Form("Rsn%s",postfix.Data()));
29       task = (AliAnalysisTaskSE *) taskRsn;
30    }
31
32    if (isPhysSel>=0) task->SelectCollisionCandidates((AliVEvent::EOfflineTriggerTypes)isPhysSel);
33
34    // TODO this is tmp hack
35    if (!rsnIH) rsnIH = new AliRsnInputHandler();
36
37    //   gROOT->LoadMacro("RsnConfig.C");
38    if (!RsnConfig(task,useMC,isMixing,rsnIH,listRsn)) {
39       Printf("Error in RsnConfig.C");
40       return 0;
41    }
42
43    // add the task to manager
44    mgr->AddTask(task);
45
46    AliRsnDaughterSelector *sel = 0;
47
48    if (!isRsnMini) {
49       sel = rsnIH->GetSelector();
50       sel->Init();
51    }
52
53    // connect input container according to source choice
54    mgr->ConnectInput(task, 0, mgr->GetCommonInputContainer());
55
56    // create paths for the output in the common file
57    TString commonPath = AliAnalysisManager::GetCommonFileName();
58
59    // create containers for output
60    AliAnalysisDataContainer *output = mgr->CreateContainer(Form("RsnHist%s", postfix.Data()), TList::Class(), AliAnalysisManager::kOutputContainer, commonPath.Data());
61
62    // big outout (expert only)
63    Int_t useBigOutput = 0;
64    if (useBigOutput) {
65       Printf("Using Big output ...");
66       task->UseBigOutput();
67       output->SetSpecialOutput();
68       mgr->SetSpecialOutputLocation("root://lx000.saske.sk:21094//tmp/mvala/");
69    }
70
71    mgr->ConnectOutput(task, 1, output);
72
73    return task;
74 }