75a2ef2be7622ec6117f1a8be904721e5ac02feb
[u/mrichter/AliRoot.git] / PWGCF / FLOW / macros / AddTaskFlowCentralityPIDQC.C
1 /////////////////////////////////////////////////////////////////////////////////////////////\r
2 //\r
3 // AddTask* macro for flow analysis\r
4 // Creates a Flow Event task and adds it to the analysis manager.\r
5 // Sets the cuts using the correction framework (CORRFW) classes.\r
6 // Also creates Flow Analysis tasks and connects them to the output of the flow event task.\r
7 //\r
8 /////////////////////////////////////////////////////////////////////////////////////////////\r
9 \r
10 void AddTaskFlowCentralityPIDQC( Float_t centrMin=10.,\r
11                                Float_t centrMax=20.,\r
12                                TString fileNameBase="output",\r
13                                Bool_t isPID = kTRUE,\r
14                                AliPID::EParticleType particleType=AliPID::kPion,\r
15                                AliFlowTrackCuts::PIDsource sourcePID = AliFlowTrackCuts::kTOFbayesian,\r
16                                Int_t charge=0,\r
17                                Int_t harmonic=2,\r
18                                Bool_t doQA=kFALSE,\r
19                                Float_t etamin=-0.8,\r
20                                Float_t etamax=0.8,       \r
21                                TString uniqueStr="" )\r
22 {\r
23   // Define the range for eta subevents (for SP method)\r
24   Double_t minA = -5;\r
25   Double_t maxA = -1.5;\r
26   Double_t minB = 1.5;\r
27   Double_t maxB = 5;\r
28 \r
29   // AFTERBURNER\r
30   Bool_t useAfterBurner=kFALSE;\r
31   Double_t v1=0.0;\r
32   Double_t v2=0.0;\r
33   Double_t v3=0.0;\r
34   Double_t v4=0.0;\r
35   Int_t numberOfTrackClones=0; //non-flow\r
36 \r
37   // Define a range of the detector to exclude\r
38   Bool_t ExcludeRegion = kFALSE;\r
39   Double_t excludeEtaMin = -0.;\r
40   Double_t excludeEtaMax = 0.;\r
41   Double_t excludePhiMin = 0.;\r
42   Double_t excludePhiMax = 0.;\r
43 \r
44   // use physics selection class\r
45   Bool_t  UsePhysicsSelection = kTRUE;\r
46 \r
47   // QA\r
48   Bool_t runQAtask=kFALSE;\r
49   Bool_t FillQAntuple=kFALSE;\r
50   Bool_t DoQAcorrelations=kFALSE;\r
51 \r
52   // RUN SETTINGS\r
53   // Flow analysis method can be:(set to kTRUE or kFALSE)\r
54   Bool_t SP       = kFALSE;  // scalar product method (similar to eventplane method)\r
55   Bool_t QC       = kTRUE;  // cumulants using Q vectors\r
56   \r
57   //these are OBSOLETE, use at own peril\r
58   Bool_t GFC      = kFALSE;  // cumulants based on generating function\r
59   Bool_t MCEP     = kFALSE;  // correlation with Monte Carlo reaction plane\r
60   Bool_t FQD      = kFALSE;  // fit of the distribution of the Q vector (only integrated v)\r
61   Bool_t LYZ1SUM  = kFALSE;  // Lee Yang Zeroes using sum generating function (integrated v)\r
62   Bool_t LYZ1PROD = kFALSE;  // Lee Yang Zeroes using product generating function (integrated v)\r
63   Bool_t LYZ2SUM  = kFALSE; // Lee Yang Zeroes using sum generating function (second pass differential v)\r
64   Bool_t LYZ2PROD = kFALSE; // Lee Yang Zeroes using product generating function (second pass differential v)\r
65   Bool_t LYZEP    = kFALSE; // Lee Yang Zeroes Event plane using sum generating function (gives eventplane + weight)\r
66   Bool_t MH       = kFALSE;  // azimuthal correlators in mixed harmonics  \r
67   Bool_t NL       = kFALSE;  // nested loops (for instance distribution of phi1-phi2 for all distinct pairs)\r
68 \r
69   Bool_t METHODS[] = {SP,LYZ1SUM,LYZ1PROD,LYZ2SUM,LYZ2PROD,LYZEP,GFC,QC,FQD,MCEP,MH,NL};\r
70 \r
71   // Boolean to use/not use weights for the Q vector\r
72   Bool_t WEIGHTS[] = {kFALSE,kFALSE,kFALSE}; //Phi, v'(pt), v'(eta)\r
73 \r
74   // SETTING THE CUTS\r
75 \r
76   //---------Data selection----------\r
77   //kMC, kGlobal, kESD_TPConly, kESD_SPDtracklet\r
78   AliFlowTrackCuts::trackParameterType rptype = AliFlowTrackCuts::kTPCstandalone;\r
79   AliFlowTrackCuts::trackParameterType poitype = AliFlowTrackCuts::kTPCstandalone;\r
80 \r
81   //---------Parameter mixing--------\r
82   //kPure - no mixing, kTrackWithMCkine, kTrackWithMCPID, kTrackWithMCpt\r
83   AliFlowTrackCuts::trackParameterMix rpmix = AliFlowTrackCuts::kPure;\r
84   AliFlowTrackCuts::trackParameterMix poimix = AliFlowTrackCuts::kPure;\r
85 \r
86 \r
87   const char* rptypestr = AliFlowTrackCuts::GetParamTypeName(rptype);\r
88   const char* poitypestr = AliFlowTrackCuts::GetParamTypeName(poitype);\r
89 \r
90   //===========================================================================\r
91   // EVENTS CUTS:\r
92   AliFlowEventCuts* cutsEvent = new AliFlowEventCuts("event cuts");\r
93   cutsEvent->SetCentralityPercentileRange(centrMin,centrMax);\r
94   cutsEvent->SetCentralityPercentileMethod(AliFlowEventCuts::kV0);\r
95 //  cutsEvent->SetRefMultMethod(AliFlowEventCuts::kV0);\r
96   //cutsEvent->SetCentralityPercentileMethod(AliFlowEventCuts::kSPD1tracklets);\r
97 //  cutsEvent->SetNContributorsRange(2);\r
98   cutsEvent->SetPrimaryVertexZrange(-10.,10.);\r
99   cutsEvent->SetQA(doQA);\r
100   cutsEvent->SetCutTPCmultiplicityOutliers();\r
101   \r
102   // RP TRACK CUTS:\r
103   AliFlowTrackCuts* cutsRP2 = AliFlowTrackCuts::GetStandardVZEROOnlyTrackCuts();\r
104   AliFlowTrackCuts* cutsRP = new AliFlowTrackCuts("TPConlyRP");\r
105   cutsRP->SetParamType(rptype);\r
106   cutsRP->SetParamMix(rpmix);\r
107   cutsRP->SetPtRange(0.2,5.);\r
108   cutsRP->SetEtaRange(etamin,etamax);\r
109   cutsRP->SetMinNClustersTPC(70);\r
110 //  cutsRP->SetMinChi2PerClusterTPC(0.1);\r
111 //  cutsRP->SetMaxChi2PerClusterTPC(4.0);\r
112   cutsRP->SetMaxDCAToVertexXY(3.0);\r
113   cutsRP->SetMaxDCAToVertexZ(3.0);\r
114   cutsRP->SetAcceptKinkDaughters(kFALSE);\r
115   cutsRP->SetMinimalTPCdedx(10.);\r
116   cutsRP->SetAODfilterBit(1);  \r
117   cutsRP->SetQA(doQA);\r
118 \r
119   // POI TRACK CUTS:\r
120   AliFlowTrackCuts* cutsPOI = new AliFlowTrackCuts("TPConlyPOI");\r
121   cutsPOI->SetParamType(poitype);\r
122   cutsPOI->SetParamMix(poimix);\r
123   cutsPOI->SetPtRange(0.0,10.);\r
124   cutsPOI->SetEtaRange(etamin,etamax);\r
125   //cutsPOI->SetRequireCharge(kTRUE);\r
126   //cutsPOI->SetPID(PdgRP);\r
127   cutsPOI->SetMinNClustersTPC(70);\r
128 //  cutsPOI->SetMinChi2PerClusterTPC(0.1);\r
129 //  cutsPOI->SetMaxChi2PerClusterTPC(4.0);\r
130 //  cutsPOI->SetRequireITSRefit(kTRUE);\r
131 //  cutsPOI->SetRequireTPCRefit(kTRUE);\r
132 //  cutsPOI->SetMinNClustersITS(2);\r
133   //cutsPOI->SetMaxChi2PerClusterITS(1.e+09);\r
134   cutsPOI->SetMaxDCAToVertexXY(3.0);\r
135   cutsPOI->SetMaxDCAToVertexZ(3.0);\r
136   //cutsPOI->SetDCAToVertex2D(kTRUE);\r
137   //cutsPOI->SetMaxNsigmaToVertex(1.e+10);\r
138   //cutsPOI->SetRequireSigmaToVertex(kFALSE);\r
139   cutsPOI->SetAcceptKinkDaughters(kFALSE);\r
140   if(isPID) cutsPOI->SetPID(particleType, sourcePID);\r
141   if (charge!=0) cutsPOI->SetCharge(charge);\r
142   //cutsPOI->SetAllowTOFmismatch(kFALSE);\r
143   cutsPOI->SetRequireStrictTOFTPCagreement(kTRUE);\r
144   //iexample: francesco's tunig TPC Bethe Bloch for data:\r
145   //cutsPOI->GetESDpid().GetTPCResponse().SetBetheBlochParameters(4.36414e-02,1.75977e+01,1.14385e-08,2.27907e+00,3.36699e+00);\r
146   //cutsPOI->GetESDpid().GetTPCResponse().SetMip(49);\r
147   cutsPOI->SetMinimalTPCdedx(10.);\r
148   cutsPOI->SetAODfilterBit(1);\r
149   cutsPOI->SetQA(doQA);\r
150   cutsPOI->SetPriors((centrMin+centrMax)*0.5); // set priors and PID as a function of the centrality\r
151 \r
152   TString outputSlotName("");\r
153   outputSlotName+=uniqueStr;\r
154   outputSlotName+=Form("QC(%i) ",harmonic);\r
155   outputSlotName+=cutsRP->GetName();\r
156   outputSlotName+=" ";\r
157   outputSlotName+=cutsPOI->GetName();\r
158   outputSlotName+=Form(" %.0f-",centrMin);\r
159   outputSlotName+=Form("%.0f ",centrMax);\r
160   if(isPID){\r
161      outputSlotName+=AliFlowTrackCuts::PIDsourceName(sourcePID);\r
162      outputSlotName+=" ";\r
163      outputSlotName+=AliPID::ParticleName(particleType);\r
164   }\r
165   else{\r
166      outputSlotName+="AllCharged";\r
167   }\r
168   if (charge<0) outputSlotName+="-";\r
169   if (charge>0) outputSlotName+="+";\r
170 \r
171   TString fileName(fileNameBase);\r
172   fileName.Append(".root");\r
173 \r
174   Bool_t useWeights  = WEIGHTS[0] || WEIGHTS[1] || WEIGHTS[2];\r
175   if (useWeights) cout<<"Weights are used"<<endl;\r
176   else cout<<"Weights are not used"<<endl;\r
177   \r
178   // Get the pointer to the existing analysis manager via the static access method.\r
179   //==============================================================================\r
180   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();\r
181   if (!mgr) {\r
182     Error("AddTaskFlowEvent", "No analysis manager to connect to.");\r
183     return NULL;\r
184   }\r
185   \r
186   // Check the analysis type using the event handlers connected to the analysis\r
187   // manager. The availability of MC handler can also be checked here.\r
188   //==============================================================================\r
189   if (!mgr->GetInputEventHandler()) {\r
190     ::Error("AddTaskFlowEvent", "This task requires an input event handler");\r
191     return NULL;\r
192   }  \r
193 \r
194   // Open external input files\r
195   //===========================================================================\r
196   //weights: \r
197   TFile *weightsFile = NULL;\r
198   TList *weightsList = NULL;\r
199 \r
200   if(useWeights) {\r
201     //open the file with the weights:\r
202     weightsFile = TFile::Open("weights.root","READ");\r
203     if(weightsFile) {\r
204       //access the list which holds the histos with weigths:\r
205       weightsList = (TList*)weightsFile->Get("weights");\r
206     }\r
207     else {\r
208       cout<<" WARNING: the file <weights.root> with weights from the previous run was not available."<<endl;\r
209       break;\r
210     } \r
211   }\r
212   \r
213   //LYZ2\r
214   if (LYZ2SUM || LYZ2PROD) {\r
215     //read the outputfile of the first run\r
216     TString outputFileName = "AnalysisResults1.root";\r
217     TString pwd(gSystem->pwd());\r
218     pwd+="/";\r
219     pwd+=outputFileName.Data();\r
220     TFile *outputFile = NULL;\r
221     if(gSystem->AccessPathName(pwd.Data(),kFileExists)) {\r
222       cout<<"WARNING: You do not have an output file:"<<endl;\r
223       cout<<"         "<<pwd.Data()<<endl;\r
224       exit(0);\r
225     } else { outputFile = TFile::Open(pwd.Data(),"READ");}\r
226     \r
227     if (LYZ2SUM){  \r
228       // read the output directory from LYZ1SUM \r
229       TString inputFileNameLYZ2SUM = "outputLYZ1SUManalysis" ;\r
230       inputFileNameLYZ2SUM += rptypestr;\r
231       cout<<"The input directory is "<<inputFileNameLYZ2SUM.Data()<<endl;\r
232       TFile* fInputFileLYZ2SUM = (TFile*)outputFile->FindObjectAny(inputFileNameLYZ2SUM.Data());\r
233       if(!fInputFileLYZ2SUM || fInputFileLYZ2SUM->IsZombie()) { \r
234         cerr << " ERROR: To run LYZ2SUM you need the output file from LYZ1SUM. This file is not there! Please run LYZ1SUM first." << endl ; \r
235         break;\r
236       }\r
237       else {\r
238         TList* fInputListLYZ2SUM = (TList*)fInputFileLYZ2SUM->Get("LYZ1SUM");\r
239         if (!fInputListLYZ2SUM) {cout<<"list is NULL pointer!"<<endl;}\r
240       }\r
241       cout<<"LYZ2SUM input file/list read..."<<endl;\r
242     }\r
243 \r
244     if (LYZ2PROD){  \r
245       // read the output directory from LYZ1PROD \r
246       TString inputFileNameLYZ2PROD = "outputLYZ1PRODanalysis" ;\r
247       inputFileNameLYZ2PROD += rptypestr;\r
248       cout<<"The input directory is "<<inputFileNameLYZ2PROD.Data()<<endl;\r
249       TFile* fInputFileLYZ2PROD = (TFile*)outputFile->FindObjectAny(inputFileNameLYZ2PROD.Data());\r
250       if(!fInputFileLYZ2PROD || fInputFileLYZ2PROD->IsZombie()) { \r
251         cerr << " ERROR: To run LYZ2PROD you need the output file from LYZ1PROD. This file is not there! Please run LYZ1PROD first." << endl ; \r
252         break;\r
253       }\r
254       else {\r
255         TList* fInputListLYZ2PROD = (TList*)fInputFileLYZ2PROD->Get("LYZ1PROD");\r
256         if (!fInputListLYZ2PROD) {cout<<"list is NULL pointer!"<<endl;}\r
257       }\r
258       cout<<"LYZ2PROD input file/list read..."<<endl;\r
259     }\r
260   }\r
261 \r
262   if (LYZEP) {\r
263     //read the outputfile of the second run\r
264     TString outputFileName = "AnalysisResults2.root";\r
265     TString pwd(gSystem->pwd());\r
266     pwd+="/";\r
267     pwd+=outputFileName.Data();\r
268     TFile *outputFile = NULL;\r
269     if(gSystem->AccessPathName(pwd.Data(),kFileExists)) {\r
270       cout<<"WARNING: You do not have an output file:"<<endl;\r
271       cout<<"         "<<pwd.Data()<<endl;\r
272       exit(0);\r
273     } else {\r
274       outputFile = TFile::Open(pwd.Data(),"READ");\r
275     }\r
276     \r
277     // read the output file from LYZ2SUM\r
278     TString inputFileNameLYZEP = "outputLYZ2SUManalysis" ;\r
279     inputFileNameLYZEP += rptypestr;\r
280     cout<<"The input file is "<<inputFileNameLYZEP.Data()<<endl;\r
281     TFile* fInputFileLYZEP = (TFile*)outputFile->FindObjectAny(inputFileNameLYZEP.Data());\r
282     if(!fInputFileLYZEP || fInputFileLYZEP->IsZombie()) { \r
283       cerr << " ERROR: To run LYZEP you need the output file from LYZ2SUM. This file is not there! Please run LYZ2SUM first." << endl ; \r
284       break;\r
285     }\r
286     else {\r
287       TList* fInputListLYZEP = (TList*)fInputFileLYZEP->Get("LYZ2SUM");\r
288       if (!fInputListLYZEP) {cout<<"list is NULL pointer!"<<endl;}\r
289     }\r
290     cout<<"LYZEP input file/list read..."<<endl;\r
291   }\r
292   \r
293   \r
294   // Create the FMD task and add it to the manager\r
295   //===========================================================================\r
296   if (rptypestr == "FMD") {\r
297     AliFMDAnalysisTaskSE *taskfmd = NULL;\r
298     if (rptypestr == "FMD") {\r
299       taskfmd = new AliFMDAnalysisTaskSE("TaskFMD");\r
300       mgr->AddTask(taskfmd);\r
301       \r
302       AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance();\r
303       pars->Init();\r
304       pars->SetProcessPrimary(kTRUE); //for MC only\r
305       pars->SetProcessHits(kFALSE);\r
306       \r
307       //pars->SetRealData(kTRUE); //for real data\r
308       //pars->SetProcessPrimary(kFALSE); //for real data\r
309     }\r
310   }\r
311   \r
312   // Create the flow event task, add it to the manager.\r
313   //===========================================================================\r
314   AliAnalysisTaskFlowEvent *taskFE = NULL;\r
315 \r
316   if(useAfterBurner)\r
317     { \r
318       taskFE = new AliAnalysisTaskFlowEvent(Form("TaskFlowEvent %s",outputSlotName.Data()),"",doQA,1);\r
319       taskFE->SetFlow(v1,v2,v3,v4); \r
320       taskFE->SetNonFlowNumberOfTrackClones(numberOfTrackClones);\r
321       taskFE->SetAfterburnerOn();\r
322     }\r
323   else {taskFE = new AliAnalysisTaskFlowEvent(Form("TaskFlowEvent %s",outputSlotName.Data()),"",doQA); }\r
324   if (ExcludeRegion) {\r
325     taskFE->DefineDeadZone(excludeEtaMin, excludeEtaMax, excludePhiMin, excludePhiMax); \r
326   }\r
327   taskFE->SetSubeventEtaRange(minA, maxA, minB, maxB);\r
328   if (UsePhysicsSelection) {\r
329     taskFE->SelectCollisionCandidates(AliVEvent::kMB);\r
330     cout<<"Using Physics Selection"<<endl;\r
331   }\r
332   mgr->AddTask(taskFE);\r
333   \r
334   // Pass cuts for RPs and POIs to the task:\r
335   taskFE->SetCutsEvent(cutsEvent);\r
336   taskFE->SetCutsRP(cutsRP);\r
337   taskFE->SetCutsPOI(cutsPOI);\r
338   if (cutsRP->GetParamType()==AliFlowTrackCuts::kV0)\r
339   { \r
340     //TODO: since this is set in a static object all analyses in an analysis train\r
341     //will be affected.\r
342     taskFE->SetHistWeightvsPhiMin(0.);\r
343     taskFE->SetHistWeightvsPhiMax(200.);\r
344   }\r
345 \r
346   // Create the analysis tasks, add them to the manager.\r
347   //===========================================================================\r
348   if (SP){\r
349     AliAnalysisTaskScalarProduct *taskSP = new AliAnalysisTaskScalarProduct(Form("TaskScalarProduct %s",outputSlotName.Data()),WEIGHTS[0]);\r
350     taskSP->SetRelDiffMsub(1.0);\r
351     taskSP->SetApplyCorrectionForNUA(kTRUE);\r
352     mgr->AddTask(taskSP);\r
353   }\r
354   if (LYZ1SUM){\r
355     AliAnalysisTaskLeeYangZeros *taskLYZ1SUM = new AliAnalysisTaskLeeYangZeros(Form("TaskLeeYangZerosSUM %s",outputSlotName.Data()),kTRUE);\r
356     taskLYZ1SUM->SetFirstRunLYZ(kTRUE);\r
357     taskLYZ1SUM->SetUseSumLYZ(kTRUE);\r
358     mgr->AddTask(taskLYZ1SUM);\r
359   }\r
360   if (LYZ1PROD){\r
361     AliAnalysisTaskLeeYangZeros *taskLYZ1PROD = new AliAnalysisTaskLeeYangZeros(Form("TaskLeeYangZerosPROD %s",outputSlotName.Data()),kTRUE);\r
362     taskLYZ1PROD->SetFirstRunLYZ(kTRUE);\r
363     taskLYZ1PROD->SetUseSumLYZ(kFALSE);\r
364     mgr->AddTask(taskLYZ1PROD);\r
365   }\r
366   if (LYZ2SUM){\r
367     AliAnalysisTaskLeeYangZeros *taskLYZ2SUM = new AliAnalysisTaskLeeYangZeros(Form("TaskLeeYangZerosSUM %s",outputSlotName.Data()),kFALSE);\r
368     taskLYZ2SUM->SetFirstRunLYZ(kFALSE);\r
369     taskLYZ2SUM->SetUseSumLYZ(kTRUE);\r
370     mgr->AddTask(taskLYZ2SUM);\r
371   }\r
372   if (LYZ2PROD){\r
373     AliAnalysisTaskLeeYangZeros *taskLYZ2PROD = new AliAnalysisTaskLeeYangZeros(Form("TaskLeeYangZerosPROD %s",outputSlotName.Data()),kFALSE);\r
374     taskLYZ2PROD->SetFirstRunLYZ(kFALSE);\r
375     taskLYZ2PROD->SetUseSumLYZ(kFALSE);\r
376     mgr->AddTask(taskLYZ2PROD);\r
377   }\r
378   if (LYZEP){\r
379     AliAnalysisTaskLYZEventPlane *taskLYZEP = new AliAnalysisTaskLYZEventPlane(Form("TaskLYZEventPlane %s",outputSlotName.Data()));\r
380     mgr->AddTask(taskLYZEP);\r
381   }\r
382   if (GFC){\r
383     AliAnalysisTaskCumulants *taskGFC = new AliAnalysisTaskCumulants(Form("TaskCumulants %s",outputSlotName.Data()),useWeights);\r
384     taskGFC->SetUsePhiWeights(WEIGHTS[0]); \r
385     taskGFC->SetUsePtWeights(WEIGHTS[1]);\r
386     taskGFC->SetUseEtaWeights(WEIGHTS[2]); \r
387     mgr->AddTask(taskGFC);\r
388   }\r
389   if (QC){\r
390     AliAnalysisTaskQCumulants *taskQC = new AliAnalysisTaskQCumulants(Form("TaskQCumulants %s",outputSlotName.Data()),useWeights);\r
391     taskQC->SetUsePhiWeights(WEIGHTS[0]); \r
392     taskQC->SetUsePtWeights(WEIGHTS[1]);\r
393     taskQC->SetUseEtaWeights(WEIGHTS[2]); \r
394     taskQC->SetCalculateCumulantsVsM(kFALSE);\r
395     taskQC->SetnBinsMult(10000);\r
396     taskQC->SetMinMult(0.);\r
397     taskQC->SetMaxMult(10000.);\r
398     taskQC->SetHarmonic(harmonic);\r
399     taskQC->SetApplyCorrectionForNUA(kFALSE);\r
400     taskQC->SetFillMultipleControlHistograms(kFALSE);     \r
401     mgr->AddTask(taskQC);\r
402   }\r
403   if (FQD){\r
404     AliAnalysisTaskFittingQDistribution *taskFQD = new AliAnalysisTaskFittingQDistribution(Form("TaskFittingQDistribution %s",outputSlotName.Data()),kFALSE);\r
405     taskFQD->SetUsePhiWeights(WEIGHTS[0]); \r
406     taskFQD->SetqMin(0.);\r
407     taskFQD->SetqMax(1000.);\r
408     taskFQD->SetqNbins(10000);\r
409     mgr->AddTask(taskFQD);\r
410   }\r
411   if (MCEP){\r
412     AliAnalysisTaskMCEventPlane *taskMCEP = new AliAnalysisTaskMCEventPlane(Form("TaskMCEventPlane %s",outputSlotName.Data()));\r
413     mgr->AddTask(taskMCEP);\r
414   }\r
415   if (MH){\r
416     AliAnalysisTaskMixedHarmonics *taskMH = new AliAnalysisTaskMixedHarmonics(Form("TaskMixedHarmonics %s",outputSlotName.Data()),useWeights);\r
417     taskMH->SetHarmonic(1); // n in cos[n(phi1+phi2-2phi3)] and cos[n(psi1+psi2-2phi3)]\r
418     taskMH->SetNoOfMultipicityBins(10000);\r
419     taskMH->SetMultipicityBinWidth(1.);\r
420     taskMH->SetMinMultiplicity(1.);\r
421     taskMH->SetCorrectForDetectorEffects(kTRUE);\r
422     taskMH->SetEvaluateDifferential3pCorrelator(kFALSE); // evaluate <<cos[n(psi1+psi2-2phi3)]>> (Remark: two nested loops)    \r
423     taskMH->SetOppositeChargesPOI(kFALSE); // POIs psi1 and psi2 in cos[n(psi1+psi2-2phi3)] will have opposite charges  \r
424     mgr->AddTask(taskMH);\r
425   }  \r
426   if (NL){\r
427     AliAnalysisTaskNestedLoops *taskNL = new AliAnalysisTaskNestedLoops(Form("TaskNestedLoops %s",outputSlotName.Data()),useWeights);\r
428     taskNL->SetHarmonic(1); // n in cos[n(phi1+phi2-2phi3)] and cos[n(psi1+psi2-2phi3)]\r
429     taskNL->SetEvaluateNestedLoopsForRAD(kTRUE); // RAD = Relative Angle Distribution\r
430     taskNL->SetEvaluateNestedLoopsForMH(kTRUE); // evalaute <<cos[n(phi1+phi2-2phi3)]>> (Remark: three nested loops)   \r
431     taskNL->SetEvaluateDifferential3pCorrelator(kFALSE); // evaluate <<cos[n(psi1+psi2-2phi3)]>>  (Remark: three nested loops)   \r
432     taskNL->SetOppositeChargesPOI(kFALSE); // POIs psi1 and psi2 in cos[n(psi1+psi2-2phi3)] will have opposite charges  \r
433     mgr->AddTask(taskNL);\r
434   }\r
435 \r
436   // Create the output container for the data produced by the task\r
437   // Connect to the input and output containers\r
438   //===========================================================================\r
439   AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();\r
440   \r
441   if (rptypestr == "FMD") {\r
442     AliAnalysisDataContainer *coutputFMD = \r
443       mgr->CreateContainer(Form("BackgroundCorrected %s",outputSlotName.Data()), TList::Class(), AliAnalysisManager::kExchangeContainer);\r
444     //input and output taskFMD     \r
445     mgr->ConnectInput(taskfmd, 0, cinput1);\r
446     mgr->ConnectOutput(taskfmd, 1, coutputFMD);\r
447     //input into taskFE\r
448     mgr->ConnectInput(taskFE,1,coutputFMD);\r
449   }\r
450   \r
451   AliAnalysisDataContainer *coutputFE = \r
452   mgr->CreateContainer(Form("FlowEventSimple %s",outputSlotName.Data()),AliFlowEventSimple::Class(),AliAnalysisManager::kExchangeContainer);\r
453   mgr->ConnectInput(taskFE,0,cinput1); \r
454   mgr->ConnectOutput(taskFE,1,coutputFE);\r
455  \r
456   if (taskFE->GetQAOn())\r
457   {\r
458     TString outputQA = fileName;\r
459     outputQA += ":QA";\r
460     AliAnalysisDataContainer* coutputFEQA = \r
461     mgr->CreateContainer(Form("QA %s",outputSlotName.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,outputQA);\r
462     mgr->ConnectOutput(taskFE,2,coutputFEQA);\r
463   }\r
464 \r
465   // Create the output containers for the data produced by the analysis tasks\r
466   // Connect to the input and output containers\r
467   //===========================================================================\r
468   if (useWeights) {    \r
469     AliAnalysisDataContainer *cinputWeights = mgr->CreateContainer(Form("Weights %s",outputSlotName.Data()),\r
470                                                                    TList::Class(),AliAnalysisManager::kInputContainer); \r
471   }\r
472 \r
473   if(SP) {\r
474     TString outputSP = fileName;\r
475     outputSP += ":outputSPanalysis";\r
476     outputSP+= rptypestr;\r
477     AliAnalysisDataContainer *coutputSP = mgr->CreateContainer(Form("SP %s",outputSlotName.Data()), \r
478                                                                TList::Class(),AliAnalysisManager::kOutputContainer,outputSP); \r
479     mgr->ConnectInput(taskSP,0,coutputFE); \r
480     mgr->ConnectOutput(taskSP,1,coutputSP); \r
481     if (WEIGHTS[0]) {\r
482       mgr->ConnectInput(taskSP,1,cinputWeights);\r
483       cinputWeights->SetData(weightsList);\r
484     }\r
485   }\r
486   if(LYZ1SUM) {\r
487     TString outputLYZ1SUM = fileName;\r
488     outputLYZ1SUM += ":outputLYZ1SUManalysis";\r
489     outputLYZ1SUM+= rptypestr;\r
490     AliAnalysisDataContainer *coutputLYZ1SUM = mgr->CreateContainer(Form("LYZ1SUM %s",outputSlotName.Data()), \r
491                                                                     TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ1SUM); \r
492     mgr->ConnectInput(taskLYZ1SUM,0,coutputFE);\r
493     mgr->ConnectOutput(taskLYZ1SUM,1,coutputLYZ1SUM);\r
494   }\r
495   if(LYZ1PROD) {\r
496     TString outputLYZ1PROD = fileName;\r
497     outputLYZ1PROD += ":outputLYZ1PRODanalysis";\r
498     outputLYZ1PROD+= rptypestr;\r
499     AliAnalysisDataContainer *coutputLYZ1PROD = mgr->CreateContainer(Form("LYZ1PROD %s",outputSlotName.Data()), \r
500                                                                      TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ1PROD); \r
501     mgr->ConnectInput(taskLYZ1PROD,0,coutputFE); \r
502     mgr->ConnectOutput(taskLYZ1PROD,1,coutputLYZ1PROD);\r
503   }\r
504   if(LYZ2SUM) {\r
505     AliAnalysisDataContainer *cinputLYZ2SUM = mgr->CreateContainer(Form("LYZ2SUMin %s",outputSlotName.Data()),\r
506                                                                    TList::Class(),AliAnalysisManager::kInputContainer);\r
507     TString outputLYZ2SUM = fileName;\r
508     outputLYZ2SUM += ":outputLYZ2SUManalysis";\r
509     outputLYZ2SUM+= rptypestr;\r
510     \r
511     AliAnalysisDataContainer *coutputLYZ2SUM = mgr->CreateContainer(Form("LYZ2SUM %s",outputSlotName.Data()), \r
512                                                                     TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ2SUM); \r
513     mgr->ConnectInput(taskLYZ2SUM,0,coutputFE); \r
514     mgr->ConnectInput(taskLYZ2SUM,1,cinputLYZ2SUM);\r
515     mgr->ConnectOutput(taskLYZ2SUM,1,coutputLYZ2SUM); \r
516     cinputLYZ2SUM->SetData(fInputListLYZ2SUM);\r
517   }\r
518   if(LYZ2PROD) {\r
519     AliAnalysisDataContainer *cinputLYZ2PROD = mgr->CreateContainer(Form("LYZ2PRODin %s",outputSlotName.Data()),\r
520                                                                     TList::Class(),AliAnalysisManager::kInputContainer);\r
521     TString outputLYZ2PROD = fileName;\r
522     outputLYZ2PROD += ":outputLYZ2PRODanalysis";\r
523     outputLYZ2PROD+= rptypestr;\r
524     \r
525     AliAnalysisDataContainer *coutputLYZ2PROD = mgr->CreateContainer(Form("LYZ2PROD %s",outputSlotName.Data()), \r
526                                                                      TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ2PROD); \r
527     mgr->ConnectInput(taskLYZ2PROD,0,coutputFE); \r
528     mgr->ConnectInput(taskLYZ2PROD,1,cinputLYZ2PROD);\r
529     mgr->ConnectOutput(taskLYZ2PROD,1,coutputLYZ2PROD); \r
530     cinputLYZ2PROD->SetData(fInputListLYZ2PROD);\r
531   }\r
532   if(LYZEP) {\r
533     AliAnalysisDataContainer *cinputLYZEP = mgr->CreateContainer(Form("LYZEPin %s",outputSlotName.Data()),\r
534                                                                  TList::Class(),AliAnalysisManager::kInputContainer);\r
535     TString outputLYZEP = fileName;\r
536     outputLYZEP += ":outputLYZEPanalysis";\r
537     outputLYZEP+= rptypestr;\r
538     \r
539     AliAnalysisDataContainer *coutputLYZEP = mgr->CreateContainer(Form("LYZEP %s",outputSlotName.Data()), \r
540                                                                   TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZEP); \r
541     mgr->ConnectInput(taskLYZEP,0,coutputFE); \r
542     mgr->ConnectInput(taskLYZEP,1,cinputLYZEP);\r
543     mgr->ConnectOutput(taskLYZEP,1,coutputLYZEP); \r
544     cinputLYZEP->SetData(fInputListLYZEP);\r
545   }\r
546   if(GFC) {\r
547     TString outputGFC = fileName;\r
548     outputGFC += ":outputGFCanalysis";\r
549     outputGFC+= rptypestr;\r
550     \r
551     AliAnalysisDataContainer *coutputGFC = mgr->CreateContainer(Form("GFC %s",outputSlotName.Data()), \r
552                                                                 TList::Class(),AliAnalysisManager::kOutputContainer,outputGFC); \r
553     mgr->ConnectInput(taskGFC,0,coutputFE); \r
554     mgr->ConnectOutput(taskGFC,1,coutputGFC);\r
555     if (useWeights) {\r
556       mgr->ConnectInput(taskGFC,1,cinputWeights);\r
557       cinputWeights->SetData(weightsList);\r
558     } \r
559   }\r
560   if(QC) {\r
561     TString outputQC = fileName;\r
562     outputQC += ":outputQCanalysis";\r
563     outputQC+= rptypestr;\r
564 \r
565     AliAnalysisDataContainer *coutputQC = mgr->CreateContainer(Form("QC %s",outputSlotName.Data()), \r
566                                                                TList::Class(),AliAnalysisManager::kOutputContainer,outputQC); \r
567     mgr->ConnectInput(taskQC,0,coutputFE); \r
568     mgr->ConnectOutput(taskQC,1,coutputQC);\r
569     if (useWeights) {\r
570       mgr->ConnectInput(taskQC,1,cinputWeights);\r
571       cinputWeights->SetData(weightsList);\r
572     }\r
573   }\r
574   if(FQD) {\r
575     TString outputFQD = fileName;\r
576     outputFQD += ":outputFQDanalysis";\r
577     outputFQD+= rptypestr;\r
578     \r
579     AliAnalysisDataContainer *coutputFQD = mgr->CreateContainer(Form("FQD %s",outputSlotName.Data()), \r
580                                                                 TList::Class(),AliAnalysisManager::kOutputContainer,outputFQD); \r
581     mgr->ConnectInput(taskFQD,0,coutputFE); \r
582     mgr->ConnectOutput(taskFQD,1,coutputFQD);\r
583     if(useWeights) {\r
584       mgr->ConnectInput(taskFQD,1,cinputWeights);\r
585       cinputWeights->SetData(weightsList);\r
586     } \r
587   }\r
588   if(MCEP) {\r
589     TString outputMCEP = fileName;\r
590     outputMCEP += ":outputMCEPanalysis";\r
591     outputMCEP+= rptypestr;\r
592     \r
593     AliAnalysisDataContainer *coutputMCEP = mgr->CreateContainer(Form("MCEP %s",outputSlotName.Data()), \r
594                                                                  TList::Class(),AliAnalysisManager::kOutputContainer,outputMCEP); \r
595     mgr->ConnectInput(taskMCEP,0,coutputFE);\r
596     mgr->ConnectOutput(taskMCEP,1,coutputMCEP); \r
597   }\r
598   if(MH) {\r
599     TString outputMH = fileName;\r
600     outputMH += ":outputMHanalysis";\r
601     outputMH += rptypestr;\r
602         \r
603     AliAnalysisDataContainer *coutputMH = mgr->CreateContainer(Form("MH %s",outputSlotName.Data()), \r
604                                                                TList::Class(),AliAnalysisManager::kOutputContainer,outputMH); \r
605     mgr->ConnectInput(taskMH,0,coutputFE); \r
606     mgr->ConnectOutput(taskMH,1,coutputMH); \r
607     //if (useWeights) {\r
608     //  mgr->ConnectInput(taskMH,1,cinputWeights);\r
609     //  cinputWeights->SetData(weightsList);\r
610     //} \r
611   }\r
612   if(NL) {\r
613     TString outputNL = fileName;\r
614     outputNL += ":outputNLanalysis";\r
615     outputNL += rptypestr;\r
616 \r
617     AliAnalysisDataContainer *coutputNL = mgr->CreateContainer(Form("NL %s",outputSlotName.Data()), \r
618                                                                TList::Class(),AliAnalysisManager::kOutputContainer,outputNL); \r
619     mgr->ConnectInput(taskNL,0,coutputFE);\r
620     mgr->ConnectOutput(taskNL,1,coutputNL);\r
621     //if (useWeights) {\r
622     //  mgr->ConnectInput(taskNL,1,cinputWeights);\r
623     //  cinputWeights->SetData(weightsList);\r
624     //} \r
625   }\r
626 \r
627   ///////////////////////////////////////////////////////////////////////////////////////////\r
628   if (runQAtask)\r
629   {\r
630     AliAnalysisTaskQAflow* taskQAflow = new AliAnalysisTaskQAflow(Form("TaskQAflow %s",outputSlotName.Data()));\r
631     taskQAflow->SetEventCuts(cutsEvent);\r
632     taskQAflow->SetTrackCuts(cutsRP);\r
633     taskQAflow->SetFillNTuple(FillQAntuple);\r
634     taskQAflow->SetDoCorrelations(DoQAcorrelations);\r
635     mgr->AddTask(taskQAflow);\r
636     \r
637     Printf("outputSlotName %s",outputSlotName.Data());\r
638     TString taskQAoutputFileName(fileNameBase);\r
639     taskQAoutputFileName.Append("_QA.root");\r
640     AliAnalysisDataContainer* coutputQAtask = mgr->CreateContainer(Form("flowQA %s",outputSlotName.Data()),\r
641                                               TObjArray::Class(),\r
642                                               AliAnalysisManager::kOutputContainer,\r
643                                               taskQAoutputFileName);\r
644     AliAnalysisDataContainer* coutputQAtaskTree = mgr->CreateContainer(Form("flowQAntuple %s",outputSlotName.Data()),\r
645                                               TNtuple::Class(),\r
646                                               AliAnalysisManager::kOutputContainer,\r
647                                               taskQAoutputFileName);\r
648     mgr->ConnectInput(taskQAflow,0,mgr->GetCommonInputContainer());\r
649     mgr->ConnectInput(taskQAflow,1,coutputFE);\r
650     mgr->ConnectOutput(taskQAflow,1,coutputQAtask);\r
651     if (FillQAntuple) mgr->ConnectOutput(taskQAflow,2,coutputQAtaskTree);\r
652   }\r
653 }\r
654 \r
655 \r
656 \r
657 \r
658 \r