6d61858d8d4a67ea349bfe93d274cc2f38d3bb88
[u/mrichter/AliRoot.git] / PWGGA / PHOSTasks / PHOS_pPb / AddTaskPHOSPi0pPbMC.C
1 AliAnalysisTaskPi0FlowMC* AddTaskPHOSPi0pPbMC (const char* name = "PHOSPi0pPbMC",
2                                             const char* options = "",
3                                                UInt_t offlineTriggerMask = AliVEvent::kINT7,
4                                                const char* centrality = "V0M",
5                                                const Int_t nCentBins = 5,
6                                                const Int_t centEdge0 = 0,
7                                                const Int_t centEdge1 = 20,
8                                                const Int_t centEdge2 = 40,
9                                                const Int_t centEdge3 = 60,
10                                                const Int_t centEdge4 = 80,
11                                                const Int_t centEdge5 = 100)
12 {
13   //Add a task AliAnalysisTaskPi0FlowMC to the analysis train, for LHC13 PbP MC productions
14   //Author:  Paul Baetzing
15   /* $Id$ */
16
17   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
18   if (!mgr) {
19     ::Error("AddTaskPHOSPi0pPbMC", "No analysis manager to connect to");
20     return NULL;
21   }
22   
23   if (!mgr->GetInputEventHandler()) {
24     ::Error("AddTaskPHOSPi0pPbMC", "This task requires an input event handler");
25     return NULL;
26   }
27
28   AliAnalysisTaskPi0FlowMC* task = new AliAnalysisTaskPi0FlowMC(Form("%sTask", name));
29
30   if( AliVEvent::kINT7 == offlineTriggerMask ) {
31     if (nCentBins<1) {
32       ::Error("AddTaskPHOSPi0pPb", Form("Invalid number of centrality bins: %d",nCentBins));
33       return NULL;
34     }
35     Double_t *cbin = new Double_t[nCentBins+1];
36     cbin[0] = centEdge0;
37     cbin[1] = centEdge1;
38     if (nCentBins > 1) cbin[2] = centEdge2;
39     if (nCentBins > 2) cbin[3] = centEdge3;
40     if (nCentBins > 3) cbin[4] = centEdge4;
41     if (nCentBins > 4) cbin[5] = centEdge5;
42     TArrayD tbin(nCentBins+1, cbin);
43
44     Int_t    *nMixed = new Int_t[nCentBins];
45     for (Int_t ibin=0; ibin<nCentBins; ibin++) nMixed[ibin] = 20;
46     TArrayI tNMixed(nCentBins, nMixed);
47     task->SetCentralityBinning(tbin, tNMixed);
48   }
49
50   task->SetCentralityEstimator(centrality);
51
52
53   //task->SetEventMixingRPBinning(9);
54   //task->SetMixingArraysLength(10);
55   task->SelectCollisionCandidates(offlineTriggerMask);
56   
57   task->SetEnablePHOSModule(2, kFALSE);
58
59   mgr->AddTask(task);
60   mgr->ConnectInput(task, 0, mgr->GetCommonInputContainer() );
61   
62   TString cname(Form("%sCoutput1", name));
63   TString pname(Form("%s:%s", AliAnalysisManager::GetCommonFileName(), name));
64   AliAnalysisDataContainer *coutput1 = mgr->CreateContainer(cname.Data(), TList::Class(), AliAnalysisManager::kOutputContainer, pname.Data());
65   mgr->ConnectOutput(task, 1, coutput1);
66   
67   return task;
68 }