First version of the pid code for the balance function (Alis Rodriguez Manso)
[u/mrichter/AliRoot.git] / PWGCF / EBYE / macros / AddTaskBalanceCentralityTrain.C
CommitLineData
a0ce3c86 1// now in options\r
3feee083 2//=============================================//\r
a0ce3c86 3//const char* centralityEstimator = "V0M";\r
32a4f715 4//const char* centralityEstimator = "CL1";\r
5//const char* centralityEstimator = "TRK";\r
3feee083 6//=============================================//\r
a839b0a3 7//Bool_t gRunShuffling = kFALSE;\r
a0ce3c86 8//Bool_t gRunShuffling = kTRUE;\r
10a747d2 9//=============================================//\r
3c3bbd53 10\r
11//PID config\r
12Bool_t kUseNSigmaPID = kFALSE;\r
13Double_t nSigmaMax = 3.0;\r
14Bool_t kUseBayesianPID = kTRUE;\r
15Double_t gMinAcceptedProbability = 0.7;\r
16kDetectorUsedForPID pidMethod = AliAnalysisTaskBF::kTPCTOF;\r
17kParticleOfInterest particleOfInterest = AliAnalysisTaskBF::kPion;\r
18\r
3feee083 19//_________________________________________________________//\r
20AliAnalysisTaskBF *AddTaskBalanceCentralityTrain(Double_t centrMin=0.,\r
21 Double_t centrMax=100.,\r
a0ce3c86 22 Bool_t gRunShuffling=kFALSE,\r
23 TString centralityEstimator="V0M",\r
1900bf4e 24 Double_t vertexZ=10.,\r
a839b0a3 25 Double_t DCAxy=-1,\r
26 Double_t DCAz=-1,\r
1900bf4e 27 Double_t ptMin=0.3,\r
28 Double_t ptMax=1.5,\r
29 Double_t etaMin=-0.8,\r
30 Double_t etaMax=0.8,\r
a839b0a3 31 Double_t maxTPCchi2 = -1, \r
32 Int_t minNClustersTPC = -1,\r
3c3bbd53 33 Bool_t kUsePID = kFALSE,\r
01f7f002 34 Int_t AODfilterBit = 128,\r
3feee083 35 TString fileNameBase="AnalysisResults") {\r
1900bf4e 36\r
3feee083 37 // Creates a balance function analysis task and adds it to the analysis manager.\r
38 // Get the pointer to the existing analysis manager via the static access method.\r
39 TString centralityName("");\r
40 centralityName+=Form("%.0f",centrMin);\r
41 centralityName+="-";\r
42 centralityName+=Form("%.0f",centrMax);\r
1900bf4e 43 centralityName+="_";\r
ebfe944b 44 centralityName+=Form("%s",centralityEstimator.Data());\r
45 centralityName+="_";\r
1900bf4e 46 centralityName+=Form("vZ%.1f",vertexZ);\r
47 centralityName+="_";\r
48 centralityName+=Form("DCAxy%.1f",DCAxy);\r
49 centralityName+="_";\r
50 centralityName+=Form("DCAz%.1f",DCAz);\r
51 centralityName+="_Pt";\r
52 centralityName+=Form("%.1f",ptMin);\r
53 centralityName+="-";\r
54 centralityName+=Form("%.1f",ptMax);\r
55 centralityName+="_Eta";\r
56 centralityName+=Form("%.1f",etaMin);\r
57 centralityName+="-";\r
58 centralityName+=Form("%.1f",etaMax);\r
01f7f002 59 centralityName+="_Chi";\r
60 centralityName+=Form("%.1f",maxTPCchi2);\r
61 centralityName+="_nClus";\r
62 centralityName+=Form("%d",minNClustersTPC);\r
63 centralityName+="_Bit";\r
64 centralityName+=Form("%d",AODfilterBit);\r
65\r
66\r
67\r
3feee083 68\r
69 TString outputFileName(fileNameBase);\r
70 outputFileName.Append(".root");\r
71\r
72 //===========================================================================\r
73 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();\r
74 if (!mgr) {\r
75 ::Error("AddTaskBF", "No analysis manager to connect to.");\r
76 return NULL;\r
77 }\r
78\r
79 // Check the analysis type using the event handlers connected to the analysis manager.\r
80 //===========================================================================\r
81 if (!mgr->GetInputEventHandler()) {\r
82 ::Error("AddTaskBF", "This task requires an input event handler");\r
83 return NULL;\r
84 }\r
85 TString analysisType = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"\r
a0ce3c86 86 if(dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler())) analysisType = "MC";\r
87\r
88 // for local changed BF configuration\r
89 //gROOT->LoadMacro("./configBalanceFunctionAnalysis.C");\r
a022cbd0 90 gROOT->LoadMacro("$ALICE_ROOT/PWGCF/EBYE/macros/configBalanceFunctionAnalysis.C");\r
1900bf4e 91 AliBalance *bf = 0; // Balance Function object\r
92 AliBalance *bfs = 0; // shuffled Balance function object\r
93\r
94 if (analysisType=="ESD"){\r
74b04dd4 95 bf = GetBalanceFunctionObject("ESD",centralityEstimator,centrMin,centrMax);\r
96 if(gRunShuffling) bfs = GetBalanceFunctionObject("ESD",centralityEstimator,centrMin,centrMax,kTRUE);\r
1900bf4e 97 }\r
98 else if (analysisType=="AOD"){\r
74b04dd4 99 bf = GetBalanceFunctionObject("AOD",centralityEstimator,centrMin,centrMax);\r
100 if(gRunShuffling) bfs = GetBalanceFunctionObject("AOD",centralityEstimator,centrMin,centrMax,kTRUE);\r
1900bf4e 101 }\r
a0ce3c86 102 else if (analysisType=="MC"){\r
74b04dd4 103 bf = GetBalanceFunctionObject("MC",centralityEstimator,centrMin,centrMax);\r
104 if(gRunShuffling) bfs = GetBalanceFunctionObject("MC",centralityEstimator,centrMin,centrMax,kTRUE);\r
1900bf4e 105 }\r
a0ce3c86 106 else{\r
107 ::Error("AddTaskBF", "analysis type NOT known.");\r
108 return NULL;\r
109 }\r
3feee083 110\r
111 // Create the task, add it to manager and configure it.\r
112 //===========================================================================\r
113 AliAnalysisTaskBF *taskBF = new AliAnalysisTaskBF("TaskBF");\r
a839b0a3 114 taskBF->SetAnalysisObject(bf);\r
115 if(gRunShuffling) taskBF->SetShufflingObject(bfs);\r
116\r
3feee083 117 taskBF->SetCentralityPercentileRange(centrMin,centrMax);\r
118 if(analysisType == "ESD") {\r
a839b0a3 119 AliESDtrackCuts *trackCuts = GetTrackCutsObject(ptMin,ptMax,etaMin,etaMax,maxTPCchi2,DCAxy,DCAz,minNClustersTPC);\r
3feee083 120 taskBF->SetAnalysisCutObject(trackCuts);\r
3c3bbd53 121 if(kUsePID) {\r
122 if(kUseBayesianPID)\r
123 taskBF->SetUseBayesianPID(gMinAcceptedProbability);\r
124 else if(kUseNSigmaPID)\r
125 taskBF->SetUseNSigmaPID(nSigmaMax);\r
126 taskBF->SetParticleOfInterest(particleOfInterest);\r
127 taskBF->SetDetectorUsedForPID(pidMethod);\r
128 }\r
3feee083 129 }\r
130 else if(analysisType == "AOD") {\r
131 // pt and eta cut (pt_min, pt_max, eta_min, eta_max)\r
01f7f002 132 taskBF->SetAODtrackCutBit(AODfilterBit);\r
1900bf4e 133 taskBF->SetKinematicsCutsAOD(ptMin,ptMax,etaMin,etaMax);\r
a839b0a3 134\r
135 // set extra DCA cuts (-1 no extra cut)\r
1900bf4e 136 taskBF->SetExtraDCACutsAOD(DCAxy,DCAz);\r
a839b0a3 137\r
138 // set extra TPC chi2 / nr of clusters cut\r
139 taskBF->SetExtraTPCCutsAOD(maxTPCchi2, minNClustersTPC);\r
140 \r
3feee083 141 }\r
a0ce3c86 142 else if(analysisType == "MC") {\r
143 taskBF->SetKinematicsCutsAOD(ptMin,ptMax,etaMin,etaMax); \r
144 }\r
3feee083 145\r
a0ce3c86 146 // offline trigger selection (AliVEvent.h)\r
147 // taskBF->UseOfflineTrigger(); // NOT used (selection is done with the AliAnalysisTaskSE::SelectCollisionCandidates()) \r
148 // with this only selected events are analyzed (first 2 bins in event QA histogram are the same))\r
149 // documentation in https://twiki.cern.ch/twiki/bin/viewauth/ALICE/PWG1EvSelDocumentation\r
150 taskBF->SelectCollisionCandidates(AliVEvent::kMB);\r
151 \r
32a4f715 152 // centrality estimator (default = V0M)\r
a0ce3c86 153 taskBF->SetCentralityEstimator(centralityEstimator);\r
154 \r
155 // vertex cut (x,y,z)\r
156 taskBF->SetVertexDiamond(.3,.3,vertexZ);\r
157 \r
a839b0a3 158\r
3feee083 159\r
a0ce3c86 160 //bf->PrintAnalysisSettings();\r
161 mgr->AddTask(taskBF);\r
162 \r
3feee083 163 // Create ONLY the output containers for the data produced by the task.\r
164 // Get and connect other common input/output containers via the manager as below\r
165 //==============================================================================\r
166 TString outputFileName = AliAnalysisManager::GetCommonFileName();\r
a022cbd0 167 outputFileName += ":PWGCFEbyE.outputBalanceFunctionAnalysis";\r
3feee083 168 AliAnalysisDataContainer *coutQA = mgr->CreateContainer(Form("listQA_%s",centralityName.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,outputFileName.Data());\r
169 AliAnalysisDataContainer *coutBF = mgr->CreateContainer(Form("listBF_%s",centralityName.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,outputFileName.Data());\r
10a747d2 170 if(gRunShuffling) AliAnalysisDataContainer *coutBFS= mgr->CreateContainer(Form("listBFShuffled_%s",centralityName.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,outputFileName.Data());\r
3feee083 171 mgr->ConnectInput(taskBF, 0, mgr->GetCommonInputContainer());\r
6432ac6a 172 mgr->ConnectOutput(taskBF, 1, coutQA);\r
173 mgr->ConnectOutput(taskBF, 2, coutBF);\r
10a747d2 174 if(gRunShuffling) mgr->ConnectOutput(taskBF, 3, coutBFS);\r
3feee083 175\r
176 return taskBF;\r
177}\r