AliPhysics  d565ceb (d565ceb)
AddTaskCFVertexingHFLctoV0bachelorTMVA.C
Go to the documentation of this file.
1 const Double_t ymin = -1.2 ;
2 const Double_t ymax = 1.2 ;
3 const Double_t cosminTS = -1.05;
4 const Double_t cosmaxTS = 1.05;
5 const Double_t cosmin = 0.7;
6 const Double_t cosmax = 1.02;
7 const Double_t cTmin = 0; // micron
8 const Double_t cTmax = 300; // micron
9 const Double_t dcamin = 0; // micron
10 const Double_t dcamax = 600; // micron
11 const Double_t d0xd0min = -80000; // micron
12 const Double_t d0xd0max = 100000; // micron
13 const Double_t phimin = 0.0;
16 const Int_t charge = 1 ;
17 const Int_t minclustersTPC = 50 ;
18 // cuts
19 const Double_t ptmin = 0.1;
20 const Double_t ptmax = 9999.;
21 const Double_t etamin = -0.9;
22 const Double_t etamax = 0.9;
23 const Double_t zmin = -15;
24 const Double_t zmax = 15;
26 
27 const Float_t centmin_0_10 = 0.;
28 const Float_t centmax_0_10 = 10.;
29 const Float_t centmin_10_60 = 10.;
30 const Float_t centmax_10_60 = 60.;
31 const Float_t centmin_60_100 = 60.;
32 const Float_t centmax_60_100 = 100.;
33 const Float_t centmax = 100.;
34 const Float_t fakemin = -0.5;
35 const Float_t fakemax = 2.5.;
36 const Float_t cosminXY = 0.95;
37 const Float_t cosmaxXY = 1.0;
41 const Float_t multmax_0_20 = 20;
47 const Float_t multmax_80_100 = 100;
50 
51 
52 //----------------------------------------------------
53 
54 AliCFTaskVertexingHF *AddTaskCFVertexingHFLctoV0bachelorTMVA(const char* cutFile = "CutsLc2pK0STMVA_20140311.root",
55  TString cutObjectName = "LctoV0AnalysisCuts",
56  TString suffix = "TMVA",
57  Int_t configuration = AliCFTaskVertexingHF::kCheetah,
58  Bool_t isKeepDfromB = kTRUE,
59  Bool_t isKeepDfromBOnly = kFALSE,
60  Int_t pdgCode = 4122,
61  Char_t isSign = 2,
62  Bool_t useWeight = kFALSE,
63  Bool_t useFlatPtWeight = kFALSE,
64  Bool_t useZWeight = kFALSE,
65  Bool_t useNchWeight = kFALSE,
66  Bool_t useNtrkWeight = kFALSE,
67  TString estimatorFilename="",
68  Int_t multiplicityEstimator = AliCFTaskVertexingHF::kNtrk10,
69  Bool_t isPPData = kFALSE,
70  Bool_t isPPbData = kFALSE,
71  Double_t refMult = 9.26,
72  Bool_t isFineNtrkBin = kFALSE)
73 {
74  printf("Adding CF task using cuts from file %s\n",cutFile);
75  if (configuration == AliCFTaskVertexingHF::kSnail){
76  printf("The configuration is set to be SLOW --> all the variables will be used to fill the CF\n");
77  }
78  else if (configuration == AliCFTaskVertexingHF::kCheetah){
79  printf("The configuration is set to be FAST --> using only pt, y, ct, phi, zvtx, centrality, fake, multiplicity to fill the CF\n");
80  }
81  else if (configuration == AliCFTaskVertexingHF::kFalcon){
82  printf("The configuration is set to be FAST --> using only pt, y, centrality, multiplicity to fill the CF\n");
83  }
84  else{
85  printf("The configuration is not defined! returning\n");
86  return;
87  }
88 
89  gSystem->Sleep(2000);
90 
91  // isSign = 0 --> D* only
92  // isSign = 1 --> D*bar only
93  // isSign = 2 --> D* + D*bar
94 
95  TString expected;
96  if (isSign == 0 && pdgCode < 0){
97  AliError(Form("Error setting PDG code (%d) and sign (0 --> D* only): they are not compatible, returning"));
98  return 0x0;
99  }
100  else if (isSign == 1 && pdgCode > 0){
101  AliError(Form("Error setting PDG code (%d) and sign (1 --> D*bar only): they are not compatible, returning"));
102  return 0x0;
103  }
104  else if (isSign > 2 || isSign < 0){
105  AliError(Form("Sign not valid (%d, possible values are 0, 1, 2), returning"));
106  return 0x0;
107  }
108 
109  TFile* fileCuts = TFile::Open(cutFile);
110  if(!fileCuts || (fileCuts && !fileCuts->IsOpen())){
111  AliError("Wrong cut file");
112  return 0x0;
113  }
114 
115  AliRDHFCutsLctoV0 *cutsLcTMVA = (AliRDHFCutsLctoV0*)fileCuts->Get(cutObjectName.Data());
116 
117  // check that the fKeepD0fromB flag is set to true when the fKeepD0fromBOnly flag is true
118  // for now the binning is the same than for all D's
119  if (isKeepDfromBOnly) isKeepDfromB = true;
120 
121  Double_t ptmin_0_6;
122  Double_t ptmax_0_6;
123  Double_t ptmin_6_8;
124  Double_t ptmax_6_8;
125  Double_t ptmin_8_16;
126  Double_t ptmax_8_16;
127  Double_t ptmin_16_24;
128  Double_t ptmax_16_24;
129 
130  ptmin_0_6 = 0.0 ;
131  ptmax_0_6 = 6.0 ;
132  ptmin_6_8 = 6.0 ;
133  ptmax_6_8 = 8.0 ;
134  ptmin_8_16 = 8.0 ;
135  ptmax_8_16 = 16.0 ;
136  ptmin_16_24 = 16.0 ;
137  ptmax_16_24 = 24.0 ;
138 
139  //CONTAINER DEFINITION
140  Info("AliCFTaskVertexingHF","SETUP CONTAINER");
141  const Double_t phimax = 2*TMath::Pi();
142  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
143 
144  //const UInt_t ipT, iy, icosThetaStar, ipTpi, ipTk, icT, idca, id0xd0, ipointing, iphi, izvtx, icent, ifake, ipointingXY, iNormDecayLXY, imult;
145  const Int_t nbiny = 24 ; //bins in y
146  const Int_t nbincosThetaStar = 42 ; //bins in cosThetaStar
147  const Int_t nbincT = 15 ; //bins in cT
148  const Int_t nbindca = 20 ; //bins in dca
149  const Int_t nbind0xd0 = 90 ; //bins in d0xd0
150  const Int_t nbinpointing = 50 ; //bins in cosPointingAngle
151  const Int_t nbinphi = 18 ; //bins in Phi
152  const Int_t nbinzvtx = 30 ; //bins in z vertex
153  const Int_t nbincent = 28; //bins in centrality
154  const Int_t nbincent_0_10 = 4; //bins in centrality between 0 and 10
155  const Int_t nbincent_10_60 = 20; //bins in centrality between 10 and 60
156  const Int_t nbincent_60_100 = 4; //bins in centrality between 60 and 100
157  const Int_t nbinfake = 3; //bins in fake
158  const Int_t nbinpointingXY = 50; //bins in cosPointingAngleXY
159  const Int_t nbinnormDecayLXY = 20; //bins in NormDecayLengthXY
160  const Int_t nbinmult = 49; //bins in multiplicity (total number)
161  const Int_t nbinmult_0_20 = 20; //bins in multiplicity between 0 and 20
162  const Int_t nbinmult_20_50 = 15; //bins in multiplicity between 20 and 50
163  const Int_t nbinmult_50_80 = 10; //bins in multiplicity between 50 and 80
164  const Int_t nbinmult_80_100 = 4; //bins in multiplicity between 80 and 100
165  const Int_t nbinmult_100_400 = 3; //bins in multiplicity between 100 and 400
166  if(isPPbData) nbinmult += nbinmult_100_400;
167 
168 
169  //the sensitive variables, their indices
170 
171  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
172 
173  // variables' indices
174  const UInt_t ipT = 0;
175  const UInt_t iy = 1;
176  const UInt_t icosThetaStar = 2;
177  const UInt_t ipTpi = 3;
178  const UInt_t ipTk = 4;
179  const UInt_t icT = 5;
180  const UInt_t idca = 6;
181  const UInt_t id0xd0 = 7;
182  const UInt_t ipointing = 8;
183  const UInt_t iphi = 9;
184  const UInt_t izvtx = 10;
185  const UInt_t icent = 11;
186  const UInt_t ifake = 12;
187  const UInt_t ipointingXY = 13;
188  const UInt_t inormDecayLXY = 14;
189  const UInt_t imult = 15;
190 
191  //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
192 
193  //arrays for the number of bins in each dimension
194  Int_t iBin[nvarTot];
195 
196  const Int_t nbinpt = cutsLcTMVA->GetNPtBins(); // bins in pT
197  iBin[ipT] = nbinpt;
198  iBin[ipTpi] = nbinpt;
199  iBin[ipTk] = nbinpt;
200  Double_t *binLimpT = new Double_t[iBin[ipT]+1];
201  Double_t *binLimpTpi = new Double_t[iBin[ipTpi]+1];
202  Double_t *binLimpTk = new Double_t[iBin[ipTk]+1];
203  // values for bin lower bounds
204  Float_t* floatbinLimpT = cutsLcTMVA->GetPtBinLimits();
205  for (Int_t ibin0 = 0 ; ibin0<iBin[ipT]+1; ibin0++){
206  binLimpT[ibin0] = (Double_t)floatbinLimpT[ibin0];
207  binLimpTpi[ibin0] = (Double_t)floatbinLimpT[ibin0];
208  binLimpTk[ibin0] = (Double_t)floatbinLimpT[ibin0];
209  }
210  for(Int_t i=0; i<=nbinpt; i++) printf("binLimpT[%d]=%f\n",i,binLimpT[i]);
211 
212  printf("pT: nbin (from cuts file) = %d\n",nbinpt);
213 
214  // Fine Ntrk binning setting
215  Double_t *binLimmultFine;
216  Int_t nbinmultTmp = nbinmult;
217  if (isFineNtrkBin) {
218  Int_t nbinLimmultFine = 100;
219  if (isPPbData) nbinLimmultFine = 200;
220  const UInt_t nbinMultFine = nbinLimmultFine;
221  binLimmultFine = new Double_t[nbinMultFine+1];
222  for (Int_t ibin0 = 0; ibin0 < nbinMultFine+1; ibin0++) {
223  binLimmultFine[ibin0] = ibin0;
224  }
225  nbinmultTmp = nbinLimmultFine;
226  }
227  const Int_t nbinmultTot = nbinmultTmp;
228 
229  // defining now the binning for the other variables:
230 
231  AliLog::SetClassDebugLevel("AliCFManager",AliLog::kInfo);
232 
233  iBin[iy] = nbiny;
234  iBin[icosThetaStar] = nbincosThetaStar;
235  iBin[icT] = nbincT;
236  iBin[idca] = nbindca;
237  iBin[id0xd0] = nbind0xd0;
238  iBin[ipointing] = nbinpointing;
239  iBin[iphi] = nbinphi;
240  iBin[izvtx] = nbinzvtx;
241  iBin[icent] = nbincent;
242  iBin[ifake] = nbinfake;
243  iBin[ipointingXY] = nbinpointingXY;
244  iBin[inormDecayLXY] = nbinnormDecayLXY;
245  iBin[imult] = nbinmultTot;
246 
247  //arrays for lower bounds :
248  Double_t *binLimy = new Double_t[iBin[iy]+1];
249  Double_t *binLimcosThetaStar = new Double_t[iBin[icosThetaStar]+1];
250  Double_t *binLimcT = new Double_t[iBin[icT]+1];
251  Double_t *binLimdca = new Double_t[iBin[idca]+1];
252  Double_t *binLimd0xd0 = new Double_t[iBin[id0xd0]+1];
253  Double_t *binLimpointing = new Double_t[iBin[ipointing]+1];
254  Double_t *binLimphi = new Double_t[iBin[iphi]+1];
255  Double_t *binLimzvtx = new Double_t[iBin[izvtx]+1];
256  Double_t *binLimcent = new Double_t[iBin[icent]+1];
257  Double_t *binLimfake = new Double_t[iBin[ifake]+1];
258  Double_t *binLimpointingXY = new Double_t[iBin[ipointingXY]+1];
259  Double_t *binLimnormDecayLXY = new Double_t[iBin[inormDecayLXY]+1];
260  Double_t *binLimmult = new Double_t[iBin[imult]+1];
261 
262 
263  // y
264  for(Int_t i=0; i<=nbiny; i++) binLimy[i] = (Double_t)ymin + (ymax-ymin) /nbiny*(Double_t)i ;
265 
266  // cosThetaStar
267  for(Int_t i=0; i<=nbincosThetaStar; i++) binLimcosThetaStar[i] = (Double_t)cosminTS + (cosmaxTS-cosminTS) /nbincosThetaStar*(Double_t)i ;
268 
269  // cT
270  for(Int_t i=0; i<=nbincT; i++) binLimcT[i] = (Double_t)cTmin + (cTmax-cTmin) /nbincT*(Double_t)i ;
271 
272  // dca
273  for(Int_t i=0; i<=nbindca; i++) binLimdca[i] = (Double_t)dcamin + (dcamax-dcamin) /nbindca*(Double_t)i ;
274 
275  // d0xd0
276  for(Int_t i=0; i<=nbind0xd0; i++) binLimd0xd0[i] = (Double_t)d0xd0min + (d0xd0max-d0xd0min) /nbind0xd0*(Double_t)i ;
277 
278  // cosPointingAngle
279  for(Int_t i=0; i<=nbinpointing; i++) binLimpointing[i] = (Double_t)cosmin + (cosmax-cosmin) /nbinpointing*(Double_t)i ;
280 
281  // Phi
282  for(Int_t i=0; i<=nbinphi; i++) binLimphi[i] = (Double_t)phimin + (phimax-phimin) /nbinphi*(Double_t)i ;
283 
284  // z Primary Vertex
285  for(Int_t i=0; i<=nbinzvtx; i++) {
286  binLimzvtx[i] = (Double_t)zmin + (zmax-zmin) /nbinzvtx*(Double_t)i ;
287  }
288 
289  // centrality
290  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 ;
291  if (binLimcent[nbincent_0_10] != centmin_10_60) {
292  Error("AliCFHeavyFlavourTaskMultiVarMultiStep","Calculated bin lim for cent - 1st range - differs from expected!\n");
293  }
294  for(Int_t i=0; i<=nbincent_10_60; i++) binLimcent[i+nbincent_0_10] = (Double_t)centmin_10_60 + (centmax_10_60-centmin_10_60)/nbincent_10_60*(Double_t)i ;
295  if (binLimcent[nbincent_0_10+nbincent_10_60] != centmin_60_100) {
296  Error("AliCFHeavyFlavourTaskMultiVarMultiStep","Calculated bin lim for cent - 2st range - differs from expected!\n");
297  }
298  for(Int_t i=0; i<=nbincent_60_100; i++) binLimcent[i+nbincent_0_10+nbincent_10_60] = (Double_t)centmin_60_100 + (centmax_60_100-centmin_60_100)/nbincent_60_100*(Double_t)i ;
299 
300  // fake
301  for(Int_t i=0; i<=nbinfake; i++) {
302  binLimfake[i] = (Double_t)fakemin + (fakemax-fakemin)/nbinfake * (Double_t)i;
303  }
304 
305  // cosPointingAngleXY
306  for(Int_t i=0; i<=nbinpointingXY; i++) binLimpointingXY[i] = (Double_t)cosminXY + (cosmaxXY-cosminXY) /nbinpointingXY*(Double_t)i ;
307 
308  // normDecayLXY
309  for(Int_t i=0; i<=nbinnormDecayLXY; i++) binLimnormDecayLXY[i] = (Double_t)normDecLXYmin + (normDecLXYmax-normDecLXYmin) /nbinnormDecayLXY*(Double_t)i ;
310 
311 
312  // multiplicity
313  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 ;
314  if (binLimmult[nbinmult_0_20] != multmin_20_50) {
315  Error("AliCFHeavyFlavourTaskMultiVarMultiStep","Calculated bin lim for mult - 1st range - differs from expected!\n");
316  }
317  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 ;
318  if (binLimmult[nbinmult_0_20+nbinmult_20_50] != multmin_50_80) {
319  Error("AliCFHeavyFlavourTaskMultiVarMultiStep","Calculated bin lim for mult - 2nd range - differs from expected!\n");
320  }
321  for(Int_t i=0; i<=nbinmult_50_80; i++) binLimmult[i+nbinmult_0_20+nbinmult_20_50] = (Double_t)multmin_50_80 + (multmax_50_80-multmin_50_80)/nbinmult_50_80*(Double_t)i ;
322  if (binLimmult[nbinmult_0_20+nbinmult_20_50+nbinmult_50_80] != multmin_80_100) {
323  Error("AliCFHeavyFlavourTaskMultiVarMultiStep","Calculated bin lim for mult - 3rd range - differs from expected!\n");
324  }
325  for(Int_t i=0; i<=nbinmult_80_100; i++) binLimmult[i+nbinmult_0_20+nbinmult_20_50+nbinmult_50_80] = (Double_t)multmin_80_100 + (multmax_80_100-multmin_80_100)/nbinmult_80_100*(Double_t)i ;
326  if (binLimmult[nbinmult_0_20+nbinmult_20_50+nbinmult_50_80+nbinmult_80_100] != multmin_100_400) {
327  Error("AliCFHeavyFlavourTaskMultiVarMultiStep","Calculated bin lim for mult - 4th range - differs from expected!\n");
328  }
329  if(isPPbData){
330  for (Int_t i = 0; i<=nbinmult_100_400; i++) binLimmult[i+nbinmult_0_20+nbinmult_20_50+nbinmult_50_80+nbinmult_80_100] = (Double_t)multmin_100_400 + (multmax_100_400-multmin_100_400)/nbinmult_100_400*(Double_t)i ;
331  }
332 
333  //one "container" for MC
334  TString nameContainer="";
335  if(!isKeepDfromB) {
336  nameContainer = "CFHFccontainer0";
337  }
338  else if(isKeepDfromBOnly){
339  nameContainer = "CFHFccontainer0DfromB";
340  }
341  else {
342  nameContainer = "CFHFccontainer0allD";
343  }
344  nameContainer += suffix;
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 
384  if (isFineNtrkBin) container->SetBinLimits(imult, binLimmultFine);
385  else container->SetBinLimits(imult, binLimmult);
386 
387  container -> SetVarTitle(ipT,"pt");
388  container -> SetVarTitle(iy,"y");
389  container -> SetVarTitle(icosThetaStar, "cosThetaStar");
390  container -> SetVarTitle(ipTpi, "ptpi");
391  container -> SetVarTitle(ipTk, "ptK");
392  container -> SetVarTitle(icT, "ct");
393  container -> SetVarTitle(idca, "dca");
394  container -> SetVarTitle(id0xd0, "d0xd0");
395  container -> SetVarTitle(ipointing, "pointing");
396  container -> SetVarTitle(iphi, "phi");
397  container -> SetVarTitle(izvtx, "zvtx");
398  container -> SetVarTitle(icent, "centrality");
399  container -> SetVarTitle(ifake, "fake");
400  container -> SetVarTitle(ipointingXY, "piointingXY");
401  container -> SetVarTitle(inormDecayLXY, "normDecayLXY");
402  container -> SetVarTitle(imult, "multiplicity");
403  }
404  else if (configuration == AliCFTaskVertexingHF::kCheetah){
405  //arrays for the number of bins in each dimension
406  const Int_t nvar = 8;
407 
408  const UInt_t ipTFast = 0;
409  const UInt_t iyFast = 1;
410  const UInt_t icTFast = 2;
411  const UInt_t iphiFast = 3;
412  const UInt_t izvtxFast = 4;
413  const UInt_t icentFast = 5;
414  const UInt_t ifakeFast = 6;
415  const UInt_t imultFast = 7;
416 
417  Int_t iBinFast[nvar];
418  iBinFast[ipTFast] = iBin[ipT];
419  iBinFast[iyFast] = iBin[iy];
420  iBinFast[icTFast] = iBin[icT];
421  iBinFast[iphiFast] = iBin[iphi];
422  iBinFast[izvtxFast] = iBin[izvtx];
423  iBinFast[icentFast] = iBin[icent];
424  iBinFast[ifakeFast] = iBin[ifake];
425  iBinFast[imultFast] = iBin[imult];
426 
427  container = new AliCFContainer(nameContainer,"container for tracks", nstep, nvar, iBinFast);
428  printf("pt\n");
429  container -> SetBinLimits(ipTFast, binLimpT);
430  printf("y\n");
431  container -> SetBinLimits(iyFast, binLimy);
432  printf("ct\n");
433  container -> SetBinLimits(icTFast, binLimcT);
434  printf("phi\n");
435  container -> SetBinLimits(iphiFast, binLimphi);
436  printf("zvtx\n");
437  container -> SetBinLimits(izvtxFast, binLimzvtx);
438  printf("centrality\n");
439  container -> SetBinLimits(icentFast, binLimcent);
440  printf("fake\n");
441  container -> SetBinLimits(ifakeFast, binLimfake);
442  printf("multiplicity\n");
443  if(isFineNtrkBin) container -> SetBinLimits(imultFast, binLimmultFine);
444  else container -> SetBinLimits(imultFast, binLimmult);
445 
446  container -> SetVarTitle(ipTFast, "pt");
447  container -> SetVarTitle(iyFast, "y");
448  container -> SetVarTitle(icTFast, "ct");
449  container -> SetVarTitle(iphiFast, "phi");
450  container -> SetVarTitle(izvtxFast, "zvtx");
451  container -> SetVarTitle(icentFast, "centrality");
452  container -> SetVarTitle(ifakeFast, "fake");
453  container -> SetVarTitle(imultFast, "multiplicity");
454  }
455  else if (configuration == AliCFTaskVertexingHF::kFalcon){
456  //arrays for the number of bins in each dimension
457  const Int_t nvar = 4;
458 
459  const UInt_t ipTSuperFast = 0;
460  const UInt_t iySuperFast = 1;
461  const UInt_t icentSuperFast = 2;
462  const UInt_t imultSuperFast = 3;
463 
464  Int_t iBinSuperFast[nvar];
465  iBinSuperFast[ipTSuperFast] = iBin[ipT];
466  iBinSuperFast[iySuperFast] = iBin[iy];
467  iBinSuperFast[icentSuperFast] = iBin[icent];
468  iBinSuperFast[imultSuperFast] = iBin[imult];
469 
470  container = new AliCFContainer(nameContainer,"container for tracks", nstep, nvar, iBinSuperFast);
471  printf("pt\n");
472  container -> SetBinLimits(ipTSuperFast, binLimpT);
473  printf("y\n");
474  container -> SetBinLimits(iySuperFast, binLimy);
475  printf("centrality\n");
476  container -> SetBinLimits(icentSuperFast, binLimcent);
477  printf("multiplicity\n");
478  if(isFineNtrkBin) container -> SetBinLimits(imultSuperFast, binLimmultFine);
479  else container -> SetBinLimits(imultSuperFast, binLimmult);
480 
481  container -> SetVarTitle(ipTSuperFast, "pt");
482  container -> SetVarTitle(iySuperFast, "y");
483  container -> SetVarTitle(icentSuperFast, "centrality");
484  container -> SetVarTitle(imultSuperFast, "multiplicity");
485  }
486 
487  container -> SetStepTitle(0, "MCLimAcc");
488  container -> SetStepTitle(1, "MC");
489  container -> SetStepTitle(2, "MCAcc");
490  container -> SetStepTitle(3, "RecoVertex");
491  container -> SetStepTitle(4, "RecoRefit");
492  container -> SetStepTitle(5, "Reco");
493  container -> SetStepTitle(6, "RecoAcc");
494  container -> SetStepTitle(7, "RecoITSCluster");
495  container -> SetStepTitle(8, "RecoCuts");
496  container -> SetStepTitle(9, "RecoPID");
497 
498  //return container;
499 
500  //CREATE THE CUTS -----------------------------------------------
501 
502  // Gen-Level kinematic cuts
503  AliCFTrackKineCuts *mcKineCuts = new AliCFTrackKineCuts("mcKineCuts","MC-level kinematic cuts");
504 
505  //Particle-Level cuts:
506  AliCFParticleGenCuts* mcGenCuts = new AliCFParticleGenCuts("mcGenCuts","MC particle generation cuts");
507  Bool_t useAbsolute = kTRUE;
508  if (isSign != 2){
509  useAbsolute = kFALSE;
510  }
511  mcGenCuts->SetRequirePdgCode(pdgCode, useAbsolute); // kTRUE set in order to include D0_bar
512  mcGenCuts->SetAODMC(1); //special flag for reading MC in AOD tree (important)
513 
514  // Acceptance cuts:
515  AliCFAcceptanceCuts* accCuts = new AliCFAcceptanceCuts("accCuts", "Acceptance cuts");
516  AliCFTrackKineCuts *kineAccCuts = new AliCFTrackKineCuts("kineAccCuts","Kine-Acceptance cuts");
517  kineAccCuts->SetPtRange(ptmin, ptmax);
518  kineAccCuts->SetEtaRange(etamin, etamax);
519 
520  // Rec-Level kinematic cuts
521  AliCFTrackKineCuts *recKineCuts = new AliCFTrackKineCuts("recKineCuts", "rec-level kine cuts");
522 
523  AliCFTrackQualityCuts *recQualityCuts = new AliCFTrackQualityCuts("recQualityCuts", "rec-level quality cuts");
524 
525  AliCFTrackIsPrimaryCuts *recIsPrimaryCuts = new AliCFTrackIsPrimaryCuts("recIsPrimaryCuts", "rec-level isPrimary cuts");
526 
527  printf("CREATE MC KINE CUTS\n");
528  TObjArray* mcList = new TObjArray(0) ;
529  mcList->AddLast(mcKineCuts);
530  mcList->AddLast(mcGenCuts);
531 
532  printf("CREATE ACCEPTANCE CUTS\n");
533  TObjArray* accList = new TObjArray(0) ;
534  accList->AddLast(kineAccCuts);
535 
536  printf("CREATE RECONSTRUCTION CUTS\n");
537  TObjArray* recList = new TObjArray(0) ; // not used!!
538  recList->AddLast(recKineCuts);
539  recList->AddLast(recQualityCuts);
540  recList->AddLast(recIsPrimaryCuts);
541 
542  TObjArray* emptyList = new TObjArray(0);
543 
544  //CREATE THE INTERFACE TO CORRECTION FRAMEWORK USED IN THE TASK
545  printf("CREATE INTERFACE AND CUTS\n");
546  AliCFManager* man = new AliCFManager() ;
547  man->SetParticleContainer(container);
548  man->SetParticleCutsList(0 , mcList); // MC, Limited Acceptance
549  man->SetParticleCutsList(1 , mcList); // MC
550  man->SetParticleCutsList(2 , accList); // Acceptance
551  man->SetParticleCutsList(3 , emptyList); // Vertex
552  man->SetParticleCutsList(4 , emptyList); // Refit
553  man->SetParticleCutsList(5 , emptyList); // AOD
554  man->SetParticleCutsList(6 , emptyList); // AOD in Acceptance
555  man->SetParticleCutsList(7 , emptyList); // AOD with required n. of ITS clusters
556  man->SetParticleCutsList(8 , emptyList); // AOD Reco (PPR cuts implemented in Task)
557  man->SetParticleCutsList(9 , emptyList); // AOD Reco PID
558 
559  // Get the pointer to the existing analysis manager via the static access method.
560  //==============================================================================
561  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
562  if (!mgr) {
563  ::Error("AddTaskCompareHF", "No analysis manager to connect to.");
564  return NULL;
565  }
566  //CREATE THE TASK
567  printf("CREATE TASK\n");
568 
569  // create the task
570  AliCFTaskVertexingHF *task = new AliCFTaskVertexingHF("AliCFTaskVertexingHF", cutsLcTMVA);
571  task->SetConfiguration(configuration);
572  task->SetFillFromGenerated(kFALSE);
573  task->SetCFManager(man); //here is set the CF manager
574  task->SetDecayChannel(22);
576  task->SetUseAdditionalCuts(kTRUE);
577  task->SetUseCutsForTMVA(kFALSE);
578  task->SetUseFlatPtWeight(useFlatPtWeight);
579  task->SetUseWeight(useWeight);
580  task->SetUseZWeight(useZWeight);
581  task->SetSign(isSign);
582  task->SetCentralitySelection(kFALSE);
583  task->SetFakeSelection(0);
584  // task->SetRejectCandidateIfNotFromQuark(kTRUE); // put to false if you want to keep HIJING D0!!
585  task->SetRejectCandidateIfNotFromQuark(kFALSE); // put to false if you want to keep HIJING D0!!
586  task->SetUseMCVertex(kFALSE); // put to true if you want to do studies on pp
587  //task->SetPtWeightsFromDataPbPb276overLHC12a17a();
588  task->SetCutOnMomConservation(0.0000005);
589 
590  if (isKeepDfromB && !isKeepDfromBOnly) task->SetDselection(2);
591  if (isKeepDfromB && isKeepDfromBOnly) task->SetDselection(1);
592 
593  TF1* funcWeight = 0x0;
594  if (task->GetUseWeight()) {
595  funcWeight = (TF1*)fileCuts->Get("funcWeight");
596  if (funcWeight == 0x0){
597  Printf("FONLL Weights will be used");
598  }
599  else {
600  task->SetWeightFunction(funcWeight);
601  Printf("User-defined Weights will be used. The function being:");
602  task->GetWeightFunction()->Print();
603  }
604  }
605 
606  if (useNchWeight || useNtrkWeight){
607  TH1F *hNchPrimaries;
608  TH1F *hNchMeasured;
609  if (isPPbData) hNchPrimaries = (TH1F*)fileCuts->Get("hNtrUnCorrEvWithCandWeight");
610  else hNchPrimaries = (TH1F*)fileCuts->Get("hGenPrimaryParticlesInelGt0");
611  hNchMeasured = (TH1F*)fileCuts->Get("hNchMeasured");
612  if(hNchPrimaries) {
613  task->SetUseNchWeight(kTRUE);
614  task->SetMCNchHisto(hNchPrimaries);
615  if(isPPbData) task->SetUseNchTrackletsWeight();
616  } else {
617  AliFatal("Histogram for multiplicity weights not found");
618  return 0x0;
619  }
620  if(hNchMeasured) task->SetMeasuredNchHisto(hNchMeasured);
621  if(useNtrkWeight) task->SetUseNchTrackletsWeight();
622  }
623 
624  task->SetMultiplicityEstimator(multiplicityEstimator);
625  if(estimatorFilename.EqualTo("") ) {
626  printf("Estimator file not provided, multiplicity corrected histograms will not be filled\n");
627  task->SetUseZvtxCorrectedNtrkEstimator(kFALSE);
628  } else{
629  TFile* fileEstimator=TFile::Open(estimatorFilename.Data());
630  if(!fileEstimator) {
631  AliFatal("File with multiplicity estimator not found");
632  return;
633  }
635  task->SetReferenceMultiplcity(refMult);
636 
637  if (isPPbData) { //load multiplicity estimators for pPb
638  task->SetIsPPbData(kTRUE);
639  const Char_t* periodNames[2] = {"LHC13b", "LHC13c"};
640  TProfile *multEstimatorAvg[2];
641  for (Int_t ip=0; ip < 2; ip++) {
642  multEstimatorAvg[ip] = (TProfile*)(fileEstimator->Get(Form("SPDmult10_%s",periodNames[ip]))->Clone(Form("SPDmult10_%s_clone",periodNames[ip])));
643  if (!multEstimatorAvg[ip]) {
644  AliFatal(Form("Multiplicity estimator for %s not found! Please check your estimator file",periodNames[ip]));
645  return;
646  }
647  }
648  task->SetMultiplVsZProfileLHC13b(multEstimatorAvg[0]);
649  task->SetMultiplVsZProfileLHC13c(multEstimatorAvg[1]);
650 
651  } else { //load multiplicity estimators for pp
652  const Char_t* periodNames[4] = {"LHC10b", "LHC10c", "LHC10d", "LHC10e"};
653  TProfile* multEstimatorAvg[4];
654 
655  for(Int_t ip=0; ip<4; ip++) {
656  multEstimatorAvg[ip] = (TProfile*)(fileEstimator->Get(Form("SPDmult10_%s",periodNames[ip]))->Clone(Form("SPDmult10_%s_clone",periodNames[ip])));
657  if (!multEstimatorAvg[ip]) {
658  AliFatal(Form("Multiplicity estimator for %s not found! Please check your estimator file",periodNames[ip]));
659  return;
660  }
661  }
662  task->SetMultiplVsZProfileLHC10b(multEstimatorAvg[0]);
663  task->SetMultiplVsZProfileLHC10c(multEstimatorAvg[1]);
664  task->SetMultiplVsZProfileLHC10d(multEstimatorAvg[2]);
665  task->SetMultiplVsZProfileLHC10e(multEstimatorAvg[3]);
666  }
667  }
668  Printf("***************** CONTAINER SETTINGS *****************");
669  Printf("decay channel = %d", (Int_t)task->GetDecayChannel());
670  Printf("FillFromGenerated = %d", (Int_t)task->GetFillFromGenerated());
671  Printf("Dselection = %d", (Int_t)task->GetDselection());
672  Printf("UseWeight = %d", (Int_t)task->GetUseWeight());
673  if (task->GetUseWeight()) {
674  if(funcWeight) Printf("User-defined Weight function");
675  else Printf("FONLL will be used for the weights");
676  }
677 
678  Printf("Use Nch weight = %d", (Int_t)task->GetUseNchWeight());
679  Printf("Sign = %d", (Int_t)task->GetSign());
680  Printf("Centrality selection = %d", (Int_t)task->GetCentralitySelection());
681  Printf("Fake selection = %d", (Int_t)task->GetFakeSelection());
682  Printf("RejectCandidateIfNotFromQuark selection = %d", (Int_t)task->GetRejectCandidateIfNotFromQuark());
683  Printf("UseMCVertex selection = %d", (Int_t)task->GetUseMCVertex());
684  Printf("UseCascadeTask = %d", (Int_t)task->GetUseCascadeTaskForLctoV0bachelor());
685  Printf("***************END CONTAINER SETTINGS *****************\n");
686 
687 
688  //-----------------------------------------------------------//
689  // create correlation matrix for unfolding - only eta-pt //
690  //-----------------------------------------------------------//
691 
692  Bool_t AcceptanceUnf = kTRUE; // unfold at acceptance level, otherwise PPR
693 
694  Int_t thnDim[4];
695 
696  //first half : reconstructed
697  //second half : MC
698 
699  thnDim[0] = iBin[0];
700  thnDim[2] = iBin[0];
701  thnDim[1] = iBin[1];
702  thnDim[3] = iBin[1];
703 
704  TString nameCorr="";
705  if(!isKeepDfromB) {
706  nameCorr="CFHFcorr0";
707  }
708  else if(isKeepDfromBOnly){
709  nameCorr= "CFHFcorr0KeepDfromBOnly";
710  }
711  else {
712  nameCorr="CFHFcorr0allD";
713 
714  }
715  nameCorr += suffix;
716 
717  THnSparseD* correlation = new THnSparseD(nameCorr,"THnSparse with correlations",4,thnDim);
718  Double_t** binEdges = new Double_t[2];
719 
720  // set bin limits
721 
722  binEdges[0]= binLimpT;
723  binEdges[1]= binLimy;
724 
725  correlation->SetBinEdges(0,binEdges[0]);
726  correlation->SetBinEdges(2,binEdges[0]);
727 
728  correlation->SetBinEdges(1,binEdges[1]);
729  correlation->SetBinEdges(3,binEdges[1]);
730 
731  correlation->Sumw2();
732 
733  // correlation matrix ready
734  //------------------------------------------------//
735 
736  task->SetCorrelationMatrix(correlation); // correlation matrix for unfolding
737 
738  // Create and connect containers for input/output
739 
740  // ------ input data ------
741  AliAnalysisDataContainer *cinput0 = mgr->GetCommonInputContainer();
742 
743  // ----- output data -----
744 
745  TString outputfile = AliAnalysisManager::GetCommonFileName();
746  TString output1name="", output2name="", output3name="",output4name="", output5name="";
747  output2name=nameContainer;
748  output3name=nameCorr;
749  output4name= "Cuts";
750  output5name= "coutProfDst";
751  if(!isKeepDfromB) {
752  outputfile += ":PWG3_D2H_CFtaskLctoK0SpCascade";
753  output1name="CFHFchist0";
754  output3name+="_cOnly";
755  output4name+="_cOnly";
756  output5name+="_cOnly";
757  }
758  else if(isKeepDfromBOnly){
759  outputfile += ":PWG3_D2H_CFtaskLctoK0SpCascadeKeepDfromBOnly";
760  output1name="CFHFchist0DfromB";
761  output3name+="_bOnly";
762  output4name+="_bOnly";
763  output5name+="_bOnly";
764  }
765  else{
766  outputfile += ":PWG3_D2H_CFtaskLctoK0SpCascadeKeepDfromB";
767  output1name="CFHFchist0allD";
768  output3name+="_all";
769  output4name+="_all";
770  output5name+="_all";
771  }
772 
773  outputfile += suffix;
774  output1name += suffix;
775  output4name += suffix;
776  output5name += suffix;
777 
778  //now comes user's output objects :
779  // output TH1I for event counting
780  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer(output1name, TH1I::Class(),AliAnalysisManager::kOutputContainer,outputfile.Data());
781  // output Correction Framework Container (for acceptance & efficiency calculations)
782  AliAnalysisDataContainer *coutput2 = mgr->CreateContainer(output2name, AliCFContainer::Class(),AliAnalysisManager::kOutputContainer,outputfile.Data());
783  // Unfolding - correlation matrix
784  AliAnalysisDataContainer *coutput3 = mgr->CreateContainer(output3name, THnSparseD::Class(),AliAnalysisManager::kOutputContainer,outputfile.Data());
785  // cuts
786  AliAnalysisDataContainer *coutput4 = mgr->CreateContainer(output4name, AliRDHFCuts::Class(),AliAnalysisManager::kOutputContainer, outputfile.Data());
787  // estimators list
788  AliAnalysisDataContainer *coutput5 = mgr->CreateContainer(output5name, TList::Class(),AliAnalysisManager::kOutputContainer, outputfile.Data());
789 
790  mgr->AddTask(task);
791 
792  mgr->ConnectInput(task,0,mgr->GetCommonInputContainer());
793  mgr->ConnectOutput(task,1,coutput1);
794  mgr->ConnectOutput(task,2,coutput2);
795  mgr->ConnectOutput(task,3,coutput3);
796  mgr->ConnectOutput(task,4,coutput4);
797  mgr->ConnectOutput(task,5,coutput5);
798  return task;
799 
800 }
const Double_t cTmin
void SetCutOnMomConservation(Float_t cut)
void SetWeightFunction(TF1 *func)
void SetRejectCandidateIfNotFromQuark(Bool_t opt)
double Double_t
Definition: External.C:58
void SetMultiplVsZProfileLHC10e(TProfile *hprof)
const Float_t centmax_10_60
const Float_t multmin_20_50
const Double_t ymax
void SetCFManager(AliCFManager *io)
CORRECTION FRAMEWORK RELATED FUNCTIONS.
const Double_t cosmax
const Float_t multmin_100_400
const Float_t centmin_10_60
const Float_t centmin_0_10
const Int_t minITSClusters
const Double_t dcamax
void SetDecayChannel(Int_t decayChannel)
TSystem * gSystem
char Char_t
Definition: External.C:18
void SetFillFromGenerated(Bool_t flag)
get corr manager
void SetUseNchTrackletsWeight(Bool_t useWeight=kTRUE)
const Double_t cosmaxTS
void SetUseMCVertex(Bool_t opt)
const Double_t cTmax
void SetUseAdditionalCuts(Bool_t flag)
const Double_t cosmin
const Float_t multmax_80_100
const Double_t phimin
const Float_t cosminXY
const Double_t d0xd0max
const Int_t mintrackrefsITS
const Float_t multmax_0_20
int Int_t
Definition: External.C:63
const Float_t multmin_50_80
void SetMeasuredNchHisto(TH1F *h)
unsigned int UInt_t
Definition: External.C:33
fast configuration, only a subset of variables
float Float_t
Definition: External.C:68
void SetIsPPbData(Bool_t flag)
void SetCentralitySelection(Bool_t centSelec=kTRUE)
slow configuration, all variables
const Double_t ptmax
const Float_t centmax_60_100
void SetUseCutsForTMVA(Bool_t useCutsForTMVA)
void SetReferenceMultiplcity(Double_t rmu)
void SetUseWeight(Bool_t useWeight)
void SetUseZvtxCorrectedNtrkEstimator(Bool_t flag)
const Double_t ptmin
const Float_t multmin_0_20
const Float_t multmin_80_100
void SetConfiguration(Int_t configuration)
void SetDselection(UShort_t originDselection)
const Double_t cosminTS
const Float_t cosmaxXY
const Float_t normDecLXYmin
const Float_t multmax_20_50
const Float_t normDecLXYmax
Float_t * GetPtBinLimits() const
Definition: AliRDHFCuts.h:247
AliCFTaskVertexingHF * AddTaskCFVertexingHFLctoV0bachelorTMVA(const char *cutFile="CutsLc2pK0STMVA_20140311.root", TString cutObjectName="LctoV0AnalysisCuts", TString suffix="TMVA", Int_t configuration=AliCFTaskVertexingHF::kCheetah, Bool_t isKeepDfromB=kTRUE, Bool_t isKeepDfromBOnly=kFALSE, Int_t pdgCode=4122, Char_t isSign=2, Bool_t useWeight=kFALSE, Bool_t useFlatPtWeight=kFALSE, Bool_t useZWeight=kFALSE, Bool_t useNchWeight=kFALSE, Bool_t useNtrkWeight=kFALSE, TString estimatorFilename="", Int_t multiplicityEstimator=AliCFTaskVertexingHF::kNtrk10, Bool_t isPPData=kFALSE, Bool_t isPPbData=kFALSE, Double_t refMult=9.26, Bool_t isFineNtrkBin=kFALSE)
TF1 * GetWeightFunction() const
void SetUseNchWeight(Bool_t useWeight)
void SetUseFlatPtWeight(Bool_t useWeight)
const Float_t multmax_50_80
const Int_t mintrackrefsTPC
void SetCorrelationMatrix(THnSparse *h)
UNFOLDING.
void SetMultiplVsZProfileLHC10b(TProfile *hprof)
const Double_t etamin
const Double_t dcamin
const Float_t multmax_100_400
void SetMultiplVsZProfileLHC10d(TProfile *hprof)
Int_t GetNPtBins() const
Definition: AliRDHFCuts.h:248
void SetSign(Char_t isSign)
Bool_t GetUseNchWeight() const
const Double_t ymin
Bool_t GetUseWeight() const
bool Bool_t
Definition: External.C:53
const Int_t minclustersTPC
void SetMultiplicityEstimator(Int_t value)
Bool_t GetUseCascadeTaskForLctoV0bachelor() const
const Float_t centmin_60_100
void SetMultiplVsZProfileLHC13b(TProfile *hprof)
Bool_t GetFillFromGenerated() const
void SetMultiplVsZProfileLHC13c(TProfile *hprof)
const Double_t etamax
void SetFakeSelection(Int_t fakeSel=0)
void SetUseCascadeTaskForLctoV0bachelor(Bool_t useCascadeTaskForLctoV0bachelor)
void SetUseZWeight(Bool_t useWeight)
const Float_t centmax_0_10
void SetMultiplVsZProfileLHC10c(TProfile *hprof)
const Double_t d0xd0min