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