]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGCF/FLOW/macros/AddTaskPhiFlow.C
add a convenience script to load flow libraries
[u/mrichter/AliRoot.git] / PWGCF / FLOW / macros / AddTaskPhiFlow.C
1 /////////////////////////////////////////////////////////////////////////////////////////////
2 //
3 // AddTaskPhiFlow macro
4 // Author: Redmer A. Bertens, Utrecht University, 2012
5 //         rbertens@cern.ch, r.a.bertens@uu.nl
6 //         Commented where necessary
7 /////////////////////////////////////////////////////////////////////////////////////////////
8
9 class AliAnalysisDataContainer;
10 class AliFlowTrackCuts;
11 class AliFlowTrackSimpleCuts;
12 class AliFlowEventCuts;
13 class AliFlowEventSimpleCuts;
14 class AliAnalysisDataContainer;
15
16 AliAnalysisTaskPhiFlow* AddTaskPhiFlow(Bool_t SP = kTRUE, // select flow analysis methods
17                                        Bool_t SPSUB = kTRUE,
18                                        Bool_t QC = kTRUE,
19                                        Bool_t EP = kTRUE,
20                                        Bool_t EP3sub = kFALSE,
21                                        Bool_t VZERO_SP = kFALSE, // use vzero sp method
22                                        Float_t centrMin = 20., // centrality selection
23                                        Float_t centrMax = 30.,
24                                        Double_t ITSsigma = 0., // pid mode (see task implementation)
25                                        Double_t ITSrange = 0.,
26                                        Double_t TPCcontrol = 1.,
27                                        Double_t TPCsigma = 3.,
28                                        Double_t TPCrange = 0.,
29                                        Double_t ITScontrol = -1.,
30                                        Double_t Bpurity = 0.3,
31                                        TString suffixName = "UniqueID", // unique id for output objects
32                                        Bool_t bCentralTrigger = kTRUE, // trigger selection
33                                        Float_t EtaGap = 0., // eta gap for SPSUB
34                                        TString DCA = "pt", // dca mode (see task implementation)
35                                        Int_t harm = 2, // harmonic vn
36                                        UInt_t poi_filter = 1024, // aod filterbits
37                                        UInt_t rp_filter = 1024,
38                                        Bool_t event_mixing = kFALSE,
39                                        Bool_t highPtMode = kFALSE, // use with caution !!! disables invariant mass fit method
40                                        Float_t deltaPhiMass = 0.0003, // dM in which to look for phi 
41                                        Float_t POIPtMax = 5., // max pt of daughterp particles
42                                        Bool_t shrinkSP = kTRUE, // shrink output
43                                        Bool_t debug = kTRUE) // macro debug mode, for task's debug mode see header
44 {
45    // some defaults that have been removed as function arguments (august 30 2012)
46    Float_t POIPtMin = 0.2;  // pt of daughters
47    Float_t deltaDip = 0.;
48    Float_t deltaDipMaxPt = 0.;
49    Bool_t TPCStandAloneTracks = kFALSE; // deprecated
50    Bool_t useGlobalRPCuts = kTRUE; // deprecated
51    Float_t vertexZ = 10.;
52    Float_t POIEtaMin = -0.8;
53    Float_t POIEtaMax = 0.8;
54    // start of macro
55    Double_t PIDconfig[] = {ITSsigma, ITSrange, TPCcontrol, TPCsigma, TPCrange, ITScontrol, Bpurity};
56    // main function, create and add tasks
57    if(debug) cout << " === Adding Task PhiFlow === " << endl;
58    // set up main output container's name
59    TString fileName = AliAnalysisManager::GetCommonFileName();
60    fileName += ":PhiReconstruction";
61    suffixName += Form("%.0f", centrMin);
62    suffixName += Form("%.0f", centrMax);
63    fileName+=suffixName;
64    if(debug) cout << "    --> Reconstruction data container: " << fileName << endl;
65    // check validity of arguments
66    if(EP3sub) {
67        if(highPtMode) {
68            if(debug) cout << " --> Can't launch 3 subevent method for high pt analysis, exiting ... <--" << endl;
69            return 0x0;
70        }
71        if(debug) cout << " --> Starting 3 subevent plane method - try at your own risk !!! <-- " << endl;
72        if(!(harm!=2||harm!=3)) {
73            if(debug) cout << " --> Fatal error: can only return v2 and v3 with 3 subevent method! " << endl;
74            return 0x0;
75        }
76    }
77   // get the manager and input event handler
78    AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
79    if (!mgr) {
80       if(debug) cout << " Fatal error: no analysis manager found! " << endl;
81       return 0x0;
82    }
83    if (!mgr->GetInputEventHandler()) {
84       if(debug) cout << " Fatal error: no imput event handler found!" << endl;
85       return 0x0;
86    }
87    if(EP3sub&&debug) { // don't use this on train ! this is why it's only enabled in macro debug mode
88          gROOT->LoadMacro("$ALICE_ROOT/PWGCF/FLOW/macros/AddTaskVZERO.C");
89          AddTaskVZERO(0,0,0,0);
90    }
91    // create the main task
92    AliAnalysisTaskPhiFlow *task = new AliAnalysisTaskPhiFlow("TaskPhiFlow");
93    if(debug) cout << " === AliAnalysisTaskPhiFlow === " << task << endl;
94    if(!task) {
95        if(debug) cout << " --> Unexpected error occurred: NO TASK WAS CREATED! (could be a library problem!) " << endl;
96        return 0x0;
97    }
98    if(task->SetVZEROSubEvents(EP3sub)) cout << " --> Setting up VZERO subevents method ... " << endl;
99    if(event_mixing) {
100       if(debug) cout << " --> Enabeling event mixing for reconstruction - try at your own risk !!! <-- " << endl;
101       // set vertex and mixing bins - arrays MUST have length 20!
102       Int_t c[] = {0, 2, 4, 6, 8, 10, 20, 30, 40, 50, 60, 70, 80, 90, 101, 0, 0, 0, 0, 0};
103       Int_t v[] = {-10, -8, -6, -4, -2, 0, 2, 4, 6, 8, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0};
104       if(((Int_t)(sizeof(c)/sizeof(c[1]))!=20)||((Int_t)(sizeof(v)/sizeof(v[1]))!=20)) {
105           cout << " --> Fatal error: check mixing parameters ! <-- " << endl;
106           return 0x0;
107       }
108       else task->SetMixingBins(c, v);
109    }  
110    // set triggers
111    if (bCentralTrigger) task->SelectCollisionCandidates(AliVEvent::kMB | AliVEvent::kCentral | AliVEvent::kSemiCentral);
112    else                 task->SelectCollisionCandidates(AliVEvent::kMB);
113    if(debug) cout << "    --> Set trigger selection to ";
114    if(debug&&bCentralTrigger) cout << " kMB, kCentral, kSemiCentral " << endl;
115    if(debug&&(!bCentralTrigger)) cout << " kMB " << endl;
116    //set RP cuts for flow package analysis
117    cutsRP = new AliFlowTrackCuts("RFPcuts");
118    if(!cutsRP) {
119        if(debug) cout << " Fatal error: no RP cuts found, could be a library problem! " << endl;
120        return 0x0;
121    }
122    if(useGlobalRPCuts&&(!VZERO_SP)) {
123        AliFlowTrackCuts::trackParameterType rptype = AliFlowTrackCuts::kGlobal;
124        cutsRP->SetParamType(rptype);
125        cutsRP->SetPtRange(0.2, 5.0);
126        cutsRP->SetEtaRange(-0.8, 0.8);
127        cutsRP->SetMinNClustersTPC(70);
128        cutsRP->SetMinChi2PerClusterTPC(0.1);
129        cutsRP->SetMaxChi2PerClusterTPC(4.0);
130        cutsRP->SetRequireTPCRefit(kTRUE);
131        cutsRP->SetMaxDCAToVertexXY(0.3);
132        cutsRP->SetMaxDCAToVertexZ(0.3);
133        cutsRP->SetAcceptKinkDaughters(kFALSE);
134        cutsRP->SetMinimalTPCdedx(10.);
135        if(rp_filter < 9999 ) {
136            if(debug) cout << "  > set RP filterbit " << rp_filter << endl;     
137            cutsRP->SetAODfilterBit(rp_filter);
138        }
139        if(debug) cout << "    --> kGlobal RP's " << cutsRP << endl;
140    }
141    if(VZERO_SP) { // use vzero sub analysis
142        cutsRP = cutsRP->GetStandardVZEROOnlyTrackCuts(); // select vzero tracks
143        SP = kFALSE; // disable other methods
144        SPSUB = kTRUE; // calculate sp_qa and sp_qb
145        QC = kFALSE;
146        EP = kFALSE;
147        EP3sub = kFALSE;
148        EtaGap = 0.; // no eta gap, full tpc poi's
149        if(debug) cout << "    --> VZERO RP's " << cutsRP << endl;
150    }
151    task->SetRPCuts(cutsRP);
152    // set POI cuts for kaon selection
153    AliFlowTrackCuts* cutsPOI = new AliFlowTrackCuts("GlobalPOI");
154    if(!cutsPOI) {
155        if(debug) cout << " Fatal error: no POI cuts (could be a library problem)!" << endl;
156        return 0x0;
157    }
158    AliFlowTrackCuts* cutsPOI = cutsPOI->GetStandardGlobalTrackCuts2010();
159    cutsPOI->SetPtRange(POIPtMin, POIPtMax); // pt range of DAUGHTERS !!!
160    cutsPOI->SetMaxDCAToVertexXY(0.3); // FIXME not implemented in aod086 aod095 see PassesDCACut() in implementation
161    cutsPOI->SetMaxDCAToVertexZ(0.3);
162    if(poi_filter < 9999 ) {
163        if(debug) cout << "  > set POI filterbit " << poi_filter << endl;     
164        cutsPOI->SetAODfilterBit(poi_filter);
165    }
166    if(debug) cout << "    --> cutsPOI " << cutsPOI << endl;
167    task->SetPOICuts(cutsPOI);
168    //set POI cuts for aods XY Z - 3 distinct cases
169    Double_t POIDCA[] = {0., 0., 0., 0., 0.};
170    if(DCA == "none" ) { // 1 --- do nothing
171        if (debug) cout << " --> No DCA cut on POI's <-- " << endl;
172        for (Int_t i = 0; i < 5; i++) POIDCA[i] = 0.;
173    }
174    if(DCA == "fix" ) { // 2 --- use fixed values for xy z
175        if (debug) cout << " --> Fixed DCA cut on POI's <-- " << endl;
176        POIDCA[0] = -1.; POIDCA[1] = 0.3; POIDCA[2] = 0.3; POIDCA[3] = 0.; POIDCA[4] = 0.;
177    }
178    if(DCA == "pt" ) { // 3 --- use pt dependent cut
179        if (debug) cout << " --> Pt dependent DCA cut on POI's <-- " << endl;
180        POIDCA[0] = 1.; POIDCA[1] = 0.0105; POIDCA[2] = 0.0350; POIDCA[3] = 1.1; POIDCA[4] = 2.;
181    }
182    task->SetPOIDCAXYZ(POIDCA);
183    if(highPtMode) { // high pt loop - loop will end macro
184        Float_t _pt[] = {0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 12., 15.};
185        task->SetPtBins(_pt, (Int_t)(sizeof(_pt)/sizeof(_pt[1]))-1);
186        // general approach: use kinematic filters which select kaon pairs with a certain mass window
187        AliFlowTrackSimpleCuts* HighPtSubEventFilterA = new AliFlowTrackSimpleCuts("HighPtSubEventFilterA"); 
188        HighPtSubEventFilterA->SetEtaMin(-0.8);
189        HighPtSubEventFilterA->SetEtaMax(0.0);
190        HighPtSubEventFilterA->SetMassMin(1.019445 - deltaPhiMass);
191        HighPtSubEventFilterA->SetMassMax(1.019445 + deltaPhiMass);
192        AliFlowTrackSimpleCuts* HighPtSubEventFilterB = new AliFlowTrackSimpleCuts("HighPtSubEventFilterB"); 
193        HighPtSubEventFilterA->SetEtaMin(0.0);
194        HighPtSubEventFilterA->SetEtaMax(+0.8);
195        HighPtSubEventFilterA->SetMassMin(1.019445 - deltaPhiMass);
196        HighPtSubEventFilterA->SetMassMax(1.019445 + deltaPhiMass);
197        AliFlowTrackSimpleCuts* HighPtGenericFilter = new AliFlowTrackSimpleCuts("HighPtGenericFilter");
198        HighPtGenericFilter->SetEtaMin(-0.8);
199        HighPtGenericFilter->SetEtaMax(+0.8);
200        HighPtGenericFilter->SetMassMin(1.019445 - deltaPhiMass);
201        HighPtGenericFilter->SetMassMax(1.019445 + deltaPhiMass);
202        if(debug) cout << "    --> Created poi filters " << endl;
203        // set pair and event cuts
204        if((deltaDip>0.005)&&(deltaDipMaxPt>0.005)) task->SetMaxDeltaDipAngleAndPt(deltaDip, deltaDipMaxPt);
205        else cout << " --> Disabled Delta-Dip exclusion. <-- " << endl;
206        task->SetCandidateEtaAndPt(POIEtaMin, POIEtaMax, 0., 15.);
207        task->SetCentralityParameters(centrMin, centrMax, "TRK", "V0M", kTRUE, kFALSE);
208        task->SetVertexZ(vertexZ);
209        if(debug) cout << "    --> Set pair cuts and event cuts" << endl;
210        // specify the PID procedure which will be used
211        task->SetPIDConfiguration(PIDconfig);
212        AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
213        AliAnalysisDataContainer *coutHist = mgr->CreateContainer(Form("PhiV2_%s", OutputName(centrMin, centrMax,PIDconfig, suffixName, bCentralTrigger, EtaGap, POIEtaMin, POIEtaMax, 0., 15., deltaDip, deltaDipMaxPt, DCA, harm, TPCStandAloneTracks, vertexZ, debug, useGlobalRPCuts).Data()), TList::Class(), AliAnalysisManager::kOutputContainer, fileName);
214        if(debug) cout << "    --> Created IO containers " << cinput << ", " << coutHist << endl;
215        mgr->AddTask(task);
216        if(debug) cout << " === ADDING MAIN TASK == " << endl;
217        mgr->ConnectInput(task, 0, cinput);
218        mgr->ConnectOutput(task, 1, coutHist);
219        if(debug) cout << "    --> Connected IO containers " << endl;
220        if (SP || EP || QC || SPSUB) // if flow analysis should be done after reconstruction
221        {
222           Int_t mb(999);
223           if(debug) cout << " === RECEIVED REQUEST FOR FLOW ANALYSIS === " << endl;
224           AliAnalysisDataContainer *flowEvent = mgr->CreateContainer(Form("FC%s", suffixName.Data()), AliFlowEventSimple::Class(), AliAnalysisManager::kExchangeContainer);
225           mgr->ConnectOutput(task, 2, flowEvent);
226           if(debug) cout << "    --> Created IO containers " << flowEvent << endl;
227           if(debug) cout << "    --> suffixName " << suffixName << endl;
228           if (QC) {  // add qc tasks
229              AddQCmethod(Form("QCTPCMB_%d_%s", mb, suffixName.Data()), harm, flowEvent, HighPtGenericFilter, debug, 0x0, suffixName.Data());
230              if(debug) cout << "    --> Hanging QC task ... " << mb << " succes! "<< endl;
231           }
232           if (SPSUB) {  // add sp subevent tasks
233              AddSPmethod(Form("SPTPCMB_%d_%s", mb, suffixName.Data()), -0.8, -.5*EtaGap, .5*EtaGap, +0.8, "Qa", harm, flowEvent, HighPtSubEventFilterB, NULL, false, shrinkSP, debug, true, suffixName.Data());
234              if(debug) cout << "    --> Hanging SP Qa task " << mb << " succes!" << endl;
235              AddSPmethod(Form("SPTPCMB_%d_%s", mb, suffixName.Data()), -0.8, -.5*EtaGap, .5*EtaGap, +0.8, "Qb", harm, flowEvent, HighPtSubEventFilterA, NULL, false, shrinkSP, debug, true, suffixName.Data());
236              if(debug) cout << "    --> Hanging SP Qb task ..." << mb << " succes!"<< endl;
237           }
238           if (SP) { // add sp tasks
239              AddSPmethod(Form("SPTPCMB_%d_%s", mb, suffixName.Data()), -0.8, -0.0, +0.0, +0.8, "QaQb", harm, flowEvent, HighPtGenericFilter, NULL, false, shrinkSP, debug, 0x0, suffixName.Data());
240              if(debug) cout << "    --> Hanging SP task ... " << mb << " succes!" << endl;
241           }
242           if (EP) { // add ep tasks
243              AddSPmethod(Form("EPTPCMB_%d_%s", mb, suffixName.Data()), -0.8, -0.0, +0.0, +0.8, "QaQb", harm, flowEvent, HighPtGenericFilter, NULL, true, shrinkSP, debug, 0x0, suffixName.Data());
244              if(debug) cout << "    --> Hanging EP task ... " << mb << " succes!" << endl;
245           }
246        }
247        // print summary to screen
248        cout << endl << endl << "       ==== AddTaskPhiFlow launched  ===== " << endl;
249        cout << " ************ Configured PID routine ************ " << endl;
250        cout << "      0 < " << PIDconfig[1] << " p_t, ITS || TPC with s < " << PIDconfig[0] << endl;
251        if(PIDconfig[2] < 0.) cout << "    --> TPC control disabled " << endl;
252        if(PIDconfig[2] > 0.) cout << "    --> TPC control enabled " << endl;
253        cout << "    " << PIDconfig[1] << " < " << PIDconfig[4] << " p_t, TPC || ITS with s < " << PIDconfig[3] << endl;
254        if(PIDconfig[5] < 0.) cout << "    --> ITS control disabled " << endl;
255        if(PIDconfig[5] > 0.) cout << "    --> ITS control enabled " << endl;
256        cout << "      " << PIDconfig[4] << " < 7 p_t, TPC / TOF Bayesian with p < " << PIDconfig[6] << endl;
257        cout << " ************ Configured DCA setup ************** " << endl;
258        cout << "  DCA type: " << DCA;
259        if (DCA == "") cout << "default";
260        cout << endl << " ************* Task statisti:q!cs ****************** " << endl;
261        cout << "   -> Launched PHI reconstruction " << endl;
262        if(SP) cout << "   --> Launched QaQb SP filters and corresponding SP task " << endl;
263        if(EP) cout << "   --> Launched QaQb QC filters and corresponding EP task " << endl;
264        if(SPSUB) cout << "   --> Launched Qa&&Qb SP filters and corresponding SP tasks " << endl;
265        if(QC) cout << "   --> Launched QaQb QC filters and corresponding QC task " << endl;
266        if(EP3sub) cout << " --> Launched VZERO subevent analysis alongside reconstruction - USE WITH CAUTION!" << endl;
267        cout << " ************************************************ " << endl;
268        TString condit = "";
269        (task->SetQA(kFALSE)) ? condit+= " --> Enabled QA plots <-- " : condit+= " --> Disabled QA plots <-- ";
270        (task->SetIsMC(kFALSE)) ? condit+= " --> MC mode <-- " : condit+= " --> DATA mode <-- ";
271        (task->UseEventMixing(event_mixing, kTRUE)) ? condit+= " --> Using EVENT MIXING <--" : condit+= "--> Combinatorial background <--";
272        cout << condit << endl;
273        cout << "           --> Now go for a coffee! <-- " << endl;
274        cout << " ************************************************ " << endl;
275        return task;
276    } //  end of high pt loop - high-pt task is ready to go at this point
277    Float_t _pt[] = {0.0, 0.3, 0.6, 0.9, 1.2, 1.5, 1.8, 2.1, 2.4, 2.7, 3.0, 3.5, 4.0, 4.5, 5.0, 5.5, 6.0, 6.5, 7.0};
278    task->SetPtBins(_pt, (Int_t)(sizeof(_pt)/sizeof(_pt[1]))-1);
279    // POI filter cuts, will filter invm mass bands and subevents
280    AliFlowTrackSimpleCuts* POIfilterQC[30];
281    AliFlowTrackSimpleCuts* POIfilterSP[30][2];
282    Double_t flowBands[2][30];
283    for (Int_t mb = 0; mb < 30; mb++) {
284       flowBands[0][mb] = 0.99 + mb * 0.0034;
285       flowBands[1][mb] = 0.99 + (mb + 1) * 0.0034;
286       POIfilterSP[mb][0] = new AliFlowTrackSimpleCuts(Form("FilterPOISP_MB%d_ETANEG", mb));
287       if(!POIfilterSP[mb][0]) {
288           if(debug) cout << " FAILED to initialize POI filters, could be a library problem!" << endl;
289           return 0x0;
290       }
291       POIfilterSP[mb][0]->SetEtaMin(-0.8);
292       POIfilterSP[mb][0]->SetEtaMax(0.0);
293       POIfilterSP[mb][0]->SetMassMin(flowBands[0][mb]);
294       POIfilterSP[mb][0]->SetMassMax(flowBands[1][mb]);
295       POIfilterSP[mb][1] = new AliFlowTrackSimpleCuts(Form("FilterPOISP_MB%d_ETAPOS", mb));
296       POIfilterSP[mb][1]->SetEtaMin(0.0);
297       POIfilterSP[mb][1]->SetEtaMax(+0.8);
298       POIfilterSP[mb][1]->SetMassMin(flowBands[0][mb]);
299       POIfilterSP[mb][1]->SetMassMax(flowBands[1][mb]);
300       POIfilterQC[mb] = new AliFlowTrackSimpleCuts(Form("FilterPOIQC_MB%d", mb));
301       POIfilterQC[mb]->SetEtaMin(-0.8);
302       POIfilterQC[mb]->SetEtaMax(+0.8);
303       POIfilterQC[mb]->SetMassMin(flowBands[0][mb]);
304       POIfilterQC[mb]->SetMassMax(flowBands[1][mb]);
305    }
306    if(debug) cout << "    --> Created poi filters " << endl;
307    task->SetCommonConstants(30, flowBands[0][0], flowBands[1][29]);
308    if(debug) cout << "    --> Set common constants " << endl;
309    // set pair and event cuts
310    if((deltaDip>0.005)&&(deltaDipMaxPt>0.005)) task->SetMaxDeltaDipAngleAndPt(deltaDip, deltaDipMaxPt);
311    else cout << " --> Disabled Delta-Dip exclusion. <-- " << endl;
312    task->SetCandidateEtaAndPt(POIEtaMin, POIEtaMax, 0., 10.);
313    task->SetCentralityParameters(centrMin, centrMax, "TRK", "V0M", kTRUE, kFALSE);
314    task->SetVertexZ(vertexZ);
315    if(debug) cout << "    --> Set pair cuts and event cuts" << endl;
316    // set the kaon cuts, and specify the PID procedure which will be used
317    task->SetPIDConfiguration(PIDconfig);
318    if(debug) {
319        cout << " ************ Configured PID routine ************ " << endl;
320        cout << "    0 < " << PIDconfig[1] << " p_t, ITS || TPC with s < " << PIDconfig[0] << endl;
321        if(PIDconfig[2] < 0.) cout << "  --> TPC control disabled " << endl;
322        if(PIDconfig[2] > 0.) cout << "  --> TPC control enabled " << endl;
323        cout << "    " << PIDconfig[1] << " < " << PIDconfig[4] << " p_t, TPC || ITS with s < " << PIDconfig[3] << endl;
324        if(PIDconfig[5] < 0.) cout << "  --> ITS control disabled " << endl;
325        if(PIDconfig[5] > 0.) cout << "  --> ITS control enabled " << endl;
326        cout << "    " << PIDconfig[4] << " < 7 p_t, TPC / TOF Bayesian with p < " << PIDconfig[6] << endl;
327        cout << " ************************************************ " << endl;
328    }
329    if (TPCStandAloneTracks)
330    { // switch to tpc standalone tracks for POI selection
331       if(debug) cout << "    --> Switching to TPC standalone analsis " << endl;
332       task->SetRequireStrictKaonCuts();
333       task->SetRequireTPCStandAloneKaons();
334    }
335    // create and configure IO containers
336    AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
337    AliAnalysisDataContainer *coutHist = mgr->CreateContainer(Form("PhiV2_%s", OutputName(centrMin, centrMax,PIDconfig, suffixName, bCentralTrigger, EtaGap, POIEtaMin, POIEtaMax, 0., 10., deltaDip, deltaDipMaxPt, DCA, harm, TPCStandAloneTracks, vertexZ, debug, useGlobalRPCuts).Data()), TList::Class(), AliAnalysisManager::kOutputContainer, fileName);
338    if(debug) cout << "    --> Created IO containers " << cinput << ", " << coutHist << endl;
339    mgr->AddTask(task);
340    if(debug) cout << " === ADDING MAIN TASK == " << endl;
341    mgr->ConnectInput(task, 0, cinput);
342    mgr->ConnectOutput(task, 1, coutHist);
343    if(debug) cout << "    --> Connected IO containers " << endl;
344    if (SP || EP || QC || SPSUB) // if flow analysis should be done after reconstruction
345    {
346       if(debug) cout << " === RECEIVED REQUEST FOR FLOW ANALYSIS === " << endl;
347       AliAnalysisDataContainer *flowEvent = mgr->CreateContainer(Form("FC%s", suffixName.Data()), AliFlowEventSimple::Class(), AliAnalysisManager::kExchangeContainer);
348       mgr->ConnectOutput(task, 2, flowEvent);
349       if(debug) cout << "    --> Created IO containers " << flowEvent << endl;
350       if(debug) cout << "    --> suffixName " << suffixName << endl;
351       for (int mb = 0; mb != 30; ++mb) {
352          if (QC) {  // add qc tasks
353             AddQCmethod(Form("QCTPCMB_%d_%s", mb, suffixName.Data()), harm, flowEvent, POIfilterQC[mb], debug, 0x0, suffixName.Data());
354             if(debug) cout << "    --> Hanging QC task ... " << mb << " succes! "<< endl;
355          }
356          if (SPSUB) {  // add sp subevent tasks
357             AddSPmethod(Form("SPTPCMB_%d_%s", mb, suffixName.Data()), -0.8, -.5*EtaGap, .5*EtaGap, +0.8, "Qa", harm, flowEvent, POIfilterSP[mb][1], NULL, false, shrinkSP, debug, true, suffixName.Data(), VZERO_SP);
358             if(debug) cout << "    --> Hanging SP Qa task " << mb << " succes!" << endl;
359             AddSPmethod(Form("SPTPCMB_%d_%s", mb, suffixName.Data()), -0.8, -.5*EtaGap, .5*EtaGap, +0.8, "Qb", harm, flowEvent, POIfilterSP[mb][0], NULL, false, shrinkSP, debug, true, suffixName.Data(), VZERO_SP);
360             if(debug) cout << "    --> Hanging SP Qb task ..." << mb << " succes!"<< endl;
361          }
362          if (SP) { // add sp tasks
363             AddSPmethod(Form("SPTPCMB_%d_%s", mb, suffixName.Data()), -0.8, -0.0, +0.0, +0.8, "QaQb", harm, flowEvent, POIfilterQC[mb], NULL, false, shrinkSP, debug, 0x0, suffixName.Data());
364             if(debug) cout << "    --> Hanging SP task ... " << mb << " succes!" << endl;
365          }
366          if (EP) { // add ep tasks
367             AddSPmethod(Form("EPTPCMB_%d_%s", mb, suffixName.Data()), -0.8, -0.0, +0.0, +0.8, "QaQb", harm, flowEvent, POIfilterQC[mb], NULL, true, shrinkSP, debug, 0x0, suffixName.Data());
368             if(debug) cout << "    --> Hanging EP task ... " << mb << " succes!" << endl;
369          }
370       }
371    }
372    // print summary to screen
373    cout << endl << endl << "       ==== AddTaskPhiFlow launched  ===== " << endl;
374    cout << " ************ Configured PID routine ************ " << endl;
375    cout << "      0 < " << PIDconfig[1] << " p_t, ITS || TPC with s < " << PIDconfig[0] << endl;
376    if(PIDconfig[2] < 0.) cout << "    --> TPC control disabled " << endl;
377    if(PIDconfig[2] > 0.) cout << "    --> TPC control enabled " << endl;
378    cout << "    " << PIDconfig[1] << " < " << PIDconfig[4] << " p_t, TPC || ITS with s < " << PIDconfig[3] << endl;
379    if(PIDconfig[5] < 0.) cout << "    --> ITS control disabled " << endl;
380    if(PIDconfig[5] > 0.) cout << "    --> ITS control enabled " << endl;
381    cout << "      " << PIDconfig[4] << " < 7 p_t, TPC / TOF Bayesian with p < " << PIDconfig[6] << endl;
382    cout << " ************ Configured DCA setup ************** " << endl;
383    cout << "  DCA type: " << DCA;
384    if (DCA == "") cout << "default";
385    cout << endl << " ************* Task statisti:q!cs ****************** " << endl;
386    cout << "   -> Launched PHI reconstruction " << endl;
387    if(SP) cout << "   --> Launched 30 QaQb SP filters and corresponding 30 SP tasks " << endl;
388    if(EP) cout << "   --> Launched 30 QaQb QC filters and corresponding 30 EP tasks " << endl;
389    if(SPSUB) cout << "   --> Launched 30+30 Qa&&Qb SP filters and corresponding 30+30 SP tasks " << endl;
390    if(QC) cout << "   --> Launched 30 QaQb QC filters and corresponding 30 QC tasks " << endl;
391    if(EP3sub) cout << " --> Launched VZERO subevent analysis alongside reconstruction - USE WITH CAUTION!" << endl;
392    cout << " ************************************************ " << endl;
393    TString condit = "";
394    (task->SetQA(kFALSE)) ? condit+= " --> Enabled QA plots <-- " : condit+= " --> Disabled QA plots <-- ";
395    (task->SetIsMC(kFALSE)) ? condit+= " --> MC mode <-- " : condit+= " --> DATA mode <-- ";
396    (task->UseEventMixing(event_mixing, kTRUE)) ? condit+= " --> Using EVENT MIXING <--" : condit+= "--> Combinatorial background <--";
397    cout << condit << endl;
398    cout << "           --> Now go for a coffee! <-- " << endl;
399    cout << " ************************************************ " << endl;
400    return task;
401 }
402 //_____________________________________________________________________________
403 void AddSPmethod(char *name, double minEtaA, double maxEtaA, double minEtaB, double maxEtaB, char *Qvector, int harmonic, AliAnalysisDataContainer *flowEvent, AliFlowTrackSimpleCuts *cutsPOI = NULL, AliFlowTrackSimpleCuts *cutsRFP = NULL, bool bEP, bool shrink = false, bool debug, bool etagap = false, char *suffixName, Bool_t VZERO_SP = kFALSE)
404 {
405    // add sp task and invm filter tasks
406    if(debug) (bEP) ? cout << " ****** Reveived request for EP task ****** " << endl : cout << " ******* Switching to SP task ******* " << endl;
407    TString fileName = AliAnalysisManager::GetCommonFileName();
408    (bEP) ? fileName+=":EP" : fileName+=":SP";
409    fileName+=suffixName;
410    if(etagap) {
411        fileName+="_SUBEVENTS";
412        if(debug) cout << "    --> Setting up subevent analysis <-- " << endl;
413    }
414    if(debug) cout << "    --> fileName " << fileName << endl;
415    TString myNameSP;
416    (bEP) ? myNameSP = Form("%sEPv%d%s", name, harmonic, Qvector): myNameSP = Form("%sSPv%d%s", name, harmonic, Qvector);
417    if(debug) cout << " Task and filter name: " << myNameSP << endl;
418    AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
419    AliAnalysisDataContainer *flowEvent2 = mgr->CreateContainer(Form("Filter_%s", myNameSP.Data()), AliFlowEventSimple::Class(), AliAnalysisManager::kExchangeContainer);
420    AliAnalysisTaskFilterFE *tskFilter = new AliAnalysisTaskFilterFE(Form("TaskFilter_%s", myNameSP.Data()), cutsRFP, cutsPOI);
421    tskFilter->SetSubeventEtaRange(minEtaA, maxEtaA, minEtaB, maxEtaB);
422    if(VZERO_SP) tskFilter->SetSubeventEtaRange(-10, 0, 0, 10);
423    mgr->AddTask(tskFilter);
424    mgr->ConnectInput(tskFilter, 0, flowEvent);
425    mgr->ConnectOutput(tskFilter, 1, flowEvent2);
426    AliAnalysisDataContainer *outSP = mgr->CreateContainer(myNameSP.Data(), TList::Class(), AliAnalysisManager::kOutputContainer, fileName);
427    AliAnalysisTaskScalarProduct *tskSP = new AliAnalysisTaskScalarProduct(Form("TaskScalarProduct_%s", myNameSP.Data()), kFALSE);
428    tskSP->SetApplyCorrectionForNUA(kTRUE);
429    tskSP->SetHarmonic(harmonic);
430    tskSP->SetTotalQvector(Qvector);
431    if (bEP) tskSP->SetBehaveAsEP();
432    if (shrink) tskSP->SetBookOnlyBasicCCH(kTRUE);
433    mgr->AddTask(tskSP);
434    mgr->ConnectInput(tskSP, 0, flowEvent2);
435    mgr->ConnectOutput(tskSP, 1, outSP);
436 }
437 //_____________________________________________________________________________
438 void AddQCmethod(char *name, int harmonic, AliAnalysisDataContainer *flowEvent, AliFlowTrackSimpleCuts *cutsPOI = NULL, Bool_t debug, AliFlowTrackSimpleCuts *cutsRFP = NULL, char *suffixName)
439 {
440    // add qc task and invm filter tasks
441    if(debug) cout << " ****** Received request for QC v" << harmonic << " task " << name << ", POI " << cutsPOI << ", IO ****** " << flowEvent << endl;
442    TString fileName = AliAnalysisManager::GetCommonFileName();
443    fileName+=":QC";
444    fileName+=suffixName;
445    if(debug) cout << "    --> Common filename: " << fileName << endl;
446    TString myName = Form("%s", name);
447    if(debug) cout << "    --> myName: " << myName << endl;
448    AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
449    AliAnalysisDataContainer *flowEvent2 = mgr->CreateContainer(Form("Filter_%s", myName.Data()), AliFlowEventSimple::Class(),AliAnalysisManager::kExchangeContainer);
450    AliAnalysisTaskFilterFE *tskFilter = new AliAnalysisTaskFilterFE(Form("TaskFilter_%s", myName.Data()), cutsRFP, cutsPOI);
451    mgr->AddTask(tskFilter);
452    mgr->ConnectInput(tskFilter, 0, flowEvent);
453    mgr->ConnectOutput(tskFilter, 1, flowEvent2);
454    AliAnalysisDataContainer *outQC = mgr->CreateContainer(myName.Data(), TList::Class(), AliAnalysisManager::kOutputContainer, fileName);
455    AliAnalysisTaskQCumulants *tskQC = new AliAnalysisTaskQCumulants(Form("TaskQCumulants_%s", myName.Data()), kFALSE);
456    tskQC->SetApplyCorrectionForNUA(kTRUE);
457    tskQC->SetHarmonic(harmonic);
458    tskQC->SetBookOnlyBasicCCH(kTRUE);
459    mgr->AddTask(tskQC);
460    mgr->ConnectInput(tskQC, 0, flowEvent2);
461    mgr->ConnectOutput(tskQC, 1, outQC);
462 }
463 //_____________________________________________________________________________
464 TString OutputName( Float_t centrMin,
465                     Float_t centrMax,
466                     Double_t PIDconfig[7],
467                     TString suffixName,
468                     Bool_t bCentralTrigger,
469                     Float_t EtaGap,
470                     Float_t POIEtaMin,
471                     Float_t POIEtaMax,
472                     Float_t POIPtMin,
473                     Float_t POIPtMax,
474                     Float_t deltaDip,
475                     Float_t deltaDipMaxPt,
476                     TString DCA,
477                     Int_t harm,
478                     Bool_t TPCStandAloneTracks,
479                     Float_t vertexZ,
480                     Bool_t debug,
481                     Bool_t useGlobalRPCuts)
482 {
483    // generate output name
484    TString centralityName = "";
485    centralityName += suffixName;
486    centralityName += "_DCA";
487    centralityName += DCA;
488    centralityName += Form("_vZ%.f", vertexZ);
489    centralityName += "_";
490    for(Int_t i = 0; i < 7; i++) centralityName += Form("%.1f_", PIDconfig[i]);
491    centralityName += "_POIEta";
492    centralityName += Form("%.1f", POIEtaMin);
493    centralityName += Form("%.1f", POIEtaMax);
494    centralityName += "_gap";
495    centralityName += Form("%.1f", -0.5*EtaGap);
496    centralityName += Form("%.1f", 0.5*EtaGap);
497    centralityName += "_";
498    centralityName += Form("dDip%.2f", deltaDip);
499    centralityName += "-";
500    centralityName += Form("dDipPt%.2f", deltaDipMaxPt);
501    if (TPCStandAloneTracks) {
502       centralityName += "-";
503       centralityName += "TPCStandAloneTracks";
504    }
505    if (bCentralTrigger) {
506       centralityName += "-";
507       centralityName += "kMBkCkSC";
508    }
509    if (!useGlobalRPCuts) {
510        centralityName += "-";
511        centralityName += "TPCRP";
512    }
513    if(debug) cout << "    --> centralityName " << centralityName << endl;
514    return centralityName;
515 }
516 //_____________________________________________________________________________
517