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