]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ANALYSIS/macros/AddTaskProtons.C
Small typos corrected.
[u/mrichter/AliRoot.git] / ANALYSIS / macros / AddTaskProtons.C
1 AliAnalysisTaskProtons *AddTaskProtons(const char *analysisType="Hybrid",
2                                        const char *pidMode="Bayesian")
3 {
4 // Creates a proton analysis task and adds it to the analysis manager.
5    
6    // Get the pointer to the existing analysis manager via the static access method.
7    //==============================================================================
8    AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
9    if (!mgr) {
10       Error("AddTaskESDFilter", "No analysis manager to connect to.");
11       return NULL;
12    }   
13
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");
18       return NULL;
19    }   
20    TString type = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"
21    gROOT->LoadMacro("$ALICE_ROOT/PWG2/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);
26
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);
32       
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    AliAnalysisDataContainer *cout_proton = mgr->CreateContainer("protonhist", TList::Class(),
37                  AliAnalysisManager::kOutputContainer,"protonhist.root");                              
38    mgr->ConnectInput(taskproton, 0, mgr->GetCommonInputContainer());
39    mgr->ConnectOutput(taskproton, 0, cout_proton);
40
41    // Return task pointer at the end
42    return taskproton;
43 }