Fix in physics selection OADB
[u/mrichter/AliRoot.git] / ANALYSIS / macros / AddTaskCentrality.C
CommitLineData
377e5a61 1AliCentralitySelectionTask *AddTaskCentrality(Bool_t fillHistos=kTRUE, Bool_t aod=kFALSE)
2defbca5 2{
3// Macro to connect a centrality selection task to an existing analysis manager.
4 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
5 if (!mgr) {
6 ::Error("AddTaskCentrality", "No analysis manager to connect to.");
7 return NULL;
8 }
9 // Check the analysis type using the event handlers connected to the analysis manager.
10 //==============================================================================
11 if (!mgr->GetInputEventHandler()) {
12 ::Error("AddTaskCentrality", "This task requires an input event handler");
13 return NULL;
14 }
15 TString inputDataType = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"
377e5a61 16 if (!aod && (inputDataType != "ESD")) {
2defbca5 17 ::Error("AddTaskCentrality", "This task works only on ESD analysis");
18 return NULL;
19 }
da35823e
RS
20 //
21 AliInputEventHandler* hdl = (AliInputEventHandler*)mgr->GetInputEventHandler();
22 if (hdl) hdl->SetNeedField();
23 //
2defbca5 24 AliCentralitySelectionTask *centralityTask = new AliCentralitySelectionTask("CentralitySelection");
377e5a61 25 centralityTask->SetInput(inputDataType);
ebb6dbd1 26 centralityTask->SelectCollisionCandidates(AliVEvent::kAny);
9b1ab560 27 mgr->AddTask(centralityTask);
28
2defbca5 29 mgr->ConnectInput(centralityTask, 0, mgr->GetCommonInputContainer());
9b55f3ac 30 if (fillHistos) {
31 centralityTask->SetFillHistos();
32 AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("CentralityStat",
33 TList::Class(),
34 AliAnalysisManager::kOutputContainer,
35 "EventStat_temp.root");
36 mgr->ConnectOutput(centralityTask,1,coutput1);
37 }
2defbca5 38
39 return centralityTask;
40}