]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/SPECTRA/macros/AddTaskProtons.C
Removing deprecated linearization and MC rescaling (now part of the centrality framework)
[u/mrichter/AliRoot.git] / PWG2 / SPECTRA / macros / AddTaskProtons.C
1 AliAnalysisTaskProtons *AddTaskProtons(Bool_t kAnalyzeMC = kFALSE,
2                                        const char *analysisType="Hybrid",
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) {
11     ::Error("AddTaskProtons", "No analysis manager to connect to.");
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;
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);
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   //==============================================================================
39   TString outputFileName = AliAnalysisManager::GetCommonFileName();
40   outputFileName += ":PWG2BaryonRatioAnalysis";
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
44   mgr->ConnectInput(taskproton, 0, mgr->GetCommonInputContainer());
45   mgr->ConnectOutput(taskproton, 0, cout_proton);
46   mgr->ConnectOutput(taskproton, 1, cout_proton_QA);
47   
48   // Return task pointer at the end
49   return taskproton;
50 }