AliPhysics  5eaf189 (5eaf189)
AliRDHFCutsB0toDStarPi.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-2010, ALICE Experiment at CERN, All rights reserved. *
3  * *
4  * Author: The ALICE Off-line Project. *
5  * Contributors are mentioned in the code where appropriate. *
6  * *
7  * Permission to use, copy, modify and distribute this software and its *
8  * documentation strictly for non-commercial purposes is hereby granted *
9  * without fee, provided that the above copyright notice appears in all *
10  * copies and that both the copyright notice and this permission notice *
11  * appear in the supporting documentation. The authors make no claims *
12  * about the suitability of this software for any purpose. It is *
13  * provided "as is" without express or implied warranty. *
14  **************************************************************************/
15 
16 /* $Id: AliRDHFCutsB0toDStarPi.cxx $ */
17 
19 //
20 // Class for cuts on AOD reconstructed B0->DStarPi->D0PiPi->KPiPiPi
21 //
22 // Author: Lennart van Doremalen, l.v.r.vandoremalen@uu.nl
23 //
24 // Based on work by A.Grelli, alessandro.grelli@uu.nl
25 // PID method implemented by Y.Wang, yifei@physi.uni-heidelberg.de
26 //
28 
29 #include <TDatabasePDG.h>
30 #include <Riostream.h>
33 #include "AliRDHFCutsD0toKpi.h"
34 #include "AliRDHFCutsB0toDStarPi.h"
35 #include "AliAODTrack.h"
36 #include "AliESDtrack.h"
37 #include "AliAODPid.h"
38 #include "AliTPCPIDResponse.h"
39 #include "AliAODVertex.h"
40 #include "AliESDVertex.h"
41 
42 using std::cout;
43 using std::endl;
44 
46 ClassImp(AliRDHFCutsB0toDStarPi);
48 
49 
50 //--------------------------------------------------------------------------
52  AliRDHFCuts(name),
53  fMaxPtPid(9999.),
54  fTPCflag(999.),
55  fCircRadius(0.),
56  fIsCutUsed(0),
57  fCutsRDD0forD0ptbin(0),
58  fnPtBinsD0forD0ptbin(1),
59  fnPtBinLimitsD0forD0ptbin(1),
60  fPtBinLimitsD0forD0ptbin(0),
61  fIsUpperCutD0forD0ptbin(0),
62  fIsCutUsedD0forD0ptbin(0),
63  fVarNamesD0forD0ptbin(0),
64  fCutsRDD0forDStarptbin(0),
65  fnPtBinsD0forDStarptbin(1),
66  fnPtBinLimitsD0forDStarptbin(1),
67  fPtBinLimitsD0forDStarptbin(0),
68  fIsUpperCutD0forDStarptbin(0),
69  fIsCutUsedD0forDStarptbin(0),
70  fVarNamesD0forDStarptbin(0),
71  fCutsRDDStarforDStarptbin(0),
72  fnPtBinsDStarforDStarptbin(1),
73  fnPtBinLimitsDStarforDStarptbin(1),
74  fPtBinLimitsDStarforDStarptbin(0),
75  fIsUpperCutDStarforDStarptbin(0),
76  fIsCutUsedDStarforDStarptbin(0),
77  fVarNamesDStarforDStarptbin(0)
78 {
79  //
80  // Default Constructor
81  //
82 
83  // Main cut setup as function of B0 pt bins
84  const Int_t nvars=85;
85  SetNVars(nvars);
86 
87  TString varNames[nvars];
88  Int_t iterator = 0;
89 
90  //D0 cut variables
91  varNames[iterator++]= /*-00-*/ "inv. mass width[GeV]";
92  varNames[iterator++]= /*-01-*/ "delta mass width [GeV]"; //not used for D0
93  varNames[iterator++]= /*-02-*/ "pointing angle [Cos(theta)]";
94  varNames[iterator++]= /*-03-*/ "dca [cm]";
95  varNames[iterator++]= /*-04-*/ "Pt D0 [GeV/c]";
96  varNames[iterator++]= /*-05-*/ "Pt first daughter [GeV/c]";
97  varNames[iterator++]= /*-06-*/ "Pt second daughter [GeV/c]";
98  varNames[iterator++]= /*-07-*/ "d0 D0 [cm]";
99  varNames[iterator++]= /*-08-*/ "d0 first daughter [cm]";
100  varNames[iterator++]= /*-09-*/ "d0 second daughter [cm]";
101  varNames[iterator++]= /*-10-*/ "d0d0 [cm^2]";
102  varNames[iterator++]= /*-11-*/ "d0d0 XY [cm^2]";
103 
104  varNames[iterator++]= /*-12-*/ "angle between both daughters";
105  varNames[iterator++]= /*-13-*/ "angle mother with first daughter";
106  varNames[iterator++]= /*-14-*/ "angle mother with second daughter";
107  varNames[iterator++]= /*-15-*/ "cosThetaStar";
108  varNames[iterator++]= /*-16-*/ "vertexDistance";
109  varNames[iterator++]= /*-17-*/ "pseudoProperDecayTime";
110  varNames[iterator++]= /*-18-*/ "DecayTime";
111  varNames[iterator++]= /*-19-*/ "normalizedDecayTime";
112  varNames[iterator++]= /*-20-*/ "normDecayLength";
113  varNames[iterator++]= /*-21-*/ "topomatic first daughter";
114  varNames[iterator++]= /*-22-*/ "topomatic second daughter";
115  varNames[iterator++]= /*-23-*/ "topomatic max";
116  varNames[iterator++]= /*-24-*/ "topomatic min";
117 
118 
119  varNames[iterator++]= /*-25-*/ "pointingAngleToDStar";
120  varNames[iterator++]= /*-26-*/ "d0MotherToDStar";
121  varNames[iterator++]= /*-27-*/ "d0FirstDaughterToDStar";
122  varNames[iterator++]= /*-28-*/ "d0SecondDaughterToDStar";
123  varNames[iterator++]= /*-29-*/ "impactProductToDStar";
124  varNames[iterator++]= /*-30-*/ "impactProductXYToDStar";
125  varNames[iterator++]= /*-31-*/ "normDecayLengthToDStar";
126  varNames[iterator++]= /*-32-*/ "pseudoProperDecayTimeToDStar";
127  varNames[iterator++]= /*-33-*/ "DecayTimeToDStar";
128  varNames[iterator++]= /*-34-*/ "normalizedDecayTimeToDStar";
129 
130 
131  //DStar cut variables
132  varNames[iterator++]= /*-35-*/ "inv. mass width[GeV]";
133  varNames[iterator++]= /*-36-*/ "delta mass width [GeV]";
134  varNames[iterator++]= /*-37-*/ "pointing angle [Cos(theta)]";
135  varNames[iterator++]= /*-38-*/ "dca [cm]";
136  varNames[iterator++]= /*-39-*/ "Pt DStar [GeV/c]";
137  varNames[iterator++]= /*-40-*/ "Pt D0 [GeV/c]";
138  varNames[iterator++]= /*-41-*/ "Pt Pion [GeV/c]";
139  varNames[iterator++]= /*-42-*/ "d0 DStar [cm]";
140  varNames[iterator++]= /*-43-*/ "d0 D0 [cm]";
141  varNames[iterator++]= /*-44-*/ "d0 Pion [cm]";
142  varNames[iterator++]= /*-45-*/ "d0d0 [cm^2]";
143  varNames[iterator++]= /*-46-*/ "d0d0 XY [cm^2]";
144 
145  varNames[iterator++]= /*-47-*/ "angle between both daughters";
146  varNames[iterator++]= /*-48-*/ "angle mother with first daughter";
147  varNames[iterator++]= /*-49-*/ "angle mother with second daughter";
148  varNames[iterator++]= /*-50-*/ "cosThetaStar";
149  varNames[iterator++]= /*-51-*/ "vertexDistance";
150  varNames[iterator++]= /*-52-*/ "pseudoProperDecayTime";
151  varNames[iterator++]= /*-53-*/ "DecayTime";
152  varNames[iterator++]= /*-54-*/ "normalizedDecayTime";
153  varNames[iterator++]= /*-55-*/ "normDecayLength";
154  varNames[iterator++]= /*-56-*/ "topomatic first daughter";
155  varNames[iterator++]= /*-57-*/ "topomatic second daughter";
156  varNames[iterator++]= /*-58-*/ "topomatic max";
157  varNames[iterator++]= /*-59-*/ "topomatic min";
158 
159 
160  //B0 cut variables
161  varNames[iterator++]= /*-60-*/ "inv. mass width[GeV]";
162  varNames[iterator++]= /*-61-*/ "delta mass width [GeV]";
163  varNames[iterator++]= /*-62-*/ "pointing angle [Cos(theta)]";
164  varNames[iterator++]= /*-63-*/ "dca [cm]";
165  varNames[iterator++]= /*-64-*/ "Pt B0 [GeV/c]";
166  varNames[iterator++]= /*-65-*/ "Pt DStar [GeV/c]";
167  varNames[iterator++]= /*-66-*/ "Pt Pion [GeV/c]";
168  varNames[iterator++]= /*-67-*/ "d0 B0 [cm]";
169  varNames[iterator++]= /*-68-*/ "d0 DStar [cm]";
170  varNames[iterator++]= /*-69-*/ "d0 Pion [cm]";
171  varNames[iterator++]= /*-70-*/ "d0d0 [cm^2]";
172  varNames[iterator++]= /*-71-*/ "d0d0 XY [cm^2]";
173 
174  varNames[iterator++]= /*-72-*/ "angle between both daughters";
175  varNames[iterator++]= /*-73-*/ "angle mother with first daughter";
176  varNames[iterator++]= /*-74-*/ "angle mother with second daughter";
177  varNames[iterator++]= /*-75-*/ "cosThetaStar";
178  varNames[iterator++]= /*-76-*/ "vertexDistance";
179  varNames[iterator++]= /*-77-*/ "pseudoProperDecayTime";
180  varNames[iterator++]= /*-78-*/ "DecayTime";
181  varNames[iterator++]= /*-79-*/ "normalizedDecayTime";
182  varNames[iterator++]= /*-80-*/ "normDecayLength";
183  varNames[iterator++]= /*-81-*/ "topomatic first daughter";
184  varNames[iterator++]= /*-82-*/ "topomatic second daughter";
185  varNames[iterator++]= /*-83-*/ "topomatic max";
186  varNames[iterator++]= /*-84-*/ "topomatic min";
187 
188  Bool_t isUpperCut[nvars]={0};
189 
190  SetVarNames(nvars,varNames,isUpperCut);
191 
192  Float_t limits[2]={0,999999999.};
193  SetPtBins(2,limits);
194 
195 
196  //
197  // Initialization of D0 cuts for D0 pt bins
198  //
199 
200  const Int_t nvarsD0forD0ptbin=25;
201  SetNVarsD0forD0ptbin(nvarsD0forD0ptbin);
202 
203  TString varNamesD0forD0ptbin[nvarsD0forD0ptbin];
204  iterator = 0;
205 
206  //D0 cut variables
207  varNamesD0forD0ptbin[iterator++]= /*-00-*/ "inv. mass width[GeV]";
208  varNamesD0forD0ptbin[iterator++]= /*-01-*/ "delta mass width [GeV]"; //not used for D0
209  varNamesD0forD0ptbin[iterator++]= /*-02-*/ "pointing angle [Cos(theta)]";
210  varNamesD0forD0ptbin[iterator++]= /*-03-*/ "dca [cm]";
211  varNamesD0forD0ptbin[iterator++]= /*-04-*/ "Pt D0 [GeV/c]";
212  varNamesD0forD0ptbin[iterator++]= /*-05-*/ "Pt first daughter [GeV/c]";
213  varNamesD0forD0ptbin[iterator++]= /*-06-*/ "Pt second daughter [GeV/c]";
214  varNamesD0forD0ptbin[iterator++]= /*-07-*/ "d0 D0 [cm]";
215  varNamesD0forD0ptbin[iterator++]= /*-08-*/ "d0 first daughter [cm]";
216  varNamesD0forD0ptbin[iterator++]= /*-09-*/ "d0 second daughter [cm]";
217  varNamesD0forD0ptbin[iterator++]= /*-10-*/ "d0d0 [cm^2]";
218  varNamesD0forD0ptbin[iterator++]= /*-11-*/ "d0d0 XY [cm^2]";
219 
220  varNamesD0forD0ptbin[iterator++]= /*-12-*/ "angle between both daughters";
221  varNamesD0forD0ptbin[iterator++]= /*-13-*/ "angle mother with first daughter";
222  varNamesD0forD0ptbin[iterator++]= /*-14-*/ "angle mother with second daughter";
223  varNamesD0forD0ptbin[iterator++]= /*-15-*/ "cosThetaStar";
224  varNamesD0forD0ptbin[iterator++]= /*-16-*/ "vertexDistance";
225  varNamesD0forD0ptbin[iterator++]= /*-17-*/ "pseudoProperDecayTime";
226  varNamesD0forD0ptbin[iterator++]= /*-18-*/ "DecayTime";
227  varNamesD0forD0ptbin[iterator++]= /*-19-*/ "normalizedDecayTime";
228  varNamesD0forD0ptbin[iterator++]= /*-20-*/ "normDecayLength";
229  varNamesD0forD0ptbin[iterator++]= /*-21-*/ "topomatic first daughter";
230  varNamesD0forD0ptbin[iterator++]= /*-22-*/ "topomatic second daughter";
231  varNamesD0forD0ptbin[iterator++]= /*-23-*/ "topomatic max";
232  varNamesD0forD0ptbin[iterator++]= /*-24-*/ "topomatic min";
233 
234  Bool_t isUpperCutD0forD0ptbin[nvarsD0forD0ptbin]={0};
235 
236  SetVarNamesD0forD0ptbin(nvarsD0forD0ptbin,varNamesD0forD0ptbin,isUpperCutD0forD0ptbin);
237 
238  Float_t limitsD0forD0ptbin[2]={0,999999999.};
239  SetPtBinsD0forD0ptbin(2,limitsD0forD0ptbin);
240 
241 
242  //
243  // Initialization of D0 cuts for DStar pt bins
244  //
245 
246  const Int_t nvarsD0forDStarptbin=35;
247  SetNVarsD0forDStarptbin(nvarsD0forDStarptbin);
248 
249  TString varNamesD0forDStarptbin[nvarsD0forDStarptbin];
250  iterator = 0;
251 
252  //D0 cut variables
253  varNamesD0forDStarptbin[iterator++]= /*-00-*/ "inv. mass width[GeV]";
254  varNamesD0forDStarptbin[iterator++]= /*-01-*/ "delta mass width [GeV]"; //not used for D0
255  varNamesD0forDStarptbin[iterator++]= /*-02-*/ "pointing angle [Cos(theta)]";
256  varNamesD0forDStarptbin[iterator++]= /*-03-*/ "dca [cm]";
257  varNamesD0forDStarptbin[iterator++]= /*-04-*/ "Pt D0 [GeV/c]";
258  varNamesD0forDStarptbin[iterator++]= /*-05-*/ "Pt first daughter [GeV/c]";
259  varNamesD0forDStarptbin[iterator++]= /*-06-*/ "Pt second daughter [GeV/c]";
260  varNamesD0forDStarptbin[iterator++]= /*-07-*/ "d0 D0 [cm]";
261  varNamesD0forDStarptbin[iterator++]= /*-08-*/ "d0 first daughter [cm]";
262  varNamesD0forDStarptbin[iterator++]= /*-09-*/ "d0 second daughter [cm]";
263  varNamesD0forDStarptbin[iterator++]= /*-10-*/ "d0d0 [cm^2]";
264  varNamesD0forDStarptbin[iterator++]= /*-11-*/ "d0d0 XY [cm^2]";
265 
266  varNamesD0forDStarptbin[iterator++]= /*-12-*/ "angle between both daughters";
267  varNamesD0forDStarptbin[iterator++]= /*-13-*/ "angle mother with first daughter";
268  varNamesD0forDStarptbin[iterator++]= /*-14-*/ "angle mother with second daughter";
269  varNamesD0forDStarptbin[iterator++]= /*-15-*/ "cosThetaStar";
270  varNamesD0forDStarptbin[iterator++]= /*-16-*/ "vertexDistance";
271  varNamesD0forDStarptbin[iterator++]= /*-17-*/ "pseudoProperDecayTime";
272  varNamesD0forDStarptbin[iterator++]= /*-18-*/ "DecayTime";
273  varNamesD0forDStarptbin[iterator++]= /*-19-*/ "normalizedDecayTime";
274  varNamesD0forDStarptbin[iterator++]= /*-20-*/ "normDecayLength";
275  varNamesD0forDStarptbin[iterator++]= /*-21-*/ "topomatic first daughter";
276  varNamesD0forDStarptbin[iterator++]= /*-22-*/ "topomatic second daughter";
277  varNamesD0forDStarptbin[iterator++]= /*-23-*/ "topomatic max";
278  varNamesD0forDStarptbin[iterator++]= /*-24-*/ "topomatic min";
279 
280  varNamesD0forDStarptbin[iterator++]= /*-25-*/ "pointingAngleToDStar";
281  varNamesD0forDStarptbin[iterator++]= /*-26-*/ "d0MotherToDStar";
282  varNamesD0forDStarptbin[iterator++]= /*-27-*/ "d0FirstDaughterToDStar";
283  varNamesD0forDStarptbin[iterator++]= /*-28-*/ "d0SecondDaughterToDStar";
284  varNamesD0forDStarptbin[iterator++]= /*-29-*/ "impactProductToDStar";
285  varNamesD0forDStarptbin[iterator++]= /*-30-*/ "impactProductXYToDStar";
286  varNamesD0forDStarptbin[iterator++]= /*-31-*/ "normDecayLengthToDStar";
287  varNamesD0forDStarptbin[iterator++]= /*-32-*/ "pseudoProperDecayTimeToDStar";
288  varNamesD0forDStarptbin[iterator++]= /*-33-*/ "DecayTimeToDStar";
289  varNamesD0forDStarptbin[iterator++]= /*-34-*/ "normalizedDecayTimeToDStar";
290 
291  Bool_t isUpperCutD0forDStarptbin[nvarsD0forDStarptbin]={0};
292 
293  SetVarNamesD0forDStarptbin(nvarsD0forDStarptbin,varNamesD0forDStarptbin,isUpperCutD0forDStarptbin);
294 
295  Float_t limitsD0forDStarptbin[2]={0,999999999.};
296  SetPtBinsD0forDStarptbin(2,limitsD0forDStarptbin);
297 
298 
299  //
300  // Initialization of DStar cuts for DStar pt bins
301  //
302 
303  const Int_t nvarsDStarforDStarptbin=25;
304  SetNVarsDStarforDStarptbin(nvarsDStarforDStarptbin);
305 
306  TString varNamesDStarforDStarptbin[nvarsDStarforDStarptbin];
307  iterator = 0;
308 
309  //DStar cut variables
310  varNamesDStarforDStarptbin[iterator++]= /*-00-*/ "inv. mass width[GeV]";
311  varNamesDStarforDStarptbin[iterator++]= /*-01-*/ "delta mass width [GeV]";
312  varNamesDStarforDStarptbin[iterator++]= /*-02-*/ "pointing angle [Cos(theta)]";
313  varNamesDStarforDStarptbin[iterator++]= /*-03-*/ "dca [cm]";
314  varNamesDStarforDStarptbin[iterator++]= /*-04-*/ "Pt DStar [GeV/c]";
315  varNamesDStarforDStarptbin[iterator++]= /*-05-*/ "Pt D0 [GeV/c]";
316  varNamesDStarforDStarptbin[iterator++]= /*-06-*/ "Pt Pion [GeV/c]";
317  varNamesDStarforDStarptbin[iterator++]= /*-07-*/ "d0 DStar [cm]";
318  varNamesDStarforDStarptbin[iterator++]= /*-08-*/ "d0 D0 [cm]";
319  varNamesDStarforDStarptbin[iterator++]= /*-09-*/ "d0 Pion [cm]";
320  varNamesDStarforDStarptbin[iterator++]= /*-10-*/ "d0d0 [cm^2]";
321  varNamesDStarforDStarptbin[iterator++]= /*-11-*/ "d0d0 XY [cm^2]";
322 
323  varNamesDStarforDStarptbin[iterator++]= /*-12-*/ "angle between both daughters";
324  varNamesDStarforDStarptbin[iterator++]= /*-13-*/ "angle mother with first daughter";
325  varNamesDStarforDStarptbin[iterator++]= /*-14-*/ "angle mother with second daughter";
326  varNamesDStarforDStarptbin[iterator++]= /*-15-*/ "cosThetaStar";
327  varNamesDStarforDStarptbin[iterator++]= /*-16-*/ "vertexDistance";
328  varNamesDStarforDStarptbin[iterator++]= /*-17-*/ "pseudoProperDecayTime";
329  varNamesDStarforDStarptbin[iterator++]= /*-18-*/ "DecayTime";
330  varNamesDStarforDStarptbin[iterator++]= /*-19-*/ "normalizedDecayTime";
331  varNamesDStarforDStarptbin[iterator++]= /*-20-*/ "normDecayLength";
332  varNamesDStarforDStarptbin[iterator++]= /*-21-*/ "topomatic first daughter";
333  varNamesDStarforDStarptbin[iterator++]= /*-22-*/ "topomatic second daughter";
334  varNamesDStarforDStarptbin[iterator++]= /*-23-*/ "topomatic max";
335  varNamesDStarforDStarptbin[iterator++]= /*-24-*/ "topomatic min";
336 
337  Bool_t isUpperCutDStarforDStarptbin[nvarsDStarforDStarptbin]={0};
338 
339  SetVarNamesDStarforDStarptbin(nvarsDStarforDStarptbin,varNamesDStarforDStarptbin,isUpperCutDStarforDStarptbin);
340 
341  Float_t limitsDStarforDStarptbin[2]={0,999999999.};
342  SetPtBinsDStarforDStarptbin(2,limitsDStarforDStarptbin);
343 
344 
345 
346 
347 
348 
349  Bool_t forOpt[16]={0}; //not yet used for B0 analysis
350  SetVarsForOpt(16,forOpt);
351 
352 }
353 //--------------------------------------------------------------------------
355  AliRDHFCuts(source),
356  fMaxPtPid(source.fMaxPtPid),
357  fTPCflag(source.fTPCflag),
358  fCircRadius(source.fCircRadius),
359  fIsCutUsed(source.fIsCutUsed),
381 {
382  //
383  // Copy constructor
384  //
385 }
386 //--------------------------------------------------------------------------
388  //
389  // Default Destructor
390  //
391  if(fIsCutUsed) { delete [] fIsCutUsed; fIsCutUsed=0; }
407 }
408 //--------------------------------------------------------------------------
410 {
411  //
412  // assignment operator
413  //
414  if(&source == this) return *this;
415 
416  AliRDHFCuts::operator=(source);
417 
418  return *this;
419 }
420 //--------------------------------------------------------------------------
422  // not yet used
423 
424  return;
425 }
426 //--------------------------------------------------------------------------
427 Int_t AliRDHFCutsB0toDStarPi::IsSelected(TObject* obj,Int_t selectionLevel, AliAODEvent* aod, Bool_t bCutArray[85]) {
428  //
429  // In this function we apply the selection cuts on the B0 candidate and its daughters.
430  // The function returns 0 if the candidate is cut and is able to return information on which cuts the candidate passes.
431  //
432 
433  fIsSelectedCuts=0;
434  fIsSelectedPID=0;
435 
436  // The cuts used in this class have to be set in the maketfile.
437  if(!fCutsRD){
438  cout<<"Cut matrice not inizialized. Exit..."<<endl;
439  return 0;
440  }
441 
443  if(!candidateB0){
444  cout<<"candidateB0 null"<<endl;
445  return 0;
446  }
447 
448  AliAODRecoDecayHF2Prong* candidateDStar = (AliAODRecoDecayHF2Prong*)candidateB0->GetDaughter(1);
449  if(!candidateDStar){
450  cout<<"candidateDStar null"<<endl;
451  return 0;
452  }
453 
454  AliAODTrack *candidatePion = (AliAODTrack*)candidateB0->GetDaughter(0);
455  if(!candidatePion){
456  cout<<"candidatePion null"<<endl;
457  return 0;
458  }
459 
460  AliAODVertex * vertexB0 = candidateB0->GetSecondaryVtx();
461  if(!vertexB0){
462  cout<<"vertexB0 null"<<endl;
463  return 0;
464  }
465 
466  AliAODVertex * primaryVertex = aod->GetPrimaryVertex();
467  if(!primaryVertex){
468  cout<<"primaryVertex null"<<endl;
469  return 0;
470  }
471 
472  Int_t returnvalue=1;
473  Bool_t bPassedCut = kFALSE;
474 
475  //get the magnetic field
476  Double_t bz = (Double_t)aod->GetMagneticField();
477 
478  // selection on candidate
479  if(selectionLevel==AliRDHFCuts::kAll ||
480  selectionLevel==AliRDHFCuts::kCandidate) {
481 
482  // We check to which pt bin the candidate belongs
483  Int_t ptbin = PtBin(candidateB0->Pt());
484  if(ptbin==-1) return -1;
485 
486  // We obtain the variable values in the section below
487  // D0Mass and B0mass
488  Double_t mD0PDG = TDatabasePDG::Instance()->GetParticle(421)->Mass();
489  Double_t mB0PDG = TDatabasePDG::Instance()->GetParticle(511)->Mass();
490 
491  // delta mass PDG
492  Double_t deltaPDG = mD0PDG-mB0PDG;
493 
494  // Half width B0 mass
495  UInt_t prongs[2];
496  prongs[0] = 211; prongs[1] = 413;
497  Double_t invMassB0 = candidateB0->InvMass(2,prongs);
498  Double_t invMassDifference = TMath::Abs(mB0PDG - invMassB0);
499  Double_t invMassDelta = TMath::Abs(deltaPDG-(DeltaInvMassB0Kpipipi(candidateB0)));
500 
501  Double_t pointingAngle = candidateB0->CosPointingAngle();
502  Double_t dcaMother = candidateB0->GetDCA();
503  Double_t ptMother = candidateB0->Pt();
504  Double_t momentumMother = candidateB0->P();
505  Double_t ptDStar = candidateDStar->Pt();
506  Double_t ptPion = candidatePion->Pt();
507 
508  AliExternalTrackParam motherTrack;
509  motherTrack.CopyFromVTrack(candidateB0);
510  Double_t d0z0[2],covd0z0[3],d0[2];
511  motherTrack.PropagateToDCA(primaryVertex,bz,100.,d0z0,covd0z0);
512  d0[0] = d0z0[0];
513  Double_t d0Mother = TMath::Abs(d0[0]);
514  Double_t d0firstTrack = TMath::Abs(candidateB0->Getd0Prong(0));
515  Double_t d0secondTrack = TMath::Abs(candidateB0->Getd0Prong(1));
516 
517  Double_t impactProduct = candidateB0->Prodd0d0();
518  Double_t impactProductXY = TMath::Abs(candidateB0->ImpParXY());
519 
520  Double_t angleBetweenBothDaughters = (candidateDStar->Px() * candidatePion->Px() + candidateDStar->Py() * candidatePion->Py() + candidateDStar->Pz() * candidatePion->Pz()) /(candidateDStar->P() * candidatePion->P());
521  Double_t angleMotherFirstDaughter = (candidateB0->Px() * candidatePion->Px() + candidateB0->Py() * candidatePion->Py() + candidateB0->Pz() * candidatePion->Pz()) /(candidateB0->P() * candidatePion->P());
522  Double_t angleMotherSecondDaughter = (candidateB0->Px() * candidateDStar->Px() + candidateB0->Py() * candidateDStar->Py() + candidateB0->Pz() * candidateDStar->Pz()) /(candidateB0->P() * candidateDStar->P());
523 
524  Double_t cosThetaStar = candidateB0->CosThetaStar(0,511,211,413);
525  Double_t vertexDistance = vertexB0->DistanceToVertex(primaryVertex);
526  Double_t normDecayLength = candidateB0->NormalizedDecayLength();
527  Double_t pdgMassMother = TDatabasePDG::Instance()->GetParticle(511)->Mass();
528  Double_t pseudoProperDecayLength = ((vertexB0->GetX() - primaryVertex->GetX()) * candidateB0->Px() / TMath::Abs(candidateB0->Pt())) + ((vertexB0->GetY() - primaryVertex->GetY()) * candidateB0->Py() / TMath::Abs(candidateB0->Pt()));
529  Double_t pseudoProperDecayTime = pseudoProperDecayLength * pdgMassMother/ptMother;
530  Double_t decayTime = vertexDistance / (299792458 * TMath::Sqrt(1/((pdgMassMother*pdgMassMother/(momentumMother*momentumMother)) + 1)));
531 
532  Double_t phi = candidateB0->Phi();
533  Double_t theta = candidateB0->Theta();
534  Double_t covMatrix[21];
535  candidateB0->GetCovarianceXYZPxPyPz(covMatrix);
536 
537  Double_t cp = TMath::Cos(phi);
538  Double_t sp = TMath::Sin(phi);
539  Double_t ct = TMath::Cos(theta);
540  Double_t st = TMath::Sin(theta);
541 
542  Double_t errorMomentum = covMatrix[9]*cp*cp*ct*ct // GetCovPxPx
543  +covMatrix[13]*2.*cp*sp*ct*ct // GetCovPxPy
544  +covMatrix[18]*2.*cp*ct*st // GetCovPxPz
545  +covMatrix[14]*sp*sp*ct*ct // GetCovPyPy
546  +covMatrix[19]*2.*sp*ct*st // GetCovPyPz
547  +covMatrix[20]*st*st; // GetCovPzPz
548  Double_t normalizedDecayTime = candidateB0->NormalizedDecayLength() / (299792458 * TMath::Sqrt(1/((pdgMassMother*pdgMassMother*errorMomentum*errorMomentum/(momentumMother*momentumMother)) + 1)));
549 
550  //Topomatic
551  Double_t dd0pr1=0.;
552  Double_t dd0pr2=0.;
553  Double_t dd0max=0.;
554  Double_t dd0min=0.;
555  for(Int_t ipr=0; ipr<2; ipr++)
556  {
557  Double_t diffIP, errdiffIP;
558  candidateB0->Getd0MeasMinusExpProng(ipr,bz,diffIP,errdiffIP);
559  Double_t normdd0=0.;
560  if(errdiffIP>0.) normdd0=diffIP/errdiffIP;
561  if(ipr==0) dd0pr1=normdd0;
562  if(ipr==1) dd0pr2=normdd0;
563  }
564  if(TMath::Abs(dd0pr1)>TMath::Abs(dd0pr2)) {dd0max=dd0pr1; dd0min=dd0pr2;}
565  else {dd0max=dd0pr2; dd0min=dd0pr1;}
566 
567 
568  // We apply the cuts
569  Int_t nCutIndex = 0;
570  Double_t cutVariableValue = 0.0;
571 
572  // "inv. mass width [GeV]" --------------------------------------------
573  nCutIndex = 60;
574  cutVariableValue = invMassDifference;
575  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
576  if(!bPassedCut && !fGetCutInfo) return 0;
577  //---------------------------------------------------------------------
578 
579  // "delta mass width [GeV]" -------------------------------------------
580  nCutIndex = 61;
581  cutVariableValue = invMassDelta;
582  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
583  if(!bPassedCut && !fGetCutInfo) return 0;
584  //---------------------------------------------------------------------
585 
586  // "pointing angle [Cos(theta)]" --------------------------------------
587  nCutIndex = 62;
588  cutVariableValue = pointingAngle;
589  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
590  if(!bPassedCut && !fGetCutInfo) return 0;
591  //---------------------------------------------------------------------
592 
593  // "dca [cm]" ---------------------------------------------------------
594  nCutIndex = 63;
595  cutVariableValue = dcaMother;
596  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
597  if(!bPassedCut && !fGetCutInfo) return 0;
598  //---------------------------------------------------------------------
599 
600  // "Pt B0 [GeV/c]" ----------------------------------------------------
601  nCutIndex = 64;
602  cutVariableValue = ptMother;
603  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
604  if(!bPassedCut && !fGetCutInfo) return 0;
605  //---------------------------------------------------------------------
606 
607  // "Pt DStar [GeV/c]" -------------------------------------------------
608  nCutIndex = 65;
609  cutVariableValue = ptDStar;
610  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
611  if(!bPassedCut && !fGetCutInfo) return 0;
612  //---------------------------------------------------------------------
613 
614  // "Pt Pion [GeV/c]" --------------------------------------------------
615  nCutIndex = 66;
616  cutVariableValue = ptPion;
617  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
618  if(!bPassedCut && !fGetCutInfo) return 0;
619  //---------------------------------------------------------------------
620 
621  // "d0 B0 [cm]" -------------------------------------------------------
622  nCutIndex = 67;
623  cutVariableValue = d0Mother;
624  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
625  if(!bPassedCut && !fGetCutInfo) return 0;
626  //---------------------------------------------------------------------
627 
628  // "d0 DStar [cm]"-----------------------------------------------------
629  nCutIndex = 68;
630  cutVariableValue = d0firstTrack;
631  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
632  if(!bPassedCut && !fGetCutInfo) return 0;
633  //---------------------------------------------------------------------
634 
635  // "d0 Pion [cm]" -----------------------------------------------------
636  nCutIndex = 69;
637  cutVariableValue = d0secondTrack;
638  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
639  if(!bPassedCut && !fGetCutInfo) return 0;
640  //---------------------------------------------------------------------
641 
642  // "d0d0 [cm^2]" ------------------------------------------------------
643  nCutIndex = 70;
644  cutVariableValue = impactProduct;
645  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
646  if(!bPassedCut && !fGetCutInfo) return 0;
647  //---------------------------------------------------------------------
648 
649  // "d0d0 XY [cm^2]" ---------------------------------------------------
650  nCutIndex = 71;
651  cutVariableValue = impactProductXY;
652  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
653  if(!bPassedCut && !fGetCutInfo) return 0;
654  //---------------------------------------------------------------------
655 
656  // "angle between both daughters" -------------------------------------
657  nCutIndex = 72;
658  cutVariableValue = angleBetweenBothDaughters;
659  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
660  if(!bPassedCut && !fGetCutInfo) return 0;
661  //---------------------------------------------------------------------
662 
663  // "angle mother with first daughter" ---------------------------------
664  nCutIndex = 73;
665  cutVariableValue = angleMotherFirstDaughter;
666  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
667  if(!bPassedCut && !fGetCutInfo) return 0;
668  //---------------------------------------------------------------------
669 
670  // "angle mother with second daughter" --------------------------------
671  nCutIndex = 74;
672  cutVariableValue = angleMotherSecondDaughter;
673  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
674  if(!bPassedCut && !fGetCutInfo) return 0;
675  //---------------------------------------------------------------------
676 
677  // "cosThetaStar" -----------------------------------------------------
678  nCutIndex = 75;
679  cutVariableValue = cosThetaStar;
680  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
681  if(!bPassedCut && !fGetCutInfo) return 0;
682  //---------------------------------------------------------------------
683 
684  // "vertexDistance" ---------------------------------------------------
685  nCutIndex = 76;
686  cutVariableValue = vertexDistance;
687  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
688  if(!bPassedCut && !fGetCutInfo) return 0;
689  //---------------------------------------------------------------------
690 
691  // "pseudoProperDecayTime" --------------------------------------------
692  nCutIndex = 77;
693  cutVariableValue = pseudoProperDecayTime;
694  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
695  if(!bPassedCut && !fGetCutInfo) return 0;
696  //---------------------------------------------------------------------
697 
698  // "DecayTime" --------------------------------------------------------
699  nCutIndex = 78;
700  cutVariableValue = decayTime;
701  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
702  if(!bPassedCut && !fGetCutInfo) return 0;
703  //---------------------------------------------------------------------
704 
705  // "normalizedDecayTime" ----------------------------------------------------
706  nCutIndex = 79;
707  cutVariableValue = normalizedDecayTime;
708  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
709  if(!bPassedCut && !fGetCutInfo) return 0;
710  //---------------------------------------------------------------------
711 
712  // "normDecayLength" --------------------------------------------------
713  nCutIndex = 80;
714  cutVariableValue = normDecayLength;
715  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
716  if(!bPassedCut && !fGetCutInfo) return 0;
717  //---------------------------------------------------------------------
718 
719  // "topomatic first daughter" -----------------------------------------
720  nCutIndex = 81;
721  cutVariableValue = dd0pr1;
722  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
723  if(!bPassedCut && !fGetCutInfo) return 0;
724  //---------------------------------------------------------------------
725 
726  // "topomatic second daughter" ----------------------------------------
727  nCutIndex = 82;
728  cutVariableValue = dd0pr2;
729  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
730  if(!bPassedCut && !fGetCutInfo) return 0;
731  //---------------------------------------------------------------------
732 
733  // "topomatic max" ----------------------------------------------------
734  nCutIndex = 83;
735  cutVariableValue = dd0max;
736  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
737  if(!bPassedCut && !fGetCutInfo) return 0;
738  //---------------------------------------------------------------------
739 
740  // "topomatic min" ----------------------------------------------------
741  nCutIndex = 84;
742  cutVariableValue = dd0min;
743  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
744  if(!bPassedCut && !fGetCutInfo) return 0;
745  //---------------------------------------------------------------------
746 
747  // select DStar that passes D0 cuts
748  bPassedCut = IsDStarFromB0Selected(ptMother,candidateDStar,selectionLevel,aod,bCutArray);
749  if(!bPassedCut && !fGetCutInfo) return 0;
750  }
751 
752  if(bPassedCut==kFALSE)
753  {
754  returnvalue = 0;
755  } else
756  {
757  for (Int_t i = 60; i < 85; ++i)
758  {
759  if(bCutArray[i]==kTRUE){
760  returnvalue = 0;
761  break;
762  }
763  }
764  }
765 
766  fIsSelectedCuts = returnvalue;
767 
768  return returnvalue;
769 }
770 //---------------------------------------------------------------------------
772  //
773  // Apply selection for DStar candidate
774  //
775 
776  if(!fCutsRD){
777  cout<<"Cut matrice not inizialized. Exit..."<<endl;
778  return 0;
779  }
780 
781  AliAODRecoDecayHF2Prong* candidateDStar = (AliAODRecoDecayHF2Prong*)obj;
782  if(!candidateDStar){
783  cout<<"candidateDStar null"<<endl;
784  return 0;
785  }
786 
787  AliAODRecoDecayHF2Prong* candidateD0 = (AliAODRecoDecayHF2Prong*)candidateDStar->GetDaughter(1);
788  if(!candidateD0){
789  cout<<"candidateD0 null"<<endl;
790  return 0;
791  }
792 
793  AliAODTrack *candidatePion = (AliAODTrack*)candidateDStar->GetDaughter(0);
794  if(!candidatePion){
795  cout<<"candidatePion null"<<endl;
796  return 0;
797  }
798 
799  AliAODVertex * vertexDStar = candidateDStar->GetSecondaryVtx();
800  if(!vertexDStar){
801  cout<<"vertexDStar null"<<endl;
802  return 0;
803  }
804 
805  AliAODVertex * primaryVertex = aod->GetPrimaryVertex();
806  if(!primaryVertex){
807  cout<<"primaryVertex null"<<endl;
808  return 0;
809  }
810 
811  Int_t returnvalue=1;
812  Bool_t bPassedCut = kFALSE;
813 
814  //get the magnetic field
815  Double_t bz = (Double_t)aod->GetMagneticField();
816 
817  // selection on candidate
818  if(selectionLevel==AliRDHFCuts::kAll ||
819  selectionLevel==AliRDHFCuts::kCandidate) {
820 
821  Int_t ptbin=PtBin(ptB0);
822 
823  // DStarMass and D0mass
824  Double_t mDSPDG = TDatabasePDG::Instance()->GetParticle(413)->Mass();
825  Double_t mD0PDG = TDatabasePDG::Instance()->GetParticle(421)->Mass();
826 
827  // delta mass PDG
828  Double_t deltaPDG = mDSPDG-mD0PDG;
829 
830  // Half width DStar mass
831  UInt_t prongs[2];
832  prongs[0] = 211; prongs[1] = 421;
833  Double_t invMassDStar = candidateDStar->InvMass(2,prongs);
834  Double_t invMassDifference = TMath::Abs(mDSPDG - invMassDStar);
835  Double_t invMassDelta = TMath::Abs(deltaPDG-(DeltaInvMassDStarKpipi(candidateDStar)));
836 
837  Double_t pointingAngle = candidateDStar->CosPointingAngle();
838  Double_t dcaMother = candidateDStar->GetDCA();
839  Double_t ptMother = candidateDStar->Pt();
840  Double_t momentumMother = candidateDStar->P();
841  Double_t ptD0 = candidateD0->Pt();
842  Double_t ptPion = candidatePion->Pt();
843 
844  AliExternalTrackParam motherTrack;
845  motherTrack.CopyFromVTrack(candidateDStar);
846  Double_t d0z0[2],covd0z0[3],d0[2];
847  motherTrack.PropagateToDCA(primaryVertex,bz,100.,d0z0,covd0z0);
848  d0[0] = d0z0[0];
849  Double_t d0Mother = TMath::Abs(d0[0]);
850  Double_t d0firstTrack = TMath::Abs(candidateDStar->Getd0Prong(0));
851  Double_t d0secondTrack = TMath::Abs(candidateDStar->Getd0Prong(1));
852 
853  Double_t impactProduct = candidateDStar->Prodd0d0();
854  Double_t impactProductXY = TMath::Abs(candidateDStar->ImpParXY());
855 
856  Double_t angleBetweenBothDaughters = (candidateD0->Px() * candidatePion->Px() + candidateD0->Py() * candidatePion->Py() + candidateD0->Pz() * candidatePion->Pz()) /(candidateD0->P() * candidatePion->P());
857  Double_t angleMotherFirstDaughter = (candidateDStar->Px() * candidatePion->Px() + candidateDStar->Py() * candidatePion->Py() + candidateDStar->Pz() * candidatePion->Pz()) /(candidateDStar->P() * candidatePion->P());
858  Double_t angleMotherSecondDaughter = (candidateDStar->Px() * candidateD0->Px() + candidateDStar->Py() * candidateD0->Py() + candidateDStar->Pz() * candidateD0->Pz()) /(candidateDStar->P() * candidateD0->P());
859 
860  Double_t cosThetaStar = candidateDStar->CosThetaStar(0,413,211,421);
861  Double_t vertexDistance = vertexDStar->DistanceToVertex(primaryVertex);
862  Double_t normDecayLength = candidateDStar->NormalizedDecayLength();
863  Double_t pdgMassMother = TDatabasePDG::Instance()->GetParticle(413)->Mass();
864  Double_t pseudoProperDecayLength = ((vertexDStar->GetX() - primaryVertex->GetX()) * candidateDStar->Px() / TMath::Abs(candidateDStar->Pt())) + ((vertexDStar->GetY() - primaryVertex->GetY()) * candidateDStar->Py() / TMath::Abs(candidateDStar->Pt()));
865  Double_t pseudoProperDecayTime = pseudoProperDecayLength * pdgMassMother/ptMother;
866  Double_t decayTime = vertexDistance / (299792458 * TMath::Sqrt(1/((pdgMassMother*pdgMassMother/(momentumMother*momentumMother)) + 1)));
867 
868  Double_t phi = candidateDStar->Phi();
869  Double_t theta = candidateDStar->Theta();
870  Double_t covMatrix[21];
871  candidateDStar->GetCovarianceXYZPxPyPz(covMatrix);
872 
873  Double_t cp = TMath::Cos(phi);
874  Double_t sp = TMath::Sin(phi);
875  Double_t ct = TMath::Cos(theta);
876  Double_t st = TMath::Sin(theta);
877 
878  Double_t errorMomentum = covMatrix[9]*cp*cp*ct*ct // GetCovPxPx
879  +covMatrix[13]*2.*cp*sp*ct*ct // GetCovPxPy
880  +covMatrix[18]*2.*cp*ct*st // GetCovPxPz
881  +covMatrix[14]*sp*sp*ct*ct // GetCovPyPy
882  +covMatrix[19]*2.*sp*ct*st // GetCovPyPz
883  +covMatrix[20]*st*st; // GetCovPzPz
884  Double_t normalizedDecayTime = candidateDStar->NormalizedDecayLength() / (299792458 * TMath::Sqrt(1/((pdgMassMother*pdgMassMother*errorMomentum*errorMomentum/(momentumMother*momentumMother)) + 1)));
885 
886  //Topomatic
887  Double_t dd0pr1=0.;
888  Double_t dd0pr2=0.;
889  Double_t dd0max=0.;
890  Double_t dd0min=0.;
891  for(Int_t ipr=0; ipr<2; ipr++)
892  {
893  Double_t diffIP, errdiffIP;
894  candidateDStar->Getd0MeasMinusExpProng(ipr,bz,diffIP,errdiffIP);
895  Double_t normdd0=0.;
896  if(errdiffIP>0.) normdd0=diffIP/errdiffIP;
897  if(ipr==0) dd0pr1=normdd0;
898  if(ipr==1) dd0pr2=normdd0;
899  }
900  if(TMath::Abs(dd0pr1)>TMath::Abs(dd0pr2)) {dd0max=dd0pr1; dd0min=dd0pr2;}
901  else {dd0max=dd0pr2; dd0min=dd0pr1;}
902 
903 
904  // We apply the cuts
905  Int_t nCutIndex = 0;
906  Double_t cutVariableValue = 0.0;
907 
908  // "inv. mass width [GeV]" --------------------------------------------
909  nCutIndex = 35;
910  cutVariableValue = invMassDifference;
911  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
912  if(!bPassedCut && !fGetCutInfo) return 0;
913  //---------------------------------------------------------------------
914 
915  // "delta mass width [GeV]" -------------------------------------------
916  nCutIndex = 36;
917  cutVariableValue = invMassDelta;
918  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
919  if(!bPassedCut && !fGetCutInfo) return 0;
920  //---------------------------------------------------------------------
921 
922  // "pointing angle [Cos(theta)]" --------------------------------------
923  nCutIndex = 37;
924  cutVariableValue = pointingAngle;
925  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
926  if(!bPassedCut && !fGetCutInfo) return 0;
927  //---------------------------------------------------------------------
928 
929  // "dca [cm]" ---------------------------------------------------------
930  nCutIndex = 38;
931  cutVariableValue = dcaMother;
932  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
933  if(!bPassedCut && !fGetCutInfo) return 0;
934  //---------------------------------------------------------------------
935 
936  // "Pt DStar [GeV/c]" ----------------------------------------------------
937  nCutIndex = 39;
938  cutVariableValue = ptMother;
939  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
940  if(!bPassedCut && !fGetCutInfo) return 0;
941  //---------------------------------------------------------------------
942 
943  // "Pt D0 [GeV/c]" -------------------------------------------------
944  nCutIndex = 40;
945  cutVariableValue = ptD0;
946  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
947  if(!bPassedCut && !fGetCutInfo) return 0;
948  //---------------------------------------------------------------------
949 
950  // "Pt Pion [GeV/c]" --------------------------------------------------
951  nCutIndex = 41;
952  cutVariableValue = ptPion;
953  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
954  if(!bPassedCut && !fGetCutInfo) return 0;
955  //---------------------------------------------------------------------
956 
957  // "d0 DStar [cm]" -------------------------------------------------------
958  nCutIndex = 42;
959  cutVariableValue = d0Mother;
960  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
961  if(!bPassedCut && !fGetCutInfo) return 0;
962  //---------------------------------------------------------------------
963 
964  // "d0 D0 [cm]"-----------------------------------------------------
965  nCutIndex = 43;
966  cutVariableValue = d0firstTrack;
967  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
968  if(!bPassedCut && !fGetCutInfo) return 0;
969  //---------------------------------------------------------------------
970 
971  // "d0 Pion [cm]" -----------------------------------------------------
972  nCutIndex = 44;
973  cutVariableValue = d0secondTrack;
974  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
975  if(!bPassedCut && !fGetCutInfo) return 0;
976  //---------------------------------------------------------------------
977 
978  // "d0d0 [cm^2]" ------------------------------------------------------
979  nCutIndex = 45;
980  cutVariableValue = impactProduct;
981  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
982  if(!bPassedCut && !fGetCutInfo) return 0;
983  //---------------------------------------------------------------------
984 
985  // "d0d0 XY [cm^2]" ---------------------------------------------------
986  nCutIndex = 46;
987  cutVariableValue = impactProductXY;
988  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
989  if(!bPassedCut && !fGetCutInfo) return 0;
990  //---------------------------------------------------------------------
991 
992  // "angle between both daughters" -------------------------------------
993  nCutIndex = 47;
994  cutVariableValue = angleBetweenBothDaughters;
995  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
996  if(!bPassedCut && !fGetCutInfo) return 0;
997  //---------------------------------------------------------------------
998 
999  // "angle mother with first daughter" ---------------------------------
1000  nCutIndex = 48;
1001  cutVariableValue = angleMotherFirstDaughter;
1002  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1003  if(!bPassedCut && !fGetCutInfo) return 0;
1004  //---------------------------------------------------------------------
1005 
1006  // "angle mother with second daughter" --------------------------------
1007  nCutIndex = 49;
1008  cutVariableValue = angleMotherSecondDaughter;
1009  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1010  if(!bPassedCut && !fGetCutInfo) return 0;
1011  //---------------------------------------------------------------------
1012 
1013  // "cosThetaStar" -----------------------------------------------------
1014  nCutIndex = 50;
1015  cutVariableValue = cosThetaStar;
1016  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1017  if(!bPassedCut && !fGetCutInfo) return 0;
1018  //---------------------------------------------------------------------
1019 
1020  // "vertexDistance" ---------------------------------------------------
1021  nCutIndex = 51;
1022  cutVariableValue = vertexDistance;
1023  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1024  if(!bPassedCut && !fGetCutInfo) return 0;
1025  //---------------------------------------------------------------------
1026 
1027  // "pseudoProperDecayTime" --------------------------------------------
1028  nCutIndex = 52;
1029  cutVariableValue = pseudoProperDecayTime;
1030  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1031  if(!bPassedCut && !fGetCutInfo) return 0;
1032  //---------------------------------------------------------------------
1033 
1034  // "DecayTime" --------------------------------------------------------
1035  nCutIndex = 53;
1036  cutVariableValue = decayTime;
1037  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1038  if(!bPassedCut && !fGetCutInfo) return 0;
1039  //---------------------------------------------------------------------
1040 
1041  // "normalizedDecayTime" ----------------------------------------------------
1042  nCutIndex = 54;
1043  cutVariableValue = normalizedDecayTime;
1044  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1045  if(!bPassedCut && !fGetCutInfo) return 0;
1046  //---------------------------------------------------------------------
1047 
1048  // "normDecayLength" --------------------------------------------------
1049  nCutIndex = 55;
1050  cutVariableValue = normDecayLength;
1051  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1052  if(!bPassedCut && !fGetCutInfo) return 0;
1053  //---------------------------------------------------------------------
1054 
1055  // "topomatic first daughter" -----------------------------------------
1056  nCutIndex = 56;
1057  cutVariableValue = dd0pr1;
1058  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1059  if(!bPassedCut && !fGetCutInfo) return 0;
1060  //---------------------------------------------------------------------
1061 
1062  // "topomatic second daughter" ----------------------------------------
1063  nCutIndex = 57;
1064  cutVariableValue = dd0pr2;
1065  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1066  if(!bPassedCut && !fGetCutInfo) return 0;
1067  //---------------------------------------------------------------------
1068 
1069  // "topomatic max" ----------------------------------------------------
1070  nCutIndex = 58;
1071  cutVariableValue = dd0max;
1072  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1073  if(!bPassedCut && !fGetCutInfo) return 0;
1074  //---------------------------------------------------------------------
1075 
1076  // "topomatic min" ----------------------------------------------------
1077  nCutIndex = 59;
1078  cutVariableValue = dd0min;
1079  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1080  if(!bPassedCut && !fGetCutInfo) return 0;
1081  //---------------------------------------------------------------------
1082 
1083  // select D0 - have to pass DStar candidate to get variables w.r.t. DStar vertex.
1084  bPassedCut = IsD0FromDStarSelected(ptB0,candidateDStar,selectionLevel, aod, bCutArray);
1085  if(!bPassedCut && !fGetCutInfo) return 0;
1086  }
1087 
1088  if(bPassedCut==kFALSE)
1089  {
1090  returnvalue = 0;
1091  } else
1092  {
1093  for (Int_t i = 35; i < 60; ++i)
1094  {
1095  if(bCutArray[i]==kTRUE){
1096  returnvalue = 0;
1097  break;
1098  }
1099  }
1100  }
1101 
1102 
1103  return returnvalue;
1104 
1105 }
1106 //_________________________________________________________________________________________________
1108  //
1109  // Apply selection on D0 candidate from DStar candidate. We have to pass the DStar candidate to this function to get variables w.r.t. DStar vertex.
1110  //
1111 
1112  if(!fCutsRD){
1113  cout<<"Cut matrice not inizialized. Exit..."<<endl;
1114  return 0;
1115  }
1116 
1117  AliAODRecoDecayHF2Prong* candidateDStar = (AliAODRecoDecayHF2Prong*)obj;
1118  if(!candidateDStar){
1119  cout<<"candidateDStar null"<<endl;
1120  return 0;
1121  }
1122 
1123  AliAODRecoDecayHF2Prong* candidateD0 = (AliAODRecoDecayHF2Prong*)candidateDStar->GetDaughter(1);
1124  if(!candidateD0){
1125  cout<<"candidateD0 null"<<endl;
1126  return 0;
1127  }
1128 
1129  AliAODTrack *candidatePion = (AliAODTrack*)candidateD0->GetDaughter(0);
1130  if(!candidatePion){
1131  cout<<"candidatePion null"<<endl;
1132  return 0;
1133  }
1134 
1135  AliAODTrack *candidateKaon = (AliAODTrack*)candidateD0->GetDaughter(1);
1136  if(!candidateKaon){
1137  cout<<"candidateKaon null"<<endl;
1138  return 0;
1139  }
1140 
1141  AliAODVertex * vertexDStar = candidateDStar->GetSecondaryVtx();
1142  if(!vertexDStar){
1143  cout<<"vertexDStar null"<<endl;
1144  return 0;
1145  }
1146 
1147  AliAODVertex * vertexD0 = candidateD0->GetSecondaryVtx();
1148  if(!vertexD0){
1149  cout<<"vertexD0 null"<<endl;
1150  return 0;
1151  }
1152 
1153  AliAODVertex * primaryVertex = aod->GetPrimaryVertex();
1154  if(!primaryVertex){
1155  cout<<"primaryVertex null"<<endl;
1156  return 0;
1157  }
1158 
1159  Int_t returnvalue=1;
1160  Bool_t bPassedCut = kFALSE;
1161 
1162  //get the magnetic field
1163  Double_t bz = (Double_t)aod->GetMagneticField();
1164 
1165 
1166  // selection on candidate
1167  if(selectionLevel==AliRDHFCuts::kAll ||
1168  selectionLevel==AliRDHFCuts::kCandidate) {
1169 
1170  Int_t ptbin=PtBin(ptB0);
1171 
1172  // D0mass
1173  Double_t mD0PDG = TDatabasePDG::Instance()->GetParticle(421)->Mass();
1174 
1175  // Half width DStar mass
1176  Int_t chargeDStar = candidateDStar->Charge();
1177  UInt_t prongs[2];
1178  if(chargeDStar==1)
1179  {
1180  prongs[0] = 211;
1181  prongs[1] = 321;
1182  }
1183  else if (chargeDStar==-1)
1184  {
1185  prongs[1] = 211;
1186  prongs[0] = 321;
1187  }
1188  else
1189  {
1190  cout << "Wrong charge DStar." << endl;
1191  return 0;
1192  }
1193  Double_t invMassD0 = candidateD0->InvMass(2,prongs);
1194  Double_t invMassDifference = TMath::Abs(mD0PDG - invMassD0);
1195 
1196  Double_t pointingAngle = candidateD0->CosPointingAngle();
1197  Double_t dcaMother = candidateD0->GetDCA();
1198  Double_t ptMother = candidateD0->Pt();
1199  Double_t momentumMother = candidateD0->P();
1200  Double_t ptPion = candidatePion->Pt();
1201  Double_t ptKaon = candidateKaon->Pt();
1202 
1203  AliExternalTrackParam motherTrack;
1204  motherTrack.CopyFromVTrack(candidateD0);
1205  Double_t d0z0[2],covd0z0[3],d0[2];
1206  motherTrack.PropagateToDCA(primaryVertex,bz,100.,d0z0,covd0z0);
1207  d0[0] = d0z0[0];
1208  Double_t d0Mother = TMath::Abs(d0[0]);
1209  Double_t d0firstTrack = TMath::Abs(candidateD0->Getd0Prong(0));
1210  Double_t d0secondTrack = TMath::Abs(candidateD0->Getd0Prong(1));
1211 
1212  Double_t impactProduct = candidateD0->Prodd0d0();
1213  Double_t impactProductXY = TMath::Abs(candidateD0->ImpParXY());
1214 
1215  Double_t angleBetweenBothDaughters = (candidateKaon->Px() * candidatePion->Px() + candidateKaon->Py() * candidatePion->Py() + candidateKaon->Pz() * candidatePion->Pz()) /(candidateKaon->P() * candidatePion->P());
1216  Double_t angleMotherFirstDaughter = (candidateD0->Px() * candidatePion->Px() + candidateD0->Py() * candidatePion->Py() + candidateD0->Pz() * candidatePion->Pz()) /(candidateD0->P() * candidatePion->P());
1217  Double_t angleMotherSecondDaughter = (candidateD0->Px() * candidateKaon->Px() + candidateD0->Py() * candidateKaon->Py() + candidateD0->Pz() * candidateKaon->Pz()) /(candidateD0->P() * candidateKaon->P());
1218 
1219  Double_t cosThetaStar = candidateD0->CosThetaStar(0,421,211,321);
1220  Double_t vertexDistance = vertexD0->DistanceToVertex(primaryVertex);
1221  Double_t normDecayLength = candidateD0->NormalizedDecayLength();
1222  Double_t pdgMassMother = TDatabasePDG::Instance()->GetParticle(421)->Mass();
1223  Double_t pseudoProperDecayLength = ((vertexD0->GetX() - primaryVertex->GetX()) * candidateD0->Px() / TMath::Abs(candidateD0->Pt())) + ((vertexD0->GetY() - primaryVertex->GetY()) * candidateD0->Py() / TMath::Abs(candidateD0->Pt()));
1224  Double_t pseudoProperDecayTime = pseudoProperDecayLength * pdgMassMother/ptMother;
1225  Double_t decayTime = vertexDistance / (299792458 * TMath::Sqrt(1/((pdgMassMother*pdgMassMother/(momentumMother*momentumMother)) + 1)));
1226 
1227  Double_t phi = candidateD0->Phi();
1228  Double_t theta = candidateD0->Theta();
1229  Double_t covMatrix[21];
1230  candidateD0->GetCovarianceXYZPxPyPz(covMatrix);
1231 
1232  Double_t cp = TMath::Cos(phi);
1233  Double_t sp = TMath::Sin(phi);
1234  Double_t ct = TMath::Cos(theta);
1235  Double_t st = TMath::Sin(theta);
1236 
1237  Double_t errorMomentum = covMatrix[9]*cp*cp*ct*ct // GetCovPxPx
1238  +covMatrix[13]*2.*cp*sp*ct*ct // GetCovPxPy
1239  +covMatrix[18]*2.*cp*ct*st // GetCovPxPz
1240  +covMatrix[14]*sp*sp*ct*ct // GetCovPyPy
1241  +covMatrix[19]*2.*sp*ct*st // GetCovPyPz
1242  +covMatrix[20]*st*st; // GetCovPzPz
1243  Double_t normalizedDecayTime = candidateD0->NormalizedDecayLength() / (299792458 * TMath::Sqrt(1/((pdgMassMother*pdgMassMother*errorMomentum*errorMomentum/(momentumMother*momentumMother)) + 1)));
1244 
1245  //Topomatic
1246  Double_t dd0pr1=0.;
1247  Double_t dd0pr2=0.;
1248  Double_t dd0max=0.;
1249  Double_t dd0min=0.;
1250  for(Int_t ipr=0; ipr<2; ipr++)
1251  {
1252  Double_t diffIP, errdiffIP;
1253  candidateD0->Getd0MeasMinusExpProng(ipr,bz,diffIP,errdiffIP);
1254  Double_t normdd0=0.;
1255  if(errdiffIP>0.) normdd0=diffIP/errdiffIP;
1256  if(ipr==0) dd0pr1=normdd0;
1257  if(ipr==1) dd0pr2=normdd0;
1258  }
1259  if(TMath::Abs(dd0pr1)>TMath::Abs(dd0pr2)) {dd0max=dd0pr1; dd0min=dd0pr2;}
1260  else {dd0max=dd0pr2; dd0min=dd0pr1;}
1261 
1262 
1263  // We apply the cuts
1264  Int_t nCutIndex = 0;
1265  Double_t cutVariableValue = 0.0;
1266 
1267  // "inv. mass width [GeV]" --------------------------------------------
1268  nCutIndex = 0;
1269  cutVariableValue = invMassDifference;
1270  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1271  if(!bPassedCut && !fGetCutInfo) return 0;
1272  //---------------------------------------------------------------------
1273 
1274  // "delta mass width [GeV]" -------------------------------------------
1275  // nCutIndex = 1; // not used for D0
1276  // cutVariableValue = invMassDelta;
1277  // bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1278  // if(!bPassedCut && !fGetCutInfo) return 0;
1279  //---------------------------------------------------------------------
1280 
1281  // "pointing angle [Cos(theta)]" --------------------------------------
1282  nCutIndex = 2;
1283  cutVariableValue = pointingAngle;
1284  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1285  if(!bPassedCut && !fGetCutInfo) return 0;
1286  //---------------------------------------------------------------------
1287 
1288  // "dca [cm]" ---------------------------------------------------------
1289  nCutIndex = 3;
1290  cutVariableValue = dcaMother;
1291  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1292  if(!bPassedCut && !fGetCutInfo) return 0;
1293  //---------------------------------------------------------------------
1294 
1295  // "Pt D0 [GeV/c]" ----------------------------------------------------
1296  nCutIndex = 4;
1297  cutVariableValue = ptMother;
1298  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1299  if(!bPassedCut && !fGetCutInfo) return 0;
1300  //---------------------------------------------------------------------
1301 
1302  // "Pt Kaon [GeV/c]" -------------------------------------------------
1303  nCutIndex = 5;
1304  cutVariableValue = ptKaon;
1305  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1306  if(!bPassedCut && !fGetCutInfo) return 0;
1307  //---------------------------------------------------------------------
1308 
1309  // "Pt Pion [GeV/c]" --------------------------------------------------
1310  nCutIndex = 6;
1311  cutVariableValue = ptPion;
1312  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1313  if(!bPassedCut && !fGetCutInfo) return 0;
1314  //---------------------------------------------------------------------
1315 
1316  // "d0 D0 [cm]" -------------------------------------------------------
1317  nCutIndex = 7;
1318  cutVariableValue = d0Mother;
1319  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1320  if(!bPassedCut && !fGetCutInfo) return 0;
1321  //---------------------------------------------------------------------
1322 
1323  // "d0 Kaon [cm]"-----------------------------------------------------
1324  nCutIndex = 8;
1325  cutVariableValue = d0firstTrack;
1326  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1327  if(!bPassedCut && !fGetCutInfo) return 0;
1328  //---------------------------------------------------------------------
1329 
1330  // "d0 Pion [cm]" -----------------------------------------------------
1331  nCutIndex = 9;
1332  cutVariableValue = d0secondTrack;
1333  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1334  if(!bPassedCut && !fGetCutInfo) return 0;
1335  //---------------------------------------------------------------------
1336 
1337  // "d0d0 [cm^2]" ------------------------------------------------------
1338  nCutIndex = 10;
1339  cutVariableValue = impactProduct;
1340  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1341  if(!bPassedCut && !fGetCutInfo) return 0;
1342  //---------------------------------------------------------------------
1343 
1344  // "d0d0 XY [cm^2]" ---------------------------------------------------
1345  nCutIndex = 11;
1346  cutVariableValue = impactProductXY;
1347  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1348  if(!bPassedCut && !fGetCutInfo) return 0;
1349  //---------------------------------------------------------------------
1350 
1351  // "angle between both daughters" -------------------------------------
1352  nCutIndex = 12;
1353  cutVariableValue = angleBetweenBothDaughters;
1354  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1355  if(!bPassedCut && !fGetCutInfo) return 0;
1356  //---------------------------------------------------------------------
1357 
1358  // "angle mother with first daughter" ---------------------------------
1359  nCutIndex = 13;
1360  cutVariableValue = angleMotherFirstDaughter;
1361  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1362  if(!bPassedCut && !fGetCutInfo) return 0;
1363  //---------------------------------------------------------------------
1364 
1365  // "angle mother with second daughter" --------------------------------
1366  nCutIndex = 14;
1367  cutVariableValue = angleMotherSecondDaughter;
1368  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1369  if(!bPassedCut && !fGetCutInfo) return 0;
1370  //---------------------------------------------------------------------
1371 
1372  // "cosThetaStar" -----------------------------------------------------
1373  nCutIndex = 15;
1374  cutVariableValue = cosThetaStar;
1375  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1376  if(!bPassedCut && !fGetCutInfo) return 0;
1377  //---------------------------------------------------------------------
1378 
1379  // "vertexDistance" ---------------------------------------------------
1380  nCutIndex = 16;
1381  cutVariableValue = vertexDistance;
1382  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1383  if(!bPassedCut && !fGetCutInfo) return 0;
1384  //---------------------------------------------------------------------
1385 
1386  // "pseudoProperDecayTime" --------------------------------------------
1387  nCutIndex = 17;
1388  cutVariableValue = pseudoProperDecayTime;
1389  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1390  if(!bPassedCut && !fGetCutInfo) return 0;
1391  //---------------------------------------------------------------------
1392 
1393  // "DecayTime" --------------------------------------------------------
1394  nCutIndex = 18;
1395  cutVariableValue = decayTime;
1396  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1397  if(!bPassedCut && !fGetCutInfo) return 0;
1398  //---------------------------------------------------------------------
1399 
1400  // "normalizedDecayTime" ----------------------------------------------------
1401  nCutIndex = 19;
1402  cutVariableValue = normalizedDecayTime;
1403  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1404  if(!bPassedCut && !fGetCutInfo) return 0;
1405  //---------------------------------------------------------------------
1406 
1407  // "normDecayLength" --------------------------------------------------
1408  nCutIndex = 20;
1409  cutVariableValue = normDecayLength;
1410  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1411  if(!bPassedCut && !fGetCutInfo) return 0;
1412  //---------------------------------------------------------------------
1413 
1414  // "topomatic first daughter" -----------------------------------------
1415  nCutIndex = 21;
1416  cutVariableValue = dd0pr1;
1417  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1418  if(!bPassedCut && !fGetCutInfo) return 0;
1419  //---------------------------------------------------------------------
1420 
1421  // "topomatic second daughter" ----------------------------------------
1422  nCutIndex = 22;
1423  cutVariableValue = dd0pr2;
1424  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1425  if(!bPassedCut && !fGetCutInfo) return 0;
1426  //---------------------------------------------------------------------
1427 
1428  // "topomatic max" ----------------------------------------------------
1429  nCutIndex = 23;
1430  cutVariableValue = dd0max;
1431  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1432  if(!bPassedCut && !fGetCutInfo) return 0;
1433  //---------------------------------------------------------------------
1434 
1435  // "topomatic min" ----------------------------------------------------
1436  nCutIndex = 24;
1437  cutVariableValue = dd0min;
1438  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1439  if(!bPassedCut && !fGetCutInfo) return 0;
1440  //---------------------------------------------------------------------
1441 
1442  AliAODRecoDecay* candidateD0toDStar = (AliAODRecoDecay*)candidateD0;
1443  AliExternalTrackParam pionD0Track;
1444  AliExternalTrackParam kaonD0Track;
1445 
1446  Double_t d0z0DSVert[2],covd0z0DSVert[3],d0DSVert[2];
1447 
1448  pionD0Track.CopyFromVTrack(candidatePion);
1449  pionD0Track.PropagateToDCA(vertexDStar,bz,100.,d0z0DSVert,covd0z0DSVert);
1450  d0DSVert[0] = d0z0DSVert[0];
1451 
1452  kaonD0Track.CopyFromVTrack(candidateKaon);
1453  kaonD0Track.PropagateToDCA(vertexDStar,bz,100.,d0z0DSVert,covd0z0DSVert);
1454  d0DSVert[1] = d0z0DSVert[0];
1455 
1456  AliExternalTrackParam D0Track;
1457  D0Track.CopyFromVTrack(candidateD0);
1458  Double_t d0z0D0DSVert[2],covd0z0D0DSVert[3],d0D0DSVert;
1459  motherTrack.PropagateToDCA(vertexDStar,bz,100.,d0z0D0DSVert,covd0z0D0DSVert);
1460  d0D0DSVert = TMath::Abs(d0z0D0DSVert[0]);
1461 
1462  Double_t impactProductToDStar = d0DSVert[0]*d0DSVert[1];
1463  Double_t impactProductXYToDStar = candidateD0toDStar->ImpParXY(vertexDStar);
1464 
1465  Double_t pointingAngleToDStar = candidateD0toDStar->CosPointingAngle(vertexDStar);
1466  Double_t d0FirstDaughterToDStar = TMath::Abs(d0DSVert[0]);
1467  Double_t d0SecondDaughterToDStar = TMath::Abs(d0DSVert[1]);
1468  Double_t normDecayLengthToDStar = candidateD0toDStar->NormalizedDecayLength(vertexDStar);
1469 
1470  Double_t pseudoProperDecayLengthDSVert = ((vertexD0->GetX() - vertexDStar->GetX()) * candidateD0->Px() / TMath::Abs(candidateD0->Pt())) + ((vertexD0->GetY() - vertexDStar->GetY()) * candidateD0->Py() / TMath::Abs(candidateD0->Pt()));
1471  Double_t pseudoProperDecayTimeToDStar = pseudoProperDecayLengthDSVert * pdgMassMother/ptMother;
1472  Double_t DecayTimeToDStar = vertexDistance / (299792458 * TMath::Sqrt(1/((pdgMassMother*pdgMassMother/(momentumMother*momentumMother)) + 1)));
1473 
1474  Double_t phiDSVert = candidateD0->Phi();
1475  Double_t thetaDSVert = candidateD0->Theta();
1476  Double_t covMatrixDSVert[21];
1477  candidateD0->GetCovarianceXYZPxPyPz(covMatrixDSVert);
1478 
1479  cp = TMath::Cos(phiDSVert);
1480  sp = TMath::Sin(phiDSVert);
1481  ct = TMath::Cos(thetaDSVert);
1482  st = TMath::Sin(thetaDSVert);
1483 
1484  errorMomentum = covMatrix[9]*cp*cp*ct*ct // GetCovPxPx
1485  +covMatrix[13]*2.*cp*sp*ct*ct // GetCovPxPy
1486  +covMatrix[18]*2.*cp*ct*st // GetCovPxPz
1487  +covMatrix[14]*sp*sp*ct*ct // GetCovPyPy
1488  +covMatrix[19]*2.*sp*ct*st // GetCovPyPz
1489  +covMatrix[20]*st*st; // GetCovPzPz
1490  Double_t normalizedDecayTimeToDStar = candidateD0toDStar->NormalizedDecayLength(vertexDStar) / (299792458 * TMath::Sqrt(1/((pdgMassMother*pdgMassMother*errorMomentum*errorMomentum/(momentumMother*momentumMother)) + 1)));
1491 
1492  // "pointingAngleToDStar" ---------------------------------------------
1493  nCutIndex = 25;
1494  cutVariableValue = pointingAngleToDStar;
1495  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1496  if(!bPassedCut && !fGetCutInfo) return 0;
1497  //---------------------------------------------------------------------
1498 
1499  // "d0MotherToDStar" --------------------------------------------------
1500  nCutIndex = 26;
1501  cutVariableValue = d0D0DSVert;
1502  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1503  if(!bPassedCut && !fGetCutInfo) return 0;
1504  //---------------------------------------------------------------------
1505 
1506  // "d0FirstDaughterToDStar" -------------------------------------------
1507  nCutIndex = 27;
1508  cutVariableValue = d0FirstDaughterToDStar;
1509  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1510  if(!bPassedCut && !fGetCutInfo) return 0;
1511  //---------------------------------------------------------------------
1512 
1513  // "d0SecondDaughterToDStar" ------------------------------------------
1514  nCutIndex = 28;
1515  cutVariableValue = d0SecondDaughterToDStar;
1516  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1517  if(!bPassedCut && !fGetCutInfo) return 0;
1518  //---------------------------------------------------------------------
1519 
1520  // "impactProductToDStar" ---------------------------------------------
1521  nCutIndex = 29;
1522  cutVariableValue = impactProductToDStar;
1523  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1524  if(!bPassedCut && !fGetCutInfo) return 0;
1525  //---------------------------------------------------------------------
1526 
1527  // "impactProductXYToDStar" -------------------------------------------
1528  nCutIndex = 30;
1529  cutVariableValue = impactProductXYToDStar;
1530  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1531  if(!bPassedCut && !fGetCutInfo) return 0;
1532  //---------------------------------------------------------------------
1533 
1534  // "normDecayLengthToDStar" -------------------------------------------
1535  nCutIndex = 31;
1536  cutVariableValue = normDecayLengthToDStar;
1537  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1538  if(!bPassedCut && !fGetCutInfo) return 0;
1539  //---------------------------------------------------------------------
1540 
1541  // "pseudoProperDecayTimeToDStar" -------------------------------------
1542  nCutIndex = 32;
1543  cutVariableValue = pseudoProperDecayTimeToDStar;
1544  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1545  if(!bPassedCut && !fGetCutInfo) return 0;
1546  //---------------------------------------------------------------------
1547 
1548  // "DecayTimeToDStar" -------------------------------------------------
1549  nCutIndex = 33;
1550  cutVariableValue = DecayTimeToDStar;
1551  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1552  if(!bPassedCut && !fGetCutInfo) return 0;
1553  //---------------------------------------------------------------------
1554 
1555  // "normalizedDecayTimeToDStar" ---------------------------------------------
1556  nCutIndex = 34;
1557  cutVariableValue = normalizedDecayTimeToDStar;
1558  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1559  if(!bPassedCut && !fGetCutInfo) return 0;
1560  //---------------------------------------------------------------------
1561  }
1562 
1563  for (Int_t i = 0; i < 35; ++i)
1564  {
1565  if(bCutArray[i]==kTRUE){
1566  returnvalue = 0;
1567  break;
1568  }
1569  }
1570 
1571  return returnvalue;
1572 }
1573 //----------------------------------------------------------------------------------
1575  //
1576  // Apply selection on D0 candidate.
1577  //
1578 
1579  if(!fCutsRDD0forD0ptbin){
1580  cout<<"Cut matrice not inizialized. Exit..."<<endl;
1581  return 0;
1582  }
1583 
1584  AliAODRecoDecayHF2Prong* candidateD0 = (AliAODRecoDecayHF2Prong*)obj;
1585  if(!candidateD0){
1586  cout<<"candidateD0 null"<<endl;
1587  return 0;
1588  }
1589 
1590  AliAODTrack *candidatePion = (AliAODTrack*)candidateD0->GetDaughter(0);
1591  if(!candidatePion){
1592  cout<<"candidatePion null"<<endl;
1593  return 0;
1594  }
1595 
1596  AliAODTrack *candidateKaon = (AliAODTrack*)candidateD0->GetDaughter(1);
1597  if(!candidateKaon){
1598  cout<<"candidateKaon null"<<endl;
1599  return 0;
1600  }
1601 
1602  AliAODVertex * vertexD0 = candidateD0->GetSecondaryVtx();
1603  if(!vertexD0){
1604  cout<<"vertexD0 null"<<endl;
1605  return 0;
1606  }
1607 
1608  AliAODVertex * primaryVertex = aod->GetPrimaryVertex();
1609  if(!primaryVertex){
1610  cout<<"primaryVertex null"<<endl;
1611  return 0;
1612  }
1613 
1614  Int_t returnvalue=1;
1615  Bool_t bPassedCut = kFALSE;
1616 
1617  //get the magnetic field
1618  Double_t bz = (Double_t)aod->GetMagneticField();
1619 
1620 
1621  // selection on candidate
1622  if(selectionLevel==AliRDHFCuts::kAll ||
1623  selectionLevel==AliRDHFCuts::kCandidate) {
1624 
1625  Int_t ptbin=PtBinD0forD0ptbin(candidateD0->Pt());
1626  if(ptbin==-1) return -1;
1627 
1628  // D0mass
1629  Double_t mD0PDG = TDatabasePDG::Instance()->GetParticle(421)->Mass();
1630 
1631  // Half width DStar mass
1632  UInt_t prongs[2];
1633  prongs[0] = 211; prongs[1] = 321;
1634  Double_t invMassD0 = candidateD0->InvMass(2,prongs);
1635  Double_t invMassDifference = TMath::Abs(mD0PDG - invMassD0);
1636 
1637  Double_t pointingAngle = candidateD0->CosPointingAngle();
1638  Double_t dcaMother = candidateD0->GetDCA();
1639  Double_t ptMother = candidateD0->Pt();
1640  Double_t momentumMother = candidateD0->P();
1641  Double_t ptPion = candidatePion->Pt();
1642  Double_t ptKaon = candidateKaon->Pt();
1643 
1644  AliExternalTrackParam motherTrack;
1645  motherTrack.CopyFromVTrack(candidateD0);
1646  Double_t d0z0[2],covd0z0[3],d0[2];
1647  motherTrack.PropagateToDCA(primaryVertex,bz,100.,d0z0,covd0z0);
1648  d0[0] = d0z0[0];
1649  Double_t d0Mother = TMath::Abs(d0[0]);
1650  Double_t d0firstTrack = TMath::Abs(candidateD0->Getd0Prong(0));
1651  Double_t d0secondTrack = TMath::Abs(candidateD0->Getd0Prong(1));
1652 
1653  Double_t impactProduct = candidateD0->Prodd0d0();
1654  Double_t impactProductXY = TMath::Abs(candidateD0->ImpParXY());
1655 
1656  Double_t angleBetweenBothDaughters = (candidateKaon->Px() * candidatePion->Px() + candidateKaon->Py() * candidatePion->Py() + candidateKaon->Pz() * candidatePion->Pz()) /(candidateKaon->P() * candidatePion->P());
1657  Double_t angleMotherFirstDaughter = (candidateD0->Px() * candidatePion->Px() + candidateD0->Py() * candidatePion->Py() + candidateD0->Pz() * candidatePion->Pz()) /(candidateD0->P() * candidatePion->P());
1658  Double_t angleMotherSecondDaughter = (candidateD0->Px() * candidateKaon->Px() + candidateD0->Py() * candidateKaon->Py() + candidateD0->Pz() * candidateKaon->Pz()) /(candidateD0->P() * candidateKaon->P());
1659 
1660  Double_t cosThetaStar = candidateD0->CosThetaStar(0,421,211,321);
1661  Double_t vertexDistance = vertexD0->DistanceToVertex(primaryVertex);
1662  Double_t normDecayLength = candidateD0->NormalizedDecayLength();
1663  Double_t pdgMassMother = TDatabasePDG::Instance()->GetParticle(421)->Mass();
1664  Double_t pseudoProperDecayLength = ((vertexD0->GetX() - primaryVertex->GetX()) * candidateD0->Px() / TMath::Abs(candidateD0->Pt())) + ((vertexD0->GetY() - primaryVertex->GetY()) * candidateD0->Py() / TMath::Abs(candidateD0->Pt()));
1665  Double_t pseudoProperDecayTime = pseudoProperDecayLength * pdgMassMother/ptMother;
1666  Double_t decayTime = vertexDistance / (299792458 * TMath::Sqrt(1/((pdgMassMother*pdgMassMother/(momentumMother*momentumMother)) + 1)));
1667 
1668  Double_t phi = candidateD0->Phi();
1669  Double_t theta = candidateD0->Theta();
1670  Double_t covMatrix[21];
1671  candidateD0->GetCovarianceXYZPxPyPz(covMatrix);
1672 
1673  Double_t cp = TMath::Cos(phi);
1674  Double_t sp = TMath::Sin(phi);
1675  Double_t ct = TMath::Cos(theta);
1676  Double_t st = TMath::Sin(theta);
1677 
1678  Double_t errorMomentum = covMatrix[9]*cp*cp*ct*ct // GetCovPxPx
1679  +covMatrix[13]*2.*cp*sp*ct*ct // GetCovPxPy
1680  +covMatrix[18]*2.*cp*ct*st // GetCovPxPz
1681  +covMatrix[14]*sp*sp*ct*ct // GetCovPyPy
1682  +covMatrix[19]*2.*sp*ct*st // GetCovPyPz
1683  +covMatrix[20]*st*st; // GetCovPzPz
1684  Double_t normalizedDecayTime = candidateD0->NormalizedDecayLength() / (299792458 * TMath::Sqrt(1/((pdgMassMother*pdgMassMother*errorMomentum*errorMomentum/(momentumMother*momentumMother)) + 1)));
1685 
1686  //Topomatic
1687  Double_t dd0pr1=0.;
1688  Double_t dd0pr2=0.;
1689  Double_t dd0max=0.;
1690  Double_t dd0min=0.;
1691  for(Int_t ipr=0; ipr<2; ipr++)
1692  {
1693  Double_t diffIP, errdiffIP;
1694  candidateD0->Getd0MeasMinusExpProng(ipr,bz,diffIP,errdiffIP);
1695  Double_t normdd0=0.;
1696  if(errdiffIP>0.) normdd0=diffIP/errdiffIP;
1697  if(ipr==0) dd0pr1=normdd0;
1698  if(ipr==1) dd0pr2=normdd0;
1699  }
1700  if(TMath::Abs(dd0pr1)>TMath::Abs(dd0pr2)) {dd0max=dd0pr1; dd0min=dd0pr2;}
1701  else {dd0max=dd0pr2; dd0min=dd0pr1;}
1702 
1703 
1704  // We apply the cuts
1705  Int_t nCutIndex = 0;
1706  Double_t cutVariableValue = 0.0;
1707 
1708  // "inv. mass width [GeV]" --------------------------------------------
1709  nCutIndex = 0;
1710  cutVariableValue = invMassDifference;
1711  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
1712  if(!bPassedCut && !fGetCutInfo) return 0;
1713  //---------------------------------------------------------------------
1714 
1715  // "delta mass width [GeV]" -------------------------------------------
1716  // nCutIndex = 1; // not used for D0
1717  // cutVariableValue = invMassDelta;
1718  // bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
1719  // if(!bPassedCut && !fGetCutInfo) return 0;
1720  //---------------------------------------------------------------------
1721 
1722  // "pointing angle [Cos(theta)]" --------------------------------------
1723  nCutIndex = 2;
1724  cutVariableValue = pointingAngle;
1725  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
1726  if(!bPassedCut && !fGetCutInfo) return 0;
1727  //---------------------------------------------------------------------
1728 
1729  // "dca [cm]" ---------------------------------------------------------
1730  nCutIndex = 3;
1731  cutVariableValue = dcaMother;
1732  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
1733  if(!bPassedCut && !fGetCutInfo) return 0;
1734  //---------------------------------------------------------------------
1735 
1736  // "Pt D0 [GeV/c]" ----------------------------------------------------
1737  nCutIndex = 4;
1738  cutVariableValue = ptMother;
1739  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
1740  if(!bPassedCut && !fGetCutInfo) return 0;
1741  //---------------------------------------------------------------------
1742 
1743  // "Pt Kaon [GeV/c]" -------------------------------------------------
1744  nCutIndex = 5;
1745  cutVariableValue = ptKaon;
1746  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
1747  if(!bPassedCut && !fGetCutInfo) return 0;
1748  //---------------------------------------------------------------------
1749 
1750  // "Pt Pion [GeV/c]" --------------------------------------------------
1751  nCutIndex = 6;
1752  cutVariableValue = ptPion;
1753  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
1754  if(!bPassedCut && !fGetCutInfo) return 0;
1755  //---------------------------------------------------------------------
1756 
1757  // "d0 D0 [cm]" -------------------------------------------------------
1758  nCutIndex = 7;
1759  cutVariableValue = d0Mother;
1760  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
1761  if(!bPassedCut && !fGetCutInfo) return 0;
1762  //---------------------------------------------------------------------
1763 
1764  // "d0 Kaon [cm]"-----------------------------------------------------
1765  nCutIndex = 8;
1766  cutVariableValue = d0firstTrack;
1767  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
1768  if(!bPassedCut && !fGetCutInfo) return 0;
1769  //---------------------------------------------------------------------
1770 
1771  // "d0 Pion [cm]" -----------------------------------------------------
1772  nCutIndex = 9;
1773  cutVariableValue = d0secondTrack;
1774  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
1775  if(!bPassedCut && !fGetCutInfo) return 0;
1776  //---------------------------------------------------------------------
1777 
1778  // "d0d0 [cm^2]" ------------------------------------------------------
1779  nCutIndex = 10;
1780  cutVariableValue = impactProduct;
1781  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
1782  if(!bPassedCut && !fGetCutInfo) return 0;
1783  //---------------------------------------------------------------------
1784 
1785  // "d0d0 XY [cm^2]" ---------------------------------------------------
1786  nCutIndex = 11;
1787  cutVariableValue = impactProductXY;
1788  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
1789  if(!bPassedCut && !fGetCutInfo) return 0;
1790  //---------------------------------------------------------------------
1791 
1792  // "angle between both daughters" -------------------------------------
1793  nCutIndex = 12;
1794  cutVariableValue = angleBetweenBothDaughters;
1795  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
1796  if(!bPassedCut && !fGetCutInfo) return 0;
1797  //---------------------------------------------------------------------
1798 
1799  // "angle mother with first daughter" ---------------------------------
1800  nCutIndex = 13;
1801  cutVariableValue = angleMotherFirstDaughter;
1802  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
1803  if(!bPassedCut && !fGetCutInfo) return 0;
1804  //---------------------------------------------------------------------
1805 
1806  // "angle mother with second daughter" --------------------------------
1807  nCutIndex = 14;
1808  cutVariableValue = angleMotherSecondDaughter;
1809  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
1810  if(!bPassedCut && !fGetCutInfo) return 0;
1811  //---------------------------------------------------------------------
1812 
1813  // "cosThetaStar" -----------------------------------------------------
1814  nCutIndex = 15;
1815  cutVariableValue = cosThetaStar;
1816  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
1817  if(!bPassedCut && !fGetCutInfo) return 0;
1818  //---------------------------------------------------------------------
1819 
1820  // "vertexDistance" ---------------------------------------------------
1821  nCutIndex = 16;
1822  cutVariableValue = vertexDistance;
1823  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
1824  if(!bPassedCut && !fGetCutInfo) return 0;
1825  //---------------------------------------------------------------------
1826 
1827  // "pseudoProperDecayTime" --------------------------------------------
1828  nCutIndex = 17;
1829  cutVariableValue = pseudoProperDecayTime;
1830  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
1831  if(!bPassedCut && !fGetCutInfo) return 0;
1832  //---------------------------------------------------------------------
1833 
1834  // "DecayTime" --------------------------------------------------------
1835  nCutIndex = 18;
1836  cutVariableValue = decayTime;
1837  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
1838  if(!bPassedCut && !fGetCutInfo) return 0;
1839  //---------------------------------------------------------------------
1840 
1841  // "normalizedDecayTime" ----------------------------------------------------
1842  nCutIndex = 19;
1843  cutVariableValue = normalizedDecayTime;
1844  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
1845  if(!bPassedCut && !fGetCutInfo) return 0;
1846  //---------------------------------------------------------------------
1847 
1848  // "normDecayLength" --------------------------------------------------
1849  nCutIndex = 20;
1850  cutVariableValue = normDecayLength;
1851  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
1852  if(!bPassedCut && !fGetCutInfo) return 0;
1853  //---------------------------------------------------------------------
1854 
1855  // "topomatic first daughter" -----------------------------------------
1856  nCutIndex = 21;
1857  cutVariableValue = dd0pr1;
1858  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
1859  if(!bPassedCut && !fGetCutInfo) return 0;
1860  //---------------------------------------------------------------------
1861 
1862  // "topomatic second daughter" ----------------------------------------
1863  nCutIndex = 22;
1864  cutVariableValue = dd0pr2;
1865  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
1866  if(!bPassedCut && !fGetCutInfo) return 0;
1867  //---------------------------------------------------------------------
1868 
1869  // "topomatic max" ----------------------------------------------------
1870  nCutIndex = 23;
1871  cutVariableValue = dd0max;
1872  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
1873  if(!bPassedCut && !fGetCutInfo) return 0;
1874  //---------------------------------------------------------------------
1875 
1876  // "topomatic min" ----------------------------------------------------
1877  nCutIndex = 24;
1878  cutVariableValue = dd0min;
1879  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
1880  if(!bPassedCut && !fGetCutInfo) return 0;
1881  //---------------------------------------------------------------------
1882 
1883  }
1884 
1885  for (Int_t i = 0; i < 25; ++i)
1886  {
1887  if(bCutArray[i]==kTRUE){
1888  returnvalue = 0;
1889  break;
1890  }
1891  }
1892 
1893  return returnvalue;
1894 }
1895 //----------------------------------------------------------------------------------
1897  //
1898  // Apply selection on D0 candidate from DStar candidate. We have to pass the DStar candidate to this function to get variables w.r.t. DStar vertex.
1899  //
1900 
1902  cout<<"Cut matrice not inizialized. Exit..."<<endl;
1903  return 0;
1904  }
1905 
1906  AliAODRecoDecayHF2Prong* candidateDStar = (AliAODRecoDecayHF2Prong*)obj;
1907  if(!candidateDStar){
1908  cout<<"candidateDStar null"<<endl;
1909  return 0;
1910  }
1911 
1912  AliAODRecoDecayHF2Prong* candidateD0 = (AliAODRecoDecayHF2Prong*)candidateDStar->GetDaughter(1);
1913  if(!candidateD0){
1914  cout<<"candidateD0 null"<<endl;
1915  return 0;
1916  }
1917 
1918  AliAODTrack *candidatePion = (AliAODTrack*)candidateD0->GetDaughter(0);
1919  if(!candidatePion){
1920  cout<<"candidatePion null"<<endl;
1921  return 0;
1922  }
1923 
1924  AliAODTrack *candidateKaon = (AliAODTrack*)candidateD0->GetDaughter(1);
1925  if(!candidateKaon){
1926  cout<<"candidateKaon null"<<endl;
1927  return 0;
1928  }
1929 
1930  AliAODVertex * vertexDStar = candidateDStar->GetSecondaryVtx();
1931  if(!vertexDStar){
1932  cout<<"vertexDStar null"<<endl;
1933  return 0;
1934  }
1935 
1936  AliAODVertex * vertexD0 = candidateD0->GetSecondaryVtx();
1937  if(!vertexD0){
1938  cout<<"vertexD0 null"<<endl;
1939  return 0;
1940  }
1941 
1942  AliAODVertex * primaryVertex = aod->GetPrimaryVertex();
1943  if(!primaryVertex){
1944  cout<<"primaryVertex null"<<endl;
1945  return 0;
1946  }
1947 
1948  Int_t returnvalue=1;
1949  Bool_t bPassedCut = kFALSE;
1950 
1951  //get the magnetic field
1952  Double_t bz = (Double_t)aod->GetMagneticField();
1953 
1954 
1955  // selection on candidate
1956  if(selectionLevel==AliRDHFCuts::kAll ||
1957  selectionLevel==AliRDHFCuts::kCandidate) {
1958 
1959  Int_t ptbin=PtBinD0forDStarptbin(candidateDStar->Pt());
1960  if(ptbin==-1) return -1;
1961  // D0mass
1962  Double_t mD0PDG = TDatabasePDG::Instance()->GetParticle(421)->Mass();
1963 
1964  // Half width DStar mass
1965  UInt_t prongs[2];
1966  prongs[0] = 211; prongs[1] = 321;
1967  Double_t invMassD0 = candidateD0->InvMass(2,prongs);
1968  Double_t invMassDifference = TMath::Abs(mD0PDG - invMassD0);
1969 
1970  Double_t pointingAngle = candidateD0->CosPointingAngle();
1971  Double_t dcaMother = candidateD0->GetDCA();
1972  Double_t ptMother = candidateD0->Pt();
1973  Double_t momentumMother = candidateD0->P();
1974  Double_t ptPion = candidatePion->Pt();
1975  Double_t ptKaon = candidateKaon->Pt();
1976 
1977  AliExternalTrackParam motherTrack;
1978  motherTrack.CopyFromVTrack(candidateD0);
1979  Double_t d0z0[2],covd0z0[3],d0[2];
1980  motherTrack.PropagateToDCA(primaryVertex,bz,100.,d0z0,covd0z0);
1981  d0[0] = d0z0[0];
1982  Double_t d0Mother = TMath::Abs(d0[0]);
1983  Double_t d0firstTrack = TMath::Abs(candidateD0->Getd0Prong(0));
1984  Double_t d0secondTrack = TMath::Abs(candidateD0->Getd0Prong(1));
1985 
1986  Double_t impactProduct = candidateD0->Prodd0d0();
1987  Double_t impactProductXY = TMath::Abs(candidateD0->ImpParXY());
1988 
1989  Double_t angleBetweenBothDaughters = (candidateKaon->Px() * candidatePion->Px() + candidateKaon->Py() * candidatePion->Py() + candidateKaon->Pz() * candidatePion->Pz()) /(candidateKaon->P() * candidatePion->P());
1990  Double_t angleMotherFirstDaughter = (candidateD0->Px() * candidatePion->Px() + candidateD0->Py() * candidatePion->Py() + candidateD0->Pz() * candidatePion->Pz()) /(candidateD0->P() * candidatePion->P());
1991  Double_t angleMotherSecondDaughter = (candidateD0->Px() * candidateKaon->Px() + candidateD0->Py() * candidateKaon->Py() + candidateD0->Pz() * candidateKaon->Pz()) /(candidateD0->P() * candidateKaon->P());
1992 
1993  Double_t cosThetaStar = candidateD0->CosThetaStar(0,421,211,321);
1994  Double_t vertexDistance = vertexD0->DistanceToVertex(primaryVertex);
1995  Double_t normDecayLength = candidateD0->NormalizedDecayLength();
1996  Double_t pdgMassMother = TDatabasePDG::Instance()->GetParticle(421)->Mass();
1997  Double_t pseudoProperDecayLength = ((vertexD0->GetX() - primaryVertex->GetX()) * candidateD0->Px() / TMath::Abs(candidateD0->Pt())) + ((vertexD0->GetY() - primaryVertex->GetY()) * candidateD0->Py() / TMath::Abs(candidateD0->Pt()));
1998  Double_t pseudoProperDecayTime = pseudoProperDecayLength * pdgMassMother/ptMother;
1999  Double_t decayTime = vertexDistance / (299792458 * TMath::Sqrt(1/((pdgMassMother*pdgMassMother/(momentumMother*momentumMother)) + 1)));
2000 
2001  Double_t phi = candidateD0->Phi();
2002  Double_t theta = candidateD0->Theta();
2003  Double_t covMatrix[21];
2004  candidateD0->GetCovarianceXYZPxPyPz(covMatrix);
2005 
2006  Double_t cp = TMath::Cos(phi);
2007  Double_t sp = TMath::Sin(phi);
2008  Double_t ct = TMath::Cos(theta);
2009  Double_t st = TMath::Sin(theta);
2010 
2011  Double_t errorMomentum = covMatrix[9]*cp*cp*ct*ct // GetCovPxPx
2012  +covMatrix[13]*2.*cp*sp*ct*ct // GetCovPxPy
2013  +covMatrix[18]*2.*cp*ct*st // GetCovPxPz
2014  +covMatrix[14]*sp*sp*ct*ct // GetCovPyPy
2015  +covMatrix[19]*2.*sp*ct*st // GetCovPyPz
2016  +covMatrix[20]*st*st; // GetCovPzPz
2017  Double_t normalizedDecayTime = candidateD0->NormalizedDecayLength() / (299792458 * TMath::Sqrt(1/((pdgMassMother*pdgMassMother*errorMomentum*errorMomentum/(momentumMother*momentumMother)) + 1)));
2018 
2019  //Topomatic
2020  Double_t dd0pr1=0.;
2021  Double_t dd0pr2=0.;
2022  Double_t dd0max=0.;
2023  Double_t dd0min=0.;
2024  for(Int_t ipr=0; ipr<2; ipr++)
2025  {
2026  Double_t diffIP, errdiffIP;
2027  candidateD0->Getd0MeasMinusExpProng(ipr,bz,diffIP,errdiffIP);
2028  Double_t normdd0=0.;
2029  if(errdiffIP>0.) normdd0=diffIP/errdiffIP;
2030  if(ipr==0) dd0pr1=normdd0;
2031  if(ipr==1) dd0pr2=normdd0;
2032  }
2033  if(TMath::Abs(dd0pr1)>TMath::Abs(dd0pr2)) {dd0max=dd0pr1; dd0min=dd0pr2;}
2034  else {dd0max=dd0pr2; dd0min=dd0pr1;}
2035 
2036 
2037  // We apply the cuts
2038  Int_t nCutIndex = 0;
2039  Double_t cutVariableValue = 0.0;
2040 
2041  // "inv. mass width [GeV]" --------------------------------------------
2042  nCutIndex = 0;
2043  cutVariableValue = invMassDifference;
2044  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2045  if(!bPassedCut && !fGetCutInfo) return 0;
2046  //---------------------------------------------------------------------
2047 
2048  // "delta mass width [GeV]" -------------------------------------------
2049  // nCutIndex = 1; // not used for D0
2050  // cutVariableValue = invMassDelta;
2051  // bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2052  // if(!bPassedCut && !fGetCutInfo) return 0;
2053  //---------------------------------------------------------------------
2054 
2055  // "pointing angle [Cos(theta)]" --------------------------------------
2056  nCutIndex = 2;
2057  cutVariableValue = pointingAngle;
2058  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2059  if(!bPassedCut && !fGetCutInfo) return 0;
2060  //---------------------------------------------------------------------
2061 
2062  // "dca [cm]" ---------------------------------------------------------
2063  nCutIndex = 3;
2064  cutVariableValue = dcaMother;
2065  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2066  if(!bPassedCut && !fGetCutInfo) return 0;
2067  //---------------------------------------------------------------------
2068 
2069  // "Pt D0 [GeV/c]" ----------------------------------------------------
2070  nCutIndex = 4;
2071  cutVariableValue = ptMother;
2072  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2073  if(!bPassedCut && !fGetCutInfo) return 0;
2074  //---------------------------------------------------------------------
2075 
2076  // "Pt Kaon [GeV/c]" -------------------------------------------------
2077  nCutIndex = 5;
2078  cutVariableValue = ptKaon;
2079  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2080  if(!bPassedCut && !fGetCutInfo) return 0;
2081  //---------------------------------------------------------------------
2082 
2083  // "Pt Pion [GeV/c]" --------------------------------------------------
2084  nCutIndex = 6;
2085  cutVariableValue = ptPion;
2086  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2087  if(!bPassedCut && !fGetCutInfo) return 0;
2088  //---------------------------------------------------------------------
2089 
2090  // "d0 D0 [cm]" -------------------------------------------------------
2091  nCutIndex = 7;
2092  cutVariableValue = d0Mother;
2093  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2094  if(!bPassedCut && !fGetCutInfo) return 0;
2095  //---------------------------------------------------------------------
2096 
2097  // "d0 Kaon [cm]"-----------------------------------------------------
2098  nCutIndex = 8;
2099  cutVariableValue = d0firstTrack;
2100  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2101  if(!bPassedCut && !fGetCutInfo) return 0;
2102  //---------------------------------------------------------------------
2103 
2104  // "d0 Pion [cm]" -----------------------------------------------------
2105  nCutIndex = 9;
2106  cutVariableValue = d0secondTrack;
2107  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2108  if(!bPassedCut && !fGetCutInfo) return 0;
2109  //---------------------------------------------------------------------
2110 
2111  // "d0d0 [cm^2]" ------------------------------------------------------
2112  nCutIndex = 10;
2113  cutVariableValue = impactProduct;
2114  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2115  if(!bPassedCut && !fGetCutInfo) return 0;
2116  //---------------------------------------------------------------------
2117 
2118  // "d0d0 XY [cm^2]" ---------------------------------------------------
2119  nCutIndex = 11;
2120  cutVariableValue = impactProductXY;
2121  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2122  if(!bPassedCut && !fGetCutInfo) return 0;
2123  //---------------------------------------------------------------------
2124 
2125  // "angle between both daughters" -------------------------------------
2126  nCutIndex = 12;
2127  cutVariableValue = angleBetweenBothDaughters;
2128  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2129  if(!bPassedCut && !fGetCutInfo) return 0;
2130  //---------------------------------------------------------------------
2131 
2132  // "angle mother with first daughter" ---------------------------------
2133  nCutIndex = 13;
2134  cutVariableValue = angleMotherFirstDaughter;
2135  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2136  if(!bPassedCut && !fGetCutInfo) return 0;
2137  //---------------------------------------------------------------------
2138 
2139  // "angle mother with second daughter" --------------------------------
2140  nCutIndex = 14;
2141  cutVariableValue = angleMotherSecondDaughter;
2142  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2143  if(!bPassedCut && !fGetCutInfo) return 0;
2144  //---------------------------------------------------------------------
2145 
2146  // "cosThetaStar" -----------------------------------------------------
2147  nCutIndex = 15;
2148  cutVariableValue = cosThetaStar;
2149  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2150  if(!bPassedCut && !fGetCutInfo) return 0;
2151  //---------------------------------------------------------------------
2152 
2153  // "vertexDistance" ---------------------------------------------------
2154  nCutIndex = 16;
2155  cutVariableValue = vertexDistance;
2156  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2157  if(!bPassedCut && !fGetCutInfo) return 0;
2158  //---------------------------------------------------------------------
2159 
2160  // "pseudoProperDecayTime" --------------------------------------------
2161  nCutIndex = 17;
2162  cutVariableValue = pseudoProperDecayTime;
2163  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2164  if(!bPassedCut && !fGetCutInfo) return 0;
2165  //---------------------------------------------------------------------
2166 
2167  // "DecayTime" --------------------------------------------------------
2168  nCutIndex = 18;
2169  cutVariableValue = decayTime;
2170  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2171  if(!bPassedCut && !fGetCutInfo) return 0;
2172  //---------------------------------------------------------------------
2173 
2174  // "normalizedDecayTime" ----------------------------------------------------
2175  nCutIndex = 19;
2176  cutVariableValue = normalizedDecayTime;
2177  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2178  if(!bPassedCut && !fGetCutInfo) return 0;
2179  //---------------------------------------------------------------------
2180 
2181  // "normDecayLength" --------------------------------------------------
2182  nCutIndex = 20;
2183  cutVariableValue = normDecayLength;
2184  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2185  if(!bPassedCut && !fGetCutInfo) return 0;
2186  //---------------------------------------------------------------------
2187 
2188  // "topomatic first daughter" -----------------------------------------
2189  nCutIndex = 21;
2190  cutVariableValue = dd0pr1;
2191  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2192  if(!bPassedCut && !fGetCutInfo) return 0;
2193  //---------------------------------------------------------------------
2194 
2195  // "topomatic second daughter" ----------------------------------------
2196  nCutIndex = 22;
2197  cutVariableValue = dd0pr2;
2198  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2199  if(!bPassedCut && !fGetCutInfo) return 0;
2200  //---------------------------------------------------------------------
2201 
2202  // "topomatic max" ----------------------------------------------------
2203  nCutIndex = 23;
2204  cutVariableValue = dd0max;
2205  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2206  if(!bPassedCut && !fGetCutInfo) return 0;
2207  //---------------------------------------------------------------------
2208 
2209  // "topomatic min" ----------------------------------------------------
2210  nCutIndex = 24;
2211  cutVariableValue = dd0min;
2212  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2213  if(!bPassedCut && !fGetCutInfo) return 0;
2214  //---------------------------------------------------------------------
2215 
2216  AliAODRecoDecay* candidateD0toDStar = (AliAODRecoDecay*)candidateD0;
2217  AliExternalTrackParam pionD0Track;
2218  AliExternalTrackParam kaonD0Track;
2219 
2220  Double_t d0z0DSVert[2],covd0z0DSVert[3],d0DSVert[2];
2221 
2222  pionD0Track.CopyFromVTrack(candidatePion);
2223  pionD0Track.PropagateToDCA(vertexDStar,bz,100.,d0z0DSVert,covd0z0DSVert);
2224  d0DSVert[0] = d0z0DSVert[0];
2225 
2226  kaonD0Track.CopyFromVTrack(candidateKaon);
2227  kaonD0Track.PropagateToDCA(vertexDStar,bz,100.,d0z0DSVert,covd0z0DSVert);
2228  d0DSVert[1] = d0z0DSVert[0];
2229 
2230  AliExternalTrackParam D0Track;
2231  D0Track.CopyFromVTrack(candidateD0);
2232  Double_t d0z0D0DSVert[2],covd0z0D0DSVert[3],d0D0DSVert;
2233  motherTrack.PropagateToDCA(vertexDStar,bz,100.,d0z0D0DSVert,covd0z0D0DSVert);
2234  d0D0DSVert = TMath::Abs(d0z0D0DSVert[0]);
2235 
2236  Double_t impactProductToDStar = d0DSVert[0]*d0DSVert[1];
2237  Double_t impactProductXYToDStar = candidateD0toDStar->ImpParXY(vertexDStar);
2238 
2239  Double_t pointingAngleToDStar = candidateD0toDStar->CosPointingAngle(vertexDStar);
2240  Double_t d0FirstDaughterToDStar = TMath::Abs(d0DSVert[0]);
2241  Double_t d0SecondDaughterToDStar = TMath::Abs(d0DSVert[1]);
2242  Double_t normDecayLengthToDStar = candidateD0toDStar->NormalizedDecayLength(vertexDStar);
2243 
2244  Double_t pseudoProperDecayLengthDSVert = ((vertexD0->GetX() - vertexDStar->GetX()) * candidateD0->Px() / TMath::Abs(candidateD0->Pt())) + ((vertexD0->GetY() - vertexDStar->GetY()) * candidateD0->Py() / TMath::Abs(candidateD0->Pt()));
2245  Double_t pseudoProperDecayTimeToDStar = pseudoProperDecayLengthDSVert * pdgMassMother/ptMother;
2246  Double_t DecayTimeToDStar = vertexDistance / (299792458 * TMath::Sqrt(1/((pdgMassMother*pdgMassMother/(momentumMother*momentumMother)) + 1)));
2247 
2248  Double_t phiDSVert = candidateD0->Phi();
2249  Double_t thetaDSVert = candidateD0->Theta();
2250  Double_t covMatrixDSVert[21];
2251  candidateD0->GetCovarianceXYZPxPyPz(covMatrixDSVert);
2252 
2253  cp = TMath::Cos(phiDSVert);
2254  sp = TMath::Sin(phiDSVert);
2255  ct = TMath::Cos(thetaDSVert);
2256  st = TMath::Sin(thetaDSVert);
2257 
2258  errorMomentum = covMatrix[9]*cp*cp*ct*ct // GetCovPxPx
2259  +covMatrix[13]*2.*cp*sp*ct*ct // GetCovPxPy
2260  +covMatrix[18]*2.*cp*ct*st // GetCovPxPz
2261  +covMatrix[14]*sp*sp*ct*ct // GetCovPyPy
2262  +covMatrix[19]*2.*sp*ct*st // GetCovPyPz
2263  +covMatrix[20]*st*st; // GetCovPzPz
2264  Double_t normalizedDecayTimeToDStar = candidateD0toDStar->NormalizedDecayLength(vertexDStar) / (299792458 * TMath::Sqrt(1/((pdgMassMother*pdgMassMother*errorMomentum*errorMomentum/(momentumMother*momentumMother)) + 1)));
2265 
2266  // "pointingAngleToDStar" ---------------------------------------------
2267  nCutIndex = 25;
2268  cutVariableValue = pointingAngleToDStar;
2269  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2270  if(!bPassedCut && !fGetCutInfo) return 0;
2271  //---------------------------------------------------------------------
2272 
2273  // "d0MotherToDStar" --------------------------------------------------
2274  nCutIndex = 26;
2275  cutVariableValue = d0D0DSVert;
2276  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2277  if(!bPassedCut && !fGetCutInfo) return 0;
2278  //---------------------------------------------------------------------
2279 
2280  // "d0FirstDaughterToDStar" -------------------------------------------
2281  nCutIndex = 27;
2282  cutVariableValue = d0FirstDaughterToDStar;
2283  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2284  if(!bPassedCut && !fGetCutInfo) return 0;
2285  //---------------------------------------------------------------------
2286 
2287  // "d0SecondDaughterToDStar" ------------------------------------------
2288  nCutIndex = 28;
2289  cutVariableValue = d0SecondDaughterToDStar;
2290  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2291  if(!bPassedCut && !fGetCutInfo) return 0;
2292  //---------------------------------------------------------------------
2293 
2294  // "impactProductToDStar" ---------------------------------------------
2295  nCutIndex = 29;
2296  cutVariableValue = impactProductToDStar;
2297  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2298  if(!bPassedCut && !fGetCutInfo) return 0;
2299  //---------------------------------------------------------------------
2300 
2301  // "impactProductXYToDStar" -------------------------------------------
2302  nCutIndex = 30;
2303  cutVariableValue = impactProductXYToDStar;
2304  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2305  if(!bPassedCut && !fGetCutInfo) return 0;
2306  //---------------------------------------------------------------------
2307 
2308  // "normDecayLengthToDStar" -------------------------------------------
2309  nCutIndex = 31;
2310  cutVariableValue = normDecayLengthToDStar;
2311  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2312  if(!bPassedCut && !fGetCutInfo) return 0;
2313  //---------------------------------------------------------------------
2314 
2315  // "pseudoProperDecayTimeToDStar" -------------------------------------
2316  nCutIndex = 32;
2317  cutVariableValue = pseudoProperDecayTimeToDStar;
2318  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2319  if(!bPassedCut && !fGetCutInfo) return 0;
2320  //---------------------------------------------------------------------
2321 
2322  // "DecayTimeToDStar" -------------------------------------------------
2323  nCutIndex = 33;
2324  cutVariableValue = DecayTimeToDStar;
2325  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2326  if(!bPassedCut && !fGetCutInfo) return 0;
2327  //---------------------------------------------------------------------
2328 
2329  // "normalizedDecayTimeToDStar" ---------------------------------------------
2330  nCutIndex = 34;
2331  cutVariableValue = normalizedDecayTimeToDStar;
2332  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2333  if(!bPassedCut && !fGetCutInfo) return 0;
2334  //---------------------------------------------------------------------
2335  }
2336 
2337  for (Int_t i = 0; i < 35; ++i)
2338  {
2339  if(bCutArray[i]==kTRUE){
2340  returnvalue = 0;
2341  break;
2342  }
2343  }
2344 
2345  return returnvalue;
2346 }
2347 //---------------------------------------------------------------------------
2349  //
2350  // Apply selection for DStar candidate
2351  //
2352 
2354  cout<<"Cut matrice not inizialized. Exit..."<<endl;
2355  return 0;
2356  }
2357 
2358  AliAODRecoDecayHF2Prong* candidateDStar = (AliAODRecoDecayHF2Prong*)obj;
2359  if(!candidateDStar){
2360  cout<<"candidateDStar null"<<endl;
2361  return 0;
2362  }
2363 
2364  AliAODRecoDecayHF2Prong* candidateD0 = (AliAODRecoDecayHF2Prong*)candidateDStar->GetDaughter(1);
2365  if(!candidateD0){
2366  cout<<"candidateD0 null"<<endl;
2367  return 0;
2368  }
2369 
2370  AliAODTrack *candidatePion = (AliAODTrack*)candidateDStar->GetDaughter(0);
2371  if(!candidatePion){
2372  cout<<"candidatePion null"<<endl;
2373  return 0;
2374  }
2375 
2376  AliAODVertex * vertexDStar = candidateDStar->GetSecondaryVtx();
2377  if(!vertexDStar){
2378  cout<<"vertexDStar null"<<endl;
2379  return 0;
2380  }
2381 
2382  AliAODVertex * primaryVertex = aod->GetPrimaryVertex();
2383  if(!primaryVertex){
2384  cout<<"primaryVertex null"<<endl;
2385  return 0;
2386  }
2387 
2388  Int_t returnvalue=1;
2389  Bool_t bPassedCut = kFALSE;
2390 
2391  //get the magnetic field
2392  Double_t bz = (Double_t)aod->GetMagneticField();
2393 
2394  // selection on candidate
2395  if(selectionLevel==AliRDHFCuts::kAll ||
2396  selectionLevel==AliRDHFCuts::kCandidate) {
2397 
2398  Int_t ptbin=PtBinDStarforDStarptbin(candidateDStar->Pt());
2399  if(ptbin==-1) return -1;
2400 
2401  // DStarMass and D0mass
2402  Double_t mDSPDG = TDatabasePDG::Instance()->GetParticle(413)->Mass();
2403  Double_t mD0PDG = TDatabasePDG::Instance()->GetParticle(421)->Mass();
2404 
2405  // delta mass PDG
2406  Double_t deltaPDG = mDSPDG-mD0PDG;
2407 
2408  // Half width DStar mass
2409  UInt_t prongs[2];
2410  prongs[0] = 211; prongs[1] = 421;
2411  Double_t invMassDStar = candidateDStar->InvMass(2,prongs);
2412  Double_t invMassDifference = TMath::Abs(mDSPDG - invMassDStar);
2413  Double_t invMassDelta = TMath::Abs(deltaPDG-(DeltaInvMassDStarKpipi(candidateDStar)));
2414 
2415  Double_t pointingAngle = candidateDStar->CosPointingAngle();
2416  Double_t dcaMother = candidateDStar->GetDCA();
2417  Double_t ptMother = candidateDStar->Pt();
2418  Double_t momentumMother = candidateDStar->P();
2419  Double_t ptD0 = candidateD0->Pt();
2420  Double_t ptPion = candidatePion->Pt();
2421 
2422  AliExternalTrackParam motherTrack;
2423  motherTrack.CopyFromVTrack(candidateDStar);
2424  Double_t d0z0[2],covd0z0[3],d0[2];
2425  motherTrack.PropagateToDCA(primaryVertex,bz,100.,d0z0,covd0z0);
2426  d0[0] = d0z0[0];
2427  Double_t d0Mother = TMath::Abs(d0[0]);
2428  Double_t d0firstTrack = TMath::Abs(candidateDStar->Getd0Prong(0));
2429  Double_t d0secondTrack = TMath::Abs(candidateDStar->Getd0Prong(1));
2430 
2431  Double_t impactProduct = candidateDStar->Prodd0d0();
2432  Double_t impactProductXY = TMath::Abs(candidateDStar->ImpParXY());
2433 
2434  Double_t angleBetweenBothDaughters = (candidateD0->Px() * candidatePion->Px() + candidateD0->Py() * candidatePion->Py() + candidateD0->Pz() * candidatePion->Pz()) /(candidateD0->P() * candidatePion->P());
2435  Double_t angleMotherFirstDaughter = (candidateDStar->Px() * candidatePion->Px() + candidateDStar->Py() * candidatePion->Py() + candidateDStar->Pz() * candidatePion->Pz()) /(candidateDStar->P() * candidatePion->P());
2436  Double_t angleMotherSecondDaughter = (candidateDStar->Px() * candidateD0->Px() + candidateDStar->Py() * candidateD0->Py() + candidateDStar->Pz() * candidateD0->Pz()) /(candidateDStar->P() * candidateD0->P());
2437 
2438  Double_t cosThetaStar = candidateDStar->CosThetaStar(0,413,211,421);
2439  Double_t vertexDistance = vertexDStar->DistanceToVertex(primaryVertex);
2440  Double_t normDecayLength = candidateDStar->NormalizedDecayLength();
2441  Double_t pdgMassMother = TDatabasePDG::Instance()->GetParticle(413)->Mass();
2442  Double_t pseudoProperDecayLength = ((vertexDStar->GetX() - primaryVertex->GetX()) * candidateDStar->Px() / TMath::Abs(candidateDStar->Pt())) + ((vertexDStar->GetY() - primaryVertex->GetY()) * candidateDStar->Py() / TMath::Abs(candidateDStar->Pt()));
2443  Double_t pseudoProperDecayTime = pseudoProperDecayLength * pdgMassMother/ptMother;
2444  Double_t decayTime = vertexDistance / (299792458 * TMath::Sqrt(1/((pdgMassMother*pdgMassMother/(momentumMother*momentumMother)) + 1)));
2445 
2446  Double_t phi = candidateDStar->Phi();
2447  Double_t theta = candidateDStar->Theta();
2448  Double_t covMatrix[21];
2449  candidateDStar->GetCovarianceXYZPxPyPz(covMatrix);
2450 
2451  Double_t cp = TMath::Cos(phi);
2452  Double_t sp = TMath::Sin(phi);
2453  Double_t ct = TMath::Cos(theta);
2454  Double_t st = TMath::Sin(theta);
2455 
2456  Double_t errorMomentum = covMatrix[9]*cp*cp*ct*ct // GetCovPxPx
2457  +covMatrix[13]*2.*cp*sp*ct*ct // GetCovPxPy
2458  +covMatrix[18]*2.*cp*ct*st // GetCovPxPz
2459  +covMatrix[14]*sp*sp*ct*ct // GetCovPyPy
2460  +covMatrix[19]*2.*sp*ct*st // GetCovPyPz
2461  +covMatrix[20]*st*st; // GetCovPzPz
2462  Double_t normalizedDecayTime = candidateDStar->NormalizedDecayLength() / (299792458 * TMath::Sqrt(1/((pdgMassMother*pdgMassMother*errorMomentum*errorMomentum/(momentumMother*momentumMother)) + 1)));
2463 
2464  //Topomatic
2465  Double_t dd0pr1=0.;
2466  Double_t dd0pr2=0.;
2467  Double_t dd0max=0.;
2468  Double_t dd0min=0.;
2469  for(Int_t ipr=0; ipr<2; ipr++)
2470  {
2471  Double_t diffIP, errdiffIP;
2472  candidateDStar->Getd0MeasMinusExpProng(ipr,bz,diffIP,errdiffIP);
2473  Double_t normdd0=0.;
2474  if(errdiffIP>0.) normdd0=diffIP/errdiffIP;
2475  if(ipr==0) dd0pr1=normdd0;
2476  if(ipr==1) dd0pr2=normdd0;
2477  }
2478  if(TMath::Abs(dd0pr1)>TMath::Abs(dd0pr2)) {dd0max=dd0pr1; dd0min=dd0pr2;}
2479  else {dd0max=dd0pr2; dd0min=dd0pr1;}
2480 
2481 
2482  // We apply the cuts
2483  Int_t nCutIndex = 0;
2484  Double_t cutVariableValue = 0.0;
2485 
2486  // "inv. mass width [GeV]" --------------------------------------------
2487  nCutIndex = 0;
2488  cutVariableValue = invMassDifference;
2489  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2490  if(!bPassedCut && !fGetCutInfo) return 0;
2491  //---------------------------------------------------------------------
2492 
2493  // "delta mass width [GeV]" -------------------------------------------
2494  nCutIndex = 1;
2495  cutVariableValue = invMassDelta;
2496  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2497  if(!bPassedCut && !fGetCutInfo) return 0;
2498  //---------------------------------------------------------------------
2499 
2500  // "pointing angle [Cos(theta)]" --------------------------------------
2501  nCutIndex = 2;
2502  cutVariableValue = pointingAngle;
2503  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2504  if(!bPassedCut && !fGetCutInfo) return 0;
2505  //---------------------------------------------------------------------
2506 
2507  // "dca [cm]" ---------------------------------------------------------
2508  nCutIndex = 3;
2509  cutVariableValue = dcaMother;
2510  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2511  if(!bPassedCut && !fGetCutInfo) return 0;
2512  //---------------------------------------------------------------------
2513 
2514  // "Pt DStar [GeV/c]" ----------------------------------------------------
2515  nCutIndex = 4;
2516  cutVariableValue = ptMother;
2517  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2518  if(!bPassedCut && !fGetCutInfo) return 0;
2519  //---------------------------------------------------------------------
2520 
2521  // "Pt D0 [GeV/c]" -------------------------------------------------
2522  nCutIndex = 5;
2523  cutVariableValue = ptD0;
2524  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2525  if(!bPassedCut && !fGetCutInfo) return 0;
2526  //---------------------------------------------------------------------
2527 
2528  // "Pt Pion [GeV/c]" --------------------------------------------------
2529  nCutIndex = 6;
2530  cutVariableValue = ptPion;
2531  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2532  if(!bPassedCut && !fGetCutInfo) return 0;
2533  //---------------------------------------------------------------------
2534 
2535  // "d0 DStar [cm]" -------------------------------------------------------
2536  nCutIndex = 7;
2537  cutVariableValue = d0Mother;
2538  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2539  if(!bPassedCut && !fGetCutInfo) return 0;
2540  //---------------------------------------------------------------------
2541 
2542  // "d0 D0 [cm]"-----------------------------------------------------
2543  nCutIndex = 8;
2544  cutVariableValue = d0firstTrack;
2545  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2546  if(!bPassedCut && !fGetCutInfo) return 0;
2547  //---------------------------------------------------------------------
2548 
2549  // "d0 Pion [cm]" -----------------------------------------------------
2550  nCutIndex = 9;
2551  cutVariableValue = d0secondTrack;
2552  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2553  if(!bPassedCut && !fGetCutInfo) return 0;
2554  //---------------------------------------------------------------------
2555 
2556  // "d0d0 [cm^2]" ------------------------------------------------------
2557  nCutIndex = 10;
2558  cutVariableValue = impactProduct;
2559  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2560  if(!bPassedCut && !fGetCutInfo) return 0;
2561  //---------------------------------------------------------------------
2562 
2563  // "d0d0 XY [cm^2]" ---------------------------------------------------
2564  nCutIndex = 11;
2565  cutVariableValue = impactProductXY;
2566  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2567  if(!bPassedCut && !fGetCutInfo) return 0;
2568  //---------------------------------------------------------------------
2569 
2570  // "angle between both daughters" -------------------------------------
2571  nCutIndex = 12;
2572  cutVariableValue = angleBetweenBothDaughters;
2573  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2574  if(!bPassedCut && !fGetCutInfo) return 0;
2575  //---------------------------------------------------------------------
2576 
2577  // "angle mother with first daughter" ---------------------------------
2578  nCutIndex = 13;
2579  cutVariableValue = angleMotherFirstDaughter;
2580  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2581  if(!bPassedCut && !fGetCutInfo) return 0;
2582  //---------------------------------------------------------------------
2583 
2584  // "angle mother with second daughter" --------------------------------
2585  nCutIndex = 14;
2586  cutVariableValue = angleMotherSecondDaughter;
2587  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2588  if(!bPassedCut && !fGetCutInfo) return 0;
2589  //---------------------------------------------------------------------
2590 
2591  // "cosThetaStar" -----------------------------------------------------
2592  nCutIndex = 15;
2593  cutVariableValue = cosThetaStar;
2594  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2595  if(!bPassedCut && !fGetCutInfo) return 0;
2596  //---------------------------------------------------------------------
2597 
2598  // "vertexDistance" ---------------------------------------------------
2599  nCutIndex = 16;
2600  cutVariableValue = vertexDistance;
2601  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2602  if(!bPassedCut && !fGetCutInfo) return 0;
2603  //---------------------------------------------------------------------
2604 
2605  // "pseudoProperDecayTime" --------------------------------------------
2606  nCutIndex = 17;
2607  cutVariableValue = pseudoProperDecayTime;
2608  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2609  if(!bPassedCut && !fGetCutInfo) return 0;
2610  //---------------------------------------------------------------------
2611 
2612  // "DecayTime" --------------------------------------------------------
2613  nCutIndex = 18;
2614  cutVariableValue = decayTime;
2615  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2616  if(!bPassedCut && !fGetCutInfo) return 0;
2617  //---------------------------------------------------------------------
2618 
2619  // "normalizedDecayTime" ----------------------------------------------------
2620  nCutIndex = 19;
2621  cutVariableValue = normalizedDecayTime;
2622  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2623  if(!bPassedCut && !fGetCutInfo) return 0;
2624  //---------------------------------------------------------------------
2625 
2626  // "normDecayLength" --------------------------------------------------
2627  nCutIndex = 20;
2628  cutVariableValue = normDecayLength;
2629  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2630  if(!bPassedCut && !fGetCutInfo) return 0;
2631  //---------------------------------------------------------------------
2632 
2633  // "topomatic first daughter" -----------------------------------------
2634  nCutIndex = 21;
2635  cutVariableValue = dd0pr1;
2636  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2637  if(!bPassedCut && !fGetCutInfo) return 0;
2638  //---------------------------------------------------------------------
2639 
2640  // "topomatic second daughter" ----------------------------------------
2641  nCutIndex = 22;
2642  cutVariableValue = dd0pr2;
2643  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2644  if(!bPassedCut && !fGetCutInfo) return 0;
2645  //---------------------------------------------------------------------
2646 
2647  // "topomatic max" ----------------------------------------------------
2648  nCutIndex = 23;
2649  cutVariableValue = dd0max;
2650  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2651  if(!bPassedCut && !fGetCutInfo) return 0;
2652  //---------------------------------------------------------------------
2653 
2654  // "topomatic min" ----------------------------------------------------
2655  nCutIndex = 24;
2656  cutVariableValue = dd0min;
2657  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2658  if(!bPassedCut && !fGetCutInfo) return 0;
2659  //---------------------------------------------------------------------
2660  }
2661 
2662  for (Int_t i = 0; i < 25; ++i)
2663  {
2664  if(bCutArray[i]==kTRUE){
2665  returnvalue = 0;
2666  break;
2667  }
2668  }
2669 
2670  return returnvalue;
2671 }
2672 //----------------------------------------------------------------------------------
2674 {
2675  //
2676  // D* fiducial acceptance region // not (yet) used for the B0
2677  //
2678 
2679  // if(fMaxRapidityCand>-998.){
2680  // if(TMath::Abs(y) > fMaxRapidityCand) return kFALSE;
2681  // else return kTRUE;
2682  // }
2683 
2684  // if(pt > 5.) {
2685  // // applying cut for pt > 5 GeV
2686  // AliDebug(4,Form("pt of D* = %f (> 5), cutting at |y| < 0.8\n",pt));
2687  // if (TMath::Abs(y) > 0.8){
2688  // return kFALSE;
2689  // }
2690  // } else {
2691  // // appliying smooth cut for pt < 5 GeV
2692  // Double_t maxFiducialY = -0.2/15*pt*pt+1.9/15*pt+0.5;
2693  // Double_t minFiducialY = 0.2/15*pt*pt-1.9/15*pt-0.5;
2694  // AliDebug(2,Form("pt of D* = %f (< 5), cutting according to the fiducial zone [%f, %f]\n",pt,minFiducialY,maxFiducialY));
2695  // if (y < minFiducialY || y > maxFiducialY){
2696  // return kFALSE;
2697  // }
2698  // }
2699 
2700  return kTRUE;
2701 }
2702 //_______________________________________________________________________________-
2704 {
2705  //
2706  // PID method, n sigma approach default // not used for B0, done seperately for each daughter
2707  //
2708 
2709  // AliAODRecoDecayHF2Prong* dstar = (AliAODRecoDecayHF2Prong*)obj;
2710  // if(!dstar){
2711  // cout<<"AliAODRecoDecayHF2Prong null"<<endl;
2712  // return 0;
2713  // }
2714 
2715  // if(!fUsePID || dstar->Pt() > fMaxPtPid) return 3;
2716 
2717  // AliAODRecoDecayHF2Prong* d0 = (AliAODRecoDecayHF2Prong*)dstar->Get2Prong();
2718  // if(!d0){
2719  // cout<<"AliAODRecoDecayHF2Prong null"<<endl;
2720  // return 0;
2721  // }
2722 
2723  // // here the PID
2724  // AliAODTrack *pos = (AliAODTrack*)dstar->Get2Prong()->GetDaughter(0);
2725  // AliAODTrack *neg = (AliAODTrack*)dstar->Get2Prong()->GetDaughter(1);
2726 
2727  // if (dstar->Charge()>0){
2728  // if(!SelectPID(pos,2)) return 0;//pion+
2729  // if(!SelectPID(neg,3)) return 0;//kaon-
2730  // }else{
2731  // if(!SelectPID(pos,3)) return 0;//kaon+
2732  // if(!SelectPID(neg,2)) return 0;//pion-
2733  // }
2734 
2735  // if ((fPidHF->GetMatch() == 10 || fPidHF->GetMatch() == 11) && fPidHF->GetITS()) { //ITS n sigma band
2736  // AliAODTrack *softPion = (AliAODTrack*) dstar->GetBachelor();
2737 
2738  // if (fPidHF->CheckBands(AliPID::kPion, AliPIDResponse::kITS, softPion) == -1) {
2739  // return 0;
2740  // }
2741  // }
2742 
2743  return 3;
2744 }
2745 //_______________________________________________________________________________-
2747 {
2748  //
2749  // here the PID
2750 
2751  Bool_t isParticle=kTRUE;
2752  Int_t match = fPidHF->GetMatch();
2753 
2754  if(match == 1){//n-sigma
2755  Bool_t TPCon=TMath::Abs(2)>1e-4?kTRUE:kFALSE;
2756  Bool_t TOFon=TMath::Abs(3)>1e-4?kTRUE:kFALSE;
2757 
2758  Bool_t isTPC=kTRUE;
2759  Bool_t isTOF=kTRUE;
2760 
2761  if (TPCon){//TPC
2762  if(fPidHF->CheckStatus(track,"TPC")){
2763  if(type==2) isTPC=fPidHF->IsPionRaw(track,"TPC");
2764  if(type==3) isTPC=fPidHF->IsKaonRaw(track,"TPC");
2765  }
2766  }
2767  if (TOFon){//TOF
2768  if(fPidHF->CheckStatus(track,"TOF")){
2769  if(type==2) isTOF=fPidHF->IsPionRaw(track,"TOF");
2770  if(type==3) isTOF=fPidHF->IsKaonRaw(track,"TOF");
2771  }
2772  }
2773 
2774  //--------------------------------
2775  // cut on high momentum in the TPC
2776  //--------------------------------
2777  Double_t pPIDcut = track->P();
2778  if(pPIDcut>fTPCflag) isTPC=1;
2779 
2780  isParticle = isTPC&&isTOF;
2781  }
2782 
2783  if(match == 2){//bayesian
2784  //Double_t priors[5]={0.01,0.001,0.3,0.3,0.3};
2785  Double_t prob[5]={1.,1.,1.,1.,1.};
2786 
2787  //fPidHF->SetPriors(priors,5);
2788  // fPidHF->BayesianProbability(track,prob);
2789 
2790  Double_t max=0.;
2791  Int_t k=-1;
2792  for (Int_t i=0; i<5; i++) {
2793  if (prob[i]>max) {k=i; max=prob[i];}
2794  }
2795  isParticle = Bool_t(k==type);
2796  }
2797 
2798  if (match == 10 || match == 11) { //Assymetric PID using histograms
2799  Int_t checkTPC = fPidHF->CheckBands((AliPID::EParticleType) type, AliPIDResponse::kTPC, track);
2800  Int_t checkTOF = fPidHF->CheckBands((AliPID::EParticleType) type, AliPIDResponse::kTOF, track);
2801 
2802  isParticle = checkTPC >= 0 && checkTOF >= 0 ? kTRUE : kFALSE; //Standard: both at least compatible
2803  if (match == 11) { //Extra requirement: at least one identified
2804  isParticle = isParticle && checkTPC+checkTOF >= 1 ? kTRUE : kFALSE;
2805  }
2806  }
2807 
2808  if (match == 12) { //Circular cut
2809  Double_t nSigmaTOF = 0;
2810  Double_t nSigmaTPC = 0;
2811 
2812  Double_t radius = fCircRadius;
2813 
2814  isParticle = kTRUE;
2815  if (radius > 0) {
2816  Int_t TPCok = fPidHF->GetnSigmaTPC(track, type, nSigmaTPC);
2817  Int_t TOFok = fPidHF->GetnSigmaTOF(track, type, nSigmaTOF);
2818  if (TPCok != -1 && TOFok != -1) {
2819  //Both detectors gave PID information
2820  isParticle = TMath::Sqrt(nSigmaTPC*nSigmaTPC + nSigmaTOF*nSigmaTOF) <= radius ? kTRUE : kFALSE;
2821  }
2822  else {
2823  //Maximum one detector gave PID information
2824  if (TPCok != -1) {
2825  isParticle = nSigmaTPC <= radius ? kTRUE : kFALSE;
2826  }
2827  if (TOFok != -1) {
2828  isParticle = nSigmaTOF <= radius ? kTRUE : kFALSE;
2829  }
2830  }
2831  }
2832  }
2833 
2834  return isParticle;
2835 
2836 }
2837 //-------------------------------------------------------------------------------------
2839 {
2843  Int_t chargeDStar = DStar->Charge();
2844 
2845  Double_t e[3];
2846  UInt_t prongs[2];
2847  if(chargeDStar==1){
2848  e[0]=((AliAODRecoDecayHF2Prong*)DStar->GetDaughter(1))->EProng(0,211);
2849  e[1]=((AliAODRecoDecayHF2Prong*)DStar->GetDaughter(1))->EProng(1,321);
2850  prongs[0] = 211;
2851  prongs[1] = 321;
2852  }
2853  else if (chargeDStar==-1)
2854  {
2855  e[0]=((AliAODRecoDecayHF2Prong*)DStar->GetDaughter(1))->EProng(1,211);
2856  e[1]=((AliAODRecoDecayHF2Prong*)DStar->GetDaughter(1))->EProng(0,321);
2857  prongs[1] = 211;
2858  prongs[0] = 321;
2859  }
2860  else
2861  {
2862  cout << "Wrong charge DStar." << endl;
2863  return 0;
2864  }
2865  e[2]=DStar->EProng(0,211);
2866 
2867  Double_t esum = e[0]+e[1]+e[2];
2868  Double_t invMassDStar = TMath::Sqrt(esum*esum-DStar->P()*DStar->P());
2869  Double_t invMassD0 = ((AliAODRecoDecayHF2Prong*)DStar->GetDaughter(1))->InvMass(2,prongs);
2870 
2871  return invMassDStar - invMassD0;
2872 }
2873 //-------------------------------------------------------------------------------------
2875 {
2879 
2880  AliAODRecoDecayHF2Prong * DStar = (AliAODRecoDecayHF2Prong*)B0->GetDaughter(1);
2881  Int_t chargeDStar = DStar->Charge();
2882 
2883  Double_t e[4];
2884  UInt_t prongs[2];
2885  if(chargeDStar==1){
2886  e[1]=((AliAODRecoDecayHF2Prong*)DStar->GetDaughter(1))->EProng(0,211);
2887  e[2]=((AliAODRecoDecayHF2Prong*)DStar->GetDaughter(1))->EProng(1,321);
2888  prongs[0] = 211;
2889  prongs[1] = 321;
2890  }
2891  else if (chargeDStar==-1)
2892  {
2893  e[1]=((AliAODRecoDecayHF2Prong*)DStar->GetDaughter(1))->EProng(1,211);
2894  e[2]=((AliAODRecoDecayHF2Prong*)DStar->GetDaughter(1))->EProng(0,321);
2895  prongs[1] = 211;
2896  prongs[0] = 321;
2897  }
2898  else
2899  {
2900  cout << "Wrong charge DStar." << endl;
2901  return 0;
2902  }
2903  e[0]=DStar->EProng(0,211);
2904  e[3]=B0->EProng(0,211);
2905 
2906  Double_t esum = e[0]+e[1]+e[2]+e[3];
2907  Double_t invMassB0 = TMath::Sqrt(esum*esum-B0->P()*B0->P());
2908 
2909  Double_t invMassD0 = ((AliAODRecoDecayHF2Prong*)DStar->GetDaughter(1))->InvMass(2,prongs);
2910 
2911  return invMassB0 - invMassD0;
2912 }
2913 
2914 
2915 //---------------------------------------------------------------------------
2916 //
2917 // DO for D0 pt bin functions
2918 //
2919 //---------------------------------------------------------------------------
2920 
2922  //
2923  // store the cuts
2924  //
2925 
2926  if(nVars!=fnVarsD0forD0ptbin) {
2927  printf("Wrong number of variables: it has to be %d\n",fnVarsD0forD0ptbin);
2928  AliFatal("exiting");
2929  }
2930  if(nPtBins!=fnPtBinsD0forD0ptbin) {
2931  printf("Wrong number of pt bins: it has to be %d\n",fnPtBinsD0forD0ptbin);
2932  AliFatal("exiting");
2933  }
2934 
2936 
2937 
2938  for(Int_t iv=0; iv<fnVarsD0forD0ptbin; iv++)
2939  {
2940  for(Int_t ib=0; ib<fnPtBinsD0forD0ptbin; ib++)
2941  {
2942  //check
2943 
2945  {
2946  cout<<"Overflow, exit..."<<endl;
2947  return;
2948  }
2949 
2950  fCutsRDD0forD0ptbin[GetGlobalIndexD0forD0ptbin(iv,ib)] = cutsRDD0forD0ptbin[iv][ib];
2951 
2952  }
2953  }
2954 
2955  return;
2956 }
2957 //---------------------------------------------------------------------------
2959  //
2960  //give the pt bin where the pt lies.
2961  //
2962  Int_t ptbin=-1;
2963  if(pt<fPtBinLimitsD0forD0ptbin[0])return ptbin;
2964  for (Int_t i=0;i<fnPtBinsD0forD0ptbin;i++){
2965  if(pt<fPtBinLimitsD0forD0ptbin[i+1]) {
2966  ptbin=i;
2967  break;
2968  }
2969  }
2970  return ptbin;
2971 }
2972 //---------------------------------------------------------------------------
2974  // Set the pt bins
2975 
2977  delete [] fPtBinLimitsD0forD0ptbin;
2978  fPtBinLimitsD0forD0ptbin = NULL;
2979  printf("Changing the pt bins\n");
2980  }
2981 
2982  if(nPtBinLimits != fnPtBinsD0forD0ptbin+1){
2983  cout<<"Warning: ptBinLimits dimension "<<nPtBinLimits<<" != nPtBins+1 ("<<fnPtBinsD0forD0ptbin+1<<")\nSetting nPtBins to "<<nPtBinLimits-1<<endl;
2984  SetNPtBinsD0forD0ptbin(nPtBinLimits-1);
2985  }
2986 
2987  fnPtBinLimitsD0forD0ptbin = nPtBinLimits;
2989  //cout<<"Changing also Global Index -> "<<fGlobalIndex<<endl;
2991  for(Int_t ib=0; ib<nPtBinLimits; ib++) fPtBinLimitsD0forD0ptbin[ib]=ptBinLimits[ib];
2992  for(Int_t ib=0; ib<nPtBinLimits; ib++) std::cout << "limit " << ib << " = " << fPtBinLimitsD0forD0ptbin[ib] << std::endl;
2993 
2994  return;
2995 }
2996 
2997 
2998 
2999 //---------------------------------------------------------------------------
3000 //
3001 // DO for DStar pt bin functions
3002 //
3003 //---------------------------------------------------------------------------
3004 
3005 
3007  //
3008  // store the cuts
3009  //
3010  if(nVars!=fnVarsD0forDStarptbin) {
3011  printf("Wrong number of variables: it has to be %d\n",fnVarsD0forDStarptbin);
3012  AliFatal("exiting");
3013  }
3014  if(nPtBins!=fnPtBinsD0forDStarptbin) {
3015  printf("Wrong number of pt bins: it has to be %d\n",fnPtBinsD0forDStarptbin);
3016  AliFatal("exiting");
3017  }
3018 
3020 
3021 
3022  for(Int_t iv=0; iv<fnVarsD0forDStarptbin; iv++)
3023  {
3024  for(Int_t ib=0; ib<fnPtBinsD0forDStarptbin; ib++)
3025  {
3026  //check
3028  {
3029  cout<<"Overflow, exit..."<<endl;
3030  return;
3031  }
3032 
3033  fCutsRDD0forDStarptbin[GetGlobalIndexD0forDStarptbin(iv,ib)] = cutsRDD0forDStarptbin[iv][ib];
3034 
3035  }
3036  }
3037  return;
3038 }
3039 //---------------------------------------------------------------------------
3041  //
3042  //give the pt bin where the pt lies.
3043  //
3044  Int_t ptbin=-1;
3045  if(pt<fPtBinLimitsD0forDStarptbin[0])return ptbin;
3046  for (Int_t i=0;i<fnPtBinsD0forDStarptbin;i++){
3047  if(pt<fPtBinLimitsD0forDStarptbin[i+1]) {
3048  ptbin=i;
3049  break;
3050  }
3051  }
3052  return ptbin;
3053 }
3054 //---------------------------------------------------------------------------
3056  // Set the pt bins
3057 
3059  delete [] fPtBinLimitsD0forDStarptbin;
3061  printf("Changing the pt bins\n");
3062  }
3063 
3064  if(nPtBinLimits != fnPtBinsD0forDStarptbin+1){
3065  cout<<"Warning: ptBinLimits dimension "<<nPtBinLimits<<" != nPtBins+1 ("<<fnPtBinsD0forDStarptbin+1<<")\nSetting nPtBins to "<<nPtBinLimits-1<<endl;
3066  SetNPtBinsD0forDStarptbin(nPtBinLimits-1);
3067  }
3068 
3069  fnPtBinLimitsD0forDStarptbin = nPtBinLimits;
3071  //cout<<"Changing also Global Index -> "<<fGlobalIndex<<endl;
3073  for(Int_t ib=0; ib<nPtBinLimits; ib++) fPtBinLimitsD0forDStarptbin[ib]=ptBinLimits[ib];
3074 
3075  return;
3076 }
3077 
3078 
3079 
3080 
3081 //---------------------------------------------------------------------------
3082 //
3083 // DStar for DStar pt bin functions
3084 //
3085 //---------------------------------------------------------------------------
3086 
3087 
3088 
3090  //
3091  // store the cuts
3092  //
3093  if(nVars!=fnVarsDStarforDStarptbin) {
3094  printf("Wrong number of variables: it has to be %d\n",fnVarsDStarforDStarptbin);
3095  AliFatal("exiting");
3096  }
3097  if(nPtBins!=fnPtBinsDStarforDStarptbin) {
3098  printf("Wrong number of pt bins: it has to be %d\n",fnPtBinsDStarforDStarptbin);
3099  AliFatal("exiting");
3100  }
3101 
3103 
3104 
3105  for(Int_t iv=0; iv<fnVarsDStarforDStarptbin; iv++)
3106  {
3107  for(Int_t ib=0; ib<fnPtBinsDStarforDStarptbin; ib++)
3108  {
3109  //check
3111  {
3112  cout<<"Overflow, exit..."<<endl;
3113  return;
3114  }
3115 
3116  fCutsRDDStarforDStarptbin[GetGlobalIndexDStarforDStarptbin(iv,ib)] = cutsRDDStarforDStarptbin[iv][ib];
3117 
3118  }
3119  }
3120  return;
3121 }
3122 //---------------------------------------------------------------------------
3124  //
3125  //give the pt bin where the pt lies.
3126  //
3127  Int_t ptbin=-1;
3128  if(pt<fPtBinLimitsDStarforDStarptbin[0])return ptbin;
3129  for (Int_t i=0;i<fnPtBinsDStarforDStarptbin;i++){
3130  if(pt<fPtBinLimitsDStarforDStarptbin[i+1]) {
3131  ptbin=i;
3132  break;
3133  }
3134  }
3135  return ptbin;
3136 }
3137 //---------------------------------------------------------------------------
3139  // Set the pt bins and initialize the cut values to 0 and use of cuts to kFALSE
3140 
3144  printf("Changing the pt bins\n");
3145  }
3146 
3147  if(nPtBinLimits != fnPtBinsDStarforDStarptbin+1){
3148  cout<<"Warning: ptBinLimits dimension "<<nPtBinLimits<<" != nPtBins+1 ("<<fnPtBinsDStarforDStarptbin+1<<")\nSetting nPtBins to "<<nPtBinLimits-1<<endl;
3149  SetNPtBinsDStarforDStarptbin(nPtBinLimits-1);
3150  }
3151 
3152  fnPtBinLimitsDStarforDStarptbin = nPtBinLimits;
3154 
3156  for(Int_t ib=0; ib<nPtBinLimits; ib++) fPtBinLimitsDStarforDStarptbin[ib]=ptBinLimits[ib];
3157 
3158  return;
3159 }
3160 //---------------------------------------------------------------------------
3161 Int_t AliRDHFCutsB0toDStarPi::ApplyCutOnVariable(Int_t nCutIndex, Int_t ptbin, Float_t cutVariableValue, Bool_t bCutArray[85]){
3162 
3163  if(GetIsCutUsed(nCutIndex,ptbin)==kTRUE)
3164  {
3165  Bool_t bCut = kFALSE;
3166  if(GetIsUpperCut(nCutIndex)==kTRUE)
3167  {
3168  if(cutVariableValue > fCutsRD[GetGlobalIndex(nCutIndex,ptbin)]) bCut = kTRUE;
3169  } else
3170  {
3171  if(cutVariableValue < fCutsRD[GetGlobalIndex(nCutIndex,ptbin)]) bCut = kTRUE;
3172  }
3173  if(bCut == kTRUE) {bCutArray[nCutIndex] = 1; return 0;}
3174  }
3175  return 1;
3176 }
3177 //---------------------------------------------------------------------------
3178 Int_t AliRDHFCutsB0toDStarPi::ApplyCutOnVariableD0forD0ptbin(Int_t nCutIndex, Int_t ptbin, Float_t cutVariableValue, Bool_t bCutArray[25]){
3179 
3180  // std::cout << "index: " << nCutIndex << ", ptbin: " << ptbin << ", used: " << GetIsCutUsedD0forD0ptbin(nCutIndex,ptbin) << ", upper: " << GetIsUpperCutD0forD0ptbin(nCutIndex) << ", value: " << cutVariableValue << ", cutvalue: " << fCutsRDD0forD0ptbin[GetGlobalIndexD0forD0ptbin(nCutIndex,ptbin)] << std::endl;
3181  if(GetIsCutUsedD0forD0ptbin(nCutIndex,ptbin)==kTRUE)
3182  {
3183  Bool_t bCut = kFALSE;
3184  if(GetIsUpperCutD0forD0ptbin(nCutIndex)==kTRUE)
3185  {
3186  if(cutVariableValue > fCutsRDD0forD0ptbin[GetGlobalIndexD0forD0ptbin(nCutIndex,ptbin)]) bCut = kTRUE;
3187  } else
3188  {
3189  if(cutVariableValue < fCutsRDD0forD0ptbin[GetGlobalIndexD0forD0ptbin(nCutIndex,ptbin)]) bCut = kTRUE;
3190  }
3191  if(bCut == kTRUE) {bCutArray[nCutIndex] = 1; return 0;}
3192  }
3193  return 1;
3194 }
3195 //---------------------------------------------------------------------------
3197 
3198  if(GetIsCutUsedD0forDStarptbin(nCutIndex,ptbin)==kTRUE)
3199  {
3200  Bool_t bCut = kFALSE;
3201  if(GetIsUpperCutD0forDStarptbin(nCutIndex)==kTRUE)
3202  {
3203  if(cutVariableValue > fCutsRDD0forDStarptbin[GetGlobalIndexD0forDStarptbin(nCutIndex,ptbin)]) bCut = kTRUE;
3204  } else
3205  {
3206  if(cutVariableValue < fCutsRDD0forDStarptbin[GetGlobalIndexD0forDStarptbin(nCutIndex,ptbin)]) bCut = kTRUE;
3207  }
3208  if(bCut == kTRUE) {bCutArray[nCutIndex] = 1; return 0;}
3209  }
3210  return 1;
3211 }
3212 //---------------------------------------------------------------------------
3214 
3215  if(GetIsCutUsedDStarforDStarptbin(nCutIndex,ptbin)==kTRUE)
3216  {
3217  Bool_t bCut = kFALSE;
3218  if(GetIsUpperCutDStarforDStarptbin(nCutIndex)==kTRUE)
3219  {
3220  if(cutVariableValue > fCutsRDDStarforDStarptbin[GetGlobalIndexDStarforDStarptbin(nCutIndex,ptbin)]) bCut = kTRUE;
3221  } else
3222  {
3223  if(cutVariableValue < fCutsRDDStarforDStarptbin[GetGlobalIndexDStarforDStarptbin(nCutIndex,ptbin)]) bCut = kTRUE;
3224  }
3225  if(bCut == kTRUE) {bCutArray[nCutIndex] = 1; return 0;}
3226  }
3227  return 1;
3228 }
3229 //---------------------------------------------------------------------------
3231  // Set the variable names
3232 
3233  if(fVarNamesD0forD0ptbin) {
3234  delete [] fVarNamesD0forD0ptbin;
3235  fVarNamesD0forD0ptbin = NULL;
3236  //printf("Changing the variable names\n");
3237  }
3238  if(nVars!=fnVarsD0forD0ptbin){
3239  printf("Wrong number of variables: it has to be %d\n",fnVarsD0forD0ptbin);
3240  return;
3241  }
3242  //fnVars=nVars;
3243  fVarNamesD0forD0ptbin = new TString[nVars];
3244  fIsUpperCutD0forD0ptbin = new Bool_t[nVars];
3245  for(Int_t iv=0; iv<nVars; iv++) {
3246  fVarNamesD0forD0ptbin[iv] = varNames[iv];
3247  fIsUpperCutD0forD0ptbin[iv] = isUpperCut[iv];
3248  }
3249 
3250  return;
3251 }
3252 //---------------------------------------------------------------------------
3254  // Set the variable names
3255 
3257  delete [] fVarNamesD0forDStarptbin;
3258  fVarNamesD0forDStarptbin = NULL;
3259  //printf("Changing the variable names\n");
3260  }
3261  if(nVars!=fnVarsD0forDStarptbin){
3262  printf("Wrong number of variables: it has to be %d\n",fnVarsD0forDStarptbin);
3263  return;
3264  }
3265  //fnVars=nVars;
3266  fVarNamesD0forDStarptbin = new TString[nVars];
3267  fIsUpperCutD0forDStarptbin = new Bool_t[nVars];
3268  for(Int_t iv=0; iv<nVars; iv++) {
3269  fVarNamesD0forDStarptbin[iv] = varNames[iv];
3270  fIsUpperCutD0forDStarptbin[iv] = isUpperCut[iv];
3271  }
3272 
3273  return;
3274 }
3275 //---------------------------------------------------------------------------
3277  // Set the variable names
3278 
3280  delete [] fVarNamesDStarforDStarptbin;
3282  //printf("Changing the variable names\n");
3283  }
3284  if(nVars!=fnVarsDStarforDStarptbin){
3285  printf("Wrong number of variables: it has to be %d\n",fnVarsDStarforDStarptbin);
3286  return;
3287  }
3288  //fnVars=nVars;
3289  fVarNamesDStarforDStarptbin = new TString[nVars];
3291  for(Int_t iv=0; iv<nVars; iv++) {
3292  fVarNamesDStarforDStarptbin[iv] = varNames[iv];
3293  fIsUpperCutDStarforDStarptbin[iv] = isUpperCut[iv];
3294  }
3295 
3296  return;
3297 }
3298 //---------------------------------------------------------------------------
3300  // Set the use of all cuts to kFALSE and the cut value to zero. This function has to be called after setting the pt bins.
3301 
3302  if(fIsCutUsed) {
3303  delete [] fIsCutUsed;
3304  fIsCutUsed = NULL;
3305  }
3306 
3307  fIsCutUsed = new Bool_t[(GetNPtBins())*(GetNVars())];
3308  for(Int_t iv=0; iv<(GetNPtBins())*(GetNVars()); iv++) {
3309  fIsCutUsed[iv] = kFALSE;
3310  }
3311 
3312  if(!fCutsRD) fCutsRD = new Float_t[fGlobalIndex];
3313 
3314 
3315  for(Int_t iv=0; iv<fnVars; iv++) {
3316 
3317  for(Int_t ib=0; ib<fnPtBins; ib++) {
3318 
3319  //check
3320  if(GetGlobalIndex(iv,ib)>=fGlobalIndex) {
3321  cout<<"Overflow, exit..."<<endl;
3322  return;
3323  }
3324 
3325  fCutsRD[GetGlobalIndex(iv,ib)] = 0;
3326 
3327  }
3328  }
3329 
3330  // D0 for D0 pt bin
3331 
3333  delete [] fIsCutUsedD0forD0ptbin;
3334  fIsCutUsedD0forD0ptbin = NULL;
3335  }
3336 
3338  for(Int_t iv=0; iv<(GetNPtBinsD0forD0ptbin())*(GetNVarsD0forD0ptbin()); iv++) {
3339  fIsCutUsedD0forD0ptbin[iv] = kFALSE;
3340 
3341  }
3342 
3344 
3345  for(Int_t iv=0; iv<fnVarsD0forD0ptbin; iv++)
3346  {
3347  for(Int_t ib=0; ib<fnPtBinsD0forD0ptbin; ib++)
3348  {
3349  //check
3350 
3352  {
3353  cout<<"Overflow, exit..."<<endl;
3354  return;
3355  }
3356 
3358  }
3359  }
3360 
3361  // D0 for DStar pt bin
3362 
3364  delete [] fIsCutUsedD0forDStarptbin;
3366  }
3367 
3369  for(Int_t iv=0; iv<(GetNPtBinsD0forDStarptbin())*(GetNVarsD0forDStarptbin()); iv++) {
3370  fIsCutUsedD0forDStarptbin[iv] = kFALSE;
3371  }
3372 
3374 
3375 
3376  for(Int_t iv=0; iv<fnVarsD0forDStarptbin; iv++)
3377  {
3378  for(Int_t ib=0; ib<fnPtBinsD0forDStarptbin; ib++)
3379  {
3380  //check
3382  {
3383  cout<<"Overflow, exit..."<<endl;
3384  return;
3385  }
3386 
3388 
3389  }
3390  }
3391 
3392  // DStar for DStar pt bin
3393 
3395  delete [] fIsCutUsedDStarforDStarptbin;
3397  }
3398 
3400  for(Int_t iv=0; iv<(GetNPtBinsDStarforDStarptbin())*(GetNVarsDStarforDStarptbin()); iv++) {
3401  fIsCutUsedDStarforDStarptbin[iv] = kFALSE;
3402  }
3403 
3405 
3406 
3407  for(Int_t iv=0; iv<fnVarsDStarforDStarptbin; iv++)
3408  {
3409  for(Int_t ib=0; ib<fnPtBinsDStarforDStarptbin; ib++)
3410  {
3411  //check
3413  {
3414  cout<<"Overflow, exit..."<<endl;
3415  return;
3416  }
3417 
3419 
3420  }
3421  }
3422 
3423  return;
3424 }
3425 //---------------------------------------------------------------------------
3427  // Set the cut value and direction
3428 
3429  fIsCutUsed[GetGlobalIndex(nCutIndex,ptBin)] = kTRUE;
3430  fIsUpperCut[nCutIndex] = cutDirection;
3431  fCutsRD[GetGlobalIndex(nCutIndex,ptBin)] = cutValue;
3432 
3433  return;
3434 }
3435 //---------------------------------------------------------------------------
3437  // Set the cut value and direction
3438 
3439  fIsCutUsedD0forD0ptbin[GetGlobalIndexD0forD0ptbin(nCutIndex,ptBin)] = kTRUE;
3440  fIsUpperCutD0forD0ptbin[nCutIndex] = cutDirection;
3441  fCutsRDD0forD0ptbin[GetGlobalIndexD0forD0ptbin(nCutIndex,ptBin)] = cutValue;
3442 
3443  return;
3444 }
3445 //---------------------------------------------------------------------------
3447  // Set the cut value and direction
3448 
3449  fIsCutUsedD0forDStarptbin[GetGlobalIndexD0forDStarptbin(nCutIndex,ptBin)] = kTRUE;
3450  fIsUpperCutD0forDStarptbin[nCutIndex] = cutDirection;
3451  fCutsRDD0forDStarptbin[GetGlobalIndexD0forDStarptbin(nCutIndex,ptBin)] = cutValue;
3452 
3453  return;
3454 }
3455 //---------------------------------------------------------------------------
3457  // Set the cut value and direction
3458 
3460  fIsUpperCutDStarforDStarptbin[nCutIndex] = cutDirection;
3461  fCutsRDDStarforDStarptbin[GetGlobalIndexDStarforDStarptbin(nCutIndex,ptBin)] = cutValue;
3462 
3463  return;
3464 }
3465 //---------------------------------------------------------------------------
Int_t fIsSelectedCuts
fix the daughter track references
Definition: AliRDHFCuts.h:443
void SetVarNamesDStarforDStarptbin(Int_t nVars, TString *varNames, Bool_t *isUpperCut)
Double_t NormalizedDecayLength() const
Int_t GetGlobalIndexDStarforDStarptbin(Int_t iVar, Int_t iPtBin) const
Bool_t GetIsUpperCutDStarforDStarptbin(Int_t nCutIndex)
Int_t GetNVars() const
Definition: AliRDHFCuts.h:249
virtual Int_t SelectPID(AliAODTrack *track, Int_t type)
double Double_t
Definition: External.C:58
void Getd0MeasMinusExpProng(Int_t ip, Double_t magf, Double_t &d0diff, Double_t &errd0diff) const
Int_t GetnSigmaTOF(AliAODTrack *track, Int_t species, Double_t &sigma) const
void SetNPtBinsD0forD0ptbin(Int_t nptBins)
void SetNPtBinsD0forDStarptbin(Int_t nptBins)
void SetCutsD0forDStarptbin(Int_t nVars, Int_t nPtBins, Float_t **cutsRDD0forDStarptbin)
virtual Int_t IsSelectedPID(AliAODRecoDecayHF *rd)
void SetCutsDStarforDStarptbin(Int_t nVars, Int_t nPtBins, Float_t **cutsRDDStarforDStarptbin)
Bool_t * fIsUpperCut
Definition: AliRDHFCuts.h:421
Bool_t IsKaonRaw(AliAODTrack *track, TString detector) const
Bool_t GetIsCutUsedD0forD0ptbin(Int_t nCutIndex, Int_t ptbin)
Double_t DeltaInvMassDStarKpipi(AliAODRecoDecayHF2Prong *DStar) const
Int_t GetnSigmaTPC(AliAODTrack *track, Int_t species, Double_t &sigma) const
Int_t GetNVarsDStarforDStarptbin() const
Bool_t GetIsCutUsed(Int_t nCutIndex, Int_t ptbin)
Double_t bz
Double_t ImpParXY() const
Int_t IsDStarFromB0Selected(Double_t pt, TObject *obj, Int_t selectionLevel, AliAODEvent *aod, Bool_t *bCutArray)
Int_t ApplyCutOnVariableDStarforDStarptbin(Int_t nCutIndex, Int_t ptbin, Float_t cutVariableValue, Bool_t bCutArray[25])
Bool_t GetIsUpperCutD0forD0ptbin(Int_t nCutIndex)
void InvMass(Int_t icalo, TString particle, TString fileName)
void SetNVars(Int_t nVars)
Definition: AliRDHFCuts.h:392
Int_t PtBinDStarforDStarptbin(Double_t pt) const
void SetPtBinsDStarforDStarptbin(Int_t nPtBinLimits, Float_t *ptBinLimits)
void SetCutsD0forD0ptbin(Int_t nVars, Int_t nPtBins, Float_t **cutsRDD0forD0ptbin)
Int_t IsD0forD0ptbinSelected(TObject *obj, Int_t selectionLevel, AliAODEvent *aod, Bool_t *bCutArray)
void SetCutD0forD0ptbin(Int_t nCutIndex, Int_t ptBin, AliRDHFCutsB0toDStarPi::EUpperCut cutDirection, Float_t cutValue)
AliRDHFCuts & operator=(const AliRDHFCuts &source)
void SetNVarsD0forDStarptbin(Int_t nVars)
void SetNVarsD0forD0ptbin(Int_t nVars)
Int_t PtBinD0forDStarptbin(Double_t pt) const
void SetPtBinsD0forD0ptbin(Int_t nPtBinLimits, Float_t *ptBinLimits)
AliRDHFCutsB0toDStarPi(const char *name="CutsB0toDStarPi")
const Int_t nPtBins
Bool_t GetIsCutUsedD0forDStarptbin(Int_t nCutIndex, Int_t ptbin)
Int_t CheckBands(AliPID::EParticleType specie, AliPIDResponse::EDetector detector, AliAODTrack *track)
int Int_t
Definition: External.C:63
Bool_t * GetIsUpperCut() const
Definition: AliRDHFCuts.h:260
Int_t ApplyCutOnVariableD0forD0ptbin(Int_t nCutIndex, Int_t ptbin, Float_t cutVariableValue, Bool_t bCutArray[25])
void SetCut(Int_t nCutIndex, Int_t ptBin, AliRDHFCutsB0toDStarPi::EUpperCut cutDirection, Float_t cutValue)
unsigned int UInt_t
Definition: External.C:33
float Float_t
Definition: External.C:68
virtual Int_t IsSelected(TObject *obj, Int_t selectionLevel, AliAODEvent *aod, Bool_t *bCutArray)
Int_t ApplyCutOnVariable(Int_t nCutIndex, Int_t ptbin, Float_t cutVariableValue, Bool_t bCutArray[85])
void SetPtBinsD0forDStarptbin(Int_t nPtBinLimits, Float_t *ptBinLimits)
AliRDHFCutsB0toDStarPi & operator=(const AliRDHFCutsB0toDStarPi &source)
Int_t ApplyCutOnVariableD0forDStarptbin(Int_t nCutIndex, Int_t ptbin, Float_t cutVariableValue, Bool_t bCutArray[35])
Bool_t CheckStatus(AliAODTrack *track, TString detectors) const
Int_t IsDStarforDStarptbinSelected(TObject *obj, Int_t selectionLevel, AliAODEvent *aod, Bool_t *bCutArray)
Int_t GetNPtBinsD0forD0ptbin() const
void SetNVarsDStarforDStarptbin(Int_t nVars)
Int_t fIsSelectedPID
outcome of cuts selection
Definition: AliRDHFCuts.h:444
Bool_t GetIsCutUsedDStarforDStarptbin(Int_t nCutIndex, Int_t ptbin)
void SetCutD0forDStarptbin(Int_t nCutIndex, Int_t ptBin, AliRDHFCutsB0toDStarPi::EUpperCut cutDirection, Float_t cutValue)
virtual Bool_t IsInFiducialAcceptance(Double_t pt, Double_t y) const
Float_t * fCutsRD
fnVars*fnPtBins
Definition: AliRDHFCuts.h:420
void SetVarsForOpt(Int_t nVars, Bool_t *forOpt)
void SetVarNames(Int_t nVars, TString *varNames, Bool_t *isUpperCut)
Bool_t GetIsUpperCutD0forDStarptbin(Int_t nCutIndex)
Int_t IsD0FromDStarSelected(Double_t pt, TObject *obj, Int_t selectionLevel, AliAODEvent *aod, Bool_t *bCutArray)
Bool_t IsPionRaw(AliAODTrack *track, TString detector) const
Int_t PtBinD0forD0ptbin(Double_t pt) const
void SetVarNamesD0forDStarptbin(Int_t nVars, TString *varNames, Bool_t *isUpperCut)
void SetVarNamesD0forD0ptbin(Int_t nVars, TString *varNames, Bool_t *isUpperCut)
virtual void GetCutVarsForOpt(AliAODRecoDecayHF *d, Float_t *vars, Int_t nvars, Int_t *pdgdaughters)
Int_t GetGlobalIndexD0forD0ptbin(Int_t iVar, Int_t iPtBin) const
void SetCutDStarforDStarptbin(Int_t nCutIndex, Int_t ptBin, AliRDHFCutsB0toDStarPi::EUpperCut cutDirection, Float_t cutValue)
Int_t GetNPtBinsDStarforDStarptbin() const
void SetPtBins(Int_t nPtBinLimits, Float_t *ptBinLimits)
void SetNPtBinsDStarforDStarptbin(Int_t nptBins)
Int_t GetMatch() const
Definition: AliAODPidHF.h:145
Int_t GetGlobalIndexD0forDStarptbin(Int_t iVar, Int_t iPtBin) const
Int_t GetNVarsD0forDStarptbin() const
Int_t IsD0forDStarptbinSelected(TObject *obj, Int_t selectionLevel, AliAODEvent *aod, Bool_t *bCutArray)
Int_t GetNPtBinsD0forDStarptbin() const
Int_t GetNPtBins() const
Definition: AliRDHFCuts.h:248
bool Bool_t
Definition: External.C:53
Double_t CosPointingAngle() const
Int_t fnPtBins
cuts on the candidate
Definition: AliRDHFCuts.h:412
Double_t DeltaInvMassB0Kpipipi(AliAODRecoDecayHF2Prong *B0) const
Bool_t fGetCutInfo
Radius for circular PID nsigma cut.
AliAODPidHF * fPidHF
enable AOD049 centrality cleanup
Definition: AliRDHFCuts.h:424
Int_t fGlobalIndex
Definition: AliRDHFCuts.h:419
Int_t PtBin(Double_t pt) const
Int_t GetGlobalIndex(Int_t iVar, Int_t iPtBin) const
Int_t fnVars
Definition: AliRDHFCuts.h:415