Changed and of line style
[u/mrichter/AliRoot.git] / PWGCF / EBYE / macros / AddTaskBalancePsiCentralityTrain.C
CommitLineData
0879e280 1// now in options\r
2//=============================================//\r
3//const char* centralityEstimator = "V0M";\r
4//const char* centralityEstimator = "CL1";\r
5//const char* centralityEstimator = "TRK";\r
6//=============================================//\r
7//Bool_t gRunShuffling = kFALSE;\r
8//Bool_t gRunShuffling = kTRUE;\r
9//=============================================//\r
10\r
11//PID config\r
90bec8c5 12Bool_t kUseNSigmaPID = kTRUE;\r
0879e280 13Double_t nSigmaMax = 3.0;\r
90bec8c5 14Bool_t kUseBayesianPID = kFALSE;\r
0879e280 15Double_t gMinAcceptedProbability = 0.7;\r
16\r
17//_________________________________________________________//\r
fb128ded 18AliAnalysisTaskBFPsi *AddTaskBalancePsiCentralityTrain(Double_t centrMin=0.,\r
19 Double_t centrMax=100.,\r
20 Bool_t gRunShuffling=kFALSE,\r
1cb2a06e 21 Bool_t gRunMixing=kTRUE,\r
8cdfbf52 22 Bool_t gRunMixingWithEventPlane=kFALSE,\r
fb128ded 23 TString centralityEstimator="V0M",\r
24 Double_t vertexZ=10.,\r
25 Double_t DCAxy=-1,\r
26 Double_t DCAz=-1,\r
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
31 Double_t maxTPCchi2 = -1, \r
32 Int_t minNClustersTPC = -1,\r
90bec8c5 33 Bool_t kUsePID = kTRUE,\r
1cb2a06e 34 Bool_t bResonancesCut = kTRUE,\r
35 Bool_t bHBTcut = kTRUE,\r
d9eb282c 36 Double_t HBTCutValue = 0.02,\r
1cb2a06e 37 Bool_t bConversionCut = kTRUE,\r
a9737921 38 Double_t invMassForConversionCut = 0.04,\r
1cb2a06e 39 Bool_t bMomentumDifferenceCut = kTRUE,\r
6fa567bd 40 Double_t fQCutMin = 0.0,\r
fb128ded 41 Int_t AODfilterBit = 128,\r
42 Bool_t bCentralTrigger = kFALSE,\r
f0fb4ac1 43 TString fileNameBase="AnalysisResults",\r
1a879e25 44 TString dirNameExtra="",\r
bc225ee0 45 TString fArgEventClass="Centrality",\r
1cb2a06e 46 TString analysisTypeUser="AOD",\r
a02aded8 47 Bool_t bVertexBinning=kTRUE,\r
c443da34 48 Double_t sigmaElectronRejection=3,\r
8b3da35d 49 Bool_t electronExclusiveRejection=kFALSE,\r
6fa567bd 50 TString correctionFileName = "",\r
51 Int_t nCentralityArrayBinsForCorrection,\r
52 Double_t *gCentralityArrayForCorrections) {\r
0879e280 53 // Creates a balance function analysis task and adds it to the analysis manager.\r
54 // Get the pointer to the existing analysis manager via the static access method.\r
0879e280 55 TString outputFileName(fileNameBase);\r
56 outputFileName.Append(".root");\r
57\r
58 //===========================================================================\r
59 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();\r
60 if (!mgr) {\r
61 ::Error("AddTaskBF", "No analysis manager to connect to.");\r
62 return NULL;\r
63 }\r
64\r
65 // Check the analysis type using the event handlers connected to the analysis manager.\r
66 //===========================================================================\r
67 if (!mgr->GetInputEventHandler()) {\r
68 ::Error("AddTaskBF", "This task requires an input event handler");\r
69 return NULL;\r
70 }\r
71 TString analysisType = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"\r
72 if(dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler())) analysisType = "MC";\r
1cb2a06e 73 \r
bc225ee0 74 // to set the analysis type manually\r
75 if(analysisTypeUser != ""){\r
76 analysisType = analysisTypeUser;\r
77 ::Info("AddTaskBF",Form("Analysis Type manually set to %s",analysisType.Data()));\r
78 }\r
79\r
0879e280 80 // for local changed BF configuration\r
08e5e3ec 81 //gROOT->LoadMacro("./configBalanceFunctionPsiAnalysis.C");\r
82 gROOT->LoadMacro("$ALICE_ROOT/PWGCF/EBYE/macros/configBalanceFunctionPsiAnalysis.C");\r
0879e280 83 AliBalancePsi *bf = 0; // Balance Function object\r
84 AliBalancePsi *bfs = 0; // shuffled Balance function object\r
f06d59b3 85 AliBalancePsi *bfm = 0; // mixing Balance function object\r
0879e280 86\r
ce8126c8 87 //maximum Delta eta range\r
88 Double_t deltaEtaMax=TMath::Abs(etaMax-etaMin);\r
89\r
0879e280 90 if (analysisType=="ESD"){\r
d9eb282c 91 bf = GetBalanceFunctionObject("ESD",centralityEstimator,centrMin,centrMax,kFALSE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning);\r
92 if(gRunShuffling) bfs = GetBalanceFunctionObject("ESD",centralityEstimator,centrMin,centrMax,kTRUE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning);\r
93 if(gRunMixing) bfm = GetBalanceFunctionObject("ESD",centralityEstimator,centrMin,centrMax,kFALSE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning);\r
0879e280 94 }\r
95 else if (analysisType=="AOD"){\r
d9eb282c 96 bf = GetBalanceFunctionObject("AOD",centralityEstimator,centrMin,centrMax,kFALSE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning);\r
97 if(gRunShuffling) bfs = GetBalanceFunctionObject("AOD",centralityEstimator,centrMin,centrMax,kTRUE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning);\r
98 if(gRunMixing) bfm = GetBalanceFunctionObject("AOD",centralityEstimator,centrMin,centrMax,kFALSE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning);\r
0879e280 99 }\r
100 else if (analysisType=="MC"){\r
d9eb282c 101 bf = GetBalanceFunctionObject("MC",centralityEstimator,centrMin,centrMax,kFALSE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning);\r
102 if(gRunShuffling) bfs = GetBalanceFunctionObject("MC",centralityEstimator,centrMin,centrMax,kTRUE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning);\r
103 if(gRunMixing) bfm = GetBalanceFunctionObject("MC",centralityEstimator,centrMin,centrMax,kFALSE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning);\r
0879e280 104 }\r
1cb2a06e 105 else if (analysisType=="MCAOD"){\r
d9eb282c 106 bf = GetBalanceFunctionObject("MCAOD",centralityEstimator,centrMin,centrMax,kFALSE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning);\r
107 if(gRunShuffling) bfs = GetBalanceFunctionObject("MCAOD",centralityEstimator,centrMin,centrMax,kTRUE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning);\r
108 if(gRunMixing) bfm = GetBalanceFunctionObject("MCAOD",centralityEstimator,centrMin,centrMax,kFALSE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning);\r
1cb2a06e 109 }\r
6f719a5b 110 else if (analysisType=="MCAODrec"){\r
d9eb282c 111 bf = GetBalanceFunctionObject("MCAODrec",centralityEstimator,centrMin,centrMax,kFALSE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning);\r
112 if(gRunShuffling) bfs = GetBalanceFunctionObject("MCAODrec",centralityEstimator,centrMin,centrMax,kTRUE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning);\r
113 if(gRunMixing) bfm = GetBalanceFunctionObject("MCAODrec",centralityEstimator,centrMin,centrMax,kFALSE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning);\r
6f719a5b 114 }\r
0879e280 115 else{\r
116 ::Error("AddTaskBF", "analysis type NOT known.");\r
117 return NULL;\r
118 }\r
119\r
120 // Create the task, add it to manager and configure it.\r
121 //===========================================================================\r
1a879e25 122 AliAnalysisTaskBFPsi *taskBF = new AliAnalysisTaskBFPsi(Form("TaskBFPsi_%.0f-%.0f_Bit%d_%s%s",centrMin,centrMax,AODfilterBit,centralityEstimator.Data(),dirNameExtra.Data()));\r
f0fb4ac1 123 \r
124 //Event characteristics scheme\r
125 taskBF->SetEventClass(fArgEventClass);\r
90bec8c5 126 //taskBF->SetCustomBinning("centralityVertex:0,80");\r
127 //taskBF->SetCustomBinning("multiplicity:0,260");\r
128 \r
4d528efb 129 if(fArgEventClass == "Multiplicity") {\r
4e33f021 130 taskBF->SetMultiplicityRange(centrMin,centrMax);\r
4d528efb 131 taskBF->SetMultiplicityEstimator(centralityEstimator);\r
a3ed6fc1 132 cout<<"Multiplicity estimator "<<centralityEstimator.Data()<<endl;\r
4d528efb 133 }\r
4e33f021 134 else if(fArgEventClass == "Centrality") {\r
135 if(analysisType == "MC")\r
136 taskBF->SetImpactParameterRange(centrMin,centrMax);\r
137 else {\r
138 taskBF->SetCentralityPercentileRange(centrMin,centrMax);\r
139 // centrality estimator (default = V0M)\r
140 taskBF->SetCentralityEstimator(centralityEstimator);\r
a3ed6fc1 141 cout<<"Centrality estimator "<<centralityEstimator.Data()<<endl;\r
4e33f021 142 }\r
143 }\r
144\r
1cb2a06e 145 //++++++++++++++++++++++\r
a02aded8 146 // Efficiency + Contamination corrections\r
147 // If correctionFileName = "", do not use corrections\r
c3b1f1a5 148 if(correctionFileName != "")\r
149 taskBF->SetInputCorrection(Form("$ALICE_ROOT/PWGCF/EBYE/BalanceFunctions/Corrections/%s",correctionFileName.Data()),nCentralityArrayBinsForCorrection,gCentralityArrayForCorrections);\r
150\r
1cb2a06e 151 //+++++++++++++++++++++\r
8b4a9227 152\r
0879e280 153 taskBF->SetAnalysisObject(bf);\r
154 if(gRunShuffling) taskBF->SetShufflingObject(bfs);\r
f06d59b3 155 if(gRunMixing){\r
156 taskBF->SetMixingObject(bfm);\r
157 taskBF->SetMixingTracks(50000);\r
8cdfbf52 158 if(gRunMixingWithEventPlane){\r
159 taskBF->SetMixingWithEventPlane(gRunMixingWithEventPlane);\r
160 }\r
f06d59b3 161 }\r
0879e280 162\r
0879e280 163 if(analysisType == "ESD") {\r
164 AliESDtrackCuts *trackCuts = GetTrackCutsObject(ptMin,ptMax,etaMin,etaMax,maxTPCchi2,DCAxy,DCAz,minNClustersTPC);\r
165 taskBF->SetAnalysisCutObject(trackCuts);\r
166 if(kUsePID) {\r
167 if(kUseBayesianPID)\r
168 taskBF->SetUseBayesianPID(gMinAcceptedProbability);\r
169 else if(kUseNSigmaPID)\r
170 taskBF->SetUseNSigmaPID(nSigmaMax);\r
90bec8c5 171 taskBF->SetParticleOfInterest(AliAnalysisTaskBFPsi::kPion);\r
0879e280 172 taskBF->SetDetectorUsedForPID(AliAnalysisTaskBFPsi::kTOFpid);\r
173 }\r
174 }\r
175 else if(analysisType == "AOD") {\r
176 // pt and eta cut (pt_min, pt_max, eta_min, eta_max)\r
177 taskBF->SetAODtrackCutBit(AODfilterBit);\r
178 taskBF->SetKinematicsCutsAOD(ptMin,ptMax,etaMin,etaMax);\r
179\r
180 // set extra DCA cuts (-1 no extra cut)\r
181 taskBF->SetExtraDCACutsAOD(DCAxy,DCAz);\r
182\r
183 // set extra TPC chi2 / nr of clusters cut\r
184 taskBF->SetExtraTPCCutsAOD(maxTPCchi2, minNClustersTPC);\r
c443da34 185\r
186 // electron rejection (so far only for AOD), <0 --> no rejection\r
8b3da35d 187 if(sigmaElectronRejection > 0){\r
188 if(electronExclusiveRejection) taskBF->SetElectronOnlyRejection(sigmaElectronRejection); // no other particle in nsigma \r
189 else taskBF->SetElectronRejection(sigmaElectronRejection); // check only if electrons in nsigma\r
190 }\r
90bec8c5 191\r
192 //++++++++++++++++//\r
193 if(kUsePID) {\r
194 if(kUseBayesianPID)\r
195 taskBF->SetUseBayesianPID(gMinAcceptedProbability);\r
196 else if(kUseNSigmaPID)\r
197 taskBF->SetUseNSigmaPID(nSigmaMax);\r
198 taskBF->SetParticleOfInterest(AliAnalysisTaskBFPsi::kPion);\r
199 taskBF->SetDetectorUsedForPID(AliAnalysisTaskBFPsi::kTPCTOF); //TOFpid,TPCpid\r
200 }\r
201 //++++++++++++++++//\r
202\r
0879e280 203 }\r
204 else if(analysisType == "MC") {\r
9c2b8d33 205 taskBF->SetKinematicsCutsAOD(ptMin,ptMax,etaMin,etaMax);\r
1cb2a06e 206 }\r
207 else if(analysisType == "MCAOD") {\r
208 // pt and eta cut (pt_min, pt_max, eta_min, eta_max)\r
209 taskBF->SetAODtrackCutBit(AODfilterBit);\r
210 taskBF->SetKinematicsCutsAOD(ptMin,ptMax,etaMin,etaMax); \r
0879e280 211 }\r
6f719a5b 212 else if(analysisType == "MCAODrec") { //++++++++++++++++\r
213 // pt and eta cut (pt_min, pt_max, eta_min, eta_max)\r
214 taskBF->SetAODtrackCutBit(AODfilterBit);\r
215 taskBF->SetKinematicsCutsAOD(ptMin,ptMax,etaMin,etaMax); \r
216\r
217 // set extra DCA cuts (-1 no extra cut)\r
218 taskBF->SetExtraDCACutsAOD(DCAxy,DCAz);\r
219\r
220 // set extra TPC chi2 / nr of clusters cut\r
221 taskBF->SetExtraTPCCutsAOD(maxTPCchi2, minNClustersTPC);\r
8b3da35d 222\r
223 // electron rejection (so far only for AOD), <0 --> no rejection\r
224 if(sigmaElectronRejection > 0){\r
225 if(electronExclusiveRejection) taskBF->SetElectronOnlyRejection(sigmaElectronRejection); // no other particle in nsigma \r
226 else taskBF->SetElectronRejection(sigmaElectronRejection); // check only if electrons in nsigma\r
227 }\r
6f719a5b 228 }//++++++++++++++++\r
0879e280 229\r
230 // offline trigger selection (AliVEvent.h)\r
231 // taskBF->UseOfflineTrigger(); // NOT used (selection is done with the AliAnalysisTaskSE::SelectCollisionCandidates()) \r
232 // with this only selected events are analyzed (first 2 bins in event QA histogram are the same))\r
233 // documentation in https://twiki.cern.ch/twiki/bin/viewauth/ALICE/PWG1EvSelDocumentation\r
234 if(bCentralTrigger) taskBF->SelectCollisionCandidates(AliVEvent::kMB | AliVEvent::kCentral | AliVEvent::kSemiCentral);\r
235 else taskBF->SelectCollisionCandidates(AliVEvent::kMB);\r
1cb2a06e 236\r
237 // centrality estimator (default = V0M)\r
238 taskBF->SetCentralityEstimator(centralityEstimator);\r
0879e280 239 \r
240 // vertex cut (x,y,z)\r
1cb2a06e 241 taskBF->SetVertexDiamond(3.,3.,vertexZ);\r
0879e280 242 \r
1cb2a06e 243\r
244\r
0879e280 245 //bf->PrintAnalysisSettings();\r
246 mgr->AddTask(taskBF);\r
247 \r
248 // Create ONLY the output containers for the data produced by the task.\r
249 // Get and connect other common input/output containers via the manager as below\r
250 //==============================================================================\r
251 TString outputFileName = AliAnalysisManager::GetCommonFileName();\r
a38fd7f3 252 outputFileName += ":PWGCFEbyE.outputBalanceFunctionPsiAnalysis";\r
1a879e25 253 AliAnalysisDataContainer *coutQA = mgr->CreateContainer(Form("listQAPsi_%.0f-%.0f_Bit%d_%s%s",centrMin,centrMax,AODfilterBit,centralityEstimator.Data(),dirNameExtra.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,outputFileName.Data());\r
254 AliAnalysisDataContainer *coutBF = mgr->CreateContainer(Form("listBFPsi_%.0f-%.0f_Bit%d_%s%s",centrMin,centrMax,AODfilterBit,centralityEstimator.Data(),dirNameExtra.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,outputFileName.Data());\r
255 if(gRunShuffling) AliAnalysisDataContainer *coutBFS = mgr->CreateContainer(Form("listBFPsiShuffled_%.0f-%.0f_Bit%d_%s%s",centrMin,centrMax,AODfilterBit,centralityEstimator.Data(),dirNameExtra.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,outputFileName.Data());\r
256 if(gRunMixing) AliAnalysisDataContainer *coutBFM = mgr->CreateContainer(Form("listBFPsiMixed_%.0f-%.0f_Bit%d_%s%s",centrMin,centrMax,AODfilterBit,centralityEstimator.Data(),dirNameExtra.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,outputFileName.Data());\r
257 if(kUsePID || sigmaElectronRejection > 0) AliAnalysisDataContainer *coutQAPID = mgr->CreateContainer(Form("listQAPIDPsi_%.0f-%.0f_Bit%d_%s%s",centrMin,centrMax,AODfilterBit,centralityEstimator.Data(),dirNameExtra.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,outputFileName.Data());\r
0879e280 258\r
259 mgr->ConnectInput(taskBF, 0, mgr->GetCommonInputContainer());\r
260 mgr->ConnectOutput(taskBF, 1, coutQA);\r
261 mgr->ConnectOutput(taskBF, 2, coutBF);\r
262 if(gRunShuffling) mgr->ConnectOutput(taskBF, 3, coutBFS);\r
f06d59b3 263 if(gRunMixing) mgr->ConnectOutput(taskBF, 4, coutBFM);\r
90bec8c5 264 if(kUsePID||sigmaElectronRejection > 0) mgr->ConnectOutput(taskBF, 5, coutQAPID);\r
265 //if((kUsePID && analysisType == "AOD")||sigmaElectronRejection > 0) mgr->ConnectOutput(taskBF, 5, coutQAPID);\r
266 //if((kUsePID && analysisType == "ESD")||sigmaElectronRejection > 0) mgr->ConnectOutput(taskBF, 5, coutQAPID);\r
0879e280 267\r
268 return taskBF;\r
269}\r