]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FORWARD/analysis2/AddTaskCentralMult.C
0017bbf1ed429d162a8bbaf61ecdf84d0934efef
[u/mrichter/AliRoot.git] / PWG2 / FORWARD / analysis2 / AddTaskCentralMult.C
1 /**
2  * @file   AddTaskCentralMult.C
3  * @author Christian Holm Christensen <cholm@dalsgaard.hehi.nbi.dk>
4  * @date   Wed Mar 23 12:13:25 2011
5  * 
6  * @brief  
7  * 
8  * 
9  * @ingroup pwg2_forward_scripts_tasks
10  */
11
12 /**
13  * This is the macro to include the Central multiplicity in a train.  
14  * 
15  * @ingroup pwg2_forward_aod
16  */
17 AliAnalysisTask* 
18 AddTaskCentralMult(Bool_t mc=false, 
19                    UShort_t sys=0, UShort_t sNN=0, Short_t field=0)
20 {
21   // --- Load libraries ----------------------------------------------
22   gROOT->LoadClass("AliAODForwardMult", "libPWG2forward2");
23
24   // --- Get analysis manager ----------------------------------------
25   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
26   if (!mgr) {
27     Error("AddTaskCentralMult", "No analysis manager to connect to.");
28     return NULL;
29   }   
30
31   // --- Make the task and add it to the manager ---------------------
32   AliCentralMultiplicityTask* task = 0;
33   if (!mc) task = new AliCentralMultiplicityTask("Central");
34   else     task = new AliCentralMCMultiplicityTask("Central");
35   if(sys>0 && sNN > 0)
36     task->GetManager().Init(sys, sNN, field);
37   mgr->AddTask(task);
38
39   // --- Configure the task ------------------------------------------
40   const char* config = gSystem->Which(gROOT->GetMacroPath(),
41                                       "CentralAODConfig.C");
42   if (!config) 
43     Warning("AddTaskCentralMult", "CentralAODConfig.C not found in %s",
44             gROOT->GetMacroPath());
45   else {
46     Info("AddTaskCentralMult", 
47          "Loading configuration of '%s' from %s",
48          task->ClassName(), config);
49     gROOT->Macro(Form("%s((AliCentralMultiplicityTask*)%p)", config, task));
50     delete config;
51   }
52
53   // --- Make the output container and connect it --------------------
54   TString outputfile = AliAnalysisManager::GetCommonFileName();
55   
56   AliAnalysisDataContainer* histOut = 
57     mgr->CreateContainer("Central", TList::Class(), 
58                          AliAnalysisManager::kOutputContainer,outputfile);
59   mgr->ConnectInput(task, 0, mgr->GetCommonInputContainer());
60   mgr->ConnectOutput(task, 1, histOut);
61   
62   return task;
63 }
64 //
65 // EOF
66 //