]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG3/vertexingHF/macros/AddTaskCFVertexingHF.C
Added centrality treatment and ignoring fake status of daughter tracks (Davide)
[u/mrichter/AliRoot.git] / PWG3 / vertexingHF / macros / AddTaskCFVertexingHF.C
1 //DEFINITION OF A FEW CONSTANTS
2 const Double_t ymin  = -2.1 ;
3 const Double_t ymax  =  2.1 ;
4 const Double_t cosmin = -1.05;
5 const Double_t cosmax =  1.05;
6 const Double_t cTmin = 0;  // micron
7 const Double_t cTmax = 500;  // micron
8 const Double_t dcamin = 0;  // micron
9 const Double_t dcamax = 500;  // micron
10 const Double_t d0min = -1000;  // micron
11 const Double_t d0max = 1000;  // micron
12 const Double_t d0xd0min = -100000;  // micron
13 const Double_t d0xd0max = 100000;  // micron
14 const Double_t phimin = 0.0;  
15 const Int_t    mintrackrefsTPC = 2 ;
16 const Int_t    mintrackrefsITS = 3 ;
17 const Int_t    charge  = 1 ;
18 const Int_t    minclustersTPC = 50 ;
19 // cuts
20 const Double_t ptmin = 0.1;
21 const Double_t ptmax = 9999.;
22 const Double_t etamin = -0.9;
23 const Double_t etamax = 0.9;
24 const Double_t zmin = -15;
25 const Double_t zmax = 15;
26 const Int_t    minITSClusters = 5;
27
28 const Float_t centmin = 0.;
29 const Float_t centmax = 100.;
30
31 //----------------------------------------------------
32
33 AliCFTaskVertexingHF *AddTaskCFVertexingHF(const char* cutFile = "./D0toKpiCuts.root",Bool_t isKeepDfromB=kFALSE, Bool_t isKeepDfromBOnly=kFALSE, Int_t pdgCode = 421, Char_t isSign = 2)
34 {
35         printf("Addig CF task using cuts from file %s\n",cutFile);
36
37         // isSign = 0 --> D0 only
38         // isSign = 1 --> D0bar only
39         // isSign = 2 --> D0 + D0bar
40
41         TString expected;
42         if (isSign == 0 && pdgCode < 0){
43                 AliError(Form("Error setting PDG code (%d) and sign (0 --> D0 only): they are not compatible, returning"));
44                 return 0x0;
45         }
46         else if (isSign == 1 && pdgCode > 0){
47                 AliError(Form("Error setting PDG code (%d) and sign (1 --> D0bar only): they are not compatible, returning"));
48                 return 0x0;
49         }
50         else if (isSign > 2 || isSign < 0){
51                 AliError(Form("Sign not valid (%d, possible values are 0, 1, 2), returning"));
52                 return 0x0;
53         }
54
55         TFile* fileCuts = new TFile(cutFile);
56         AliRDHFCutsD0toKpi *cutsD0toKpi = (AliRDHFCutsD0toKpi*)fileCuts->Get("D0toKpiCuts");
57         
58         // check that the fKeepD0fromB flag is set to true when the fKeepD0fromBOnly flag is true
59         //  for now the binning is the same than for all D's
60         if(isKeepDfromBOnly) isKeepDfromB = true;
61         
62         Double_t ptmin_0_6;
63         Double_t ptmax_0_6;
64         Double_t ptmin_6_8;
65         Double_t ptmax_6_8;
66         Double_t ptmin_8_16;
67         Double_t ptmax_8_16;
68         Double_t ptmin_16_24;
69         Double_t ptmax_16_24;
70         
71         ptmin_0_6 =  0.0 ;
72         ptmax_0_6 =  6.0 ;
73         ptmin_6_8 =  6.0 ;
74         ptmax_6_8 =  8.0 ;
75         ptmin_8_16 =  8.0 ;
76         ptmax_8_16 =  16.0 ;
77         ptmin_16_24 =  16.0 ;
78         ptmax_16_24 =  24.0 ;
79
80         //CONTAINER DEFINITION
81         Info("AliCFTaskVertexingHF","SETUP CONTAINER");
82         //the sensitive variables, their indices
83         UInt_t ipt = 0;
84         UInt_t iy  = 1;
85         UInt_t icosThetaStar  = 2;
86         UInt_t ipTpi  = 3;
87         UInt_t ipTk  = 4;
88         UInt_t icT  = 5;
89         UInt_t idca  = 6;
90         UInt_t id0pi  = 7;
91         UInt_t id0K  = 8;
92         UInt_t id0xd0  = 9;
93         UInt_t ipointing  = 10;
94         UInt_t iphi  = 11;
95         UInt_t iz  = 12;
96         UInt_t icent = 13;
97
98         const Double_t phimax = 2*TMath::Pi();
99
100         //Setting up the container grid... 
101         UInt_t nstep = 10; //number of selection steps: MC with limited acceptance, MC, Acceptance, Vertex, Refit, Reco (no cuts), RecoAcceptance, RecoITSClusters (RecoAcceptance included), RecoPPR (RecoAcceptance+RecoITSCluster included), RecoPID 
102         const Int_t nvar   = 14 ; //number of variables on the grid:pt, y, cosThetaStar, pTpi, pTk, cT, dca, d0pi, d0K, d0xd0, cosPointingAngle, phi 
103
104         //Setting the bins: pt, ptPi, and ptK are considered seprately because for them you can either define the binning by hand, or using the cuts file
105
106         //arrays for the number of bins in each dimension
107         Int_t iBin[nvar];
108
109         //OPTION 1: defining the pt, ptPi, ptK bins by hand...          
110         const Int_t nbin0_0_6  = 6 ; //bins in pt from 0 to 6 GeV
111         const Int_t nbin0_6_8  = 1 ; //bins in pt from 6 to 8 GeV
112         const Int_t nbin0_8_16  = 2 ; //bins in pt from 8 to 16 GeV
113         const Int_t nbin0_16_24  = 1 ; //bins in pt from 16 to 24 GeV
114         const Int_t nbin3_0_6  = 6 ; //bins in ptPi from 0 to 6 GeV
115         const Int_t nbin3_6_8  = 1 ; //bins in ptPi from 6 to 8 GeV
116         const Int_t nbin3_8_16  = 2 ; //bins in ptPi from 8 to 16 GeV
117         const Int_t nbin3_16_24  = 1 ; //bins in ptPi from 16 to 24 GeV
118         const Int_t nbin4_0_6  = 6 ; //bins in ptK from 0 to 6 GeV
119         const Int_t nbin4_6_8  = 1 ; //bins in ptK from 6 to 8 GeV
120         const Int_t nbin4_8_16  = 2 ; //bins in ptK from 8 to 16 GeV
121         const Int_t nbin4_16_24  = 1 ; //bins in ptK from 16 to 24 GeV
122         iBin[0]=nbin0_0_6+nbin0_6_8+nbin0_8_16+nbin0_16_24;
123         iBin[3]=nbin3_0_6+nbin3_6_8+nbin3_8_16+nbin3_16_24;
124         iBin[4]=nbin4_0_6+nbin4_6_8+nbin4_8_16+nbin4_16_24;
125         Double_t *binLim0=new Double_t[iBin[0]+1];
126         Double_t *binLim3=new Double_t[iBin[3]+1];
127         Double_t *binLim4=new Double_t[iBin[4]+1];
128
129         // values for bin lower bounds
130         // pt
131         for(Int_t i=0; i<=nbin0_0_6; i++) binLim0[i]=(Double_t)ptmin_0_6 + (ptmax_0_6-ptmin_0_6)/nbin0_0_6*(Double_t)i ; 
132         if (binLim0[nbin0_0_6] != ptmin_6_8)  {
133                 Error("AliCFHeavyFlavourTaskMultiVarMultiStep","Calculated bin lim for pt - 1st range - differs from expected!\n");
134         }
135         for(Int_t i=0; i<=nbin0_6_8; i++) binLim0[i+nbin0_0_6]=(Double_t)ptmin_6_8 + (ptmax_6_8-ptmin_6_8)/nbin0_6_8*(Double_t)i ; 
136         if (binLim0[nbin0_0_6+nbin0_6_8] != ptmin_8_16)  {
137                 Error("AliCFHeavyFlavourTaskMultiVarMultiStep","Calculated bin lim for pt - 2nd range - differs from expected!\n");
138         }
139         for(Int_t i=0; i<=nbin0_8_16; i++) binLim0[i+nbin0_0_6+nbin0_6_8]=(Double_t)ptmin_8_16 + (ptmax_8_16-ptmin_8_16)/nbin0_8_16*(Double_t)i ; 
140         if (binLim0[nbin0_0_6+nbin0_6_8+nbin0_8_16] != ptmin_16_24)  {
141                 Error("AliCFHeavyFlavourTaskMultiVarMultiStep","Calculated bin lim for pt - 2nd range - differs from expected!\n");
142         }
143         for(Int_t i=0; i<=nbin0_16_24; i++) binLim0[i+nbin0_0_6+nbin0_6_8+nbin0_8_16]=(Double_t)ptmin_16_24 + (ptmax_16_24-ptmin_16_24)/nbin0_16_24*(Double_t)i ; 
144
145         // ptPi
146         for(Int_t i=0; i<=nbin3_0_6; i++) binLim3[i]=(Double_t)ptmin_0_6 + (ptmax_0_6-ptmin_0_6)/nbin3_0_6*(Double_t)i ; 
147         if (binLim3[nbin3_0_6] != ptmin_6_8)  {
148                 Error("AliCFHeavyFlavourTaskMultiVarMultiStep","Calculated bin lim for pt - 1st range - differs from expected!\n");
149         }
150         for(Int_t i=0; i<=nbin3_6_8; i++) binLim3[i+nbin3_0_6]=(Double_t)ptmin_6_8 + (ptmax_6_8-ptmin_6_8)/nbin3_6_8*(Double_t)i ; 
151         if (binLim3[nbin3_0_6+nbin3_6_8] != ptmin_8_16)  {
152                 Error("AliCFHeavyFlavourTaskMultiVarMultiStep","Calculated bin lim for pt - 2nd range - differs from expected!\n");
153         }
154         for(Int_t i=0; i<=nbin3_8_16; i++) binLim3[i+nbin3_0_6+nbin0_6_8]=(Double_t)ptmin_8_16 + (ptmax_8_16-ptmin_8_16)/nbin3_8_16*(Double_t)i ; 
155         if (binLim3[nbin3_0_6+nbin3_6_8+nbin3_8_16] != ptmin_16_24)  {
156                 Error("AliCFHeavyFlavourTaskMultiVarMultiStep","Calculated bin lim for pt - 2nd range - differs from expected!\n");
157         }
158         for(Int_t i=0; i<=nbin3_16_24; i++) binLim3[i+nbin3_0_6+nbin3_6_8+nbin3_8_16]=(Double_t)ptmin_16_24 + (ptmax_16_24-ptmin_16_24)/nbin3_16_24*(Double_t)i ; 
159
160         // ptKa
161         for(Int_t i=0; i<=nbin4_0_6; i++) binLim4[i]=(Double_t)ptmin_0_6 + (ptmax_0_6-ptmin_0_6)/nbin4_0_6*(Double_t)i ; 
162         if (binLim4[nbin4_0_6] != ptmin_6_8)  {
163                 Error("AliCFHeavyFlavourTaskMultiVarMultiStep","Calculated bin lim for pt - 1st range - differs from expected!\n");
164         }
165         for(Int_t i=0; i<=nbin4_6_8; i++) binLim4[i+nbin4_0_6]=(Double_t)ptmin_6_8 + (ptmax_6_8-ptmin_6_8)/nbin4_6_8*(Double_t)i ; 
166         if (binLim4[nbin4_0_6+nbin4_6_8] != ptmin_8_16)  {
167                 Error("AliCFHeavyFlavourTaskMultiVarMultiStep","Calculated bin lim for pt - 2nd range - differs from expected!\n");
168         }
169         for(Int_t i=0; i<=nbin4_8_16; i++) binLim4[i+nbin4_0_6+nbin0_6_8]=(Double_t)ptmin_8_16 + (ptmax_8_16-ptmin_8_16)/nbin4_8_16*(Double_t)i ; 
170         if (binLim4[nbin4_0_6+nbin4_6_8+nbin4_8_16] != ptmin_16_24)  {
171                 Error("AliCFHeavyFlavourTaskMultiVarMultiStep","Calculated bin lim for pt - 2nd range - differs from expected!\n");
172         }
173         for(Int_t i=0; i<=nbin4_16_24; i++) binLim4[i+nbin4_0_6+nbin4_6_8+nbin4_8_16]=(Double_t)ptmin_16_24 + (ptmax_16_24-ptmin_16_24)/nbin4_16_24*(Double_t)i ; 
174         
175         //OPTION 2: ...or from the cuts file
176
177         //const Int_t nbin0 = cutsD0toKpi->GetNPtBins(); // bins in pT
178         //iBin[0]=nbin0;
179         //iBin[3]=nbin0;
180         //iBin[4]=nbin0;
181         // values for bin lower bounds
182         //Float_t* floatbinLim0 = cutsD0toKpi->GetPtBinLimits();
183         //for (Int_t ibin0 = 0 ; ibin0<iBin[0]+1; ibin0++){
184         //      binLim0[ibin0] = (Double_t)floatbinLim0[ibin0];
185         //      binLim3[ibin0] = (Double_t)floatbinLim0[ibin0];
186         //      binLim4[ibin0] = (Double_t)floatbinLim0[ibin0];
187         //}
188         //for(Int_t i=0; i<=nbin0; i++) printf("binLim0[%d]=%f\n",i,binLim0[i]);  
189
190         //printf("pT: nbin (from cuts file) = %d\n",nbin0);
191
192         // defining now the binning for the other variables:
193
194         const Int_t nbin1  = 42 ; //bins in y
195         const Int_t nbin2  = 42 ; //bins in cosThetaStar 
196         const Int_t nbin5  = 24 ; //bins in cT
197         const Int_t nbin6  = 24 ; //bins in dca
198         const Int_t nbin7  = 100 ; //bins in d0pi
199         const Int_t nbin8  = 100 ; //bins in d0K
200         const Int_t nbin9  = 80 ; //bins in d0xd0
201         const Int_t nbin10  = 1050 ; //bins in cosPointingAngle
202         const Int_t nbin11  = 20 ; //bins in Phi
203         const Int_t nbin12  = 60 ; //bins in z vertex
204         const Int_t nbin13 = 10;  //bins in centrality
205
206         iBin[1]=nbin1;
207         iBin[2]=nbin2;
208         iBin[5]=nbin5;
209         iBin[6]=nbin6;
210         iBin[7]=nbin7;
211         iBin[8]=nbin8;
212         iBin[9]=nbin9;
213         iBin[10]=nbin10;
214         iBin[11]=nbin11;
215         iBin[12]=nbin12;
216         iBin[13]=nbin13;
217         
218         //arrays for lower bounds :
219         Double_t *binLim1=new Double_t[iBin[1]+1];
220         Double_t *binLim2=new Double_t[iBin[2]+1];
221         Double_t *binLim5=new Double_t[iBin[5]+1];
222         Double_t *binLim6=new Double_t[iBin[6]+1];
223         Double_t *binLim7=new Double_t[iBin[7]+1];
224         Double_t *binLim8=new Double_t[iBin[8]+1];
225         Double_t *binLim9=new Double_t[iBin[9]+1];
226         Double_t *binLim10=new Double_t[iBin[10]+1];
227         Double_t *binLim11=new Double_t[iBin[11]+1];
228         Double_t *binLim12=new Double_t[iBin[12]+1];
229         Double_t *binLim13=new Double_t[iBin[13]+1];
230
231         // y
232         for(Int_t i=0; i<=nbin1; i++) binLim1[i]=(Double_t)ymin  + (ymax-ymin)  /nbin1*(Double_t)i ;
233
234         // cosThetaStar
235         for(Int_t i=0; i<=nbin2; i++) binLim2[i]=(Double_t)cosmin  + (cosmax-cosmin)  /nbin2*(Double_t)i ;
236         
237         // cT
238         for(Int_t i=0; i<=nbin5; i++) binLim5[i]=(Double_t)cTmin  + (cTmax-cTmin)  /nbin5*(Double_t)i ;
239
240         // dca
241         for(Int_t i=0; i<=nbin6; i++) binLim6[i]=(Double_t)dcamin  + (dcamax-dcamin)  /nbin6*(Double_t)i ;
242
243         // d0pi
244         for(Int_t i=0; i<=nbin7; i++) binLim7[i]=(Double_t)d0min  + (d0max-d0min)  /nbin7*(Double_t)i ;
245
246         // d0K
247         for(Int_t i=0; i<=nbin8; i++) binLim8[i]=(Double_t)d0min  + (d0max-d0min)  /nbin8*(Double_t)i ;
248
249         // d0xd0
250         for(Int_t i=0; i<=nbin9; i++) binLim9[i]=(Double_t)d0xd0min  + (d0xd0max-d0xd0min)  /nbin9*(Double_t)i ;
251
252         // cosPointingAngle
253         for(Int_t i=0; i<=nbin10; i++) binLim10[i]=(Double_t)cosmin  + (cosmax-cosmin)  /nbin10*(Double_t)i ;
254
255         // Phi
256         for(Int_t i=0; i<=nbin11; i++) binLim11[i]=(Double_t)phimin  + (phimax-phimin)  /nbin11*(Double_t)i ;
257
258         // z Primary Vertex
259         for(Int_t i=0; i<=nbin12; i++) {
260                 binLim12[i]=(Double_t)zmin  + (zmax-zmin)  /nbin12*(Double_t)i ;
261         }
262
263         for(Int_t i=0; i<=nbin13; i++) {
264           binLim13[i]=(Double_t)centmin  + (centmax-centmin)/nbin13 * (Double_t)i;
265         }
266
267         //one "container" for MC
268         TString nameContainer="";
269         if(!isKeepDfromB) {
270                 nameContainer="CFHFccontainer0_CommonFramework";
271         }
272         else  if(isKeepDfromBOnly){
273                 nameContainer="CFHFccontainer0DfromB_CommonFramework";
274         }
275         else  {
276                 nameContainer="CFHFccontainer0allD_CommonFramework";      
277         }
278
279         AliCFContainer* container = new AliCFContainer(nameContainer,"container for tracks",nstep,nvar,iBin);
280         //setting the bin limits
281         printf("pt\n");
282         container -> SetBinLimits(ipt,binLim0);
283         printf("y\n");
284         container -> SetBinLimits(iy,binLim1);
285         printf("cts\n");
286         container -> SetBinLimits(icosThetaStar,binLim2);
287         printf("ptPi\n");
288         container -> SetBinLimits(ipTpi,binLim3);
289         printf("ptK\n");
290         container -> SetBinLimits(ipTk,binLim4);
291         printf("cT\n");
292         container -> SetBinLimits(icT,binLim5);
293         printf("dca\n");
294         container -> SetBinLimits(idca,binLim6);
295         printf("d0Pi\n");
296         container -> SetBinLimits(id0pi,binLim7);
297         printf("d0K\n");
298         container -> SetBinLimits(id0K,binLim8);
299         printf("d0xd0\n");
300         container -> SetBinLimits(id0xd0,binLim9);
301         printf("pointing\n");
302         container -> SetBinLimits(ipointing,binLim10);
303         printf("phi\n");
304         container -> SetBinLimits(iphi,binLim11);
305         printf("z\n");
306         container -> SetBinLimits(iz,binLim12);
307         printf("cent\n");
308         container -> SetBinLimits(icent,binLim13);
309         
310         container -> SetStepTitle(0, "MCLimAcc");
311         container -> SetStepTitle(1, "MC");
312         container -> SetStepTitle(2, "MCAcc");
313         container -> SetStepTitle(3, "RecoVertex");
314         container -> SetStepTitle(4, "RecoRefit");
315         container -> SetStepTitle(5, "Reco");
316         container -> SetStepTitle(6, "RecoAcc");
317         container -> SetStepTitle(7, "RecoITSCluster");
318         container -> SetStepTitle(8, "RecoCuts");
319         container -> SetStepTitle(9, "RecoPID");
320
321         container -> SetVarTitle(ipt,"pt");
322         container -> SetVarTitle(iy,"y");
323         container -> SetVarTitle(icosThetaStar, "cosThetaStar");
324         container -> SetVarTitle(ipTpi, "ptpi");
325         container -> SetVarTitle(ipTk, "ptK");
326         container -> SetVarTitle(icT, "ct");
327         container -> SetVarTitle(idca, "dca");
328         container -> SetVarTitle(id0pi, "d0pi");
329         container -> SetVarTitle(id0K, "d0K");
330         container -> SetVarTitle(id0xd0, "d0xd0");
331         container -> SetVarTitle(ipointing, "piointing");
332         container -> SetVarTitle(iphi, "phi");
333         container -> SetVarTitle(iz, "z");
334         container -> SetVarTitle(icent, "centrality");
335
336
337         //CREATE THE  CUTS -----------------------------------------------
338         
339         // Gen-Level kinematic cuts
340         AliCFTrackKineCuts *mcKineCuts = new AliCFTrackKineCuts("mcKineCuts","MC-level kinematic cuts");
341         
342         //Particle-Level cuts:  
343         AliCFParticleGenCuts* mcGenCuts = new AliCFParticleGenCuts("mcGenCuts","MC particle generation cuts");
344         Bool_t useAbsolute = kTRUE;
345         if (isSign != 2){
346                 useAbsolute = kFALSE;
347         }
348         mcGenCuts->SetRequirePdgCode(pdgCode, useAbsolute);  // kTRUE set in order to include D0_bar
349         mcGenCuts->SetAODMC(1); //special flag for reading MC in AOD tree (important)
350         
351         // Acceptance cuts:
352         AliCFAcceptanceCuts* accCuts = new AliCFAcceptanceCuts("accCuts", "Acceptance cuts");
353         AliCFTrackKineCuts *kineAccCuts = new AliCFTrackKineCuts("kineAccCuts","Kine-Acceptance cuts");
354         kineAccCuts->SetPtRange(ptmin,ptmax);
355         kineAccCuts->SetEtaRange(etamin,etamax);
356
357         // Rec-Level kinematic cuts
358         AliCFTrackKineCuts *recKineCuts = new AliCFTrackKineCuts("recKineCuts","rec-level kine cuts");
359         
360         AliCFTrackQualityCuts *recQualityCuts = new AliCFTrackQualityCuts("recQualityCuts","rec-level quality cuts");
361         
362         AliCFTrackIsPrimaryCuts *recIsPrimaryCuts = new AliCFTrackIsPrimaryCuts("recIsPrimaryCuts","rec-level isPrimary cuts");
363         
364         printf("CREATE MC KINE CUTS\n");
365         TObjArray* mcList = new TObjArray(0) ;
366         mcList->AddLast(mcKineCuts);
367         mcList->AddLast(mcGenCuts);
368         
369         printf("CREATE ACCEPTANCE CUTS\n");
370         TObjArray* accList = new TObjArray(0) ;
371         accList->AddLast(kineAccCuts);
372
373         printf("CREATE RECONSTRUCTION CUTS\n");
374         TObjArray* recList = new TObjArray(0) ;   // not used!! 
375         recList->AddLast(recKineCuts);
376         recList->AddLast(recQualityCuts);
377         recList->AddLast(recIsPrimaryCuts);
378         
379         TObjArray* emptyList = new TObjArray(0);
380
381         //CREATE THE INTERFACE TO CORRECTION FRAMEWORK USED IN THE TASK
382         printf("CREATE INTERFACE AND CUTS\n");
383         AliCFManager* man = new AliCFManager() ;
384         man->SetParticleContainer(container);
385         man->SetParticleCutsList(0 , mcList); // MC, Limited Acceptance
386         man->SetParticleCutsList(1 , mcList); // MC
387         man->SetParticleCutsList(2 , accList); // Acceptance 
388         man->SetParticleCutsList(3 , emptyList); // Vertex 
389         man->SetParticleCutsList(4 , emptyList); // Refit 
390         man->SetParticleCutsList(5 , emptyList); // AOD
391         man->SetParticleCutsList(6 , emptyList); // AOD in Acceptance
392         man->SetParticleCutsList(7 , emptyList); // AOD with required n. of ITS clusters
393         man->SetParticleCutsList(8 , emptyList); // AOD Reco (PPR cuts implemented in Task)
394         man->SetParticleCutsList(9 , emptyList); // AOD Reco PID
395         
396         // Get the pointer to the existing analysis manager via the static access method.
397         //==============================================================================
398         AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
399         if (!mgr) {
400           ::Error("AddTaskCompareHF", "No analysis manager to connect to.");
401           return NULL;
402         }   
403         //CREATE THE TASK
404         printf("CREATE TASK\n");
405
406         // create the task
407         AliCFTaskVertexingHF *task = new AliCFTaskVertexingHF("AliCFTaskVertexingHF",cutsD0toKpi);
408         task->SetFillFromGenerated(kFALSE);
409         task->SetCFManager(man); //here is set the CF manager
410         task->SetDecayChannel(2);
411         task->SetUseWeight(kFALSE);
412         task->SetSign(isSign);
413         task->SetCentralitySelection(kTRUE);
414
415         if (isKeepDfromB && !isKeepDfromBOnly) task->SetDselection(2);
416         if (isKeepDfromB && isKeepDfromBOnly) task->SetDselection(1);           
417
418         Printf("***************** CONTAINER SETTINGS *****************");
419         Printf("decay channel = %d",(Int_t)task->GetDecayChannel());
420         Printf("FillFromGenerated = %d",(Int_t)task->GetFillFromGenerated());
421         Printf("Dselection = %d",(Int_t)task->GetDselection());
422         Printf("UseWeight = %d",(Int_t)task->GetUseWeight());
423         Printf("Sign = %d",(Int_t)task->GetSign());
424         Printf("Centrality selection = %d",(Int_t)task->GetCentralitySelection());
425         Printf("***************END CONTAINER SETTINGS *****************\n");
426
427         //-----------------------------------------------------------//
428         //   create correlation matrix for unfolding - only eta-pt   //
429         //-----------------------------------------------------------//
430
431         Bool_t AcceptanceUnf = kTRUE; // unfold at acceptance level, otherwise PPR
432
433         Int_t thnDim[4];
434         
435         //first half  : reconstructed 
436         //second half : MC
437
438         thnDim[0] = iBin[0];
439         thnDim[2] = iBin[0];
440         thnDim[1] = iBin[1];
441         thnDim[3] = iBin[1];
442
443         TString nameCorr="";
444         if(!isKeepDfromB) {
445                 nameCorr="CFHFcorr0_CommonFramework";
446         }
447         else  if(isKeepDfromBOnly){
448                 nameCorr= "CFHFcorr0KeepDfromBOnly_CommonFramework";
449         }
450         else  {
451                 nameCorr="CFHFcorr0allD_CommonFramework";
452
453         }
454
455         THnSparseD* correlation = new THnSparseD(nameCorr,"THnSparse with correlations",4,thnDim);
456         Double_t** binEdges = new Double_t[2];
457
458         // set bin limits
459
460         binEdges[0]= binLim0;
461         binEdges[1]= binLim1;
462
463         correlation->SetBinEdges(0,binEdges[0]);
464         correlation->SetBinEdges(2,binEdges[0]);
465
466         correlation->SetBinEdges(1,binEdges[1]);
467         correlation->SetBinEdges(3,binEdges[1]);
468
469         correlation->Sumw2();
470   
471         // correlation matrix ready
472         //------------------------------------------------//
473
474         task->SetCorrelationMatrix(correlation); // correlation matrix for unfolding
475         
476         // Create and connect containers for input/output
477         
478         // ------ input data ------
479         AliAnalysisDataContainer *cinput0  = mgr->GetCommonInputContainer();
480         
481         // ----- output data -----
482         
483         TString outputfile = AliAnalysisManager::GetCommonFileName();
484         TString output1name="", output2name="", output3name="",output4name="";
485         output2name=nameContainer;
486         output3name=nameCorr;
487         if(!isKeepDfromB) {
488                 outputfile += ":PWG3_D2H_CFtaskD0toKpi_CommonFramework";
489                 output1name="CFHFchist0_CommonFramework";
490         }
491         else  if(isKeepDfromBOnly){
492                 outputfile += ":PWG3_D2H_CFtaskD0toKpiKeepDfromBOnly_CommonFramework";
493                 output1name="CFHFchist0DfromB_CommonFramework";
494         }
495         else{
496                 outputfile += ":PWG3_D2H_CFtaskD0toKpiKeepDfromB_CommonFramework";
497                 output1name="CFHFchist0allD_CommonFramework";
498         }
499         output4name= "Cuts_CommonFramework";
500
501         //now comes user's output objects :
502         // output TH1I for event counting
503         AliAnalysisDataContainer *coutput1 = mgr->CreateContainer(output1name, TH1I::Class(),AliAnalysisManager::kOutputContainer,outputfile.Data());
504         // output Correction Framework Container (for acceptance & efficiency calculations)
505         AliAnalysisDataContainer *coutput2 = mgr->CreateContainer(output2name, AliCFContainer::Class(),AliAnalysisManager::kOutputContainer,outputfile.Data());
506         // Unfolding - correlation matrix
507         AliAnalysisDataContainer *coutput3 = mgr->CreateContainer(output3name, THnSparseD::Class(),AliAnalysisManager::kOutputContainer,outputfile.Data());
508         // cuts
509         AliAnalysisDataContainer *coutput4 = mgr->CreateContainer(output4name, AliRDHFCuts::Class(),AliAnalysisManager::kOutputContainer, outputfile.Data());
510
511         mgr->AddTask(task);
512         
513         mgr->ConnectInput(task,0,mgr->GetCommonInputContainer());
514         mgr->ConnectOutput(task,1,coutput1);
515         mgr->ConnectOutput(task,2,coutput2);
516         mgr->ConnectOutput(task,3,coutput3);
517         mgr->ConnectOutput(task,4,coutput4);
518         return task;
519 }
520