AliPhysics  3337bb0 (3337bb0)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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>
32 #include "AliAODRecoCascadeHF.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 Kaon [GeV/c]";
97  varNames[iterator++]= /*-06-*/ "Pt Pion [GeV/c]";
98  varNames[iterator++]= /*-07-*/ "d0 D0 [cm]";
99  varNames[iterator++]= /*-08-*/ "d0 Kaon [cm]";
100  varNames[iterator++]= /*-09-*/ "d0 Pion [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 Kaon [GeV/c]";
213  varNamesD0forD0ptbin[iterator++]= /*-06-*/ "Pt Pion [GeV/c]";
214  varNamesD0forD0ptbin[iterator++]= /*-07-*/ "d0 D0 [cm]";
215  varNamesD0forD0ptbin[iterator++]= /*-08-*/ "d0 Kaon [cm]";
216  varNamesD0forD0ptbin[iterator++]= /*-09-*/ "d0 Pion [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 Kaon [GeV/c]";
259  varNamesD0forDStarptbin[iterator++]= /*-06-*/ "Pt Pion [GeV/c]";
260  varNamesD0forDStarptbin[iterator++]= /*-07-*/ "d0 D0 [cm]";
261  varNamesD0forDStarptbin[iterator++]= /*-08-*/ "d0 Kaon [cm]";
262  varNamesD0forDStarptbin[iterator++]= /*-09-*/ "d0 Pion [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),
360  fCutsRDD0forD0ptbin(source.fCutsRDD0forD0ptbin),
361  fnPtBinsD0forD0ptbin(source.fnPtBinsD0forD0ptbin),
362  fPtBinLimitsD0forD0ptbin(source.fPtBinLimitsD0forD0ptbin),
363  fIsUpperCutD0forD0ptbin(source.fIsUpperCutD0forD0ptbin),
364  fIsCutUsedD0forD0ptbin(source.fIsCutUsedD0forD0ptbin),
365  fVarNamesD0forD0ptbin(source.fVarNamesD0forD0ptbin),
366  fCutsRDD0forDStarptbin(source.fCutsRDD0forDStarptbin),
367  fnPtBinsD0forDStarptbin(source.fnPtBinsD0forDStarptbin),
368  fPtBinLimitsD0forDStarptbin(source.fPtBinLimitsD0forDStarptbin),
369  fIsUpperCutD0forDStarptbin(source.fIsUpperCutD0forDStarptbin),
370  fIsCutUsedD0forDStarptbin(source.fIsCutUsedD0forDStarptbin),
371  fVarNamesD0forDStarptbin(source.fVarNamesD0forDStarptbin),
372  fCutsRDDStarforDStarptbin(source.fCutsRDDStarforDStarptbin),
373  fnPtBinsDStarforDStarptbin(source.fnPtBinsDStarforDStarptbin),
374  fPtBinLimitsDStarforDStarptbin(source.fPtBinLimitsDStarforDStarptbin),
375  fIsUpperCutDStarforDStarptbin(source.fIsUpperCutDStarforDStarptbin),
376  fIsCutUsedDStarforDStarptbin(source.fIsCutUsedDStarforDStarptbin),
377  fVarNamesDStarforDStarptbin(source.fVarNamesDStarforDStarptbin),
378  fnPtBinLimitsD0forD0ptbin(source.fnPtBinLimitsD0forD0ptbin),
379  fnPtBinLimitsD0forDStarptbin(source.fnPtBinLimitsD0forDStarptbin),
380  fnPtBinLimitsDStarforDStarptbin(source.fnPtBinLimitsDStarforDStarptbin)
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 
442  AliAODRecoCascadeHF* candidateB0 = (AliAODRecoCascadeHF*)obj;
443  if(!candidateB0){
444  cout<<"candidateB0 null"<<endl;
445  return 0;
446  }
447 
448  AliAODRecoCascadeHF* candidateDStar = (AliAODRecoCascadeHF*)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  AliAODRecoCascadeHF* candidateDStar = (AliAODRecoCascadeHF*)obj;
782  if(!candidateDStar){
783  cout<<"candidateDStar null"<<endl;
784  return 0;
785  }
786 
787  AliAODRecoDecayHF2Prong* candidateD0 = (AliAODRecoDecayHF2Prong*)candidateDStar->Get2Prong();
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  AliAODRecoCascadeHF* candidateDStar = (AliAODRecoCascadeHF*)obj;
1118  if(!candidateDStar){
1119  cout<<"candidateDStar null"<<endl;
1120  return 0;
1121  }
1122 
1123  AliAODRecoDecayHF2Prong* candidateD0 = (AliAODRecoDecayHF2Prong*)candidateDStar->Get2Prong();
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  UInt_t prongs[2];
1177  prongs[0] = 211; prongs[1] = 321;
1178  Double_t invMassD0 = candidateD0->InvMass(2,prongs);
1179  Double_t invMassDifference = TMath::Abs(mD0PDG - invMassD0);
1180 
1181  Double_t pointingAngle = candidateD0->CosPointingAngle();
1182  Double_t dcaMother = candidateD0->GetDCA();
1183  Double_t ptMother = candidateD0->Pt();
1184  Double_t momentumMother = candidateD0->P();
1185  Double_t ptPion = candidatePion->Pt();
1186  Double_t ptKaon = candidateKaon->Pt();
1187 
1188  AliExternalTrackParam motherTrack;
1189  motherTrack.CopyFromVTrack(candidateD0);
1190  Double_t d0z0[2],covd0z0[3],d0[2];
1191  motherTrack.PropagateToDCA(primaryVertex,bz,100.,d0z0,covd0z0);
1192  d0[0] = d0z0[0];
1193  Double_t d0Mother = TMath::Abs(d0[0]);
1194  Double_t d0firstTrack = TMath::Abs(candidateD0->Getd0Prong(0));
1195  Double_t d0secondTrack = TMath::Abs(candidateD0->Getd0Prong(1));
1196 
1197  Double_t impactProduct = candidateD0->Prodd0d0();
1198  Double_t impactProductXY = TMath::Abs(candidateD0->ImpParXY());
1199 
1200  Double_t angleBetweenBothDaughters = (candidateKaon->Px() * candidatePion->Px() + candidateKaon->Py() * candidatePion->Py() + candidateKaon->Pz() * candidatePion->Pz()) /(candidateKaon->P() * candidatePion->P());
1201  Double_t angleMotherFirstDaughter = (candidateD0->Px() * candidatePion->Px() + candidateD0->Py() * candidatePion->Py() + candidateD0->Pz() * candidatePion->Pz()) /(candidateD0->P() * candidatePion->P());
1202  Double_t angleMotherSecondDaughter = (candidateD0->Px() * candidateKaon->Px() + candidateD0->Py() * candidateKaon->Py() + candidateD0->Pz() * candidateKaon->Pz()) /(candidateD0->P() * candidateKaon->P());
1203 
1204  Double_t cosThetaStar = candidateD0->CosThetaStar(0,421,211,321);
1205  Double_t vertexDistance = vertexD0->DistanceToVertex(primaryVertex);
1206  Double_t normDecayLength = candidateD0->NormalizedDecayLength();
1207  Double_t pdgMassMother = TDatabasePDG::Instance()->GetParticle(421)->Mass();
1208  Double_t pseudoProperDecayLength = ((vertexD0->GetX() - primaryVertex->GetX()) * candidateD0->Px() / TMath::Abs(candidateD0->Pt())) + ((vertexD0->GetY() - primaryVertex->GetY()) * candidateD0->Py() / TMath::Abs(candidateD0->Pt()));
1209  Double_t pseudoProperDecayTime = pseudoProperDecayLength * pdgMassMother/ptMother;
1210  Double_t decayTime = vertexDistance / (299792458 * TMath::Sqrt(1/((pdgMassMother*pdgMassMother/(momentumMother*momentumMother)) + 1)));
1211 
1212  Double_t phi = candidateD0->Phi();
1213  Double_t theta = candidateD0->Theta();
1214  Double_t covMatrix[21];
1215  candidateD0->GetCovarianceXYZPxPyPz(covMatrix);
1216 
1217  Double_t cp = TMath::Cos(phi);
1218  Double_t sp = TMath::Sin(phi);
1219  Double_t ct = TMath::Cos(theta);
1220  Double_t st = TMath::Sin(theta);
1221 
1222  Double_t errorMomentum = covMatrix[9]*cp*cp*ct*ct // GetCovPxPx
1223  +covMatrix[13]*2.*cp*sp*ct*ct // GetCovPxPy
1224  +covMatrix[18]*2.*cp*ct*st // GetCovPxPz
1225  +covMatrix[14]*sp*sp*ct*ct // GetCovPyPy
1226  +covMatrix[19]*2.*sp*ct*st // GetCovPyPz
1227  +covMatrix[20]*st*st; // GetCovPzPz
1228  Double_t normalizedDecayTime = candidateD0->NormalizedDecayLength() / (299792458 * TMath::Sqrt(1/((pdgMassMother*pdgMassMother*errorMomentum*errorMomentum/(momentumMother*momentumMother)) + 1)));
1229 
1230  //Topomatic
1231  Double_t dd0pr1=0.;
1232  Double_t dd0pr2=0.;
1233  Double_t dd0max=0.;
1234  Double_t dd0min=0.;
1235  for(Int_t ipr=0; ipr<2; ipr++)
1236  {
1237  Double_t diffIP, errdiffIP;
1238  candidateD0->Getd0MeasMinusExpProng(ipr,bz,diffIP,errdiffIP);
1239  Double_t normdd0=0.;
1240  if(errdiffIP>0.) normdd0=diffIP/errdiffIP;
1241  if(ipr==0) dd0pr1=normdd0;
1242  if(ipr==1) dd0pr2=normdd0;
1243  }
1244  if(TMath::Abs(dd0pr1)>TMath::Abs(dd0pr2)) {dd0max=dd0pr1; dd0min=dd0pr2;}
1245  else {dd0max=dd0pr2; dd0min=dd0pr1;}
1246 
1247 
1248  // We apply the cuts
1249  Int_t nCutIndex = 0;
1250  Double_t cutVariableValue = 0.0;
1251 
1252  // "inv. mass width [GeV]" --------------------------------------------
1253  nCutIndex = 0;
1254  cutVariableValue = invMassDifference;
1255  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1256  if(!bPassedCut && !fGetCutInfo) return 0;
1257  //---------------------------------------------------------------------
1258 
1259  // "delta mass width [GeV]" -------------------------------------------
1260  // nCutIndex = 1; // not used for D0
1261  // cutVariableValue = invMassDelta;
1262  // bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1263  // if(!bPassedCut && !fGetCutInfo) return 0;
1264  //---------------------------------------------------------------------
1265 
1266  // "pointing angle [Cos(theta)]" --------------------------------------
1267  nCutIndex = 2;
1268  cutVariableValue = pointingAngle;
1269  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1270  if(!bPassedCut && !fGetCutInfo) return 0;
1271  //---------------------------------------------------------------------
1272 
1273  // "dca [cm]" ---------------------------------------------------------
1274  nCutIndex = 3;
1275  cutVariableValue = dcaMother;
1276  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1277  if(!bPassedCut && !fGetCutInfo) return 0;
1278  //---------------------------------------------------------------------
1279 
1280  // "Pt D0 [GeV/c]" ----------------------------------------------------
1281  nCutIndex = 4;
1282  cutVariableValue = ptMother;
1283  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1284  if(!bPassedCut && !fGetCutInfo) return 0;
1285  //---------------------------------------------------------------------
1286 
1287  // "Pt Kaon [GeV/c]" -------------------------------------------------
1288  nCutIndex = 5;
1289  cutVariableValue = ptKaon;
1290  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1291  if(!bPassedCut && !fGetCutInfo) return 0;
1292  //---------------------------------------------------------------------
1293 
1294  // "Pt Pion [GeV/c]" --------------------------------------------------
1295  nCutIndex = 6;
1296  cutVariableValue = ptPion;
1297  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1298  if(!bPassedCut && !fGetCutInfo) return 0;
1299  //---------------------------------------------------------------------
1300 
1301  // "d0 D0 [cm]" -------------------------------------------------------
1302  nCutIndex = 7;
1303  cutVariableValue = d0Mother;
1304  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1305  if(!bPassedCut && !fGetCutInfo) return 0;
1306  //---------------------------------------------------------------------
1307 
1308  // "d0 Kaon [cm]"-----------------------------------------------------
1309  nCutIndex = 8;
1310  cutVariableValue = d0firstTrack;
1311  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1312  if(!bPassedCut && !fGetCutInfo) return 0;
1313  //---------------------------------------------------------------------
1314 
1315  // "d0 Pion [cm]" -----------------------------------------------------
1316  nCutIndex = 9;
1317  cutVariableValue = d0secondTrack;
1318  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1319  if(!bPassedCut && !fGetCutInfo) return 0;
1320  //---------------------------------------------------------------------
1321 
1322  // "d0d0 [cm^2]" ------------------------------------------------------
1323  nCutIndex = 10;
1324  cutVariableValue = impactProduct;
1325  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1326  if(!bPassedCut && !fGetCutInfo) return 0;
1327  //---------------------------------------------------------------------
1328 
1329  // "d0d0 XY [cm^2]" ---------------------------------------------------
1330  nCutIndex = 11;
1331  cutVariableValue = impactProductXY;
1332  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1333  if(!bPassedCut && !fGetCutInfo) return 0;
1334  //---------------------------------------------------------------------
1335 
1336  // "angle between both daughters" -------------------------------------
1337  nCutIndex = 12;
1338  cutVariableValue = angleBetweenBothDaughters;
1339  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1340  if(!bPassedCut && !fGetCutInfo) return 0;
1341  //---------------------------------------------------------------------
1342 
1343  // "angle mother with first daughter" ---------------------------------
1344  nCutIndex = 13;
1345  cutVariableValue = angleMotherFirstDaughter;
1346  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1347  if(!bPassedCut && !fGetCutInfo) return 0;
1348  //---------------------------------------------------------------------
1349 
1350  // "angle mother with second daughter" --------------------------------
1351  nCutIndex = 14;
1352  cutVariableValue = angleMotherSecondDaughter;
1353  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1354  if(!bPassedCut && !fGetCutInfo) return 0;
1355  //---------------------------------------------------------------------
1356 
1357  // "cosThetaStar" -----------------------------------------------------
1358  nCutIndex = 15;
1359  cutVariableValue = cosThetaStar;
1360  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1361  if(!bPassedCut && !fGetCutInfo) return 0;
1362  //---------------------------------------------------------------------
1363 
1364  // "vertexDistance" ---------------------------------------------------
1365  nCutIndex = 16;
1366  cutVariableValue = vertexDistance;
1367  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1368  if(!bPassedCut && !fGetCutInfo) return 0;
1369  //---------------------------------------------------------------------
1370 
1371  // "pseudoProperDecayTime" --------------------------------------------
1372  nCutIndex = 17;
1373  cutVariableValue = pseudoProperDecayTime;
1374  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1375  if(!bPassedCut && !fGetCutInfo) return 0;
1376  //---------------------------------------------------------------------
1377 
1378  // "DecayTime" --------------------------------------------------------
1379  nCutIndex = 18;
1380  cutVariableValue = decayTime;
1381  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1382  if(!bPassedCut && !fGetCutInfo) return 0;
1383  //---------------------------------------------------------------------
1384 
1385  // "normalizedDecayTime" ----------------------------------------------------
1386  nCutIndex = 19;
1387  cutVariableValue = normalizedDecayTime;
1388  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1389  if(!bPassedCut && !fGetCutInfo) return 0;
1390  //---------------------------------------------------------------------
1391 
1392  // "normDecayLength" --------------------------------------------------
1393  nCutIndex = 20;
1394  cutVariableValue = normDecayLength;
1395  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1396  if(!bPassedCut && !fGetCutInfo) return 0;
1397  //---------------------------------------------------------------------
1398 
1399  // "topomatic first daughter" -----------------------------------------
1400  nCutIndex = 21;
1401  cutVariableValue = dd0pr1;
1402  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1403  if(!bPassedCut && !fGetCutInfo) return 0;
1404  //---------------------------------------------------------------------
1405 
1406  // "topomatic second daughter" ----------------------------------------
1407  nCutIndex = 22;
1408  cutVariableValue = dd0pr2;
1409  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1410  if(!bPassedCut && !fGetCutInfo) return 0;
1411  //---------------------------------------------------------------------
1412 
1413  // "topomatic max" ----------------------------------------------------
1414  nCutIndex = 23;
1415  cutVariableValue = dd0max;
1416  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1417  if(!bPassedCut && !fGetCutInfo) return 0;
1418  //---------------------------------------------------------------------
1419 
1420  // "topomatic min" ----------------------------------------------------
1421  nCutIndex = 24;
1422  cutVariableValue = dd0min;
1423  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1424  if(!bPassedCut && !fGetCutInfo) return 0;
1425  //---------------------------------------------------------------------
1426 
1427  AliAODRecoDecay* candidateD0toDStar = (AliAODRecoDecay*)candidateD0;
1428  AliExternalTrackParam pionD0Track;
1429  AliExternalTrackParam kaonD0Track;
1430 
1431  Double_t d0z0DSVert[2],covd0z0DSVert[3],d0DSVert[2];
1432 
1433  pionD0Track.CopyFromVTrack(candidatePion);
1434  pionD0Track.PropagateToDCA(vertexDStar,bz,100.,d0z0DSVert,covd0z0DSVert);
1435  d0DSVert[0] = d0z0DSVert[0];
1436 
1437  kaonD0Track.CopyFromVTrack(candidateKaon);
1438  kaonD0Track.PropagateToDCA(vertexDStar,bz,100.,d0z0DSVert,covd0z0DSVert);
1439  d0DSVert[1] = d0z0DSVert[0];
1440 
1441  AliExternalTrackParam D0Track;
1442  D0Track.CopyFromVTrack(candidateD0);
1443  Double_t d0z0D0DSVert[2],covd0z0D0DSVert[3],d0D0DSVert;
1444  motherTrack.PropagateToDCA(vertexDStar,bz,100.,d0z0D0DSVert,covd0z0D0DSVert);
1445  d0D0DSVert = TMath::Abs(d0z0D0DSVert[0]);
1446 
1447  Double_t impactProductToDStar = d0DSVert[0]*d0DSVert[1];
1448  Double_t impactProductXYToDStar = candidateD0toDStar->ImpParXY(vertexDStar);
1449 
1450  Double_t pointingAngleToDStar = candidateD0toDStar->CosPointingAngle(vertexDStar);
1451  Double_t d0FirstDaughterToDStar = TMath::Abs(d0DSVert[0]);
1452  Double_t d0SecondDaughterToDStar = TMath::Abs(d0DSVert[1]);
1453  Double_t normDecayLengthToDStar = candidateD0toDStar->NormalizedDecayLength(vertexDStar);
1454 
1455  Double_t pseudoProperDecayLengthDSVert = ((vertexD0->GetX() - vertexDStar->GetX()) * candidateD0->Px() / TMath::Abs(candidateD0->Pt())) + ((vertexD0->GetY() - vertexDStar->GetY()) * candidateD0->Py() / TMath::Abs(candidateD0->Pt()));
1456  Double_t pseudoProperDecayTimeToDStar = pseudoProperDecayLengthDSVert * pdgMassMother/ptMother;
1457  Double_t DecayTimeToDStar = vertexDistance / (299792458 * TMath::Sqrt(1/((pdgMassMother*pdgMassMother/(momentumMother*momentumMother)) + 1)));
1458 
1459  Double_t phiDSVert = candidateD0->Phi();
1460  Double_t thetaDSVert = candidateD0->Theta();
1461  Double_t covMatrixDSVert[21];
1462  candidateD0->GetCovarianceXYZPxPyPz(covMatrixDSVert);
1463 
1464  cp = TMath::Cos(phiDSVert);
1465  sp = TMath::Sin(phiDSVert);
1466  ct = TMath::Cos(thetaDSVert);
1467  st = TMath::Sin(thetaDSVert);
1468 
1469  errorMomentum = covMatrix[9]*cp*cp*ct*ct // GetCovPxPx
1470  +covMatrix[13]*2.*cp*sp*ct*ct // GetCovPxPy
1471  +covMatrix[18]*2.*cp*ct*st // GetCovPxPz
1472  +covMatrix[14]*sp*sp*ct*ct // GetCovPyPy
1473  +covMatrix[19]*2.*sp*ct*st // GetCovPyPz
1474  +covMatrix[20]*st*st; // GetCovPzPz
1475  Double_t normalizedDecayTimeToDStar = candidateD0toDStar->NormalizedDecayLength(vertexDStar) / (299792458 * TMath::Sqrt(1/((pdgMassMother*pdgMassMother*errorMomentum*errorMomentum/(momentumMother*momentumMother)) + 1)));
1476 
1477  // "pointingAngleToDStar" ---------------------------------------------
1478  nCutIndex = 25;
1479  cutVariableValue = pointingAngleToDStar;
1480  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1481  if(!bPassedCut && !fGetCutInfo) return 0;
1482  //---------------------------------------------------------------------
1483 
1484  // "d0MotherToDStar" --------------------------------------------------
1485  nCutIndex = 26;
1486  cutVariableValue = d0D0DSVert;
1487  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1488  if(!bPassedCut && !fGetCutInfo) return 0;
1489  //---------------------------------------------------------------------
1490 
1491  // "d0FirstDaughterToDStar" -------------------------------------------
1492  nCutIndex = 27;
1493  cutVariableValue = d0FirstDaughterToDStar;
1494  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1495  if(!bPassedCut && !fGetCutInfo) return 0;
1496  //---------------------------------------------------------------------
1497 
1498  // "d0SecondDaughterToDStar" ------------------------------------------
1499  nCutIndex = 28;
1500  cutVariableValue = d0SecondDaughterToDStar;
1501  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1502  if(!bPassedCut && !fGetCutInfo) return 0;
1503  //---------------------------------------------------------------------
1504 
1505  // "impactProductToDStar" ---------------------------------------------
1506  nCutIndex = 29;
1507  cutVariableValue = impactProductToDStar;
1508  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1509  if(!bPassedCut && !fGetCutInfo) return 0;
1510  //---------------------------------------------------------------------
1511 
1512  // "impactProductXYToDStar" -------------------------------------------
1513  nCutIndex = 30;
1514  cutVariableValue = impactProductXYToDStar;
1515  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1516  if(!bPassedCut && !fGetCutInfo) return 0;
1517  //---------------------------------------------------------------------
1518 
1519  // "normDecayLengthToDStar" -------------------------------------------
1520  nCutIndex = 31;
1521  cutVariableValue = normDecayLengthToDStar;
1522  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1523  if(!bPassedCut && !fGetCutInfo) return 0;
1524  //---------------------------------------------------------------------
1525 
1526  // "pseudoProperDecayTimeToDStar" -------------------------------------
1527  nCutIndex = 32;
1528  cutVariableValue = pseudoProperDecayTimeToDStar;
1529  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1530  if(!bPassedCut && !fGetCutInfo) return 0;
1531  //---------------------------------------------------------------------
1532 
1533  // "DecayTimeToDStar" -------------------------------------------------
1534  nCutIndex = 33;
1535  cutVariableValue = DecayTimeToDStar;
1536  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1537  if(!bPassedCut && !fGetCutInfo) return 0;
1538  //---------------------------------------------------------------------
1539 
1540  // "normalizedDecayTimeToDStar" ---------------------------------------------
1541  nCutIndex = 34;
1542  cutVariableValue = normalizedDecayTimeToDStar;
1543  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1544  if(!bPassedCut && !fGetCutInfo) return 0;
1545  //---------------------------------------------------------------------
1546  }
1547 
1548  for (Int_t i = 0; i < 35; ++i)
1549  {
1550  if(bCutArray[i]==kTRUE){
1551  returnvalue = 0;
1552  break;
1553  }
1554  }
1555 
1556  return returnvalue;
1557 }
1558 //----------------------------------------------------------------------------------
1560  //
1561  // Apply selection on D0 candidate.
1562  //
1563 
1564  if(!fCutsRDD0forD0ptbin){
1565  cout<<"Cut matrice not inizialized. Exit..."<<endl;
1566  return 0;
1567  }
1568 
1569  AliAODRecoDecayHF2Prong* candidateD0 = (AliAODRecoDecayHF2Prong*)obj;
1570  if(!candidateD0){
1571  cout<<"candidateD0 null"<<endl;
1572  return 0;
1573  }
1574 
1575  AliAODTrack *candidatePion = (AliAODTrack*)candidateD0->GetDaughter(0);
1576  if(!candidatePion){
1577  cout<<"candidatePion null"<<endl;
1578  return 0;
1579  }
1580 
1581  AliAODTrack *candidateKaon = (AliAODTrack*)candidateD0->GetDaughter(1);
1582  if(!candidateKaon){
1583  cout<<"candidateKaon null"<<endl;
1584  return 0;
1585  }
1586 
1587  AliAODVertex * vertexD0 = candidateD0->GetSecondaryVtx();
1588  if(!vertexD0){
1589  cout<<"vertexD0 null"<<endl;
1590  return 0;
1591  }
1592 
1593  AliAODVertex * primaryVertex = aod->GetPrimaryVertex();
1594  if(!primaryVertex){
1595  cout<<"primaryVertex null"<<endl;
1596  return 0;
1597  }
1598 
1599  Int_t returnvalue=1;
1600  Bool_t bPassedCut = kFALSE;
1601 
1602  //get the magnetic field
1603  Double_t bz = (Double_t)aod->GetMagneticField();
1604 
1605 
1606  // selection on candidate
1607  if(selectionLevel==AliRDHFCuts::kAll ||
1608  selectionLevel==AliRDHFCuts::kCandidate) {
1609 
1610  Int_t ptbin=PtBinD0forD0ptbin(candidateD0->Pt());
1611  if(ptbin==-1) return -1;
1612 
1613  // D0mass
1614  Double_t mD0PDG = TDatabasePDG::Instance()->GetParticle(421)->Mass();
1615 
1616  // Half width DStar mass
1617  UInt_t prongs[2];
1618  prongs[0] = 211; prongs[1] = 321;
1619  Double_t invMassD0 = candidateD0->InvMass(2,prongs);
1620  Double_t invMassDifference = TMath::Abs(mD0PDG - invMassD0);
1621 
1622  Double_t pointingAngle = candidateD0->CosPointingAngle();
1623  Double_t dcaMother = candidateD0->GetDCA();
1624  Double_t ptMother = candidateD0->Pt();
1625  Double_t momentumMother = candidateD0->P();
1626  Double_t ptPion = candidatePion->Pt();
1627  Double_t ptKaon = candidateKaon->Pt();
1628 
1629  AliExternalTrackParam motherTrack;
1630  motherTrack.CopyFromVTrack(candidateD0);
1631  Double_t d0z0[2],covd0z0[3],d0[2];
1632  motherTrack.PropagateToDCA(primaryVertex,bz,100.,d0z0,covd0z0);
1633  d0[0] = d0z0[0];
1634  Double_t d0Mother = TMath::Abs(d0[0]);
1635  Double_t d0firstTrack = TMath::Abs(candidateD0->Getd0Prong(0));
1636  Double_t d0secondTrack = TMath::Abs(candidateD0->Getd0Prong(1));
1637 
1638  Double_t impactProduct = candidateD0->Prodd0d0();
1639  Double_t impactProductXY = TMath::Abs(candidateD0->ImpParXY());
1640 
1641  Double_t angleBetweenBothDaughters = (candidateKaon->Px() * candidatePion->Px() + candidateKaon->Py() * candidatePion->Py() + candidateKaon->Pz() * candidatePion->Pz()) /(candidateKaon->P() * candidatePion->P());
1642  Double_t angleMotherFirstDaughter = (candidateD0->Px() * candidatePion->Px() + candidateD0->Py() * candidatePion->Py() + candidateD0->Pz() * candidatePion->Pz()) /(candidateD0->P() * candidatePion->P());
1643  Double_t angleMotherSecondDaughter = (candidateD0->Px() * candidateKaon->Px() + candidateD0->Py() * candidateKaon->Py() + candidateD0->Pz() * candidateKaon->Pz()) /(candidateD0->P() * candidateKaon->P());
1644 
1645  Double_t cosThetaStar = candidateD0->CosThetaStar(0,421,211,321);
1646  Double_t vertexDistance = vertexD0->DistanceToVertex(primaryVertex);
1647  Double_t normDecayLength = candidateD0->NormalizedDecayLength();
1648  Double_t pdgMassMother = TDatabasePDG::Instance()->GetParticle(421)->Mass();
1649  Double_t pseudoProperDecayLength = ((vertexD0->GetX() - primaryVertex->GetX()) * candidateD0->Px() / TMath::Abs(candidateD0->Pt())) + ((vertexD0->GetY() - primaryVertex->GetY()) * candidateD0->Py() / TMath::Abs(candidateD0->Pt()));
1650  Double_t pseudoProperDecayTime = pseudoProperDecayLength * pdgMassMother/ptMother;
1651  Double_t decayTime = vertexDistance / (299792458 * TMath::Sqrt(1/((pdgMassMother*pdgMassMother/(momentumMother*momentumMother)) + 1)));
1652 
1653  Double_t phi = candidateD0->Phi();
1654  Double_t theta = candidateD0->Theta();
1655  Double_t covMatrix[21];
1656  candidateD0->GetCovarianceXYZPxPyPz(covMatrix);
1657 
1658  Double_t cp = TMath::Cos(phi);
1659  Double_t sp = TMath::Sin(phi);
1660  Double_t ct = TMath::Cos(theta);
1661  Double_t st = TMath::Sin(theta);
1662 
1663  Double_t errorMomentum = covMatrix[9]*cp*cp*ct*ct // GetCovPxPx
1664  +covMatrix[13]*2.*cp*sp*ct*ct // GetCovPxPy
1665  +covMatrix[18]*2.*cp*ct*st // GetCovPxPz
1666  +covMatrix[14]*sp*sp*ct*ct // GetCovPyPy
1667  +covMatrix[19]*2.*sp*ct*st // GetCovPyPz
1668  +covMatrix[20]*st*st; // GetCovPzPz
1669  Double_t normalizedDecayTime = candidateD0->NormalizedDecayLength() / (299792458 * TMath::Sqrt(1/((pdgMassMother*pdgMassMother*errorMomentum*errorMomentum/(momentumMother*momentumMother)) + 1)));
1670 
1671  //Topomatic
1672  Double_t dd0pr1=0.;
1673  Double_t dd0pr2=0.;
1674  Double_t dd0max=0.;
1675  Double_t dd0min=0.;
1676  for(Int_t ipr=0; ipr<2; ipr++)
1677  {
1678  Double_t diffIP, errdiffIP;
1679  candidateD0->Getd0MeasMinusExpProng(ipr,bz,diffIP,errdiffIP);
1680  Double_t normdd0=0.;
1681  if(errdiffIP>0.) normdd0=diffIP/errdiffIP;
1682  if(ipr==0) dd0pr1=normdd0;
1683  if(ipr==1) dd0pr2=normdd0;
1684  }
1685  if(TMath::Abs(dd0pr1)>TMath::Abs(dd0pr2)) {dd0max=dd0pr1; dd0min=dd0pr2;}
1686  else {dd0max=dd0pr2; dd0min=dd0pr1;}
1687 
1688 
1689  // We apply the cuts
1690  Int_t nCutIndex = 0;
1691  Double_t cutVariableValue = 0.0;
1692 
1693  // "inv. mass width [GeV]" --------------------------------------------
1694  nCutIndex = 0;
1695  cutVariableValue = invMassDifference;
1696  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
1697  if(!bPassedCut && !fGetCutInfo) return 0;
1698  //---------------------------------------------------------------------
1699 
1700  // "delta mass width [GeV]" -------------------------------------------
1701  // nCutIndex = 1; // not used for D0
1702  // cutVariableValue = invMassDelta;
1703  // bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
1704  // if(!bPassedCut && !fGetCutInfo) return 0;
1705  //---------------------------------------------------------------------
1706 
1707  // "pointing angle [Cos(theta)]" --------------------------------------
1708  nCutIndex = 2;
1709  cutVariableValue = pointingAngle;
1710  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
1711  if(!bPassedCut && !fGetCutInfo) return 0;
1712  //---------------------------------------------------------------------
1713 
1714  // "dca [cm]" ---------------------------------------------------------
1715  nCutIndex = 3;
1716  cutVariableValue = dcaMother;
1717  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
1718  if(!bPassedCut && !fGetCutInfo) return 0;
1719  //---------------------------------------------------------------------
1720 
1721  // "Pt D0 [GeV/c]" ----------------------------------------------------
1722  nCutIndex = 4;
1723  cutVariableValue = ptMother;
1724  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
1725  if(!bPassedCut && !fGetCutInfo) return 0;
1726  //---------------------------------------------------------------------
1727 
1728  // "Pt Kaon [GeV/c]" -------------------------------------------------
1729  nCutIndex = 5;
1730  cutVariableValue = ptKaon;
1731  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
1732  if(!bPassedCut && !fGetCutInfo) return 0;
1733  //---------------------------------------------------------------------
1734 
1735  // "Pt Pion [GeV/c]" --------------------------------------------------
1736  nCutIndex = 6;
1737  cutVariableValue = ptPion;
1738  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
1739  if(!bPassedCut && !fGetCutInfo) return 0;
1740  //---------------------------------------------------------------------
1741 
1742  // "d0 D0 [cm]" -------------------------------------------------------
1743  nCutIndex = 7;
1744  cutVariableValue = d0Mother;
1745  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
1746  if(!bPassedCut && !fGetCutInfo) return 0;
1747  //---------------------------------------------------------------------
1748 
1749  // "d0 Kaon [cm]"-----------------------------------------------------
1750  nCutIndex = 8;
1751  cutVariableValue = d0firstTrack;
1752  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
1753  if(!bPassedCut && !fGetCutInfo) return 0;
1754  //---------------------------------------------------------------------
1755 
1756  // "d0 Pion [cm]" -----------------------------------------------------
1757  nCutIndex = 9;
1758  cutVariableValue = d0secondTrack;
1759  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
1760  if(!bPassedCut && !fGetCutInfo) return 0;
1761  //---------------------------------------------------------------------
1762 
1763  // "d0d0 [cm^2]" ------------------------------------------------------
1764  nCutIndex = 10;
1765  cutVariableValue = impactProduct;
1766  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
1767  if(!bPassedCut && !fGetCutInfo) return 0;
1768  //---------------------------------------------------------------------
1769 
1770  // "d0d0 XY [cm^2]" ---------------------------------------------------
1771  nCutIndex = 11;
1772  cutVariableValue = impactProductXY;
1773  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
1774  if(!bPassedCut && !fGetCutInfo) return 0;
1775  //---------------------------------------------------------------------
1776 
1777  // "angle between both daughters" -------------------------------------
1778  nCutIndex = 12;
1779  cutVariableValue = angleBetweenBothDaughters;
1780  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
1781  if(!bPassedCut && !fGetCutInfo) return 0;
1782  //---------------------------------------------------------------------
1783 
1784  // "angle mother with first daughter" ---------------------------------
1785  nCutIndex = 13;
1786  cutVariableValue = angleMotherFirstDaughter;
1787  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
1788  if(!bPassedCut && !fGetCutInfo) return 0;
1789  //---------------------------------------------------------------------
1790 
1791  // "angle mother with second daughter" --------------------------------
1792  nCutIndex = 14;
1793  cutVariableValue = angleMotherSecondDaughter;
1794  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
1795  if(!bPassedCut && !fGetCutInfo) return 0;
1796  //---------------------------------------------------------------------
1797 
1798  // "cosThetaStar" -----------------------------------------------------
1799  nCutIndex = 15;
1800  cutVariableValue = cosThetaStar;
1801  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
1802  if(!bPassedCut && !fGetCutInfo) return 0;
1803  //---------------------------------------------------------------------
1804 
1805  // "vertexDistance" ---------------------------------------------------
1806  nCutIndex = 16;
1807  cutVariableValue = vertexDistance;
1808  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
1809  if(!bPassedCut && !fGetCutInfo) return 0;
1810  //---------------------------------------------------------------------
1811 
1812  // "pseudoProperDecayTime" --------------------------------------------
1813  nCutIndex = 17;
1814  cutVariableValue = pseudoProperDecayTime;
1815  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
1816  if(!bPassedCut && !fGetCutInfo) return 0;
1817  //---------------------------------------------------------------------
1818 
1819  // "DecayTime" --------------------------------------------------------
1820  nCutIndex = 18;
1821  cutVariableValue = decayTime;
1822  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
1823  if(!bPassedCut && !fGetCutInfo) return 0;
1824  //---------------------------------------------------------------------
1825 
1826  // "normalizedDecayTime" ----------------------------------------------------
1827  nCutIndex = 19;
1828  cutVariableValue = normalizedDecayTime;
1829  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
1830  if(!bPassedCut && !fGetCutInfo) return 0;
1831  //---------------------------------------------------------------------
1832 
1833  // "normDecayLength" --------------------------------------------------
1834  nCutIndex = 20;
1835  cutVariableValue = normDecayLength;
1836  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
1837  if(!bPassedCut && !fGetCutInfo) return 0;
1838  //---------------------------------------------------------------------
1839 
1840  // "topomatic first daughter" -----------------------------------------
1841  nCutIndex = 21;
1842  cutVariableValue = dd0pr1;
1843  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
1844  if(!bPassedCut && !fGetCutInfo) return 0;
1845  //---------------------------------------------------------------------
1846 
1847  // "topomatic second daughter" ----------------------------------------
1848  nCutIndex = 22;
1849  cutVariableValue = dd0pr2;
1850  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
1851  if(!bPassedCut && !fGetCutInfo) return 0;
1852  //---------------------------------------------------------------------
1853 
1854  // "topomatic max" ----------------------------------------------------
1855  nCutIndex = 23;
1856  cutVariableValue = dd0max;
1857  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
1858  if(!bPassedCut && !fGetCutInfo) return 0;
1859  //---------------------------------------------------------------------
1860 
1861  // "topomatic min" ----------------------------------------------------
1862  nCutIndex = 24;
1863  cutVariableValue = dd0min;
1864  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
1865  if(!bPassedCut && !fGetCutInfo) return 0;
1866  //---------------------------------------------------------------------
1867 
1868  }
1869 
1870  for (Int_t i = 0; i < 25; ++i)
1871  {
1872  if(bCutArray[i]==kTRUE){
1873  returnvalue = 0;
1874  break;
1875  }
1876  }
1877 
1878  return returnvalue;
1879 }
1880 //----------------------------------------------------------------------------------
1882  //
1883  // 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.
1884  //
1885 
1887  cout<<"Cut matrice not inizialized. Exit..."<<endl;
1888  return 0;
1889  }
1890 
1891  AliAODRecoCascadeHF* candidateDStar = (AliAODRecoCascadeHF*)obj;
1892  if(!candidateDStar){
1893  cout<<"candidateDStar null"<<endl;
1894  return 0;
1895  }
1896 
1897  AliAODRecoDecayHF2Prong* candidateD0 = (AliAODRecoDecayHF2Prong*)candidateDStar->Get2Prong();
1898  if(!candidateD0){
1899  cout<<"candidateD0 null"<<endl;
1900  return 0;
1901  }
1902 
1903  AliAODTrack *candidatePion = (AliAODTrack*)candidateD0->GetDaughter(0);
1904  if(!candidatePion){
1905  cout<<"candidatePion null"<<endl;
1906  return 0;
1907  }
1908 
1909  AliAODTrack *candidateKaon = (AliAODTrack*)candidateD0->GetDaughter(1);
1910  if(!candidateKaon){
1911  cout<<"candidateKaon null"<<endl;
1912  return 0;
1913  }
1914 
1915  AliAODVertex * vertexDStar = candidateDStar->GetSecondaryVtx();
1916  if(!vertexDStar){
1917  cout<<"vertexDStar null"<<endl;
1918  return 0;
1919  }
1920 
1921  AliAODVertex * vertexD0 = candidateD0->GetSecondaryVtx();
1922  if(!vertexD0){
1923  cout<<"vertexD0 null"<<endl;
1924  return 0;
1925  }
1926 
1927  AliAODVertex * primaryVertex = aod->GetPrimaryVertex();
1928  if(!primaryVertex){
1929  cout<<"primaryVertex null"<<endl;
1930  return 0;
1931  }
1932 
1933  Int_t returnvalue=1;
1934  Bool_t bPassedCut = kFALSE;
1935 
1936  //get the magnetic field
1937  Double_t bz = (Double_t)aod->GetMagneticField();
1938 
1939 
1940  // selection on candidate
1941  if(selectionLevel==AliRDHFCuts::kAll ||
1942  selectionLevel==AliRDHFCuts::kCandidate) {
1943 
1944  Int_t ptbin=PtBinD0forDStarptbin(candidateDStar->Pt());
1945  if(ptbin==-1) return -1;
1946  // D0mass
1947  Double_t mD0PDG = TDatabasePDG::Instance()->GetParticle(421)->Mass();
1948 
1949  // Half width DStar mass
1950  UInt_t prongs[2];
1951  prongs[0] = 211; prongs[1] = 321;
1952  Double_t invMassD0 = candidateD0->InvMass(2,prongs);
1953  Double_t invMassDifference = TMath::Abs(mD0PDG - invMassD0);
1954 
1955  Double_t pointingAngle = candidateD0->CosPointingAngle();
1956  Double_t dcaMother = candidateD0->GetDCA();
1957  Double_t ptMother = candidateD0->Pt();
1958  Double_t momentumMother = candidateD0->P();
1959  Double_t ptPion = candidatePion->Pt();
1960  Double_t ptKaon = candidateKaon->Pt();
1961 
1962  AliExternalTrackParam motherTrack;
1963  motherTrack.CopyFromVTrack(candidateD0);
1964  Double_t d0z0[2],covd0z0[3],d0[2];
1965  motherTrack.PropagateToDCA(primaryVertex,bz,100.,d0z0,covd0z0);
1966  d0[0] = d0z0[0];
1967  Double_t d0Mother = TMath::Abs(d0[0]);
1968  Double_t d0firstTrack = TMath::Abs(candidateD0->Getd0Prong(0));
1969  Double_t d0secondTrack = TMath::Abs(candidateD0->Getd0Prong(1));
1970 
1971  Double_t impactProduct = candidateD0->Prodd0d0();
1972  Double_t impactProductXY = TMath::Abs(candidateD0->ImpParXY());
1973 
1974  Double_t angleBetweenBothDaughters = (candidateKaon->Px() * candidatePion->Px() + candidateKaon->Py() * candidatePion->Py() + candidateKaon->Pz() * candidatePion->Pz()) /(candidateKaon->P() * candidatePion->P());
1975  Double_t angleMotherFirstDaughter = (candidateD0->Px() * candidatePion->Px() + candidateD0->Py() * candidatePion->Py() + candidateD0->Pz() * candidatePion->Pz()) /(candidateD0->P() * candidatePion->P());
1976  Double_t angleMotherSecondDaughter = (candidateD0->Px() * candidateKaon->Px() + candidateD0->Py() * candidateKaon->Py() + candidateD0->Pz() * candidateKaon->Pz()) /(candidateD0->P() * candidateKaon->P());
1977 
1978  Double_t cosThetaStar = candidateD0->CosThetaStar(0,421,211,321);
1979  Double_t vertexDistance = vertexD0->DistanceToVertex(primaryVertex);
1980  Double_t normDecayLength = candidateD0->NormalizedDecayLength();
1981  Double_t pdgMassMother = TDatabasePDG::Instance()->GetParticle(421)->Mass();
1982  Double_t pseudoProperDecayLength = ((vertexD0->GetX() - primaryVertex->GetX()) * candidateD0->Px() / TMath::Abs(candidateD0->Pt())) + ((vertexD0->GetY() - primaryVertex->GetY()) * candidateD0->Py() / TMath::Abs(candidateD0->Pt()));
1983  Double_t pseudoProperDecayTime = pseudoProperDecayLength * pdgMassMother/ptMother;
1984  Double_t decayTime = vertexDistance / (299792458 * TMath::Sqrt(1/((pdgMassMother*pdgMassMother/(momentumMother*momentumMother)) + 1)));
1985 
1986  Double_t phi = candidateD0->Phi();
1987  Double_t theta = candidateD0->Theta();
1988  Double_t covMatrix[21];
1989  candidateD0->GetCovarianceXYZPxPyPz(covMatrix);
1990 
1991  Double_t cp = TMath::Cos(phi);
1992  Double_t sp = TMath::Sin(phi);
1993  Double_t ct = TMath::Cos(theta);
1994  Double_t st = TMath::Sin(theta);
1995 
1996  Double_t errorMomentum = covMatrix[9]*cp*cp*ct*ct // GetCovPxPx
1997  +covMatrix[13]*2.*cp*sp*ct*ct // GetCovPxPy
1998  +covMatrix[18]*2.*cp*ct*st // GetCovPxPz
1999  +covMatrix[14]*sp*sp*ct*ct // GetCovPyPy
2000  +covMatrix[19]*2.*sp*ct*st // GetCovPyPz
2001  +covMatrix[20]*st*st; // GetCovPzPz
2002  Double_t normalizedDecayTime = candidateD0->NormalizedDecayLength() / (299792458 * TMath::Sqrt(1/((pdgMassMother*pdgMassMother*errorMomentum*errorMomentum/(momentumMother*momentumMother)) + 1)));
2003 
2004  //Topomatic
2005  Double_t dd0pr1=0.;
2006  Double_t dd0pr2=0.;
2007  Double_t dd0max=0.;
2008  Double_t dd0min=0.;
2009  for(Int_t ipr=0; ipr<2; ipr++)
2010  {
2011  Double_t diffIP, errdiffIP;
2012  candidateD0->Getd0MeasMinusExpProng(ipr,bz,diffIP,errdiffIP);
2013  Double_t normdd0=0.;
2014  if(errdiffIP>0.) normdd0=diffIP/errdiffIP;
2015  if(ipr==0) dd0pr1=normdd0;
2016  if(ipr==1) dd0pr2=normdd0;
2017  }
2018  if(TMath::Abs(dd0pr1)>TMath::Abs(dd0pr2)) {dd0max=dd0pr1; dd0min=dd0pr2;}
2019  else {dd0max=dd0pr2; dd0min=dd0pr1;}
2020 
2021 
2022  // We apply the cuts
2023  Int_t nCutIndex = 0;
2024  Double_t cutVariableValue = 0.0;
2025 
2026  // "inv. mass width [GeV]" --------------------------------------------
2027  nCutIndex = 0;
2028  cutVariableValue = invMassDifference;
2029  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2030  if(!bPassedCut && !fGetCutInfo) return 0;
2031  //---------------------------------------------------------------------
2032 
2033  // "delta mass width [GeV]" -------------------------------------------
2034  // nCutIndex = 1; // not used for D0
2035  // cutVariableValue = invMassDelta;
2036  // bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2037  // if(!bPassedCut && !fGetCutInfo) return 0;
2038  //---------------------------------------------------------------------
2039 
2040  // "pointing angle [Cos(theta)]" --------------------------------------
2041  nCutIndex = 2;
2042  cutVariableValue = pointingAngle;
2043  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2044  if(!bPassedCut && !fGetCutInfo) return 0;
2045  //---------------------------------------------------------------------
2046 
2047  // "dca [cm]" ---------------------------------------------------------
2048  nCutIndex = 3;
2049  cutVariableValue = dcaMother;
2050  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2051  if(!bPassedCut && !fGetCutInfo) return 0;
2052  //---------------------------------------------------------------------
2053 
2054  // "Pt D0 [GeV/c]" ----------------------------------------------------
2055  nCutIndex = 4;
2056  cutVariableValue = ptMother;
2057  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2058  if(!bPassedCut && !fGetCutInfo) return 0;
2059  //---------------------------------------------------------------------
2060 
2061  // "Pt Kaon [GeV/c]" -------------------------------------------------
2062  nCutIndex = 5;
2063  cutVariableValue = ptKaon;
2064  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2065  if(!bPassedCut && !fGetCutInfo) return 0;
2066  //---------------------------------------------------------------------
2067 
2068  // "Pt Pion [GeV/c]" --------------------------------------------------
2069  nCutIndex = 6;
2070  cutVariableValue = ptPion;
2071  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2072  if(!bPassedCut && !fGetCutInfo) return 0;
2073  //---------------------------------------------------------------------
2074 
2075  // "d0 D0 [cm]" -------------------------------------------------------
2076  nCutIndex = 7;
2077  cutVariableValue = d0Mother;
2078  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2079  if(!bPassedCut && !fGetCutInfo) return 0;
2080  //---------------------------------------------------------------------
2081 
2082  // "d0 Kaon [cm]"-----------------------------------------------------
2083  nCutIndex = 8;
2084  cutVariableValue = d0firstTrack;
2085  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2086  if(!bPassedCut && !fGetCutInfo) return 0;
2087  //---------------------------------------------------------------------
2088 
2089  // "d0 Pion [cm]" -----------------------------------------------------
2090  nCutIndex = 9;
2091  cutVariableValue = d0secondTrack;
2092  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2093  if(!bPassedCut && !fGetCutInfo) return 0;
2094  //---------------------------------------------------------------------
2095 
2096  // "d0d0 [cm^2]" ------------------------------------------------------
2097  nCutIndex = 10;
2098  cutVariableValue = impactProduct;
2099  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2100  if(!bPassedCut && !fGetCutInfo) return 0;
2101  //---------------------------------------------------------------------
2102 
2103  // "d0d0 XY [cm^2]" ---------------------------------------------------
2104  nCutIndex = 11;
2105  cutVariableValue = impactProductXY;
2106  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2107  if(!bPassedCut && !fGetCutInfo) return 0;
2108  //---------------------------------------------------------------------
2109 
2110  // "angle between both daughters" -------------------------------------
2111  nCutIndex = 12;
2112  cutVariableValue = angleBetweenBothDaughters;
2113  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2114  if(!bPassedCut && !fGetCutInfo) return 0;
2115  //---------------------------------------------------------------------
2116 
2117  // "angle mother with first daughter" ---------------------------------
2118  nCutIndex = 13;
2119  cutVariableValue = angleMotherFirstDaughter;
2120  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2121  if(!bPassedCut && !fGetCutInfo) return 0;
2122  //---------------------------------------------------------------------
2123 
2124  // "angle mother with second daughter" --------------------------------
2125  nCutIndex = 14;
2126  cutVariableValue = angleMotherSecondDaughter;
2127  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2128  if(!bPassedCut && !fGetCutInfo) return 0;
2129  //---------------------------------------------------------------------
2130 
2131  // "cosThetaStar" -----------------------------------------------------
2132  nCutIndex = 15;
2133  cutVariableValue = cosThetaStar;
2134  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2135  if(!bPassedCut && !fGetCutInfo) return 0;
2136  //---------------------------------------------------------------------
2137 
2138  // "vertexDistance" ---------------------------------------------------
2139  nCutIndex = 16;
2140  cutVariableValue = vertexDistance;
2141  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2142  if(!bPassedCut && !fGetCutInfo) return 0;
2143  //---------------------------------------------------------------------
2144 
2145  // "pseudoProperDecayTime" --------------------------------------------
2146  nCutIndex = 17;
2147  cutVariableValue = pseudoProperDecayTime;
2148  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2149  if(!bPassedCut && !fGetCutInfo) return 0;
2150  //---------------------------------------------------------------------
2151 
2152  // "DecayTime" --------------------------------------------------------
2153  nCutIndex = 18;
2154  cutVariableValue = decayTime;
2155  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2156  if(!bPassedCut && !fGetCutInfo) return 0;
2157  //---------------------------------------------------------------------
2158 
2159  // "normalizedDecayTime" ----------------------------------------------------
2160  nCutIndex = 19;
2161  cutVariableValue = normalizedDecayTime;
2162  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2163  if(!bPassedCut && !fGetCutInfo) return 0;
2164  //---------------------------------------------------------------------
2165 
2166  // "normDecayLength" --------------------------------------------------
2167  nCutIndex = 20;
2168  cutVariableValue = normDecayLength;
2169  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2170  if(!bPassedCut && !fGetCutInfo) return 0;
2171  //---------------------------------------------------------------------
2172 
2173  // "topomatic first daughter" -----------------------------------------
2174  nCutIndex = 21;
2175  cutVariableValue = dd0pr1;
2176  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2177  if(!bPassedCut && !fGetCutInfo) return 0;
2178  //---------------------------------------------------------------------
2179 
2180  // "topomatic second daughter" ----------------------------------------
2181  nCutIndex = 22;
2182  cutVariableValue = dd0pr2;
2183  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2184  if(!bPassedCut && !fGetCutInfo) return 0;
2185  //---------------------------------------------------------------------
2186 
2187  // "topomatic max" ----------------------------------------------------
2188  nCutIndex = 23;
2189  cutVariableValue = dd0max;
2190  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2191  if(!bPassedCut && !fGetCutInfo) return 0;
2192  //---------------------------------------------------------------------
2193 
2194  // "topomatic min" ----------------------------------------------------
2195  nCutIndex = 24;
2196  cutVariableValue = dd0min;
2197  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2198  if(!bPassedCut && !fGetCutInfo) return 0;
2199  //---------------------------------------------------------------------
2200 
2201  AliAODRecoDecay* candidateD0toDStar = (AliAODRecoDecay*)candidateD0;
2202  AliExternalTrackParam pionD0Track;
2203  AliExternalTrackParam kaonD0Track;
2204 
2205  Double_t d0z0DSVert[2],covd0z0DSVert[3],d0DSVert[2];
2206 
2207  pionD0Track.CopyFromVTrack(candidatePion);
2208  pionD0Track.PropagateToDCA(vertexDStar,bz,100.,d0z0DSVert,covd0z0DSVert);
2209  d0DSVert[0] = d0z0DSVert[0];
2210 
2211  kaonD0Track.CopyFromVTrack(candidateKaon);
2212  kaonD0Track.PropagateToDCA(vertexDStar,bz,100.,d0z0DSVert,covd0z0DSVert);
2213  d0DSVert[1] = d0z0DSVert[0];
2214 
2215  AliExternalTrackParam D0Track;
2216  D0Track.CopyFromVTrack(candidateD0);
2217  Double_t d0z0D0DSVert[2],covd0z0D0DSVert[3],d0D0DSVert;
2218  motherTrack.PropagateToDCA(vertexDStar,bz,100.,d0z0D0DSVert,covd0z0D0DSVert);
2219  d0D0DSVert = TMath::Abs(d0z0D0DSVert[0]);
2220 
2221  Double_t impactProductToDStar = d0DSVert[0]*d0DSVert[1];
2222  Double_t impactProductXYToDStar = candidateD0toDStar->ImpParXY(vertexDStar);
2223 
2224  Double_t pointingAngleToDStar = candidateD0toDStar->CosPointingAngle(vertexDStar);
2225  Double_t d0FirstDaughterToDStar = TMath::Abs(d0DSVert[0]);
2226  Double_t d0SecondDaughterToDStar = TMath::Abs(d0DSVert[1]);
2227  Double_t normDecayLengthToDStar = candidateD0toDStar->NormalizedDecayLength(vertexDStar);
2228 
2229  Double_t pseudoProperDecayLengthDSVert = ((vertexD0->GetX() - vertexDStar->GetX()) * candidateD0->Px() / TMath::Abs(candidateD0->Pt())) + ((vertexD0->GetY() - vertexDStar->GetY()) * candidateD0->Py() / TMath::Abs(candidateD0->Pt()));
2230  Double_t pseudoProperDecayTimeToDStar = pseudoProperDecayLengthDSVert * pdgMassMother/ptMother;
2231  Double_t DecayTimeToDStar = vertexDistance / (299792458 * TMath::Sqrt(1/((pdgMassMother*pdgMassMother/(momentumMother*momentumMother)) + 1)));
2232 
2233  Double_t phiDSVert = candidateD0->Phi();
2234  Double_t thetaDSVert = candidateD0->Theta();
2235  Double_t covMatrixDSVert[21];
2236  candidateD0->GetCovarianceXYZPxPyPz(covMatrixDSVert);
2237 
2238  cp = TMath::Cos(phiDSVert);
2239  sp = TMath::Sin(phiDSVert);
2240  ct = TMath::Cos(thetaDSVert);
2241  st = TMath::Sin(thetaDSVert);
2242 
2243  errorMomentum = covMatrix[9]*cp*cp*ct*ct // GetCovPxPx
2244  +covMatrix[13]*2.*cp*sp*ct*ct // GetCovPxPy
2245  +covMatrix[18]*2.*cp*ct*st // GetCovPxPz
2246  +covMatrix[14]*sp*sp*ct*ct // GetCovPyPy
2247  +covMatrix[19]*2.*sp*ct*st // GetCovPyPz
2248  +covMatrix[20]*st*st; // GetCovPzPz
2249  Double_t normalizedDecayTimeToDStar = candidateD0toDStar->NormalizedDecayLength(vertexDStar) / (299792458 * TMath::Sqrt(1/((pdgMassMother*pdgMassMother*errorMomentum*errorMomentum/(momentumMother*momentumMother)) + 1)));
2250 
2251  // "pointingAngleToDStar" ---------------------------------------------
2252  nCutIndex = 25;
2253  cutVariableValue = pointingAngleToDStar;
2254  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2255  if(!bPassedCut && !fGetCutInfo) return 0;
2256  //---------------------------------------------------------------------
2257 
2258  // "d0MotherToDStar" --------------------------------------------------
2259  nCutIndex = 26;
2260  cutVariableValue = d0D0DSVert;
2261  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2262  if(!bPassedCut && !fGetCutInfo) return 0;
2263  //---------------------------------------------------------------------
2264 
2265  // "d0FirstDaughterToDStar" -------------------------------------------
2266  nCutIndex = 27;
2267  cutVariableValue = d0FirstDaughterToDStar;
2268  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2269  if(!bPassedCut && !fGetCutInfo) return 0;
2270  //---------------------------------------------------------------------
2271 
2272  // "d0SecondDaughterToDStar" ------------------------------------------
2273  nCutIndex = 28;
2274  cutVariableValue = d0SecondDaughterToDStar;
2275  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2276  if(!bPassedCut && !fGetCutInfo) return 0;
2277  //---------------------------------------------------------------------
2278 
2279  // "impactProductToDStar" ---------------------------------------------
2280  nCutIndex = 29;
2281  cutVariableValue = impactProductToDStar;
2282  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2283  if(!bPassedCut && !fGetCutInfo) return 0;
2284  //---------------------------------------------------------------------
2285 
2286  // "impactProductXYToDStar" -------------------------------------------
2287  nCutIndex = 30;
2288  cutVariableValue = impactProductXYToDStar;
2289  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2290  if(!bPassedCut && !fGetCutInfo) return 0;
2291  //---------------------------------------------------------------------
2292 
2293  // "normDecayLengthToDStar" -------------------------------------------
2294  nCutIndex = 31;
2295  cutVariableValue = normDecayLengthToDStar;
2296  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2297  if(!bPassedCut && !fGetCutInfo) return 0;
2298  //---------------------------------------------------------------------
2299 
2300  // "pseudoProperDecayTimeToDStar" -------------------------------------
2301  nCutIndex = 32;
2302  cutVariableValue = pseudoProperDecayTimeToDStar;
2303  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2304  if(!bPassedCut && !fGetCutInfo) return 0;
2305  //---------------------------------------------------------------------
2306 
2307  // "DecayTimeToDStar" -------------------------------------------------
2308  nCutIndex = 33;
2309  cutVariableValue = DecayTimeToDStar;
2310  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2311  if(!bPassedCut && !fGetCutInfo) return 0;
2312  //---------------------------------------------------------------------
2313 
2314  // "normalizedDecayTimeToDStar" ---------------------------------------------
2315  nCutIndex = 34;
2316  cutVariableValue = normalizedDecayTimeToDStar;
2317  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2318  if(!bPassedCut && !fGetCutInfo) return 0;
2319  //---------------------------------------------------------------------
2320  }
2321 
2322  for (Int_t i = 0; i < 35; ++i)
2323  {
2324  if(bCutArray[i]==kTRUE){
2325  returnvalue = 0;
2326  break;
2327  }
2328  }
2329 
2330  return returnvalue;
2331 }
2332 //---------------------------------------------------------------------------
2334  //
2335  // Apply selection for DStar candidate
2336  //
2337 
2339  cout<<"Cut matrice not inizialized. Exit..."<<endl;
2340  return 0;
2341  }
2342 
2343  AliAODRecoCascadeHF* candidateDStar = (AliAODRecoCascadeHF*)obj;
2344  if(!candidateDStar){
2345  cout<<"candidateDStar null"<<endl;
2346  return 0;
2347  }
2348 
2349  AliAODRecoDecayHF2Prong* candidateD0 = (AliAODRecoDecayHF2Prong*)candidateDStar->Get2Prong();
2350  if(!candidateD0){
2351  cout<<"candidateD0 null"<<endl;
2352  return 0;
2353  }
2354 
2355  AliAODTrack *candidatePion = (AliAODTrack*)candidateDStar->GetDaughter(0);
2356  if(!candidatePion){
2357  cout<<"candidatePion null"<<endl;
2358  return 0;
2359  }
2360 
2361  AliAODVertex * vertexDStar = candidateDStar->GetSecondaryVtx();
2362  if(!vertexDStar){
2363  cout<<"vertexDStar null"<<endl;
2364  return 0;
2365  }
2366 
2367  AliAODVertex * primaryVertex = aod->GetPrimaryVertex();
2368  if(!primaryVertex){
2369  cout<<"primaryVertex null"<<endl;
2370  return 0;
2371  }
2372 
2373  Int_t returnvalue=1;
2374  Bool_t bPassedCut = kFALSE;
2375 
2376  //get the magnetic field
2377  Double_t bz = (Double_t)aod->GetMagneticField();
2378 
2379  // selection on candidate
2380  if(selectionLevel==AliRDHFCuts::kAll ||
2381  selectionLevel==AliRDHFCuts::kCandidate) {
2382 
2383  Int_t ptbin=PtBinDStarforDStarptbin(candidateDStar->Pt());
2384  if(ptbin==-1) return -1;
2385 
2386  // DStarMass and D0mass
2387  Double_t mDSPDG = TDatabasePDG::Instance()->GetParticle(413)->Mass();
2388  Double_t mD0PDG = TDatabasePDG::Instance()->GetParticle(421)->Mass();
2389 
2390  // delta mass PDG
2391  Double_t deltaPDG = mDSPDG-mD0PDG;
2392 
2393  // Half width DStar mass
2394  UInt_t prongs[2];
2395  prongs[0] = 211; prongs[1] = 421;
2396  Double_t invMassDStar = candidateDStar->InvMass(2,prongs);
2397  Double_t invMassDifference = TMath::Abs(mDSPDG - invMassDStar);
2398  Double_t invMassDelta = TMath::Abs(deltaPDG-(DeltaInvMassDStarKpipi(candidateDStar)));
2399 
2400  Double_t pointingAngle = candidateDStar->CosPointingAngle();
2401  Double_t dcaMother = candidateDStar->GetDCA();
2402  Double_t ptMother = candidateDStar->Pt();
2403  Double_t momentumMother = candidateDStar->P();
2404  Double_t ptD0 = candidateD0->Pt();
2405  Double_t ptPion = candidatePion->Pt();
2406 
2407  AliExternalTrackParam motherTrack;
2408  motherTrack.CopyFromVTrack(candidateDStar);
2409  Double_t d0z0[2],covd0z0[3],d0[2];
2410  motherTrack.PropagateToDCA(primaryVertex,bz,100.,d0z0,covd0z0);
2411  d0[0] = d0z0[0];
2412  Double_t d0Mother = TMath::Abs(d0[0]);
2413  Double_t d0firstTrack = TMath::Abs(candidateDStar->Getd0Prong(0));
2414  Double_t d0secondTrack = TMath::Abs(candidateDStar->Getd0Prong(1));
2415 
2416  Double_t impactProduct = candidateDStar->Prodd0d0();
2417  Double_t impactProductXY = TMath::Abs(candidateDStar->ImpParXY());
2418 
2419  Double_t angleBetweenBothDaughters = (candidateD0->Px() * candidatePion->Px() + candidateD0->Py() * candidatePion->Py() + candidateD0->Pz() * candidatePion->Pz()) /(candidateD0->P() * candidatePion->P());
2420  Double_t angleMotherFirstDaughter = (candidateDStar->Px() * candidatePion->Px() + candidateDStar->Py() * candidatePion->Py() + candidateDStar->Pz() * candidatePion->Pz()) /(candidateDStar->P() * candidatePion->P());
2421  Double_t angleMotherSecondDaughter = (candidateDStar->Px() * candidateD0->Px() + candidateDStar->Py() * candidateD0->Py() + candidateDStar->Pz() * candidateD0->Pz()) /(candidateDStar->P() * candidateD0->P());
2422 
2423  Double_t cosThetaStar = candidateDStar->CosThetaStar(0,413,211,421);
2424  Double_t vertexDistance = vertexDStar->DistanceToVertex(primaryVertex);
2425  Double_t normDecayLength = candidateDStar->NormalizedDecayLength();
2426  Double_t pdgMassMother = TDatabasePDG::Instance()->GetParticle(413)->Mass();
2427  Double_t pseudoProperDecayLength = ((vertexDStar->GetX() - primaryVertex->GetX()) * candidateDStar->Px() / TMath::Abs(candidateDStar->Pt())) + ((vertexDStar->GetY() - primaryVertex->GetY()) * candidateDStar->Py() / TMath::Abs(candidateDStar->Pt()));
2428  Double_t pseudoProperDecayTime = pseudoProperDecayLength * pdgMassMother/ptMother;
2429  Double_t decayTime = vertexDistance / (299792458 * TMath::Sqrt(1/((pdgMassMother*pdgMassMother/(momentumMother*momentumMother)) + 1)));
2430 
2431  Double_t phi = candidateDStar->Phi();
2432  Double_t theta = candidateDStar->Theta();
2433  Double_t covMatrix[21];
2434  candidateDStar->GetCovarianceXYZPxPyPz(covMatrix);
2435 
2436  Double_t cp = TMath::Cos(phi);
2437  Double_t sp = TMath::Sin(phi);
2438  Double_t ct = TMath::Cos(theta);
2439  Double_t st = TMath::Sin(theta);
2440 
2441  Double_t errorMomentum = covMatrix[9]*cp*cp*ct*ct // GetCovPxPx
2442  +covMatrix[13]*2.*cp*sp*ct*ct // GetCovPxPy
2443  +covMatrix[18]*2.*cp*ct*st // GetCovPxPz
2444  +covMatrix[14]*sp*sp*ct*ct // GetCovPyPy
2445  +covMatrix[19]*2.*sp*ct*st // GetCovPyPz
2446  +covMatrix[20]*st*st; // GetCovPzPz
2447  Double_t normalizedDecayTime = candidateDStar->NormalizedDecayLength() / (299792458 * TMath::Sqrt(1/((pdgMassMother*pdgMassMother*errorMomentum*errorMomentum/(momentumMother*momentumMother)) + 1)));
2448 
2449  //Topomatic
2450  Double_t dd0pr1=0.;
2451  Double_t dd0pr2=0.;
2452  Double_t dd0max=0.;
2453  Double_t dd0min=0.;
2454  for(Int_t ipr=0; ipr<2; ipr++)
2455  {
2456  Double_t diffIP, errdiffIP;
2457  candidateDStar->Getd0MeasMinusExpProng(ipr,bz,diffIP,errdiffIP);
2458  Double_t normdd0=0.;
2459  if(errdiffIP>0.) normdd0=diffIP/errdiffIP;
2460  if(ipr==0) dd0pr1=normdd0;
2461  if(ipr==1) dd0pr2=normdd0;
2462  }
2463  if(TMath::Abs(dd0pr1)>TMath::Abs(dd0pr2)) {dd0max=dd0pr1; dd0min=dd0pr2;}
2464  else {dd0max=dd0pr2; dd0min=dd0pr1;}
2465 
2466 
2467  // We apply the cuts
2468  Int_t nCutIndex = 0;
2469  Double_t cutVariableValue = 0.0;
2470 
2471  // "inv. mass width [GeV]" --------------------------------------------
2472  nCutIndex = 0;
2473  cutVariableValue = invMassDifference;
2474  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2475  if(!bPassedCut && !fGetCutInfo) return 0;
2476  //---------------------------------------------------------------------
2477 
2478  // "delta mass width [GeV]" -------------------------------------------
2479  nCutIndex = 1;
2480  cutVariableValue = invMassDelta;
2481  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2482  if(!bPassedCut && !fGetCutInfo) return 0;
2483  //---------------------------------------------------------------------
2484 
2485  // "pointing angle [Cos(theta)]" --------------------------------------
2486  nCutIndex = 2;
2487  cutVariableValue = pointingAngle;
2488  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2489  if(!bPassedCut && !fGetCutInfo) return 0;
2490  //---------------------------------------------------------------------
2491 
2492  // "dca [cm]" ---------------------------------------------------------
2493  nCutIndex = 3;
2494  cutVariableValue = dcaMother;
2495  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2496  if(!bPassedCut && !fGetCutInfo) return 0;
2497  //---------------------------------------------------------------------
2498 
2499  // "Pt DStar [GeV/c]" ----------------------------------------------------
2500  nCutIndex = 4;
2501  cutVariableValue = ptMother;
2502  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2503  if(!bPassedCut && !fGetCutInfo) return 0;
2504  //---------------------------------------------------------------------
2505 
2506  // "Pt D0 [GeV/c]" -------------------------------------------------
2507  nCutIndex = 5;
2508  cutVariableValue = ptD0;
2509  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2510  if(!bPassedCut && !fGetCutInfo) return 0;
2511  //---------------------------------------------------------------------
2512 
2513  // "Pt Pion [GeV/c]" --------------------------------------------------
2514  nCutIndex = 6;
2515  cutVariableValue = ptPion;
2516  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2517  if(!bPassedCut && !fGetCutInfo) return 0;
2518  //---------------------------------------------------------------------
2519 
2520  // "d0 DStar [cm]" -------------------------------------------------------
2521  nCutIndex = 7;
2522  cutVariableValue = d0Mother;
2523  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2524  if(!bPassedCut && !fGetCutInfo) return 0;
2525  //---------------------------------------------------------------------
2526 
2527  // "d0 D0 [cm]"-----------------------------------------------------
2528  nCutIndex = 8;
2529  cutVariableValue = d0firstTrack;
2530  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2531  if(!bPassedCut && !fGetCutInfo) return 0;
2532  //---------------------------------------------------------------------
2533 
2534  // "d0 Pion [cm]" -----------------------------------------------------
2535  nCutIndex = 9;
2536  cutVariableValue = d0secondTrack;
2537  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2538  if(!bPassedCut && !fGetCutInfo) return 0;
2539  //---------------------------------------------------------------------
2540 
2541  // "d0d0 [cm^2]" ------------------------------------------------------
2542  nCutIndex = 10;
2543  cutVariableValue = impactProduct;
2544  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2545  if(!bPassedCut && !fGetCutInfo) return 0;
2546  //---------------------------------------------------------------------
2547 
2548  // "d0d0 XY [cm^2]" ---------------------------------------------------
2549  nCutIndex = 11;
2550  cutVariableValue = impactProductXY;
2551  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2552  if(!bPassedCut && !fGetCutInfo) return 0;
2553  //---------------------------------------------------------------------
2554 
2555  // "angle between both daughters" -------------------------------------
2556  nCutIndex = 12;
2557  cutVariableValue = angleBetweenBothDaughters;
2558  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2559  if(!bPassedCut && !fGetCutInfo) return 0;
2560  //---------------------------------------------------------------------
2561 
2562  // "angle mother with first daughter" ---------------------------------
2563  nCutIndex = 13;
2564  cutVariableValue = angleMotherFirstDaughter;
2565  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2566  if(!bPassedCut && !fGetCutInfo) return 0;
2567  //---------------------------------------------------------------------
2568 
2569  // "angle mother with second daughter" --------------------------------
2570  nCutIndex = 14;
2571  cutVariableValue = angleMotherSecondDaughter;
2572  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2573  if(!bPassedCut && !fGetCutInfo) return 0;
2574  //---------------------------------------------------------------------
2575 
2576  // "cosThetaStar" -----------------------------------------------------
2577  nCutIndex = 15;
2578  cutVariableValue = cosThetaStar;
2579  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2580  if(!bPassedCut && !fGetCutInfo) return 0;
2581  //---------------------------------------------------------------------
2582 
2583  // "vertexDistance" ---------------------------------------------------
2584  nCutIndex = 16;
2585  cutVariableValue = vertexDistance;
2586  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2587  if(!bPassedCut && !fGetCutInfo) return 0;
2588  //---------------------------------------------------------------------
2589 
2590  // "pseudoProperDecayTime" --------------------------------------------
2591  nCutIndex = 17;
2592  cutVariableValue = pseudoProperDecayTime;
2593  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2594  if(!bPassedCut && !fGetCutInfo) return 0;
2595  //---------------------------------------------------------------------
2596 
2597  // "DecayTime" --------------------------------------------------------
2598  nCutIndex = 18;
2599  cutVariableValue = decayTime;
2600  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2601  if(!bPassedCut && !fGetCutInfo) return 0;
2602  //---------------------------------------------------------------------
2603 
2604  // "normalizedDecayTime" ----------------------------------------------------
2605  nCutIndex = 19;
2606  cutVariableValue = normalizedDecayTime;
2607  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2608  if(!bPassedCut && !fGetCutInfo) return 0;
2609  //---------------------------------------------------------------------
2610 
2611  // "normDecayLength" --------------------------------------------------
2612  nCutIndex = 20;
2613  cutVariableValue = normDecayLength;
2614  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2615  if(!bPassedCut && !fGetCutInfo) return 0;
2616  //---------------------------------------------------------------------
2617 
2618  // "topomatic first daughter" -----------------------------------------
2619  nCutIndex = 21;
2620  cutVariableValue = dd0pr1;
2621  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2622  if(!bPassedCut && !fGetCutInfo) return 0;
2623  //---------------------------------------------------------------------
2624 
2625  // "topomatic second daughter" ----------------------------------------
2626  nCutIndex = 22;
2627  cutVariableValue = dd0pr2;
2628  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2629  if(!bPassedCut && !fGetCutInfo) return 0;
2630  //---------------------------------------------------------------------
2631 
2632  // "topomatic max" ----------------------------------------------------
2633  nCutIndex = 23;
2634  cutVariableValue = dd0max;
2635  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2636  if(!bPassedCut && !fGetCutInfo) return 0;
2637  //---------------------------------------------------------------------
2638 
2639  // "topomatic min" ----------------------------------------------------
2640  nCutIndex = 24;
2641  cutVariableValue = dd0min;
2642  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2643  if(!bPassedCut && !fGetCutInfo) return 0;
2644  //---------------------------------------------------------------------
2645  }
2646 
2647  for (Int_t i = 0; i < 25; ++i)
2648  {
2649  if(bCutArray[i]==kTRUE){
2650  returnvalue = 0;
2651  break;
2652  }
2653  }
2654 
2655  return returnvalue;
2656 }
2657 //----------------------------------------------------------------------------------
2659 {
2660  //
2661  // D* fiducial acceptance region // not (yet) used for the B0
2662  //
2663 
2664  // if(fMaxRapidityCand>-998.){
2665  // if(TMath::Abs(y) > fMaxRapidityCand) return kFALSE;
2666  // else return kTRUE;
2667  // }
2668 
2669  // if(pt > 5.) {
2670  // // applying cut for pt > 5 GeV
2671  // AliDebug(4,Form("pt of D* = %f (> 5), cutting at |y| < 0.8\n",pt));
2672  // if (TMath::Abs(y) > 0.8){
2673  // return kFALSE;
2674  // }
2675  // } else {
2676  // // appliying smooth cut for pt < 5 GeV
2677  // Double_t maxFiducialY = -0.2/15*pt*pt+1.9/15*pt+0.5;
2678  // Double_t minFiducialY = 0.2/15*pt*pt-1.9/15*pt-0.5;
2679  // AliDebug(2,Form("pt of D* = %f (< 5), cutting according to the fiducial zone [%f, %f]\n",pt,minFiducialY,maxFiducialY));
2680  // if (y < minFiducialY || y > maxFiducialY){
2681  // return kFALSE;
2682  // }
2683  // }
2684 
2685  return kTRUE;
2686 }
2687 //_______________________________________________________________________________-
2689 {
2690  //
2691  // PID method, n sigma approach default // not used for B0, done seperately for each daughter
2692  //
2693 
2694  // AliAODRecoCascadeHF* dstar = (AliAODRecoCascadeHF*)obj;
2695  // if(!dstar){
2696  // cout<<"AliAODRecoCascadeHF null"<<endl;
2697  // return 0;
2698  // }
2699 
2700  // if(!fUsePID || dstar->Pt() > fMaxPtPid) return 3;
2701 
2702  // AliAODRecoDecayHF2Prong* d0 = (AliAODRecoDecayHF2Prong*)dstar->Get2Prong();
2703  // if(!d0){
2704  // cout<<"AliAODRecoDecayHF2Prong null"<<endl;
2705  // return 0;
2706  // }
2707 
2708  // // here the PID
2709  // AliAODTrack *pos = (AliAODTrack*)dstar->Get2Prong()->GetDaughter(0);
2710  // AliAODTrack *neg = (AliAODTrack*)dstar->Get2Prong()->GetDaughter(1);
2711 
2712  // if (dstar->Charge()>0){
2713  // if(!SelectPID(pos,2)) return 0;//pion+
2714  // if(!SelectPID(neg,3)) return 0;//kaon-
2715  // }else{
2716  // if(!SelectPID(pos,3)) return 0;//kaon+
2717  // if(!SelectPID(neg,2)) return 0;//pion-
2718  // }
2719 
2720  // if ((fPidHF->GetMatch() == 10 || fPidHF->GetMatch() == 11) && fPidHF->GetITS()) { //ITS n sigma band
2721  // AliAODTrack *softPion = (AliAODTrack*) dstar->GetBachelor();
2722 
2723  // if (fPidHF->CheckBands(AliPID::kPion, AliPIDResponse::kITS, softPion) == -1) {
2724  // return 0;
2725  // }
2726  // }
2727 
2728  return 3;
2729 }
2730 //_______________________________________________________________________________-
2732 {
2733  //
2734  // here the PID
2735 
2736  Bool_t isParticle=kTRUE;
2737  Int_t match = fPidHF->GetMatch();
2738 
2739  if(match == 1){//n-sigma
2740  Bool_t TPCon=TMath::Abs(2)>1e-4?kTRUE:kFALSE;
2741  Bool_t TOFon=TMath::Abs(3)>1e-4?kTRUE:kFALSE;
2742 
2743  Bool_t isTPC=kTRUE;
2744  Bool_t isTOF=kTRUE;
2745 
2746  if (TPCon){//TPC
2747  if(fPidHF->CheckStatus(track,"TPC")){
2748  if(type==2) isTPC=fPidHF->IsPionRaw(track,"TPC");
2749  if(type==3) isTPC=fPidHF->IsKaonRaw(track,"TPC");
2750  }
2751  }
2752  if (TOFon){//TOF
2753  if(fPidHF->CheckStatus(track,"TOF")){
2754  if(type==2) isTOF=fPidHF->IsPionRaw(track,"TOF");
2755  if(type==3) isTOF=fPidHF->IsKaonRaw(track,"TOF");
2756  }
2757  }
2758 
2759  //--------------------------------
2760  // cut on high momentum in the TPC
2761  //--------------------------------
2762  Double_t pPIDcut = track->P();
2763  if(pPIDcut>fTPCflag) isTPC=1;
2764 
2765  isParticle = isTPC&&isTOF;
2766  }
2767 
2768  if(match == 2){//bayesian
2769  //Double_t priors[5]={0.01,0.001,0.3,0.3,0.3};
2770  Double_t prob[5]={1.,1.,1.,1.,1.};
2771 
2772  //fPidHF->SetPriors(priors,5);
2773  // fPidHF->BayesianProbability(track,prob);
2774 
2775  Double_t max=0.;
2776  Int_t k=-1;
2777  for (Int_t i=0; i<5; i++) {
2778  if (prob[i]>max) {k=i; max=prob[i];}
2779  }
2780  isParticle = Bool_t(k==type);
2781  }
2782 
2783  if (match == 10 || match == 11) { //Assymetric PID using histograms
2784  Int_t checkTPC = fPidHF->CheckBands((AliPID::EParticleType) type, AliPIDResponse::kTPC, track);
2785  Int_t checkTOF = fPidHF->CheckBands((AliPID::EParticleType) type, AliPIDResponse::kTOF, track);
2786 
2787  isParticle = checkTPC >= 0 && checkTOF >= 0 ? kTRUE : kFALSE; //Standard: both at least compatible
2788  if (match == 11) { //Extra requirement: at least one identified
2789  isParticle = isParticle && checkTPC+checkTOF >= 1 ? kTRUE : kFALSE;
2790  }
2791  }
2792 
2793  if (match == 12) { //Circular cut
2794  Double_t nSigmaTOF = 0;
2795  Double_t nSigmaTPC = 0;
2796 
2797  Double_t radius = fCircRadius;
2798 
2799  isParticle = kTRUE;
2800  if (radius > 0) {
2801  Int_t TPCok = fPidHF->GetnSigmaTPC(track, type, nSigmaTPC);
2802  Int_t TOFok = fPidHF->GetnSigmaTOF(track, type, nSigmaTOF);
2803  if (TPCok != -1 && TOFok != -1) {
2804  //Both detectors gave PID information
2805  isParticle = TMath::Sqrt(nSigmaTPC*nSigmaTPC + nSigmaTOF*nSigmaTOF) <= radius ? kTRUE : kFALSE;
2806  }
2807  else {
2808  //Maximum one detector gave PID information
2809  if (TPCok != -1) {
2810  isParticle = nSigmaTPC <= radius ? kTRUE : kFALSE;
2811  }
2812  if (TOFok != -1) {
2813  isParticle = nSigmaTOF <= radius ? kTRUE : kFALSE;
2814  }
2815  }
2816  }
2817  }
2818 
2819  return isParticle;
2820 
2821 }
2822 //-------------------------------------------------------------------------------------
2824 {
2828  Double_t e[3];
2829  e[0]=DStar->Get2Prong()->EProng(0,211);
2830  e[1]=DStar->Get2Prong()->EProng(1,321);
2831  e[2]=DStar->EProng(0,211);
2832 
2833  Double_t esum = e[0]+e[1]+e[2];
2834  Double_t invMassDStar = TMath::Sqrt(esum*esum-DStar->P()*DStar->P());
2835 
2836  Double_t invMassD0 = DStar->Get2Prong()->InvMassD0();
2837 
2838  return invMassDStar - invMassD0;
2839 }
2840 //-------------------------------------------------------------------------------------
2842 {
2846 
2847  AliAODRecoCascadeHF * DStar = (AliAODRecoCascadeHF*)B0->GetDaughter(1);
2848 
2849  Double_t e[4];
2850  e[0]=DStar->EProng(0,211);
2851  e[1]=DStar->Get2Prong()->EProng(0,211);
2852  e[2]=DStar->Get2Prong()->EProng(1,321);
2853  e[3]=B0->EProng(0,211);
2854  // cout << "energy 1: " << e[0] << "energy 2: " << e[1] << "energy 3: " << e[2] << "energy 4: " << e[3] << endl;
2855  Double_t esum = e[0]+e[1]+e[2]+e[3];
2856  Double_t invMassB0 = TMath::Sqrt(esum*esum-B0->P()*B0->P());
2857 
2858  UInt_t prongs[2];
2859  prongs[0] = 211;
2860  prongs[1] = 421;
2861  // Double_t invMassDStar = DStar->InvMass(2,prongs);
2862  Double_t invMassD0 = DStar->Get2Prong()->InvMassD0();
2863 
2864  return invMassB0 - invMassD0;
2865 }
2866 
2867 
2868 //---------------------------------------------------------------------------
2869 //
2870 // DO for D0 pt bin functions
2871 //
2872 //---------------------------------------------------------------------------
2873 
2875  //
2876  // store the cuts
2877  //
2878 
2879  if(nVars!=fnVarsD0forD0ptbin) {
2880  printf("Wrong number of variables: it has to be %d\n",fnVarsD0forD0ptbin);
2881  AliFatal("exiting");
2882  }
2883  if(nPtBins!=fnPtBinsD0forD0ptbin) {
2884  printf("Wrong number of pt bins: it has to be %d\n",fnPtBinsD0forD0ptbin);
2885  AliFatal("exiting");
2886  }
2887 
2889 
2890 
2891  for(Int_t iv=0; iv<fnVarsD0forD0ptbin; iv++)
2892  {
2893  for(Int_t ib=0; ib<fnPtBinsD0forD0ptbin; ib++)
2894  {
2895  //check
2896 
2898  {
2899  cout<<"Overflow, exit..."<<endl;
2900  return;
2901  }
2902 
2903  fCutsRDD0forD0ptbin[GetGlobalIndexD0forD0ptbin(iv,ib)] = cutsRDD0forD0ptbin[iv][ib];
2904 
2905  }
2906  }
2907 
2908  return;
2909 }
2910 //---------------------------------------------------------------------------
2912  //
2913  //give the pt bin where the pt lies.
2914  //
2915  Int_t ptbin=-1;
2916  if(pt<fPtBinLimitsD0forD0ptbin[0])return ptbin;
2917  for (Int_t i=0;i<fnPtBinsD0forD0ptbin;i++){
2918  if(pt<fPtBinLimitsD0forD0ptbin[i+1]) {
2919  ptbin=i;
2920  break;
2921  }
2922  }
2923  return ptbin;
2924 }
2925 //---------------------------------------------------------------------------
2927  // Set the pt bins
2928 
2930  delete [] fPtBinLimitsD0forD0ptbin;
2931  fPtBinLimitsD0forD0ptbin = NULL;
2932  printf("Changing the pt bins\n");
2933  }
2934 
2935  if(nPtBinLimits != fnPtBinsD0forD0ptbin+1){
2936  cout<<"Warning: ptBinLimits dimension "<<nPtBinLimits<<" != nPtBins+1 ("<<fnPtBinsD0forD0ptbin+1<<")\nSetting nPtBins to "<<nPtBinLimits-1<<endl;
2937  SetNPtBinsD0forD0ptbin(nPtBinLimits-1);
2938  }
2939 
2940  fnPtBinLimitsD0forD0ptbin = nPtBinLimits;
2942  //cout<<"Changing also Global Index -> "<<fGlobalIndex<<endl;
2944  for(Int_t ib=0; ib<nPtBinLimits; ib++) fPtBinLimitsD0forD0ptbin[ib]=ptBinLimits[ib];
2945  for(Int_t ib=0; ib<nPtBinLimits; ib++) std::cout << "limit " << ib << " = " << fPtBinLimitsD0forD0ptbin[ib] << std::endl;
2946 
2947  return;
2948 }
2949 
2950 
2951 
2952 //---------------------------------------------------------------------------
2953 //
2954 // DO for DStar pt bin functions
2955 //
2956 //---------------------------------------------------------------------------
2957 
2958 
2960  //
2961  // store the cuts
2962  //
2963  if(nVars!=fnVarsD0forDStarptbin) {
2964  printf("Wrong number of variables: it has to be %d\n",fnVarsD0forDStarptbin);
2965  AliFatal("exiting");
2966  }
2967  if(nPtBins!=fnPtBinsD0forDStarptbin) {
2968  printf("Wrong number of pt bins: it has to be %d\n",fnPtBinsD0forDStarptbin);
2969  AliFatal("exiting");
2970  }
2971 
2973 
2974 
2975  for(Int_t iv=0; iv<fnVarsD0forDStarptbin; iv++)
2976  {
2977  for(Int_t ib=0; ib<fnPtBinsD0forDStarptbin; ib++)
2978  {
2979  //check
2981  {
2982  cout<<"Overflow, exit..."<<endl;
2983  return;
2984  }
2985 
2986  fCutsRDD0forDStarptbin[GetGlobalIndexD0forDStarptbin(iv,ib)] = cutsRDD0forDStarptbin[iv][ib];
2987 
2988  }
2989  }
2990  return;
2991 }
2992 //---------------------------------------------------------------------------
2994  //
2995  //give the pt bin where the pt lies.
2996  //
2997  Int_t ptbin=-1;
2998  if(pt<fPtBinLimitsD0forDStarptbin[0])return ptbin;
2999  for (Int_t i=0;i<fnPtBinsD0forDStarptbin;i++){
3000  if(pt<fPtBinLimitsD0forDStarptbin[i+1]) {
3001  ptbin=i;
3002  break;
3003  }
3004  }
3005  return ptbin;
3006 }
3007 //---------------------------------------------------------------------------
3009  // Set the pt bins
3010 
3012  delete [] fPtBinLimitsD0forDStarptbin;
3014  printf("Changing the pt bins\n");
3015  }
3016 
3017  if(nPtBinLimits != fnPtBinsD0forDStarptbin+1){
3018  cout<<"Warning: ptBinLimits dimension "<<nPtBinLimits<<" != nPtBins+1 ("<<fnPtBinsD0forDStarptbin+1<<")\nSetting nPtBins to "<<nPtBinLimits-1<<endl;
3019  SetNPtBinsD0forDStarptbin(nPtBinLimits-1);
3020  }
3021 
3022  fnPtBinLimitsD0forDStarptbin = nPtBinLimits;
3024  //cout<<"Changing also Global Index -> "<<fGlobalIndex<<endl;
3026  for(Int_t ib=0; ib<nPtBinLimits; ib++) fPtBinLimitsD0forDStarptbin[ib]=ptBinLimits[ib];
3027 
3028  return;
3029 }
3030 
3031 
3032 
3033 
3034 //---------------------------------------------------------------------------
3035 //
3036 // DStar for DStar pt bin functions
3037 //
3038 //---------------------------------------------------------------------------
3039 
3040 
3041 
3043  //
3044  // store the cuts
3045  //
3046  if(nVars!=fnVarsDStarforDStarptbin) {
3047  printf("Wrong number of variables: it has to be %d\n",fnVarsDStarforDStarptbin);
3048  AliFatal("exiting");
3049  }
3050  if(nPtBins!=fnPtBinsDStarforDStarptbin) {
3051  printf("Wrong number of pt bins: it has to be %d\n",fnPtBinsDStarforDStarptbin);
3052  AliFatal("exiting");
3053  }
3054 
3056 
3057 
3058  for(Int_t iv=0; iv<fnVarsDStarforDStarptbin; iv++)
3059  {
3060  for(Int_t ib=0; ib<fnPtBinsDStarforDStarptbin; ib++)
3061  {
3062  //check
3064  {
3065  cout<<"Overflow, exit..."<<endl;
3066  return;
3067  }
3068 
3069  fCutsRDDStarforDStarptbin[GetGlobalIndexDStarforDStarptbin(iv,ib)] = cutsRDDStarforDStarptbin[iv][ib];
3070 
3071  }
3072  }
3073  return;
3074 }
3075 //---------------------------------------------------------------------------
3077  //
3078  //give the pt bin where the pt lies.
3079  //
3080  Int_t ptbin=-1;
3081  if(pt<fPtBinLimitsDStarforDStarptbin[0])return ptbin;
3082  for (Int_t i=0;i<fnPtBinsDStarforDStarptbin;i++){
3083  if(pt<fPtBinLimitsDStarforDStarptbin[i+1]) {
3084  ptbin=i;
3085  break;
3086  }
3087  }
3088  return ptbin;
3089 }
3090 //---------------------------------------------------------------------------
3092  // Set the pt bins and initialize the cut values to 0 and use of cuts to kFALSE
3093 
3097  printf("Changing the pt bins\n");
3098  }
3099 
3100  if(nPtBinLimits != fnPtBinsDStarforDStarptbin+1){
3101  cout<<"Warning: ptBinLimits dimension "<<nPtBinLimits<<" != nPtBins+1 ("<<fnPtBinsDStarforDStarptbin+1<<")\nSetting nPtBins to "<<nPtBinLimits-1<<endl;
3102  SetNPtBinsDStarforDStarptbin(nPtBinLimits-1);
3103  }
3104 
3105  fnPtBinLimitsDStarforDStarptbin = nPtBinLimits;
3107 
3109  for(Int_t ib=0; ib<nPtBinLimits; ib++) fPtBinLimitsDStarforDStarptbin[ib]=ptBinLimits[ib];
3110 
3111  return;
3112 }
3113 //---------------------------------------------------------------------------
3114 Int_t AliRDHFCutsB0toDStarPi::ApplyCutOnVariable(Int_t nCutIndex, Int_t ptbin, Float_t cutVariableValue, Bool_t bCutArray[85]){
3115 
3116  if(GetIsCutUsed(nCutIndex,ptbin)==kTRUE)
3117  {
3118  Bool_t bCut = kFALSE;
3119  if(GetIsUpperCut(nCutIndex)==kTRUE)
3120  {
3121  if(cutVariableValue > fCutsRD[GetGlobalIndex(nCutIndex,ptbin)]) bCut = kTRUE;
3122  } else
3123  {
3124  if(cutVariableValue < fCutsRD[GetGlobalIndex(nCutIndex,ptbin)]) bCut = kTRUE;
3125  }
3126  if(bCut == kTRUE) {bCutArray[nCutIndex] = 1; return 0;}
3127  }
3128  return 1;
3129 }
3130 //---------------------------------------------------------------------------
3131 Int_t AliRDHFCutsB0toDStarPi::ApplyCutOnVariableD0forD0ptbin(Int_t nCutIndex, Int_t ptbin, Float_t cutVariableValue, Bool_t bCutArray[25]){
3132 
3133  // std::cout << "index: " << nCutIndex << ", ptbin: " << ptbin << ", used: " << GetIsCutUsedD0forD0ptbin(nCutIndex,ptbin) << ", upper: " << GetIsUpperCutD0forD0ptbin(nCutIndex) << ", value: " << cutVariableValue << ", cutvalue: " << fCutsRDD0forD0ptbin[GetGlobalIndexD0forD0ptbin(nCutIndex,ptbin)] << std::endl;
3134  if(GetIsCutUsedD0forD0ptbin(nCutIndex,ptbin)==kTRUE)
3135  {
3136  Bool_t bCut = kFALSE;
3137  if(GetIsUpperCutD0forD0ptbin(nCutIndex)==kTRUE)
3138  {
3139  if(cutVariableValue > fCutsRDD0forD0ptbin[GetGlobalIndexD0forD0ptbin(nCutIndex,ptbin)]) bCut = kTRUE;
3140  } else
3141  {
3142  if(cutVariableValue < fCutsRDD0forD0ptbin[GetGlobalIndexD0forD0ptbin(nCutIndex,ptbin)]) bCut = kTRUE;
3143  }
3144  if(bCut == kTRUE) {bCutArray[nCutIndex] = 1; return 0;}
3145  }
3146  return 1;
3147 }
3148 //---------------------------------------------------------------------------
3150 
3151  if(GetIsCutUsedD0forDStarptbin(nCutIndex,ptbin)==kTRUE)
3152  {
3153  Bool_t bCut = kFALSE;
3154  if(GetIsUpperCutD0forDStarptbin(nCutIndex)==kTRUE)
3155  {
3156  if(cutVariableValue > fCutsRDD0forDStarptbin[GetGlobalIndexD0forDStarptbin(nCutIndex,ptbin)]) bCut = kTRUE;
3157  } else
3158  {
3159  if(cutVariableValue < fCutsRDD0forDStarptbin[GetGlobalIndexD0forDStarptbin(nCutIndex,ptbin)]) bCut = kTRUE;
3160  }
3161  if(bCut == kTRUE) {bCutArray[nCutIndex] = 1; return 0;}
3162  }
3163  return 1;
3164 }
3165 //---------------------------------------------------------------------------
3167 
3168  if(GetIsCutUsedDStarforDStarptbin(nCutIndex,ptbin)==kTRUE)
3169  {
3170  Bool_t bCut = kFALSE;
3171  if(GetIsUpperCutDStarforDStarptbin(nCutIndex)==kTRUE)
3172  {
3173  if(cutVariableValue > fCutsRDDStarforDStarptbin[GetGlobalIndexDStarforDStarptbin(nCutIndex,ptbin)]) bCut = kTRUE;
3174  } else
3175  {
3176  if(cutVariableValue < fCutsRDDStarforDStarptbin[GetGlobalIndexDStarforDStarptbin(nCutIndex,ptbin)]) bCut = kTRUE;
3177  }
3178  if(bCut == kTRUE) {bCutArray[nCutIndex] = 1; return 0;}
3179  }
3180  return 1;
3181 }
3182 //---------------------------------------------------------------------------
3184  // Set the variable names
3185 
3186  if(fVarNamesD0forD0ptbin) {
3187  delete [] fVarNamesD0forD0ptbin;
3188  fVarNamesD0forD0ptbin = NULL;
3189  //printf("Changing the variable names\n");
3190  }
3191  if(nVars!=fnVarsD0forD0ptbin){
3192  printf("Wrong number of variables: it has to be %d\n",fnVarsD0forD0ptbin);
3193  return;
3194  }
3195  //fnVars=nVars;
3196  fVarNamesD0forD0ptbin = new TString[nVars];
3197  fIsUpperCutD0forD0ptbin = new Bool_t[nVars];
3198  for(Int_t iv=0; iv<nVars; iv++) {
3199  fVarNamesD0forD0ptbin[iv] = varNames[iv];
3200  fIsUpperCutD0forD0ptbin[iv] = isUpperCut[iv];
3201  }
3202 
3203  return;
3204 }
3205 //---------------------------------------------------------------------------
3207  // Set the variable names
3208 
3210  delete [] fVarNamesD0forDStarptbin;
3211  fVarNamesD0forDStarptbin = NULL;
3212  //printf("Changing the variable names\n");
3213  }
3214  if(nVars!=fnVarsD0forDStarptbin){
3215  printf("Wrong number of variables: it has to be %d\n",fnVarsD0forDStarptbin);
3216  return;
3217  }
3218  //fnVars=nVars;
3219  fVarNamesD0forDStarptbin = new TString[nVars];
3220  fIsUpperCutD0forDStarptbin = new Bool_t[nVars];
3221  for(Int_t iv=0; iv<nVars; iv++) {
3222  fVarNamesD0forDStarptbin[iv] = varNames[iv];
3223  fIsUpperCutD0forDStarptbin[iv] = isUpperCut[iv];
3224  }
3225 
3226  return;
3227 }
3228 //---------------------------------------------------------------------------
3230  // Set the variable names
3231 
3233  delete [] fVarNamesDStarforDStarptbin;
3235  //printf("Changing the variable names\n");
3236  }
3237  if(nVars!=fnVarsDStarforDStarptbin){
3238  printf("Wrong number of variables: it has to be %d\n",fnVarsDStarforDStarptbin);
3239  return;
3240  }
3241  //fnVars=nVars;
3242  fVarNamesDStarforDStarptbin = new TString[nVars];
3244  for(Int_t iv=0; iv<nVars; iv++) {
3245  fVarNamesDStarforDStarptbin[iv] = varNames[iv];
3246  fIsUpperCutDStarforDStarptbin[iv] = isUpperCut[iv];
3247  }
3248 
3249  return;
3250 }
3251 //---------------------------------------------------------------------------
3253  // 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.
3254 
3255  if(fIsCutUsed) {
3256  delete [] fIsCutUsed;
3257  fIsCutUsed = NULL;
3258  }
3259 
3260  fIsCutUsed = new Bool_t[(GetNPtBins())*(GetNVars())];
3261  for(Int_t iv=0; iv<(GetNPtBins())*(GetNVars()); iv++) {
3262  fIsCutUsed[iv] = kFALSE;
3263  }
3264 
3265  if(!fCutsRD) fCutsRD = new Float_t[fGlobalIndex];
3266 
3267 
3268  for(Int_t iv=0; iv<fnVars; iv++) {
3269 
3270  for(Int_t ib=0; ib<fnPtBins; ib++) {
3271 
3272  //check
3273  if(GetGlobalIndex(iv,ib)>=fGlobalIndex) {
3274  cout<<"Overflow, exit..."<<endl;
3275  return;
3276  }
3277 
3278  fCutsRD[GetGlobalIndex(iv,ib)] = 0;
3279 
3280  }
3281  }
3282 
3283  // D0 for D0 pt bin
3284 
3286  delete [] fIsCutUsedD0forD0ptbin;
3287  fIsCutUsedD0forD0ptbin = NULL;
3288  }
3289 
3291  for(Int_t iv=0; iv<(GetNPtBinsD0forD0ptbin())*(GetNVarsD0forD0ptbin()); iv++) {
3292  fIsCutUsedD0forD0ptbin[iv] = kFALSE;
3293 
3294  }
3295 
3297 
3298  for(Int_t iv=0; iv<fnVarsD0forD0ptbin; iv++)
3299  {
3300  for(Int_t ib=0; ib<fnPtBinsD0forD0ptbin; ib++)
3301  {
3302  //check
3303 
3305  {
3306  cout<<"Overflow, exit..."<<endl;
3307  return;
3308  }
3309 
3311  }
3312  }
3313 
3314  // D0 for DStar pt bin
3315 
3317  delete [] fIsCutUsedD0forDStarptbin;
3319  }
3320 
3322  for(Int_t iv=0; iv<(GetNPtBinsD0forDStarptbin())*(GetNVarsD0forDStarptbin()); iv++) {
3323  fIsCutUsedD0forDStarptbin[iv] = kFALSE;
3324  }
3325 
3327 
3328 
3329  for(Int_t iv=0; iv<fnVarsD0forDStarptbin; iv++)
3330  {
3331  for(Int_t ib=0; ib<fnPtBinsD0forDStarptbin; ib++)
3332  {
3333  //check
3335  {
3336  cout<<"Overflow, exit..."<<endl;
3337  return;
3338  }
3339 
3341 
3342  }
3343  }
3344 
3345  // DStar for DStar pt bin
3346 
3348  delete [] fIsCutUsedDStarforDStarptbin;
3350  }
3351 
3353  for(Int_t iv=0; iv<(GetNPtBinsDStarforDStarptbin())*(GetNVarsDStarforDStarptbin()); iv++) {
3354  fIsCutUsedDStarforDStarptbin[iv] = kFALSE;
3355  }
3356 
3358 
3359 
3360  for(Int_t iv=0; iv<fnVarsDStarforDStarptbin; iv++)
3361  {
3362  for(Int_t ib=0; ib<fnPtBinsDStarforDStarptbin; ib++)
3363  {
3364  //check
3366  {
3367  cout<<"Overflow, exit..."<<endl;
3368  return;
3369  }
3370 
3372 
3373  }
3374  }
3375 
3376  return;
3377 }
3378 //---------------------------------------------------------------------------
3380  // Set the cut value and direction
3381 
3382  fIsCutUsed[GetGlobalIndex(nCutIndex,ptBin)] = kTRUE;
3383  fIsUpperCut[nCutIndex] = cutDirection;
3384  fCutsRD[GetGlobalIndex(nCutIndex,ptBin)] = cutValue;
3385 
3386  return;
3387 }
3388 //---------------------------------------------------------------------------
3390  // Set the cut value and direction
3391 
3392  fIsCutUsedD0forD0ptbin[GetGlobalIndexD0forD0ptbin(nCutIndex,ptBin)] = kTRUE;
3393  fIsUpperCutD0forD0ptbin[nCutIndex] = cutDirection;
3394  fCutsRDD0forD0ptbin[GetGlobalIndexD0forD0ptbin(nCutIndex,ptBin)] = cutValue;
3395 
3396  return;
3397 }
3398 //---------------------------------------------------------------------------
3400  // Set the cut value and direction
3401 
3402  fIsCutUsedD0forDStarptbin[GetGlobalIndexD0forDStarptbin(nCutIndex,ptBin)] = kTRUE;
3403  fIsUpperCutD0forDStarptbin[nCutIndex] = cutDirection;
3404  fCutsRDD0forDStarptbin[GetGlobalIndexD0forDStarptbin(nCutIndex,ptBin)] = cutValue;
3405 
3406  return;
3407 }
3408 //---------------------------------------------------------------------------
3410  // Set the cut value and direction
3411 
3413  fIsUpperCutDStarforDStarptbin[nCutIndex] = cutDirection;
3414  fCutsRDDStarforDStarptbin[GetGlobalIndexDStarforDStarptbin(nCutIndex,ptBin)] = cutValue;
3415 
3416  return;
3417 }
3418 //---------------------------------------------------------------------------
Int_t fIsSelectedCuts
fix the daughter track references
Definition: AliRDHFCuts.h:431
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:240
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:409
Bool_t IsKaonRaw(AliAODTrack *track, TString detector) const
Bool_t GetIsCutUsedD0forD0ptbin(Int_t nCutIndex, Int_t ptbin)
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 SetNVars(Int_t nVars)
Definition: AliRDHFCuts.h:383
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
Double_t DeltaInvMassDStarKpipi(AliAODRecoCascadeHF *DStar) 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:251
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:432
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:408
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
Double_t DeltaInvMassB0Kpipipi(AliAODRecoCascadeHF *B0) 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:239
bool Bool_t
Definition: External.C:53
Double_t CosPointingAngle() const
Int_t fnPtBins
cuts on the candidate
Definition: AliRDHFCuts.h:400
Bool_t fGetCutInfo
Radius for circular PID nsigma cut.
AliAODRecoDecayHF2Prong * Get2Prong() const
AliAODPidHF * fPidHF
enable AOD049 centrality cleanup
Definition: AliRDHFCuts.h:412
Int_t fGlobalIndex
Definition: AliRDHFCuts.h:407
Int_t PtBin(Double_t pt) const
Int_t GetGlobalIndex(Int_t iVar, Int_t iPtBin) const
Int_t fnVars
Definition: AliRDHFCuts.h:403