]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGHF/vertexingHF/macros/AddTaskCFVertexingHF3ProngLc.C
Transition PWG3 --> PWGHF
[u/mrichter/AliRoot.git] / PWGHF / vertexingHF / macros / AddTaskCFVertexingHF3ProngLc.C
1 //DEFINITION OF A FEW CONSTANTS
2 const Double_t ymin  = -1.2 ;
3 const Double_t ymax  =  1.2 ;
4 const Double_t cosmin = -0.7;
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 phimin = 0.0;  
9 const Int_t    mintrackrefsTPC = 2 ;
10 const Int_t    mintrackrefsITS = 3 ;
11 const Int_t    charge  = 1 ;
12 const Int_t    minclustersTPC = 50 ;
13 // cuts
14 const Double_t ptmin = 0.1;
15 const Double_t ptmax = 9999.;
16 const Double_t etamin = -0.9;
17 const Double_t etamax = 0.9;
18 const Double_t zvtxmin = -15;
19 const Double_t zvtxmax = 15;
20 const Int_t    minITSClusters = 5;
21
22 const Float_t centmin_0_10 = 0.;
23 const Float_t centmax_0_10 = 10.;
24 const Float_t centmin_10_100 = 10.;
25 const Float_t centmax_10_100 = 100.;
26 const Float_t centmax = 100.;
27 const Float_t fakemin = -0.5;
28 const Float_t fakemax = 2.5.;
29 const Double_t distTwoPartmin=0;
30 const Double_t distTwoPartmax=600;
31 const Double_t dispVtxmin = 0;
32 const Double_t dispVtxmax = 600;
33 const Double_t sumd02min = 0.;
34 const Double_t sumd02max = 50000.;
35 const Float_t cosminXY = 0.95;
36 const Float_t cosmaxXY = 1.0;
37 const Float_t normDecLXYmin = 0;
38 const Float_t normDecLXYmax = 20;
39 const Float_t multmin_0_20 = 0;
40 const Float_t multmax_0_20 = 20;
41 const Float_t multmin_20_50 = 20;
42 const Float_t multmax_20_50 = 50;
43 const Float_t multmin_50_102 = 50;
44 const Float_t multmax_50_102 = 102;
45
46
47 //----------------------------------------------------
48
49 //AliCFTaskVertexingHF *AddTaskCFVertexingHF3ProngLc(const char* cutFile = "./cuts4LctopKpi.root", Int_t configuration = AliCFTaskVertexingHF::kSnail, Bool_t isKeepDfromB=kFALSE, Bool_t isKeepDfromBOnly=kFALSE, Int_t pdgCode = 4122, Char_t isSign = 2)
50 AliCFContainer *AddTaskCFVertexingHF3ProngLc(const char* cutFile = "./cuts4LctopKpi.root", Int_t configuration = AliCFTaskVertexingHF::kSnail, Bool_t isKeepDfromB=kFALSE, Bool_t isKeepDfromBOnly=kFALSE, Int_t pdgCode = 4122, Char_t isSign = 2)
51 {
52         printf("Addig CF task using cuts from file %s\n",cutFile);
53         if (configuration == AliCFTaskVertexingHF::kSnail){
54                 printf("The configuration is set to be SLOW --> all the variables will be used to fill the CF\n");
55         }
56         else if (configuration == AliCFTaskVertexingHF::kCheetah){
57                 printf("The configuration is set to be FAST --> using only pt, y, ct, phi, zvtx, centrality, fake, multiplicity to fill the CF\n");
58         }
59         else{
60                 printf("The configuration is not defined! returning\n");
61                 return;
62         }
63         
64         gSystem->Sleep(2000);
65         
66         // isSign = 0 --> D0 only
67         // isSign = 1 --> D0bar only
68         // isSign = 2 --> D0 + D0bar
69         
70         TString expected;
71         if (isSign == 0 && pdgCode < 0){
72                 AliError(Form("Error setting PDG code (%d) and sign (0 --> particle (%d) only): they are not compatible, returning",pdgCode));
73                 return 0x0;
74         }
75         else if (isSign == 1 && pdgCode > 0){
76                 AliError(Form("Error setting PDG code (%d) and sign (1 --> antiparticle (%d) only): they are not compatible, returning",pdgCode));
77                 return 0x0;
78         }
79         else if (isSign > 2 || isSign < 0){
80                 AliError(Form("Sign not valid (%d, possible values are 0, 1, 2), returning"));
81                 return 0x0;
82         }
83         
84         TFile* fileCuts = new TFile(cutFile);
85         AliRDHFCutsLctopKpi *cutsLctopKpi = (AliRDHFCutsLctopKpi*)fileCuts->Get("LctopKpiProdCuts");
86         
87         // check that the fKeepD0fromB flag is set to true when the fKeepD0fromBOnly flag is true
88         //  for now the binning is the same than for all D's
89         if(isKeepDfromBOnly) isKeepDfromB = true;
90         
91         /*
92           Double_t ptmin_0_4;
93           Double_t ptmax_0_4;
94           Double_t ptmin_4_8;
95           Double_t ptmax_4_8;
96           Double_t ptmin_8_10;
97           Double_t ptmax_8_10;
98           
99           if(!isKeepDfromB){
100           ptmin_0_4 =  0.0 ;
101           ptmax_0_4 =  4.0 ;
102           ptmin_4_8 =  4.0 ;
103           ptmax_4_8 =  8.0 ;
104           ptmin_8_10 =  8.0 ;
105           ptmax_8_10 =  10.0 ;
106           } else{
107           ptmin_0_4 =  0.0 ;
108           ptmax_0_4 =  3.0 ;
109           ptmin_4_8 =  3.0 ;
110           ptmax_4_8 =  5.0 ;
111           ptmin_8_10 =  5.0 ;
112           ptmax_8_10 =  10.0 ;
113           }
114         */
115
116         //CONTAINER DEFINITION
117         Info("AliCFTaskVertexingHF","SETUP CONTAINER");
118
119         const Double_t phimax = 2*TMath::Pi();
120
121         //Setting up the container grid... 
122         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 
123 //      const Int_t nbinpt_0_4  = 8 ; //bins in pt from 0 to 4 GeV
124 //      const Int_t nbinpt_4_8  = 4 ; //bins in pt from 4 to 8 GeV
125 //      const Int_t nbinpt_8_10  = 1 ; //bins in pt from 8 to 10 GeV
126
127 /*
128         Int_t nbinpt_0_4;
129         Int_t nbinpt_4_8;
130         Int_t nbinpt_8_10;
131         if (!isKeepDfromB){
132           nbinpt_0_4  = 8 ; //bins in pt from 0 to 4 GeV
133           nbinpt_4_8  = 4 ; //bins in pt from 4 to 8 GeV
134           nbinpt_8_10  = 1 ; //bins in pt from 8 to 10 GeV
135         }else{
136           nbinpt_0_4  = 3 ; //bins in pt from 0 to 3 GeV
137           nbinpt_4_8  = 1 ; //bins in pt from 3 to 5 GeV
138           nbinpt_8_10  = 1 ; //bins in pt from 5 to 10 GeV
139         }
140 */
141         const Int_t nbinpt = cutsLctopKpi->GetNPtBins(); // bins in pT
142         printf("pT: nbin (from cuts file) = %d\n",nbinpt);
143         const Int_t nbiny  = 24 ; //bins in y
144         const Int_t nbinphi  = 18 ; //bins in phi
145         const Int_t nbincT  = 25 ; //bins in cT 
146         const Int_t nbinpointing  = 350 ; //bins in cosPointingAngle    
147         const Int_t nbinpTpi_0_4  = 8 ; //bins in ptPi from 0 to 4 GeV
148         const Int_t nbinpTpi_4_8  = 4 ; //bins in ptPi from 4 to 8 GeV
149         const Int_t nbinpTpi_8_10  = 1 ; //bins in ptPi from 8 to 10 GeV
150         const Int_t nbinpTk_0_4  = 8 ; //bins in ptKa from 0 to 4 GeV
151         const Int_t nbinpTk_4_8  = 4 ; //bins in ptKa from 4 to 8 GeV
152         const Int_t nbinpTk_8_10  = 1 ; //bins in ptKa from 8 to 10 GeV
153         const Int_t nbinpTpi2_0_4  = 8 ; //bins in ptpi2 from 0 to 4 GeV
154         const Int_t nbinpTpi2_4_8  = 4 ; //bins in ptpi2 from 4 to 8 GeV
155         const Int_t nbinpTpi2_8_10  = 1 ; //bins in ptpi2 from 8 to 10 GeV
156         const Int_t nbinzvtx  = 30 ; //bins in z vertex
157         const Int_t nbincent = 11; //bins in centrality
158         const Int_t nbincent_0_10 = 2;  //bins in centrality between 0 and 10
159         const Int_t nbincent_10_100 = 9;  //bins in centrality between 10 and 100
160         const Int_t nbinfake = 3;  //bins in fake
161         const Int_t nbindist12 = 10; //bins dist12
162         const Int_t nbindist23 = 10; //bins dist23
163         const Int_t nbinsigmaVtx = 10; //bin sigmaVtx   
164         const Int_t nbinsumd02 = 10; //bin sumD0^2      
165         const Int_t nbinpointingXY = 50;  //bins in cosPointingAngleXY
166         const Int_t nbinnormDecayLXY = 20;  //bins in NormDecayLengthXY
167         const Int_t nbinmult = 48;  //bins in multiplicity (total number)
168         const Int_t nbinmult_0_20 = 20; //bins in multiplicity between 0 and 20
169         const Int_t nbinmult_20_50 = 15; //bins in multiplicity between 20 and 50
170         const Int_t nbinmult_50_102 = 13; //bins in multiplicity between 50 and 102
171         
172         //the sensitive variables, their indices
173         const UInt_t ipT = 0;
174         const UInt_t iy  = 1;
175         const UInt_t iphi  = 2;
176         const UInt_t icT  = 3;
177         const UInt_t ipointing  = 4;
178         const UInt_t ipTpi  = 5;
179         const UInt_t ipTk  = 6;
180         const UInt_t ipTpi2  = 7;
181         const UInt_t izvtx  = 8;
182         const UInt_t icent = 9;
183         const UInt_t ifake = 10;
184         const UInt_t idist12 = 11;
185         const UInt_t idist23 = 12;
186         const UInt_t isigmaVtx = 13;
187         const UInt_t isumd02 = 14;
188         const UInt_t ipointingXY = 15;
189         const UInt_t inormDecayLXY = 16;
190         const UInt_t imult = 17;
191
192         const Int_t nvarTot   = 18 ; //number of variables on the grid:pt, y, cosThetaStar, pTpi, pTk, cT, dca, d0pi, d0K, d0xd0, cosPointingAngle, phi, zvtx, centrality, fake, cosPointingAngleXY, normDecayLengthXY, multiplicity
193
194         //arrays for the number of bins in each dimension
195         Int_t iBin[nvarTot];
196         //iBin[ipT]=nbinpt_0_4+nbinpt_4_8+nbinpt_8_10;
197         iBin[ipT]=nbinpt;
198         iBin[iy]=nbiny;
199         iBin[iphi]=nbinphi;
200         //      iBin[icT]=nbincT_0_4+nbincT_4_8+nbincT_8_10;
201         //iBin[4]=nbinpointing_0_4+nbinpointing_4_8+nbinpointing_8_10;
202         iBin[icT]=nbincT;
203         iBin[ipointing]=nbinpointing;
204         iBin[ipTpi]=nbinpt;
205         iBin[ipTk]=nbinpt;
206         iBin[ipTpi2]=nbinpt;
207         iBin[izvtx]=nbinzvtx;
208         iBin[icent]=nbincent;
209         iBin[ifake]=nbinfake;
210         iBin[idist12]=nbindist12;
211         iBin[idist23]=nbindist23;
212         iBin[isigmaVtx]=nbinsigmaVtx;
213         iBin[isumd02]=nbinsumd02;
214         iBin[ipointingXY]=nbinpointingXY;
215         iBin[inormDecayLXY]=nbinnormDecayLXY;
216         iBin[imult]=nbinmult;
217         
218         //arrays for lower bounds :
219         Double_t *binLimpT=new Double_t[iBin[ipT]+1];
220         Double_t *binLimy=new Double_t[iBin[iy]+1];
221         Double_t *binLimphi=new Double_t[iBin[iphi]+1];
222         Double_t *binLimcT=new Double_t[iBin[icT]+1];
223         Double_t *binLimpointing=new Double_t[iBin[ipointing]+1];
224         Double_t *binLimpTpi=new Double_t[iBin[ipTpi]+1];
225         Double_t *binLimpTk=new Double_t[iBin[ipTk]+1];
226         Double_t *binLimpTpi2=new Double_t[iBin[ipTpi2]+1];
227         Double_t *binLimzvtx=new Double_t[iBin[izvtx]+1];
228         Double_t *binLimcent=new Double_t[iBin[icent]+1];
229         Double_t *binLimfake=new Double_t[iBin[ifake]+1];
230         Double_t *binLimdist12=new Double_t[iBin[idist12]+1];
231         Double_t *binLimdist23=new Double_t[iBin[idist23]+1];
232         Double_t *binLimsigmaVtx=new Double_t[iBin[isigmaVtx]+1];
233         Double_t *binLimsumd02=new Double_t[iBin[isumd02]+1];   
234         Double_t *binLimpointingXY=new Double_t[iBin[ipointingXY]+1];
235         Double_t *binLimnormDecayLXY=new Double_t[iBin[inormDecayLXY]+1];
236         Double_t *binLimmult=new Double_t[iBin[imult]+1];
237         
238         // checking limits
239         /*
240           if (ptmax_0_4 != ptmin_4_8) {
241           Error("AliCFHeavyFlavourTaskMultiVarMultiStep","max lim 1st range != min lim 2nd range, please check!");
242           }
243           if (ptmax_4_8 != ptmin_8_10) {
244           Error("AliCFHeavyFlavourTaskMultiVarMultiStep","max lim 2nd range != min lim 3rd range, please check!");
245           }
246         */
247         // values for bin lower bounds
248         // pt
249         Float_t* floatbinLimpT = cutsLctopKpi->GetPtBinLimits();
250         for (Int_t ibinpT = 0 ; ibinpT<iBin[ipT]+1; ibinpT++){
251                 binLimpT[ibinpT] = (Double_t)floatbinLimpT[ibinpT];
252                 binLimpTpi[ibinpT] = (Double_t)floatbinLimpT[ibinpT];
253                 binLimpTk[ibinpT] = (Double_t)floatbinLimpT[ibinpT];
254                 binLimpTpi2[ibinpT] = (Double_t)floatbinLimpT[ibinpT];
255         }
256         for(Int_t i=0; i<=nbinpt; i++) printf("binLimpT[%d]=%f\n",i,binLimpT[i]);  
257         
258         /*
259           for(Int_t i=0; i<=nbinpt_0_4; i++) binLimpT[i]=(Double_t)ptmin_0_4 + (ptmax_0_4-ptmin_0_4)/nbinpt_0_4*(Double_t)i ; 
260           if (binLimpT[nbinpt_0_4] != ptmin_4_8)  {
261           Error("AliCFHeavyFlavourTaskMultiVarMultiStep","Calculated bin lim for pt - 1st range - differs from expected!\n");
262           }
263           for(Int_t i=0; i<=nbinpt_4_8; i++) binLimpT[i+nbinpt_0_4]=(Double_t)ptmin_4_8 + (ptmax_4_8-ptmin_4_8)/nbinpt_4_8*(Double_t)i ; 
264           if (binLimpT[nbinpt_0_4+nbinpt_4_8] != ptmin_8_10)  {
265           Error("AliCFHeavyFlavourTaskMultiVarMultiStep","Calculated bin lim for pt - 2nd range - differs from expected!\n");
266           }
267           for(Int_t i=0; i<=nbinpt_8_10; i++) binLimpT[i+nbinpt_0_4+nbinpt_4_8]=(Double_t)ptmin_8_10 + (ptmax_8_10-ptmin_8_10)/nbinpt_8_10*(Double_t)i ; 
268         */
269         
270         // y
271         for(Int_t i=0; i<=nbiny; i++) binLimy[i]=(Double_t)ymin  + (ymax-ymin)  /nbiny*(Double_t)i ;
272         
273         // Phi
274         for(Int_t i=0; i<=nbinphi; i++) binLimphi[i]=(Double_t)phimin  + (phimax-phimin)  /nbinphi*(Double_t)i ;
275         
276         // cT
277         for(Int_t i=0; i<=nbincT; i++) binLimcT[i]=(Double_t)cTmin  + (cTmax-cTmin)  /nbincT*(Double_t)i ;
278         
279         // cosPointingAngle
280         for(Int_t i=0; i<=nbinpointing; i++) binLimpointing[i]=(Double_t)cosmin  + (cosmax-cosmin)  /nbinpointing*(Double_t)i ;
281
282         /*
283         // ptPi
284         for(Int_t i=0; i<=nbincT_0_4; i++) binLimcT[i]=(Double_t)ptmin_0_4 + (ptmax_0_4-ptmin_0_4)/nbincT_0_4*(Double_t)i ; 
285         if (binLimcT[nbincT_0_4] != ptmin_4_8)  {
286         Error("AliCFHeavyFlavourTaskMultiVarMultiStep","Calculated bin lim for ptPi - 1st range - differs from expected!");
287         }
288         for(Int_t i=0; i<=nbincT_4_8; i++) binLimcT[i+nbincT_0_4]=(Double_t)ptmin_4_8 + (ptmax_4_8-ptmin_4_8)/nbincT_4_8*(Double_t)i ; 
289         if (binLimcT[nbincT_0_4+nbincT_4_8] != ptmin_8_10)  {
290         Error("AliCFHeavyFlavourTaskMultiVarMultiStep","Calculated bin lim for ptPi - 2nd range - differs from expected!\n");
291         }
292         for(Int_t i=0; i<=nbincT_8_10; i++) binLimcT[i+nbincT_0_4+nbincT_4_8]=(Double_t)ptmin_8_10 + (ptmax_8_10-ptmin_8_10)/nbincT_8_10*(Double_t)i ; 
293         
294         // ptKa
295         for(Int_t i=0; i<=nbinpointing_0_4; i++) binLimpointing[i]=(Double_t)ptmin_0_4 + (ptmax_0_4-ptmin_0_4)/nbinpointing_0_4*(Double_t)i ; 
296         if (binLimpointing[nbinpointing_0_4] != ptmin_4_8)  {
297         Error("AliCFHeavyFlavourTaskMultiVarMultiStep","Calculated bin lim for ptKa - 1st range - differs from expected!");
298         }
299         for(Int_t i=0; i<=nbinpointing_4_8; i++) binLimpointing[i+nbinpointing_0_4]=(Double_t)ptmin_4_8 + (ptmax_4_8-ptmin_4_8)/nbinpointing_4_8*(Double_t)i ; 
300         if (binLimpointing[nbinpointing_0_4+nbinpointing_4_8] != ptmin_8_10)  {
301         Error("AliCFHeavyFlavourTaskMultiVarMultiStep","Calculated bin lim for ptKa - 2nd range - differs from expected!\n");
302         }
303         for(Int_t i=0; i<=nbinpointing_8_10; i++) binLimpointing[i+nbinpointing_0_4+nbinpointing_4_8]=(Double_t)ptmin_8_10 + (ptmax_8_10-ptmin_8_10)/nbinpointing_8_10*(Double_t)i ; 
304         */
305         
306         // z Primary Vertex
307         for(Int_t i=0; i<=nbinzvtx; i++) {
308                 binLimzvtx[i]=(Double_t)zvtxmin  + (zvtxmax-zvtxmin)  /nbinzvtx*(Double_t)i ;
309         }
310         
311         // centrality
312         for(Int_t i=0; i<=nbincent_0_10; i++) binLimcent[i]=(Double_t)centmin_0_10 + (centmax_0_10-centmin_0_10)/nbincent_0_10*(Double_t)i ; 
313         if (binLimcent[nbincent_0_10] != centmin_10_100)  {
314                 Error("AliCFHeavyFlavourTaskMultiVarMultiStep","Calculated bin lim for cent - 1st range - differs from expected!\n");
315         }
316         for(Int_t i=0; i<=nbincent_10_100; i++) binLimcent[i+nbincent_0_10]=(Double_t)centmin_10_100 + (centmax_10_100-centmin_10_100)/nbincent_10_100*(Double_t)i ; 
317         
318         // fake
319         for(Int_t i=0; i<=nbinfake; i++) {
320           binLimfake[i]=(Double_t)fakemin  + (fakemax-fakemin)/nbinfake * (Double_t)i;
321         }
322
323         //dist12
324         for(Int_t i=0; i<=nbindist12; i++) {
325           binLimdist12[i]=(Double_t)distTwoPartmin  + (distTwoPartmax-distTwoPartmin)/nbindist12 * (Double_t)i;
326         }
327  
328         //dist23
329         for(Int_t i=0; i<=nbindist23; i++) {
330           binLimdist23[i]=(Double_t)distTwoPartmin  + (distTwoPartmax-distTwoPartmin)/nbindist23 * (Double_t)i;
331         }
332  
333         //dispersion Vtx
334         for(Int_t i=0; i<=nbinsigmaVtx; i++) {
335           binLimsigmaVtx[i]=(Double_t)dispVtxmin  + (dispVtxmax-dispVtxmin)/nbinsigmaVtx * (Double_t)i;
336         }
337
338         //sumd0^2
339         for(Int_t i=0; i<=nbinsumd02; i++) {
340           binLimsumd02[i]=(Double_t)sumd02min  + (sumd02max-sumd02min)/nbinsumd02 * (Double_t)i;
341         }
342
343         // cosPointingAngleXY
344         for(Int_t i=0; i<=nbinpointingXY; i++) binLimpointingXY[i]=(Double_t)cosminXY  + (cosmaxXY-cosminXY)  /nbinpointingXY*(Double_t)i ;
345
346         // normDecayLXY
347         for(Int_t i=0; i<=nbinnormDecayLXY; i++) binLimnormDecayLXY[i]=(Double_t)normDecLXYmin  + (normDecLXYmax-normDecLXYmin)  /nbinnormDecayLXY*(Double_t)i ;
348
349         // multiplicity
350         for(Int_t i=0; i<=nbinmult_0_20; i++) binLimmult[i]=(Double_t)multmin_0_20 + (multmax_0_20-multmin_0_20)/nbinmult_0_20*(Double_t)i ; 
351         if (binLimmult[nbinmult_0_20] != multmin_20_50)  {
352                 Error("AliCFHeavyFlavourTaskMultiVarMultiStep","Calculated bin lim for mult - 1st range - differs from expected!\n");
353         }
354         for(Int_t i=0; i<=nbinmult_20_50; i++) binLimmult[i+nbinmult_0_20]=(Double_t)multmin_20_50 + (multmax_20_50-multmin_20_50)/nbinmult_20_50*(Double_t)i ; 
355         if (binLimmult[nbinmult_0_20+nbinmult_20_50] != multmin_50_102)  {
356                 Error("AliCFHeavyFlavourTaskMultiVarMultiStep","Calculated bin lim for mult - 2nd range - differs from expected!\n");
357         }
358         for(Int_t i=0; i<=nbinmult_50_102; i++) binLimmult[i+nbinmult_0_20+nbinmult_20_50]=(Double_t)multmin_50_102 + (multmax_50_102-multmin_50_102)/nbinmult_50_102*(Double_t)i ; 
359         
360         //one "container" for MC
361         TString nameContainer="";
362         if(!isKeepDfromB) {
363                 nameContainer="CFHFccontainer0_3Prong_CommonFramework";
364         }
365         else  if(isKeepDfromBOnly){
366                 nameContainer="CFHFccontainer0DfromB_3Prong_CommonFramework";
367         }
368         else  {
369                 nameContainer="CFHFccontainer0allD_3Prong_CommonFramework";          
370         }
371         
372         AliCFContainer* container;
373         if (configuration == AliCFTaskVertexingHF::kSnail){
374                 container = new AliCFContainer(nameContainer,"container for tracks",nstep,nvarTot,iBin);
375                 //setting the bin limits
376                 printf("pt\n");
377                 container -> SetBinLimits(ipT,binLimpT);
378                 printf("y\n");
379                 container -> SetBinLimits(iy,binLimy);
380                 printf("Phi\n");
381                 container -> SetBinLimits(iphi,binLimphi);
382                 printf("cT\n");
383                 container -> SetBinLimits(icT,binLimcT);
384                 printf("pointing angle\n");
385                 container -> SetBinLimits(ipointing,binLimpointing);
386                 printf("ptpi\n");
387                 container -> SetBinLimits(ipTpi,binLimpTpi);
388                 printf("ptK\n");
389                 container -> SetBinLimits(ipTk,binLimpTk);
390                 printf("ptpi2\n");
391                 container -> SetBinLimits(ipTpi2,binLimpTpi2);
392                 printf("zvtx \n");
393                 container -> SetBinLimits(izvtx,binLimzvtx);
394                 printf("cent\n");
395                 container -> SetBinLimits(icent,binLimcent);
396                 printf("fake\n");
397                 container -> SetBinLimits(ifake,binLimfake);
398                 printf("dist12\n");
399                 container -> SetBinLimits(idist12,binLimdist12);
400                 printf("dist23\n");
401                 container -> SetBinLimits(idist23,binLimdist23);
402                 printf("dispVtx\n");
403                 container -> SetBinLimits(isigmaVtx,binLimsigmaVtx);
404                 printf("sumd0^2\n");
405                 container -> SetBinLimits(isumd02,binLimsumd02);
406                 printf("pointingXY\n");
407                 container -> SetBinLimits(ipointingXY,binLimpointingXY);
408                 printf("normDecayLXY\n");
409                 container -> SetBinLimits(inormDecayLXY,binLimnormDecayLXY);
410                 printf("multiplicity\n");
411                 container -> SetBinLimits(imult,binLimmult);
412                 
413                 container -> SetVarTitle(ipT,"pt");
414                 container -> SetVarTitle(iy,"y");
415                 container -> SetVarTitle(iphi, "phi");
416                 container -> SetVarTitle(icT, "ct");
417                 container -> SetVarTitle(ipointing, "pionting");        
418                 container -> SetVarTitle(ipTpi, "ptpi");
419                 container -> SetVarTitle(ipTk, "ptK");
420                 container -> SetVarTitle(ipTpi2, "ptpi2");
421                 container -> SetVarTitle(izvtx, "zvtx");
422                 container -> SetVarTitle(icent, "centrality");
423                 container -> SetVarTitle(ifake, "fake");
424                 container -> SetVarTitle(idist12, "dist12toVtx");
425                 container -> SetVarTitle(idist23, "dist23toVtx");
426                 container -> SetVarTitle(isigmaVtx, "dispertionToSecVtx");
427                 container -> SetVarTitle(isumd02, "sumd0^2");
428                 container -> SetVarTitle(ipointingXY, "piointingXY");
429                 container -> SetVarTitle(inormDecayLXY, "normDecayLXY");
430                 container -> SetVarTitle(imult, "multiplicity");
431         }
432         else if (configuration == AliCFTaskVertexingHF::kCheetah){
433                 //arrays for the number of bins in each dimension
434                 const Int_t nvar = 8;
435
436                 const UInt_t ipTFast = 0;
437                 const UInt_t iyFast = 1;
438                 const UInt_t icTFast = 2;
439                 const UInt_t iphiFast = 3;
440                 const UInt_t izvtxFast = 4;
441                 const UInt_t icentFast = 5;
442                 const UInt_t ifakeFast = 6;
443                 const UInt_t imultFast = 7;
444
445                 Int_t iBinFast[nvar];
446                 iBinFast[ipTFast] = iBin[ipT];
447                 iBinFast[iyFast] = iBin[iy];
448                 iBinFast[icTFast] = iBin[icT];
449                 iBinFast[iphiFast] = iBin[iphi];
450                 iBinFast[izvtxFast] = iBin[izvtx];
451                 iBinFast[icentFast] = iBin[icent];
452                 iBinFast[ifakeFast] = iBin[ifake];
453                 iBinFast[imultFast] = iBin[imult];
454
455                 container = new AliCFContainer(nameContainer,"container for tracks",nstep,nvar,iBinFast);
456                 printf("pt\n");
457                 container -> SetBinLimits(ipTFast,binLimpT);
458                 printf("y\n");
459                 container -> SetBinLimits(iyFast,binLimy);
460                 printf("ct\n");
461                 container -> SetBinLimits(icTFast,binLimcT);
462                 printf("phi\n");
463                 container -> SetBinLimits(iphiFast,binLimphi);
464                 printf("zvtx\n");
465                 container -> SetBinLimits(izvtxFast,binLimzvtx);
466                 printf("centrality\n");
467                 container -> SetBinLimits(icentFast,binLimcent);
468                 printf("fake\n");
469                 container -> SetBinLimits(ifakeFast,binLimfake);
470                 printf("multiplicity\n");
471                 container -> SetBinLimits(imultFast,binLimmult);
472
473                 container -> SetVarTitle(ipTFast,"pt");
474                 container -> SetVarTitle(iyFast,"y");
475                 container -> SetVarTitle(icTFast, "ct");
476                 container -> SetVarTitle(iphiFast, "phi");
477                 container -> SetVarTitle(izvtxFast, "zvtx");
478                 container -> SetVarTitle(icentFast, "centrality");
479                 container -> SetVarTitle(ifakeFast, "fake");
480                 container -> SetVarTitle(imultFast, "multiplicity");
481         }
482
483         return container;
484
485         container -> SetStepTitle(0, "MCLimAcc");
486         container -> SetStepTitle(1, "MC");
487         container -> SetStepTitle(2, "MCAcc");
488         container -> SetStepTitle(3, "RecoVertex");
489         container -> SetStepTitle(4, "RecoRefit");
490         container -> SetStepTitle(5, "Reco");
491         container -> SetStepTitle(6, "RecoAcc");
492         container -> SetStepTitle(7, "RecoITSCluster");
493         container -> SetStepTitle(8, "RecoCuts");
494         container -> SetStepTitle(9, "RecoPID");
495
496
497         //CREATE THE  CUTS -----------------------------------------------
498         
499         // Gen-Level kinematic cuts
500         AliCFTrackKineCuts *mcKineCuts = new AliCFTrackKineCuts("mcKineCuts","MC-level kinematic cuts");
501         
502         //Particle-Level cuts:  
503         AliCFParticleGenCuts* mcGenCuts = new AliCFParticleGenCuts("mcGenCuts","MC particle generation cuts");
504         Bool_t useAbsolute = kTRUE;
505         if (isSign != 2){
506                 useAbsolute = kFALSE;
507         }
508         mcGenCuts->SetRequirePdgCode(pdgCode, useAbsolute);  // kTRUE set in order to include antiparticle
509         mcGenCuts->SetAODMC(1); //special flag for reading MC in AOD tree (important)
510         
511         // Acceptance cuts:
512         AliCFAcceptanceCuts* accCuts = new AliCFAcceptanceCuts("accCuts", "Acceptance cuts");
513         AliCFTrackKineCuts *kineAccCuts = new AliCFTrackKineCuts("kineAccCuts","Kine-Acceptance cuts");
514         kineAccCuts->SetPtRange(ptmin,ptmax);
515         kineAccCuts->SetEtaRange(etamin,etamax);
516
517         // Rec-Level kinematic cuts
518         AliCFTrackKineCuts *recKineCuts = new AliCFTrackKineCuts("recKineCuts","rec-level kine cuts");
519         
520         AliCFTrackQualityCuts *recQualityCuts = new AliCFTrackQualityCuts("recQualityCuts","rec-level quality cuts");
521         
522         AliCFTrackIsPrimaryCuts *recIsPrimaryCuts = new AliCFTrackIsPrimaryCuts("recIsPrimaryCuts","rec-level isPrimary cuts");
523         
524         printf("CREATE MC KINE CUTS\n");
525         TObjArray* mcList = new TObjArray(0) ;
526         mcList->AddLast(mcKineCuts);
527         mcList->AddLast(mcGenCuts);
528         
529         printf("CREATE ACCEPTANCE CUTS\n");
530         TObjArray* accList = new TObjArray(0) ;
531         accList->AddLast(kineAccCuts);
532
533         printf("CREATE RECONSTRUCTION CUTS\n");
534         TObjArray* recList = new TObjArray(0) ;   // not used!! 
535         recList->AddLast(recKineCuts);
536         recList->AddLast(recQualityCuts);
537         recList->AddLast(recIsPrimaryCuts);
538         
539         TObjArray* emptyList = new TObjArray(0);
540
541         //CREATE THE INTERFACE TO CORRECTION FRAMEWORK USED IN THE TASK
542         printf("CREATE INTERFACE AND CUTS\n");
543         AliCFManager* man = new AliCFManager() ;
544         man->SetParticleContainer(container);
545         man->SetParticleCutsList(0 , mcList); // MC, Limited Acceptance
546         man->SetParticleCutsList(1 , mcList); // MC
547         man->SetParticleCutsList(2 , accList); // Acceptance 
548         man->SetParticleCutsList(3 , emptyList); // Vertex 
549         man->SetParticleCutsList(4 , emptyList); // Refit 
550         man->SetParticleCutsList(5 , emptyList); // AOD
551         man->SetParticleCutsList(6 , emptyList); // AOD in Acceptance
552         man->SetParticleCutsList(7 , emptyList); // AOD with required n. of ITS clusters
553         man->SetParticleCutsList(8 , emptyList); // AOD Reco (PPR cuts implemented in Task)
554         man->SetParticleCutsList(9 , emptyList); // AOD Reco PID
555         
556         // Get the pointer to the existing analysis manager via the static access method.
557         //==============================================================================
558         AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
559         if (!mgr) {
560           ::Error("AddTaskCompareHF", "No analysis manager to connect to.");
561           return NULL;
562         }   
563         //CREATE THE TASK
564         printf("CREATE TASK\n");
565
566         // create the task
567         AliCFTaskVertexingHF *task = new AliCFTaskVertexingHF("AliCFTaskVertexingHF",cutsLctopKpi);
568         task->SetFillFromGenerated(kFALSE);
569         task->SetDecayChannel(32);
570         task->SetUseWeight(kFALSE);
571         task->SetCFManager(man); //here is set the CF manager
572         task->SetSign(isSign);
573         task->SetCentralitySelection(kFALSE);
574         task->SetFakeSelection(0);
575         task->SetRejectCandidateIfNotFromQuark(kTRUE); // put to false if you want to keep HIJING D0!!
576         task->SetUseMCVertex(kFALSE); // put to true if you want to do studies on pp
577         if (isKeepDfromB && !isKeepDfromBOnly) task->SetDselection(2);
578         if (isKeepDfromB && isKeepDfromBOnly) task->SetDselection(1);           
579
580         TF1* funcWeight = 0x0;
581         if (task->GetUseWeight()) {
582                 funcWeight = (TF1*)cutFile->Get("funcWeight");
583                 if (funcWeight == 0x0){
584                         Printf("FONLL Weights will be used");
585                 }
586                 else {
587                         task->SetWeightFunction(funcWeight);
588                         Printf("User-defined Weights will be used. The function being:");
589                         task->GetWeightFunction()->Print();
590                 }
591         }
592
593         Printf("***************** CONTAINER SETTINGS *****************");
594         Printf("decay channel = %d",(Int_t)task->GetDecayChannel());
595         Printf("FillFromGenerated = %d",(Int_t)task->GetFillFromGenerated());
596         Printf("Dselection = %d",(Int_t)task->GetDselection());
597         Printf("UseWeight = %d",(Int_t)task->GetUseWeight());
598         if (task->GetUseWeight()) {
599                 funcWeight = (TF1*)cutFile->Get("funcWeight");
600                 if (funcWeight == 0x0){
601                         Printf("FONLL Weights will be used");
602                 }
603                 else {
604                         task->SetWeightFunction(funcWeight);
605                         Printf("User-defined Weights will be used. The function being:");
606                         task->GetWeightFunction()->Print();
607                 }
608         }
609         Printf("Sign = %d",(Int_t)task->GetSign());
610         Printf("Centrality selection = %d",(Int_t)task->GetCentralitySelection());
611         Printf("Fake selection = %d",(Int_t)task->GetFakeSelection());
612         Printf("RejectCandidateIfNotFromQuark selection = %d",(Int_t)task->GetRejectCandidateIfNotFromQuark());
613         Printf("UseMCVertex selection = %d",(Int_t)task->GetUseMCVertex());
614         Printf("***************END CONTAINER SETTINGS *****************\n");
615
616         //-----------------------------------------------------------//
617         //   create correlation matrix for unfolding - only eta-pt   //
618         //-----------------------------------------------------------//
619
620         Bool_t AcceptanceUnf = kTRUE; // unfold at acceptance level, otherwise PPR
621
622         Int_t thnDim[4];
623         
624         //first half  : reconstructed 
625         //second half : MC
626
627         thnDim[0] = iBin[ipT];
628         thnDim[2] = iBin[ipT];
629         thnDim[1] = iBin[iy];
630         thnDim[3] = iBin[iy];
631
632         TString nameCorr="";
633         if(!isKeepDfromB) {
634                 nameCorr="CFHFcorr0_3Prong_CommonFramework";
635         }
636         else  if(isKeepDfromBOnly){
637                 nameCorr= "CFHFcorr0KeepDfromBOnly_3Prong_CommonFramework";
638         }
639         else  {
640                 nameCorr="CFHFcorr0allD_3Prong_CommonFramework";                
641         }
642
643         THnSparseD* correlation = new THnSparseD(nameCorr,"THnSparse with correlations",4,thnDim);
644         Double_t** binEdges = new Double_t[2];
645
646         // set bin limits
647
648         binEdges[0]= binLimpT;
649         binEdges[1]= binLimy;
650
651         correlation->SetBinEdges(0,binEdges[0]);
652         correlation->SetBinEdges(2,binEdges[0]);
653
654         correlation->SetBinEdges(1,binEdges[1]);
655         correlation->SetBinEdges(3,binEdges[1]);
656
657         correlation->Sumw2();
658   
659         // correlation matrix ready
660         //------------------------------------------------//
661
662         task->SetCorrelationMatrix(correlation); // correlation matrix for unfolding
663         
664         // Create and connect containers for input/output
665         
666         // ------ input data ------
667         AliAnalysisDataContainer *cinput0  = mgr->GetCommonInputContainer();
668         
669         // ----- output data -----
670         
671         TString outputfile = AliAnalysisManager::GetCommonFileName();
672         TString output1name="", output2name="", output3name="", output4name="";;
673         output2name=nameContainer;
674         output3name=nameCorr;
675         if(!isKeepDfromB) {
676                 outputfile += ":PWG3_D2H_CFtaskLctopKpi_CommonFramework";
677                 output1name="CFHFchist0_3Prong_CommonFramework";
678         }
679         else  if(isKeepDfromBOnly){
680                 outputfile += ":PWG3_D2H_CFtaskLctopKpiKeepDfromBOnly_CommonFramework";
681                 output1name="CFHFchist0DfromB_3Prong_CommonFramework";
682         }
683         else{
684                 outputfile += ":PWG3_D2H_CFtaskLctopKpiKeepDfromB_CommonFramework";
685                 output1name="CFHFchist0allD_3Prong_CommonFramework";
686         }
687
688         output4name= "Cuts_3Prong_CommonFramework";
689
690         //now comes user's output objects :
691         // output TH1I for event counting
692         AliAnalysisDataContainer *coutput1 = mgr->CreateContainer(output1name, TH1I::Class(),AliAnalysisManager::kOutputContainer,outputfile.Data());
693         // output Correction Framework Container (for acceptance & efficiency calculations)
694         AliAnalysisDataContainer *coutput2 = mgr->CreateContainer(output2name, AliCFContainer::Class(),AliAnalysisManager::kOutputContainer,outputfile.Data());
695         // Unfolding - correlation matrix
696         AliAnalysisDataContainer *coutput3 = mgr->CreateContainer(output3name, THnSparseD::Class(),AliAnalysisManager::kOutputContainer,outputfile.Data());
697         AliAnalysisDataContainer *coutput4 = mgr->CreateContainer(output4name, AliRDHFCuts::Class(),AliAnalysisManager::kOutputContainer, outputfile.Data());
698
699         mgr->AddTask(task);
700         
701         mgr->ConnectInput(task,0,mgr->GetCommonInputContainer());
702         mgr->ConnectOutput(task,1,coutput1);
703         mgr->ConnectOutput(task,2,coutput2);
704         mgr->ConnectOutput(task,3,coutput3);
705         mgr->ConnectOutput(task,4,coutput4);
706
707         return task;
708         }
709