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