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