1 AliAnalysisTaskProtons *AddTaskProtons(const char *analysisType="Hybrid",
2 const char *pidMode="Bayesian")
4 // Creates a proton analysis task and adds it to the analysis manager.
6 // Get the pointer to the existing analysis manager via the static access method.
7 //==============================================================================
8 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
10 ::Error("AddTaskProtons", "No analysis manager to connect to.");
14 // Check the analysis type using the event handlers connected to the analysis manager.
15 //==============================================================================
16 if (!mgr->GetInputEventHandler()) {
17 ::Error("AddTaskProtons", "This task requires an input event handler");
20 TString type = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"
21 gROOT->LoadMacro("$ALICE_ROOT/PWG2/SPECTRA/macros/configProtonAnalysis.C");
22 AliProtonAnalysis *pa = 0;
23 if (type=="ESD") pa = GetProtonAnalysisObject("ESD", analysisType, pidMode);
24 else if (type=="AOD") pa = GetProtonAnalysisObject("AOD", analysisType, pidMode);
25 else pa = GetProtonAnalysisObject("MC", analysisType, pidMode);
27 // Create the task, add it to manager and configure it.
28 //===========================================================================
29 AliAnalysisTaskProtons *taskproton = new AliAnalysisTaskProtons("TaskProtons");
30 mgr->AddTask(taskproton);
31 taskproton->SetAnalysisObject(pa);
33 // Create ONLY the output containers for the data produced by the task.
34 // Get and connect other common input/output containers via the manager as below
35 //==============================================================================
36 TString outputFileName = AliAnalysisManager::GetCommonFileName();
37 outputFileName += ":PWG2BaryonRatioAnalysis";
38 AliAnalysisDataContainer *cout_proton = mgr->CreateContainer("protonhist", TList::Class(),AliAnalysisManager::kOutputContainer,outputFileName.Data());
39 mgr->ConnectInput(taskproton, 0, mgr->GetCommonInputContainer());
40 mgr->ConnectOutput(taskproton, 0, cout_proton);
42 // Return task pointer at the end