]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/SPECTRA/macros/AddTaskProtons.C
Fix Coveriry 15461
[u/mrichter/AliRoot.git] / PWG2 / SPECTRA / macros / AddTaskProtons.C
CommitLineData
790140ac 1AliAnalysisTaskProtons *AddTaskProtons(Bool_t kAnalyzeMC = kFALSE,
2 const char *analysisType="Hybrid",
cffeba66 3 const char *pidMode="Bayesian")
4{
5 // Creates a proton analysis task and adds it to the analysis manager.
6
7 // Get the pointer to the existing analysis manager via the static access method.
8 //==============================================================================
9 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
10 if (!mgr) {
16be2366 11 ::Error("AddTaskProtons", "No analysis manager to connect to.");
cffeba66 12 return NULL;
13 }
14
15 // Check the analysis type using the event handlers connected to the analysis manager.
16 //==============================================================================
17 if (!mgr->GetInputEventHandler()) {
18 ::Error("AddTaskProtons", "This task requires an input event handler");
19 return NULL;
20 }
21 TString type = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"
22 gROOT->LoadMacro("$ALICE_ROOT/PWG2/SPECTRA/macros/configProtonAnalysis.C");
23 AliProtonAnalysis *pa = 0;
790140ac 24 if (type=="ESD") pa = GetProtonAnalysisObject("ESD", kAnalyzeMC,
25 analysisType, pidMode);
26 else if (type=="AOD") pa = GetProtonAnalysisObject("AOD", kAnalyzeMC,
27 analysisType, pidMode);
28 else pa = GetProtonAnalysisObject("MC", analysisType, kAnalyzeMC, pidMode);
cffeba66 29
30 // Create the task, add it to manager and configure it.
31 //===========================================================================
32 AliAnalysisTaskProtons *taskproton = new AliAnalysisTaskProtons("TaskProtons");
33 mgr->AddTask(taskproton);
34 taskproton->SetAnalysisObject(pa);
35
36 // Create ONLY the output containers for the data produced by the task.
37 // Get and connect other common input/output containers via the manager as below
38 //==============================================================================
d7fff4c6 39 TString outputFileName = AliAnalysisManager::GetCommonFileName();
c3200d84 40 outputFileName += ":PWG2BaryonRatioAnalysis";
0894be86 41 AliAnalysisDataContainer *cout_proton = mgr->CreateContainer("outputList", TList::Class(),AliAnalysisManager::kOutputContainer,outputFileName.Data());
42 AliAnalysisDataContainer *cout_proton_QA = mgr->CreateContainer("outputQAList", TList::Class(),AliAnalysisManager::kOutputContainer,outputFileName.Data());
43
cffeba66 44 mgr->ConnectInput(taskproton, 0, mgr->GetCommonInputContainer());
45 mgr->ConnectOutput(taskproton, 0, cout_proton);
0894be86 46 mgr->ConnectOutput(taskproton, 1, cout_proton_QA);
cffeba66 47
48 // Return task pointer at the end
49 return taskproton;
50}