AliPhysics  608b256 (608b256)
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 //
23 // Author Lennart van Doremalen
24 // Utrecht University - l.v.r.vandoremalen@uu.nl
25 //
26 // Several AliPhysics classes have been used as a basis for this code
27 //
28 //
30 
31 #include <TDatabasePDG.h>
32 #include <Riostream.h>
34 #include "AliRDHFCutsD0toKpi.h"
35 #include "AliRDHFCutsB0toDStarPi.h"
36 #include "AliAODTrack.h"
37 #include "AliESDtrack.h"
38 #include "AliAODPid.h"
39 #include "AliTPCPIDResponse.h"
40 #include "AliAODVertex.h"
41 #include "AliESDVertex.h"
42 
43 using std::cout;
44 using std::endl;
45 
47 ClassImp(AliRDHFCutsB0toDStarPi);
49 
50 
51 
52 //--------------------------------------------------------------------------
54  AliRDHFCuts(name),
55  fMaxPtPid(9999.),
56  fTPCflag(999.),
57  fCircRadius(0.),
58  fGetCutInfo(0),
59  fIsCutUsed(0x0),
60  fnVarsD0forD0ptbin(0),
61  fnPtBinsD0forD0ptbin(1),
62  fGlobalIndexD0forD0ptbin(0),
63  fCutsRDD0forD0ptbin(0x0),
64  fnPtBinLimitsD0forD0ptbin(1),
65  fPtBinLimitsD0forD0ptbin(0x0),
66  fIsUpperCutD0forD0ptbin(0x0),
67  fIsCutUsedD0forD0ptbin(0x0),
68  fVarNamesD0forD0ptbin(0x0),
69  fnVarsD0forDStarptbin(0),
70  fnPtBinsD0forDStarptbin(0),
71  fGlobalIndexD0forDStarptbin(0),
72  fCutsRDD0forDStarptbin(0x0),
73  fnPtBinLimitsD0forDStarptbin(1),
74  fPtBinLimitsD0forDStarptbin(0x0),
75  fIsUpperCutD0forDStarptbin(0x0),
76  fIsCutUsedD0forDStarptbin(0x0),
77  fVarNamesD0forDStarptbin(0x0),
78  fnVarsDStarforDStarptbin(0),
79  fnPtBinsDStarforDStarptbin(1),
80  fGlobalIndexDStarforDStarptbin(0),
81  fCutsRDDStarforDStarptbin(0x0),
82  fnPtBinLimitsDStarforDStarptbin(1),
83  fPtBinLimitsDStarforDStarptbin(0x0),
84  fIsUpperCutDStarforDStarptbin(0x0),
85  fIsCutUsedDStarforDStarptbin(0x0),
86  fVarNamesDStarforDStarptbin(0x0),
87  fMinITSNclsD0FirstDaughter(0),
88  fMinTPCNclsD0FirstDaughter(0),
89  fUseITSRefitD0FirstDaughter(0),
90  fUseTPCRefitD0FirstDaughter(0),
91  fUseFilterBitD0FirstDaughter(0),
92  fFilterBitD0FirstDaughter(0),
93  fMinPtD0FirstDaughter(0),
94  fMinITSNclsD0SecondDaughter(0),
95  fMinTPCNclsD0SecondDaughter(0),
96  fUseITSRefitD0SecondDaughter(0),
97  fUseTPCRefitD0SecondDaughter(0),
98  fUseFilterBitD0SecondDaughter(0),
99  fFilterBitD0SecondDaughter(0),
100  fMinPtD0SecondDaughter(0),
101  fMinITSNclsDStarPion(0),
102  fMinTPCNclsDStarPion(0),
103  fUseITSRefitDStarPion(0),
104  fUseTPCRefitDStarPion(0),
105  fUseFilterBitDStarPion(0),
106  fFilterBitDStarPion(0),
107  fMinPtDStarPion(0),
108  fMinITSNclsB0Pion(0),
109  fMinTPCNclsB0Pion(0),
110  fUseITSRefitB0Pion(0),
111  fUseTPCRefitB0Pion(0),
112  fUseFilterBitB0Pion(0),
113  fFilterBitB0Pion(0),
114  fMinPtB0Pion(0),
115  fMaxAbsEtaD0FirstDaughter(999.),
116  fHardSelectionArrayITSD0FirstDaughter(),
117  fSoftSelectionArrayITSD0FirstDaughter(),
118  fNSoftITSCutD0FirstDaughter(0),
119  fMaxAbsEtaD0SecondDaughter(999.),
120  fHardSelectionArrayITSD0SecondDaughter(),
121  fSoftSelectionArrayITSD0SecondDaughter(),
122  fNSoftITSCutD0SecondDaughter(0),
123  fMaxAbsEtaDStarPion(999.),
124  fHardSelectionArrayITSDStarPion(),
125  fSoftSelectionArrayITSDStarPion(),
126  fNSoftITSCutDStarPion(0),
127  fMaxAbsEtaB0Pion(999.),
128  fHardSelectionArrayITSB0Pion(),
129  fSoftSelectionArrayITSB0Pion(),
130  fNSoftITSCutB0Pion(0),
131  fMaxDCADStarPionD0(999.),
132  fMaxDCADStarPionB0Pion(999.),
133  fMaxDCAB0PionD0(999.),
134  fMaxDCACombined(999.),
135  fMind0D0FirstDaughter(0),
136  fMind0D0SecondDaughter(0),
137  fMind0DStarPion(0),
138  fMind0B0Pion(0),
139  fMaxPtDStarPion(999.)
140 {
141  //
142  // Default Constructor
143  //
144 
145  // Main cut setup as function of B0 pt bins
146  const Int_t nvars=97;
147  SetNVars(nvars);
148 
149  TString varNames[nvars];
150  Int_t iterator = 0;
151 
152  //D0 cut variables
153  varNames[iterator++]= /*-00-*/ "inv. mass width[GeV]";
154  varNames[iterator++]= /*-01-*/ "delta mass width [GeV]"; //not used for D0
155  varNames[iterator++]= /*-02-*/ "pointing angle [Cos(theta)]";
156  varNames[iterator++]= /*-03-*/ "dca [cm]";
157  varNames[iterator++]= /*-04-*/ "Pt D0 [GeV/c]";
158  varNames[iterator++]= /*-05-*/ "Pt first daughter [GeV/c]";
159  varNames[iterator++]= /*-06-*/ "Pt second daughter [GeV/c]";
160  varNames[iterator++]= /*-07-*/ "d0 D0 [cm]";
161  varNames[iterator++]= /*-08-*/ "d0 first daughter [cm]";
162  varNames[iterator++]= /*-09-*/ "d0 second daughter [cm]";
163  varNames[iterator++]= /*-10-*/ "d0d0 [cm^2]";
164  varNames[iterator++]= /*-11-*/ "d0d0 XY [cm^2]";
165 
166  varNames[iterator++]= /*-12-*/ "angle between both daughters";
167  varNames[iterator++]= /*-13-*/ "angle mother with first daughter";
168  varNames[iterator++]= /*-14-*/ "angle mother with second daughter";
169  varNames[iterator++]= /*-15-*/ "cosThetaStar";
170  varNames[iterator++]= /*-16-*/ "vertexDistance";
171  varNames[iterator++]= /*-17-*/ "pseudoProperDecayTime";
172  varNames[iterator++]= /*-18-*/ "DecayTime";
173  varNames[iterator++]= /*-19-*/ "normalizedDecayTime";
174  varNames[iterator++]= /*-20-*/ "normDecayLength";
175  varNames[iterator++]= /*-21-*/ "topomatic first daughter";
176  varNames[iterator++]= /*-22-*/ "topomatic second daughter";
177  varNames[iterator++]= /*-23-*/ "topomatic max";
178  varNames[iterator++]= /*-24-*/ "topomatic min";
179 
180  varNames[iterator++]= /*-25-*/ "pointing angle XY [Cos(theta)]";
181  varNames[iterator++]= /*-26-*/ "vertex distance XY [cm]";
182  varNames[iterator++]= /*-27-*/ "normDecayLength XY";
183  varNames[iterator++]= /*-28-*/ "Chi2 per NDF vertex";
184 
185  varNames[iterator++]= /*-29-*/ "pointingAngleToDStar";
186  varNames[iterator++]= /*-30-*/ "d0MotherToDStar";
187  varNames[iterator++]= /*-31-*/ "d0FirstDaughterToDStar";
188  varNames[iterator++]= /*-32-*/ "d0SecondDaughterToDStar";
189  varNames[iterator++]= /*-33-*/ "impactProductToDStar";
190  varNames[iterator++]= /*-34-*/ "impactProductXYToDStar";
191  varNames[iterator++]= /*-35-*/ "normDecayLengthToDStar";
192  varNames[iterator++]= /*-36-*/ "pseudoProperDecayTimeToDStar";
193  varNames[iterator++]= /*-37-*/ "DecayTimeToDStar";
194  varNames[iterator++]= /*-38-*/ "normalizedDecayTimeToDStar";
195 
196 
197  //DStar cut variables
198  varNames[iterator++]= /*-39-*/ "inv. mass width[GeV]";
199  varNames[iterator++]= /*-40-*/ "delta mass width [GeV]";
200  varNames[iterator++]= /*-41-*/ "pointing angle [Cos(theta)]";
201  varNames[iterator++]= /*-42-*/ "dca [cm]";
202  varNames[iterator++]= /*-43-*/ "Pt DStar [GeV/c]";
203  varNames[iterator++]= /*-44-*/ "Pt D0 [GeV/c]";
204  varNames[iterator++]= /*-45-*/ "Pt Pion [GeV/c]";
205  varNames[iterator++]= /*-46-*/ "d0 DStar [cm]";
206  varNames[iterator++]= /*-47-*/ "d0 D0 [cm]";
207  varNames[iterator++]= /*-48-*/ "d0 Pion [cm]";
208  varNames[iterator++]= /*-49-*/ "d0d0 [cm^2]";
209  varNames[iterator++]= /*-50-*/ "d0d0 XY [cm^2]";
210 
211  varNames[iterator++]= /*-51-*/ "angle between both daughters";
212  varNames[iterator++]= /*-52-*/ "angle mother with first daughter";
213  varNames[iterator++]= /*-53-*/ "angle mother with second daughter";
214  varNames[iterator++]= /*-54-*/ "cosThetaStar";
215  varNames[iterator++]= /*-55-*/ "vertexDistance";
216  varNames[iterator++]= /*-56-*/ "pseudoProperDecayTime";
217  varNames[iterator++]= /*-57-*/ "DecayTime";
218  varNames[iterator++]= /*-58-*/ "normalizedDecayTime";
219  varNames[iterator++]= /*-59-*/ "normDecayLength";
220  varNames[iterator++]= /*-60-*/ "topomatic first daughter";
221  varNames[iterator++]= /*-61-*/ "topomatic second daughter";
222  varNames[iterator++]= /*-62-*/ "topomatic max";
223  varNames[iterator++]= /*-63-*/ "topomatic min";
224 
225  varNames[iterator++]= /*-64-*/ "pointing angle XY [Cos(theta)]";
226  varNames[iterator++]= /*-65-*/ "vertex distance XY [cm]";
227  varNames[iterator++]= /*-66-*/ "normDecayLength XY";
228  varNames[iterator++]= /*-67-*/ "Chi2 per NDF vertex";
229 
230 
231  //B0 cut variables
232  varNames[iterator++]= /*-68-*/ "inv. mass width[GeV]";
233  varNames[iterator++]= /*-69-*/ "delta mass width [GeV]";
234  varNames[iterator++]= /*-70-*/ "pointing angle [Cos(theta)]";
235  varNames[iterator++]= /*-71-*/ "dca [cm]";
236  varNames[iterator++]= /*-72-*/ "Pt B0 [GeV/c]";
237  varNames[iterator++]= /*-73-*/ "Pt DStar [GeV/c]";
238  varNames[iterator++]= /*-74-*/ "Pt Pion [GeV/c]";
239  varNames[iterator++]= /*-75-*/ "d0 B0 [cm]";
240  varNames[iterator++]= /*-76-*/ "d0 DStar [cm]";
241  varNames[iterator++]= /*-77-*/ "d0 Pion [cm]";
242  varNames[iterator++]= /*-78-*/ "d0d0 [cm^2]";
243  varNames[iterator++]= /*-79-*/ "d0d0 XY [cm^2]";
244 
245  varNames[iterator++]= /*-80-*/ "angle between both daughters";
246  varNames[iterator++]= /*-81-*/ "angle mother with first daughter";
247  varNames[iterator++]= /*-82-*/ "angle mother with second daughter";
248  varNames[iterator++]= /*-83-*/ "cosThetaStar";
249  varNames[iterator++]= /*-84-*/ "vertexDistance";
250  varNames[iterator++]= /*-85-*/ "pseudoProperDecayTime";
251  varNames[iterator++]= /*-86-*/ "DecayTime";
252  varNames[iterator++]= /*-87-*/ "normalizedDecayTime";
253  varNames[iterator++]= /*-88-*/ "normDecayLength";
254  varNames[iterator++]= /*-89-*/ "topomatic first daughter";
255  varNames[iterator++]= /*-90-*/ "topomatic second daughter";
256  varNames[iterator++]= /*-91-*/ "topomatic max";
257  varNames[iterator++]= /*-92-*/ "topomatic min";
258 
259  varNames[iterator++]= /*-93-*/ "pointing angle XY [Cos(theta)]";
260  varNames[iterator++]= /*-94-*/ "vertex distance XY [cm]";
261  varNames[iterator++]= /*-95-*/ "normDecayLength XY";
262  varNames[iterator++]= /*-96-*/ "Chi2 per NDF vertex";
263 
264  Bool_t isUpperCut[nvars]={0};
265 
266  SetVarNames(nvars,varNames,isUpperCut);
267 
268  Float_t limits[2]={0,999999999.};
269  SetPtBins(2,limits);
270 
271 
272  //
273  // Initialization of D0 cuts for D0 pt bins
274  //
275 
276  const Int_t nvarsD0forD0ptbin=29;
277  SetNVarsD0forD0ptbin(nvarsD0forD0ptbin);
278 
279  TString varNamesD0forD0ptbin[nvarsD0forD0ptbin];
280  iterator = 0;
281 
282  //D0 cut variables
283  varNamesD0forD0ptbin[iterator++]= /*-00-*/ "inv. mass width[GeV]";
284  varNamesD0forD0ptbin[iterator++]= /*-01-*/ "delta mass width [GeV]"; //not used for D0
285  varNamesD0forD0ptbin[iterator++]= /*-02-*/ "pointing angle [Cos(theta)]";
286  varNamesD0forD0ptbin[iterator++]= /*-03-*/ "dca [cm]";
287  varNamesD0forD0ptbin[iterator++]= /*-04-*/ "Pt D0 [GeV/c]";
288  varNamesD0forD0ptbin[iterator++]= /*-05-*/ "Pt first daughter [GeV/c]";
289  varNamesD0forD0ptbin[iterator++]= /*-06-*/ "Pt second daughter [GeV/c]";
290  varNamesD0forD0ptbin[iterator++]= /*-07-*/ "d0 D0 [cm]";
291  varNamesD0forD0ptbin[iterator++]= /*-08-*/ "d0 first daughter [cm]";
292  varNamesD0forD0ptbin[iterator++]= /*-09-*/ "d0 second daughter [cm]";
293  varNamesD0forD0ptbin[iterator++]= /*-10-*/ "d0d0 [cm^2]";
294  varNamesD0forD0ptbin[iterator++]= /*-11-*/ "d0d0 XY [cm^2]";
295 
296  varNamesD0forD0ptbin[iterator++]= /*-12-*/ "angle between both daughters";
297  varNamesD0forD0ptbin[iterator++]= /*-13-*/ "angle mother with first daughter";
298  varNamesD0forD0ptbin[iterator++]= /*-14-*/ "angle mother with second daughter";
299  varNamesD0forD0ptbin[iterator++]= /*-15-*/ "cosThetaStar";
300  varNamesD0forD0ptbin[iterator++]= /*-16-*/ "vertexDistance";
301  varNamesD0forD0ptbin[iterator++]= /*-17-*/ "pseudoProperDecayTime";
302  varNamesD0forD0ptbin[iterator++]= /*-18-*/ "DecayTime";
303  varNamesD0forD0ptbin[iterator++]= /*-19-*/ "normalizedDecayTime";
304  varNamesD0forD0ptbin[iterator++]= /*-20-*/ "normDecayLength";
305  varNamesD0forD0ptbin[iterator++]= /*-21-*/ "topomatic first daughter";
306  varNamesD0forD0ptbin[iterator++]= /*-22-*/ "topomatic second daughter";
307  varNamesD0forD0ptbin[iterator++]= /*-23-*/ "topomatic max";
308  varNamesD0forD0ptbin[iterator++]= /*-24-*/ "topomatic min";
309 
310  varNamesD0forD0ptbin[iterator++]= /*-25-*/ "pointing angle XY [Cos(theta)]";
311  varNamesD0forD0ptbin[iterator++]= /*-26-*/ "vertex distance XY [cm]";
312  varNamesD0forD0ptbin[iterator++]= /*-27-*/ "normDecayLength XY";
313  varNamesD0forD0ptbin[iterator++]= /*-28-*/ "Chi2 per NDF vertex";
314 
315  Bool_t isUpperCutD0forD0ptbin[nvarsD0forD0ptbin]={0};
316 
317  SetVarNamesD0forD0ptbin(nvarsD0forD0ptbin,varNamesD0forD0ptbin,isUpperCutD0forD0ptbin);
318 
319  Float_t limitsD0forD0ptbin[2]={0,999999999.};
320  SetPtBinsD0forD0ptbin(2,limitsD0forD0ptbin);
321 
322 
323  //
324  // Initialization of D0 cuts for DStar pt bins
325  //
326 
327  const Int_t nvarsD0forDStarptbin=39;
328  SetNVarsD0forDStarptbin(nvarsD0forDStarptbin);
329 
330  TString varNamesD0forDStarptbin[nvarsD0forDStarptbin];
331  iterator = 0;
332 
333  //D0 cut variables
334  varNamesD0forDStarptbin[iterator++]= /*-00-*/ "inv. mass width[GeV]";
335  varNamesD0forDStarptbin[iterator++]= /*-01-*/ "delta mass width [GeV]"; //not used for D0
336  varNamesD0forDStarptbin[iterator++]= /*-02-*/ "pointing angle [Cos(theta)]";
337  varNamesD0forDStarptbin[iterator++]= /*-03-*/ "dca [cm]";
338  varNamesD0forDStarptbin[iterator++]= /*-04-*/ "Pt D0 [GeV/c]";
339  varNamesD0forDStarptbin[iterator++]= /*-05-*/ "Pt first daughter [GeV/c]";
340  varNamesD0forDStarptbin[iterator++]= /*-06-*/ "Pt second daughter [GeV/c]";
341  varNamesD0forDStarptbin[iterator++]= /*-07-*/ "d0 D0 [cm]";
342  varNamesD0forDStarptbin[iterator++]= /*-08-*/ "d0 first daughter [cm]";
343  varNamesD0forDStarptbin[iterator++]= /*-09-*/ "d0 second daughter [cm]";
344  varNamesD0forDStarptbin[iterator++]= /*-10-*/ "d0d0 [cm^2]";
345  varNamesD0forDStarptbin[iterator++]= /*-11-*/ "d0d0 XY [cm^2]";
346 
347  varNamesD0forDStarptbin[iterator++]= /*-12-*/ "angle between both daughters";
348  varNamesD0forDStarptbin[iterator++]= /*-13-*/ "angle mother with first daughter";
349  varNamesD0forDStarptbin[iterator++]= /*-14-*/ "angle mother with second daughter";
350  varNamesD0forDStarptbin[iterator++]= /*-15-*/ "cosThetaStar";
351  varNamesD0forDStarptbin[iterator++]= /*-16-*/ "vertexDistance";
352  varNamesD0forDStarptbin[iterator++]= /*-17-*/ "pseudoProperDecayTime";
353  varNamesD0forDStarptbin[iterator++]= /*-18-*/ "DecayTime";
354  varNamesD0forDStarptbin[iterator++]= /*-19-*/ "normalizedDecayTime";
355  varNamesD0forDStarptbin[iterator++]= /*-20-*/ "normDecayLength";
356  varNamesD0forDStarptbin[iterator++]= /*-21-*/ "topomatic first daughter";
357  varNamesD0forDStarptbin[iterator++]= /*-22-*/ "topomatic second daughter";
358  varNamesD0forDStarptbin[iterator++]= /*-23-*/ "topomatic max";
359  varNamesD0forDStarptbin[iterator++]= /*-24-*/ "topomatic min";
360 
361  varNamesD0forDStarptbin[iterator++]= /*-25-*/ "pointingAngleToDStar";
362  varNamesD0forDStarptbin[iterator++]= /*-26-*/ "d0MotherToDStar";
363  varNamesD0forDStarptbin[iterator++]= /*-27-*/ "d0FirstDaughterToDStar";
364  varNamesD0forDStarptbin[iterator++]= /*-28-*/ "d0SecondDaughterToDStar";
365  varNamesD0forDStarptbin[iterator++]= /*-29-*/ "impactProductToDStar";
366  varNamesD0forDStarptbin[iterator++]= /*-30-*/ "impactProductXYToDStar";
367  varNamesD0forDStarptbin[iterator++]= /*-31-*/ "normDecayLengthToDStar";
368  varNamesD0forDStarptbin[iterator++]= /*-32-*/ "pseudoProperDecayTimeToDStar";
369  varNamesD0forDStarptbin[iterator++]= /*-33-*/ "DecayTimeToDStar";
370  varNamesD0forDStarptbin[iterator++]= /*-34-*/ "normalizedDecayTimeToDStar";
371 
372  varNamesD0forDStarptbin[iterator++]= /*-35-*/ "pointing angle XY [Cos(theta)]";
373  varNamesD0forDStarptbin[iterator++]= /*-36-*/ "vertex distance XY [cm]";
374  varNamesD0forDStarptbin[iterator++]= /*-37-*/ "normDecayLength XY";
375  varNamesD0forDStarptbin[iterator++]= /*-38-*/ "Chi2 per NDF vertex";
376 
377  Bool_t isUpperCutD0forDStarptbin[nvarsD0forDStarptbin]={0};
378 
379  SetVarNamesD0forDStarptbin(nvarsD0forDStarptbin,varNamesD0forDStarptbin,isUpperCutD0forDStarptbin);
380 
381  Float_t limitsD0forDStarptbin[2]={0,999999999.};
382  SetPtBinsD0forDStarptbin(2,limitsD0forDStarptbin);
383 
384 
385  //
386  // Initialization of DStar cuts for DStar pt bins
387  //
388 
389  const Int_t nvarsDStarforDStarptbin=29;
390  SetNVarsDStarforDStarptbin(nvarsDStarforDStarptbin);
391 
392  TString varNamesDStarforDStarptbin[nvarsDStarforDStarptbin];
393  iterator = 0;
394 
395  //DStar cut variables
396  varNamesDStarforDStarptbin[iterator++]= /*-00-*/ "inv. mass width[GeV]";
397  varNamesDStarforDStarptbin[iterator++]= /*-01-*/ "delta mass width [GeV]";
398  varNamesDStarforDStarptbin[iterator++]= /*-02-*/ "pointing angle [Cos(theta)]";
399  varNamesDStarforDStarptbin[iterator++]= /*-03-*/ "dca [cm]";
400  varNamesDStarforDStarptbin[iterator++]= /*-04-*/ "Pt DStar [GeV/c]";
401  varNamesDStarforDStarptbin[iterator++]= /*-05-*/ "Pt D0 [GeV/c]";
402  varNamesDStarforDStarptbin[iterator++]= /*-06-*/ "Pt Pion [GeV/c]";
403  varNamesDStarforDStarptbin[iterator++]= /*-07-*/ "d0 DStar [cm]";
404  varNamesDStarforDStarptbin[iterator++]= /*-08-*/ "d0 D0 [cm]";
405  varNamesDStarforDStarptbin[iterator++]= /*-09-*/ "d0 Pion [cm]";
406  varNamesDStarforDStarptbin[iterator++]= /*-10-*/ "d0d0 [cm^2]";
407  varNamesDStarforDStarptbin[iterator++]= /*-11-*/ "d0d0 XY [cm^2]";
408 
409  varNamesDStarforDStarptbin[iterator++]= /*-12-*/ "angle between both daughters";
410  varNamesDStarforDStarptbin[iterator++]= /*-13-*/ "angle mother with first daughter";
411  varNamesDStarforDStarptbin[iterator++]= /*-14-*/ "angle mother with second daughter";
412  varNamesDStarforDStarptbin[iterator++]= /*-15-*/ "cosThetaStar";
413  varNamesDStarforDStarptbin[iterator++]= /*-16-*/ "vertexDistance";
414  varNamesDStarforDStarptbin[iterator++]= /*-17-*/ "pseudoProperDecayTime";
415  varNamesDStarforDStarptbin[iterator++]= /*-18-*/ "DecayTime";
416  varNamesDStarforDStarptbin[iterator++]= /*-19-*/ "normalizedDecayTime";
417  varNamesDStarforDStarptbin[iterator++]= /*-20-*/ "normDecayLength";
418  varNamesDStarforDStarptbin[iterator++]= /*-21-*/ "topomatic first daughter";
419  varNamesDStarforDStarptbin[iterator++]= /*-22-*/ "topomatic second daughter";
420  varNamesDStarforDStarptbin[iterator++]= /*-23-*/ "topomatic max";
421  varNamesDStarforDStarptbin[iterator++]= /*-24-*/ "topomatic min";
422 
423  varNamesDStarforDStarptbin[iterator++]= /*-25-*/ "pointing angle XY [Cos(theta)]";
424  varNamesDStarforDStarptbin[iterator++]= /*-26-*/ "vertex distance XY [cm]";
425  varNamesDStarforDStarptbin[iterator++]= /*-27-*/ "normDecayLength XY";
426  varNamesDStarforDStarptbin[iterator++]= /*-28-*/ "Chi2 per NDF vertex";
427 
428  Bool_t isUpperCutDStarforDStarptbin[nvarsDStarforDStarptbin]={0};
429 
430  SetVarNamesDStarforDStarptbin(nvarsDStarforDStarptbin,varNamesDStarforDStarptbin,isUpperCutDStarforDStarptbin);
431 
432  Float_t limitsDStarforDStarptbin[2]={0,999999999.};
433  SetPtBinsDStarforDStarptbin(2,limitsDStarforDStarptbin);
434 
435  Bool_t forOpt[16]={0}; //not yet used for B0 analysis
436  SetVarsForOpt(16,forOpt);
437 
438 }
439 //--------------------------------------------------------------------------
441  AliRDHFCuts(source),
442  fMaxPtPid(source.fMaxPtPid),
443  fTPCflag(source.fTPCflag),
444  fCircRadius(source.fCircRadius),
445  fGetCutInfo(source.fGetCutInfo),
446  fIsCutUsed(0x0),
450  fCutsRDD0forD0ptbin(0x0),
501  fMinPtB0Pion(source.fMinPtB0Pion),
525  fMind0B0Pion(source.fMind0B0Pion),
527 {
528  //
529  // Copy constructor
530  //
531 
538  if(source.fIsCutUsed)
539  {
540  if(fIsCutUsed) {
541  delete [] fIsCutUsed;
542  fIsCutUsed = NULL;
543  }
544  fIsCutUsed = new Bool_t[(source.GetNPtBins())*(source.GetNVars())];
545 
546  for (Int_t i = 0; i < source.fnVars; ++i)
547  {
548  for(Int_t j = 0; j < source.fnPtBins; j++)
549  {
550  Bool_t bUse = source.GetIsCutUsed(i,j);
551  SetIsCutUsed(i,j,bUse);
552  }
553  }
554  }
555  if(source.fIsCutUsedD0forD0ptbin)
556  {
558  delete [] fIsCutUsedD0forD0ptbin;
559  fIsCutUsedD0forD0ptbin = NULL;
560  }
562  for (Int_t i = 0; i < source.fnVarsD0forD0ptbin; ++i)
563  {
564  for(Int_t j = 0; j < source.fnPtBinsD0forD0ptbin; j++)
565  {
566  Bool_t bUse = source.GetIsCutUsedD0forD0ptbin(i,j);
567  SetIsCutUsedD0forD0ptbin(i,j,bUse);
568  }
569  }
570  }
571  if(source.fIsCutUsedD0forDStarptbin)
572  {
574  delete [] fIsCutUsedD0forDStarptbin;
576  }
578  for (Int_t i = 0; i < source.fnVarsD0forDStarptbin; ++i)
579  {
580  for(Int_t j = 0; j < source.fnPtBinsD0forDStarptbin; j++)
581  {
582  Bool_t bUse = source.GetIsCutUsedD0forDStarptbin(i,j);
583  SetIsCutUsedD0forDStarptbin(i,j,bUse);
584  }
585  }
586  }
587  if(source.fIsCutUsedDStarforDStarptbin)
588  {
592  }
594  for (Int_t i = 0; i < source.fnVarsDStarforDStarptbin; ++i)
595  {
596  for(Int_t j = 0; j < source.fnPtBinsDStarforDStarptbin; j++)
597  {
598  Bool_t bUse = source.GetIsCutUsedDStarforDStarptbin(i,j);
600  }
601  }
602  }
606 
615 }
616 //--------------------------------------------------------------------------
618  //
619  // Default Destructor
620  //
621  if(fIsCutUsed) { delete [] fIsCutUsed; fIsCutUsed=0; }
637 }
638 //--------------------------------------------------------------------------
640 {
641  //
642  // assignment operator
643  //
644 
645  cout << "Assignment start" << endl;
646 
647  if(&source == this) return *this;
648 
649  cout << "Assignment 1" << endl;
650 
651  AliRDHFCuts::operator=(source);
652 
653  cout << "Assignment 2" << endl;
654 
655  fMaxPtPid = source.fMaxPtPid;
656  fTPCflag = source.fTPCflag;
657  fCircRadius = source.fCircRadius;
658  fGetCutInfo = source.fGetCutInfo;
698  fMinPtB0Pion = source.fMinPtB0Pion;
714  fMind0B0Pion = source.fMind0B0Pion;
716 
717  cout << "Assignment 3" << endl;
718 
725  if(source.fIsCutUsed)
726  {
727  if(fIsCutUsed) {
728  delete [] fIsCutUsed;
729  fIsCutUsed = NULL;
730  }
731  fIsCutUsed = new Bool_t[(source.GetNPtBins())*(source.GetNVars())];
732 
733  for (Int_t i = 0; i < source.fnVars; ++i)
734  {
735  for(Int_t j = 0; j < source.fnPtBins; j++)
736  {
737  Bool_t bUse = source.GetIsCutUsed(i,j);
738  SetIsCutUsed(i,j,bUse);
739  }
740  }
741  }
742  if(source.fIsCutUsedD0forD0ptbin)
743  {
745  delete [] fIsCutUsedD0forD0ptbin;
746  fIsCutUsedD0forD0ptbin = NULL;
747  }
749  for (Int_t i = 0; i < source.fnVarsD0forD0ptbin; ++i)
750  {
751  for(Int_t j = 0; j < source.fnPtBinsD0forD0ptbin; j++)
752  {
753  Bool_t bUse = source.GetIsCutUsedD0forD0ptbin(i,j);
754  SetIsCutUsedD0forD0ptbin(i,j,bUse);
755  }
756  }
757  }
758  if(source.fIsCutUsedD0forDStarptbin)
759  {
761  delete [] fIsCutUsedD0forDStarptbin;
763  }
765  for (Int_t i = 0; i < source.fnVarsD0forDStarptbin; ++i)
766  {
767  for(Int_t j = 0; j < source.fnPtBinsD0forDStarptbin; j++)
768  {
769  Bool_t bUse = source.GetIsCutUsedD0forDStarptbin(i,j);
770  SetIsCutUsedD0forDStarptbin(i,j,bUse);
771  }
772  }
773  }
774  if(source.fIsCutUsedDStarforDStarptbin)
775  {
779  }
781  for (Int_t i = 0; i < source.fnVarsDStarforDStarptbin; ++i)
782  {
783  for(Int_t j = 0; j < source.fnPtBinsDStarforDStarptbin; j++)
784  {
785  Bool_t bUse = source.GetIsCutUsedDStarforDStarptbin(i,j);
787  }
788  }
789  }
793 
802 
803  cout << "Assignment 4" << endl;
804  return *this;
805 }
806 //--------------------------------------------------------------------------
808  // not yet used
809 
810  return;
811 }
812 //--------------------------------------------------------------------------
813 Int_t AliRDHFCutsB0toDStarPi::IsSelected(TObject* obj,Int_t selectionLevel, AliAODEvent* aod, Bool_t bCutArray[97]) {
814  //
815  // In this function we apply the selection cuts on the B0 candidate and its daughters.
816  // The function returns 0 if the candidate is cut and is able to return information on which cuts the candidate passes.
817  //
818 
819  fIsSelectedCuts=0;
820  fIsSelectedPID=0;
821 
822  // The cuts used in this class have to be set in the maketfile.
823  if(!fCutsRD){
824  cout<<"Cut matrice not inizialized. Exit..."<<endl;
825  return 0;
826  }
827 
829  if(!candidateB0){
830  cout<<"candidateB0 null"<<endl;
831  return 0;
832  }
833 
834  AliAODRecoDecayHF2Prong* candidateDStar = (AliAODRecoDecayHF2Prong*)candidateB0->GetDaughter(1);
835  if(!candidateDStar){
836  cout<<"candidateDStar null"<<endl;
837  return 0;
838  }
839 
840  AliAODTrack *candidatePion = (AliAODTrack*)candidateB0->GetDaughter(0);
841  if(!candidatePion){
842  cout<<"candidatePion null"<<endl;
843  return 0;
844  }
845 
846  AliAODVertex * vertexB0 = candidateB0->GetSecondaryVtx();
847  if(!vertexB0){
848  cout<<"vertexB0 null"<<endl;
849  return 0;
850  }
851 
852  AliAODVertex * primaryVertex = aod->GetPrimaryVertex();
853  if(!primaryVertex){
854  cout<<"primaryVertex null"<<endl;
855  return 0;
856  }
857 
858  Int_t returnvalue=1;
859  Bool_t bPassedCut = kFALSE;
860 
861  //get the magnetic field
862  Double_t bz = (Double_t)aod->GetMagneticField();
863 
864  // selection on candidate
865  if(selectionLevel==AliRDHFCuts::kAll ||
866  selectionLevel==AliRDHFCuts::kCandidate) {
867 
868  // We check to which pt bin the candidate belongs
869  Int_t ptbin = PtBin(candidateB0->Pt());
870  if(ptbin==-1) return -1;
871 
872  // We obtain the variable values in the section below
873  // D0Mass and B0mass
874  Double_t mD0PDG = TDatabasePDG::Instance()->GetParticle(421)->Mass();
875  Double_t mB0PDG = TDatabasePDG::Instance()->GetParticle(511)->Mass();
876 
877  // delta mass PDG
878  Double_t deltaPDG = mB0PDG - mD0PDG;
879 
880  // Half width B0 mass
881  UInt_t prongs[2];
882  prongs[0] = 211; prongs[1] = 413;
883  Double_t invMassB0 = candidateB0->InvMass(2,prongs);
884  Double_t invMassDifference = TMath::Abs(mB0PDG - invMassB0);
885  Double_t invMassDelta = TMath::Abs(deltaPDG-(DeltaInvMassB0Kpipipi(candidateB0)));
886 
887  Double_t pointingAngle = candidateB0->CosPointingAngle();
888  Double_t dcaMother = candidateB0->GetDCA();
889  Double_t ptMother = candidateB0->Pt();
890  Double_t momentumMother = candidateB0->P();
891  Double_t ptDStar = candidateDStar->Pt();
892  Double_t ptPion = candidatePion->Pt();
893 
894  AliExternalTrackParam motherTrack;
895  motherTrack.CopyFromVTrack(candidateB0);
896  Double_t d0z0[2],covd0z0[3],d0[2];
897  motherTrack.PropagateToDCA(primaryVertex,bz,100.,d0z0,covd0z0);
898  d0[0] = d0z0[0];
899  Double_t d0Mother = TMath::Abs(d0[0]);
900  Double_t d0firstTrack = TMath::Abs(candidateB0->Getd0Prong(0));
901  Double_t d0secondTrack = TMath::Abs(candidateB0->Getd0Prong(1));
902 
903  Double_t impactProduct = candidateB0->Prodd0d0();
904  Double_t impactProductXY = TMath::Abs(candidateB0->ImpParXY());
905 
906  Double_t angleBetweenBothDaughters = (candidateDStar->Px() * candidatePion->Px() + candidateDStar->Py() * candidatePion->Py() + candidateDStar->Pz() * candidatePion->Pz()) /(candidateDStar->P() * candidatePion->P());
907  Double_t angleMotherFirstDaughter = (candidateB0->Px() * candidatePion->Px() + candidateB0->Py() * candidatePion->Py() + candidateB0->Pz() * candidatePion->Pz()) /(candidateB0->P() * candidatePion->P());
908  Double_t angleMotherSecondDaughter = (candidateB0->Px() * candidateDStar->Px() + candidateB0->Py() * candidateDStar->Py() + candidateB0->Pz() * candidateDStar->Pz()) /(candidateB0->P() * candidateDStar->P());
909 
910  Double_t cosThetaStar = candidateB0->CosThetaStar(0,511,211,413);
911  Double_t vertexDistance = vertexB0->DistanceToVertex(primaryVertex);
912  Double_t normDecayLength = candidateB0->NormalizedDecayLength();
913  Double_t pdgMassMother = TDatabasePDG::Instance()->GetParticle(511)->Mass();
914  Double_t pseudoProperDecayLength = ((vertexB0->GetX() - primaryVertex->GetX()) * candidateB0->Px() / TMath::Abs(candidateB0->Pt())) + ((vertexB0->GetY() - primaryVertex->GetY()) * candidateB0->Py() / TMath::Abs(candidateB0->Pt()));
915  Double_t pseudoProperDecayTime = pseudoProperDecayLength * pdgMassMother/ptMother;
916  Double_t decayTime = vertexDistance / (299792458 * TMath::Sqrt(1/((pdgMassMother*pdgMassMother/(momentumMother*momentumMother)) + 1)));
917 
918  Double_t phi = candidateB0->Phi();
919  Double_t theta = candidateB0->Theta();
920  Double_t covMatrix[21];
921  candidateB0->GetCovarianceXYZPxPyPz(covMatrix);
922 
923  Double_t cp = TMath::Cos(phi);
924  Double_t sp = TMath::Sin(phi);
925  Double_t ct = TMath::Cos(theta);
926  Double_t st = TMath::Sin(theta);
927 
928  Double_t errorMomentum = covMatrix[9]*cp*cp*ct*ct // GetCovPxPx
929  +covMatrix[13]*2.*cp*sp*ct*ct // GetCovPxPy
930  +covMatrix[18]*2.*cp*ct*st // GetCovPxPz
931  +covMatrix[14]*sp*sp*ct*ct // GetCovPyPy
932  +covMatrix[19]*2.*sp*ct*st // GetCovPyPz
933  +covMatrix[20]*st*st; // GetCovPzPz
934  Double_t normalizedDecayTime = candidateB0->NormalizedDecayLength() / (299792458 * TMath::Sqrt(1/((pdgMassMother*pdgMassMother*errorMomentum*errorMomentum/(momentumMother*momentumMother)) + 1)));
935 
936  Double_t cosPointingAngleXY = candidateB0->CosPointingAngleXY();
937  Double_t distanceXYToVertex = vertexB0->DistanceXYToVertex(primaryVertex);
938  Double_t normalizedDecayLengthXY = candidateB0->NormalizedDecayLengthXY();
939  Double_t chi2Vertex = vertexB0->GetChi2perNDF();
940 
941  //Topomatic
942  Double_t dd0pr1=0.;
943  Double_t dd0pr2=0.;
944  Double_t dd0max=0.;
945  Double_t dd0min=0.;
946  for(Int_t ipr=0; ipr<2; ipr++)
947  {
948  Double_t diffIP, errdiffIP;
949  candidateB0->Getd0MeasMinusExpProng(ipr,bz,diffIP,errdiffIP);
950  Double_t normdd0=0.;
951  if(errdiffIP>0.) normdd0=diffIP/errdiffIP;
952  if(ipr==0) dd0pr1=normdd0;
953  if(ipr==1) dd0pr2=normdd0;
954  }
955  if(TMath::Abs(dd0pr1)>TMath::Abs(dd0pr2)) {dd0max=dd0pr1; dd0min=dd0pr2;}
956  else {dd0max=dd0pr2; dd0min=dd0pr1;}
957 
958 
959  // We apply the cuts
960  Int_t nCutIndex = 0;
961  Double_t cutVariableValue = 0.0;
962 
963  // "inv. mass width [GeV]" --------------------------------------------
964  nCutIndex = 68;
965  cutVariableValue = invMassDifference;
966  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
967  if(!bPassedCut && !fGetCutInfo) return 0;
968  //---------------------------------------------------------------------
969 
970  // "delta mass width [GeV]" -------------------------------------------
971  nCutIndex = 69;
972  cutVariableValue = invMassDelta;
973  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
974  if(!bPassedCut && !fGetCutInfo) return 0;
975  //---------------------------------------------------------------------
976 
977  // "pointing angle [Cos(theta)]" --------------------------------------
978  nCutIndex = 70;
979  cutVariableValue = pointingAngle;
980  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
981  if(!bPassedCut && !fGetCutInfo) return 0;
982  //---------------------------------------------------------------------
983 
984  // "dca [cm]" ---------------------------------------------------------
985  nCutIndex = 71;
986  cutVariableValue = dcaMother;
987  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
988  if(!bPassedCut && !fGetCutInfo) return 0;
989  //---------------------------------------------------------------------
990 
991  // "Pt B0 [GeV/c]" ----------------------------------------------------
992  nCutIndex = 72;
993  cutVariableValue = ptMother;
994  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
995  if(!bPassedCut && !fGetCutInfo) return 0;
996  //---------------------------------------------------------------------
997 
998  // "Pt DStar [GeV/c]" -------------------------------------------------
999  nCutIndex = 73;
1000  cutVariableValue = ptDStar;
1001  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1002  if(!bPassedCut && !fGetCutInfo) return 0;
1003  //---------------------------------------------------------------------
1004 
1005  // "Pt Pion [GeV/c]" --------------------------------------------------
1006  nCutIndex = 74;
1007  cutVariableValue = ptPion;
1008  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1009  if(!bPassedCut && !fGetCutInfo) return 0;
1010  //---------------------------------------------------------------------
1011 
1012  // "d0 B0 [cm]" -------------------------------------------------------
1013  nCutIndex = 75;
1014  cutVariableValue = d0Mother;
1015  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1016  if(!bPassedCut && !fGetCutInfo) return 0;
1017  //---------------------------------------------------------------------
1018 
1019  // "d0 DStar [cm]"-----------------------------------------------------
1020  nCutIndex = 76;
1021  cutVariableValue = d0firstTrack;
1022  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1023  if(!bPassedCut && !fGetCutInfo) return 0;
1024  //---------------------------------------------------------------------
1025 
1026  // "d0 Pion [cm]" -----------------------------------------------------
1027  nCutIndex = 77;
1028  cutVariableValue = d0secondTrack;
1029  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1030  if(!bPassedCut && !fGetCutInfo) return 0;
1031  //---------------------------------------------------------------------
1032 
1033  // "d0d0 [cm^2]" ------------------------------------------------------
1034  nCutIndex = 78;
1035  cutVariableValue = impactProduct;
1036  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1037  if(!bPassedCut && !fGetCutInfo) return 0;
1038  //---------------------------------------------------------------------
1039 
1040  // "d0d0 XY [cm^2]" ---------------------------------------------------
1041  nCutIndex = 79;
1042  cutVariableValue = impactProductXY;
1043  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1044  if(!bPassedCut && !fGetCutInfo) return 0;
1045  //---------------------------------------------------------------------
1046 
1047  // "angle between both daughters" -------------------------------------
1048  nCutIndex = 80;
1049  cutVariableValue = angleBetweenBothDaughters;
1050  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1051  if(!bPassedCut && !fGetCutInfo) return 0;
1052  //---------------------------------------------------------------------
1053 
1054  // "angle mother with first daughter" ---------------------------------
1055  nCutIndex = 81;
1056  cutVariableValue = angleMotherFirstDaughter;
1057  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1058  if(!bPassedCut && !fGetCutInfo) return 0;
1059  //---------------------------------------------------------------------
1060 
1061  // "angle mother with second daughter" --------------------------------
1062  nCutIndex = 82;
1063  cutVariableValue = angleMotherSecondDaughter;
1064  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1065  if(!bPassedCut && !fGetCutInfo) return 0;
1066  //---------------------------------------------------------------------
1067 
1068  // "cosThetaStar" -----------------------------------------------------
1069  nCutIndex = 83;
1070  cutVariableValue = cosThetaStar;
1071  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1072  if(!bPassedCut && !fGetCutInfo) return 0;
1073  //---------------------------------------------------------------------
1074 
1075  // "vertexDistance" ---------------------------------------------------
1076  nCutIndex = 84;
1077  cutVariableValue = vertexDistance;
1078  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1079  if(!bPassedCut && !fGetCutInfo) return 0;
1080  //---------------------------------------------------------------------
1081 
1082  // "pseudoProperDecayTime" --------------------------------------------
1083  nCutIndex = 85;
1084  cutVariableValue = pseudoProperDecayTime;
1085  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1086  if(!bPassedCut && !fGetCutInfo) return 0;
1087  //---------------------------------------------------------------------
1088 
1089  // "DecayTime" --------------------------------------------------------
1090  nCutIndex = 86;
1091  cutVariableValue = decayTime;
1092  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1093  if(!bPassedCut && !fGetCutInfo) return 0;
1094  //---------------------------------------------------------------------
1095 
1096  // "normalizedDecayTime" ----------------------------------------------------
1097  nCutIndex = 87;
1098  cutVariableValue = normalizedDecayTime;
1099  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1100  if(!bPassedCut && !fGetCutInfo) return 0;
1101  //---------------------------------------------------------------------
1102 
1103  // "normDecayLength" --------------------------------------------------
1104  nCutIndex = 88;
1105  cutVariableValue = normDecayLength;
1106  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1107  if(!bPassedCut && !fGetCutInfo) return 0;
1108  //---------------------------------------------------------------------
1109 
1110  // "topomatic first daughter" -----------------------------------------
1111  nCutIndex = 89;
1112  cutVariableValue = dd0pr1;
1113  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1114  if(!bPassedCut && !fGetCutInfo) return 0;
1115  //---------------------------------------------------------------------
1116 
1117  // "topomatic second daughter" ----------------------------------------
1118  nCutIndex = 90;
1119  cutVariableValue = dd0pr2;
1120  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1121  if(!bPassedCut && !fGetCutInfo) return 0;
1122  //---------------------------------------------------------------------
1123 
1124  // "topomatic max" ----------------------------------------------------
1125  nCutIndex = 91;
1126  cutVariableValue = dd0max;
1127  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1128  if(!bPassedCut && !fGetCutInfo) return 0;
1129  //---------------------------------------------------------------------
1130 
1131  // "topomatic min" ----------------------------------------------------
1132  nCutIndex = 92;
1133  cutVariableValue = dd0min;
1134  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1135  if(!bPassedCut && !fGetCutInfo) return 0;
1136  //---------------------------------------------------------------------
1137 
1138  // "pointing angle XY" ----------------------------------------------------
1139  nCutIndex = 93;
1140  cutVariableValue = cosPointingAngleXY;
1141  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1142  if(!bPassedCut && !fGetCutInfo) return 0;
1143  //---------------------------------------------------------------------
1144 
1145  // "vertex distance XY" ----------------------------------------------------
1146  nCutIndex = 94;
1147  cutVariableValue = distanceXYToVertex;
1148  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1149  if(!bPassedCut && !fGetCutInfo) return 0;
1150  //---------------------------------------------------------------------
1151 
1152  // "normalized decay length XY" ----------------------------------------------------
1153  nCutIndex = 95;
1154  cutVariableValue = normalizedDecayLengthXY;
1155  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1156  if(!bPassedCut && !fGetCutInfo) return 0;
1157  //---------------------------------------------------------------------
1158 
1159  // "chi squared per NDF" ----------------------------------------------------
1160  nCutIndex = 96;
1161  cutVariableValue = chi2Vertex;
1162  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1163  if(!bPassedCut && !fGetCutInfo) return 0;
1164  //---------------------------------------------------------------------
1165 
1166  // select DStar that passes D0 cuts
1167  bPassedCut = IsDStarFromB0Selected(ptMother,candidateDStar,selectionLevel,aod,bCutArray);
1168  if(!bPassedCut && !fGetCutInfo) return 0;
1169  }
1170 
1171  if(bPassedCut==kFALSE)
1172  {
1173  returnvalue = 0;
1174  } else
1175  {
1176  for (Int_t i = 68; i < 97; ++i)
1177  {
1178  if(bCutArray[i]==kTRUE){
1179  returnvalue = 0;
1180  break;
1181  }
1182  }
1183  }
1184 
1185  fIsSelectedCuts = returnvalue;
1186 
1187  return returnvalue;
1188 }
1189 //---------------------------------------------------------------------------
1191  //
1192  // Apply selection for DStar candidate
1193  //
1194 
1195  if(!fCutsRD){
1196  cout<<"Cut matrice not inizialized. Exit..."<<endl;
1197  return 0;
1198  }
1199 
1200  AliAODRecoDecayHF2Prong* candidateDStar = (AliAODRecoDecayHF2Prong*)obj;
1201  if(!candidateDStar){
1202  cout<<"candidateDStar null"<<endl;
1203  return 0;
1204  }
1205 
1206  AliAODRecoDecayHF2Prong* candidateD0 = (AliAODRecoDecayHF2Prong*)candidateDStar->GetDaughter(1);
1207  if(!candidateD0){
1208  cout<<"candidateD0 null"<<endl;
1209  return 0;
1210  }
1211 
1212  AliAODTrack *candidatePion = (AliAODTrack*)candidateDStar->GetDaughter(0);
1213  if(!candidatePion){
1214  cout<<"candidatePion null"<<endl;
1215  return 0;
1216  }
1217 
1218  AliAODVertex * vertexDStar = candidateDStar->GetSecondaryVtx();
1219  if(!vertexDStar){
1220  cout<<"vertexDStar null"<<endl;
1221  return 0;
1222  }
1223 
1224  AliAODVertex * primaryVertex = aod->GetPrimaryVertex();
1225  if(!primaryVertex){
1226  cout<<"primaryVertex null"<<endl;
1227  return 0;
1228  }
1229 
1230  Int_t returnvalue=1;
1231  Bool_t bPassedCut = kFALSE;
1232 
1233  //get the magnetic field
1234  Double_t bz = (Double_t)aod->GetMagneticField();
1235 
1236  // selection on candidate
1237  if(selectionLevel==AliRDHFCuts::kAll ||
1238  selectionLevel==AliRDHFCuts::kCandidate) {
1239 
1240  Int_t ptbin=PtBin(ptB0);
1241 
1242  // DStarMass and D0mass
1243  Double_t mDSPDG = TDatabasePDG::Instance()->GetParticle(413)->Mass();
1244  Double_t mD0PDG = TDatabasePDG::Instance()->GetParticle(421)->Mass();
1245 
1246  // delta mass PDG
1247  Double_t deltaPDG = mDSPDG-mD0PDG;
1248 
1249  // Half width DStar mass
1250  UInt_t prongs[2];
1251  prongs[0] = 211; prongs[1] = 421;
1252  Double_t invMassDStar = candidateDStar->InvMass(2,prongs);
1253  Double_t invMassDifference = TMath::Abs(mDSPDG - invMassDStar);
1254  Double_t invMassDelta = TMath::Abs(deltaPDG-(DeltaInvMassDStarKpipi(candidateDStar)));
1255 
1256  Double_t pointingAngle = candidateDStar->CosPointingAngle();
1257  Double_t dcaMother = candidateDStar->GetDCA();
1258  Double_t ptMother = candidateDStar->Pt();
1259  Double_t momentumMother = candidateDStar->P();
1260  Double_t ptD0 = candidateD0->Pt();
1261  Double_t ptPion = candidatePion->Pt();
1262 
1263  AliExternalTrackParam motherTrack;
1264  motherTrack.CopyFromVTrack(candidateDStar);
1265  Double_t d0z0[2],covd0z0[3],d0[2];
1266  motherTrack.PropagateToDCA(primaryVertex,bz,100.,d0z0,covd0z0);
1267  d0[0] = d0z0[0];
1268  Double_t d0Mother = TMath::Abs(d0[0]);
1269  Double_t d0firstTrack = TMath::Abs(candidateDStar->Getd0Prong(0));
1270  Double_t d0secondTrack = TMath::Abs(candidateDStar->Getd0Prong(1));
1271 
1272  Double_t impactProduct = candidateDStar->Prodd0d0();
1273  Double_t impactProductXY = TMath::Abs(candidateDStar->ImpParXY());
1274 
1275  Double_t angleBetweenBothDaughters = (candidateD0->Px() * candidatePion->Px() + candidateD0->Py() * candidatePion->Py() + candidateD0->Pz() * candidatePion->Pz()) /(candidateD0->P() * candidatePion->P());
1276  Double_t angleMotherFirstDaughter = (candidateDStar->Px() * candidatePion->Px() + candidateDStar->Py() * candidatePion->Py() + candidateDStar->Pz() * candidatePion->Pz()) /(candidateDStar->P() * candidatePion->P());
1277  Double_t angleMotherSecondDaughter = (candidateDStar->Px() * candidateD0->Px() + candidateDStar->Py() * candidateD0->Py() + candidateDStar->Pz() * candidateD0->Pz()) /(candidateDStar->P() * candidateD0->P());
1278 
1279  Double_t cosThetaStar = candidateDStar->CosThetaStar(0,413,211,421);
1280  Double_t vertexDistance = vertexDStar->DistanceToVertex(primaryVertex);
1281  Double_t normDecayLength = candidateDStar->NormalizedDecayLength();
1282  Double_t pdgMassMother = TDatabasePDG::Instance()->GetParticle(413)->Mass();
1283  Double_t pseudoProperDecayLength = ((vertexDStar->GetX() - primaryVertex->GetX()) * candidateDStar->Px() / TMath::Abs(candidateDStar->Pt())) + ((vertexDStar->GetY() - primaryVertex->GetY()) * candidateDStar->Py() / TMath::Abs(candidateDStar->Pt()));
1284  Double_t pseudoProperDecayTime = pseudoProperDecayLength * pdgMassMother/ptMother;
1285  Double_t decayTime = vertexDistance / (299792458 * TMath::Sqrt(1/((pdgMassMother*pdgMassMother/(momentumMother*momentumMother)) + 1)));
1286 
1287  Double_t phi = candidateDStar->Phi();
1288  Double_t theta = candidateDStar->Theta();
1289  Double_t covMatrix[21];
1290  candidateDStar->GetCovarianceXYZPxPyPz(covMatrix);
1291 
1292  Double_t cp = TMath::Cos(phi);
1293  Double_t sp = TMath::Sin(phi);
1294  Double_t ct = TMath::Cos(theta);
1295  Double_t st = TMath::Sin(theta);
1296 
1297  Double_t errorMomentum = covMatrix[9]*cp*cp*ct*ct // GetCovPxPx
1298  +covMatrix[13]*2.*cp*sp*ct*ct // GetCovPxPy
1299  +covMatrix[18]*2.*cp*ct*st // GetCovPxPz
1300  +covMatrix[14]*sp*sp*ct*ct // GetCovPyPy
1301  +covMatrix[19]*2.*sp*ct*st // GetCovPyPz
1302  +covMatrix[20]*st*st; // GetCovPzPz
1303  Double_t normalizedDecayTime = candidateDStar->NormalizedDecayLength() / (299792458 * TMath::Sqrt(1/((pdgMassMother*pdgMassMother*errorMomentum*errorMomentum/(momentumMother*momentumMother)) + 1)));
1304 
1305  Double_t cosPointingAngleXY = candidateDStar->CosPointingAngleXY();
1306  Double_t distanceXYToVertex = vertexDStar->DistanceXYToVertex(primaryVertex);
1307  Double_t normalizedDecayLengthXY = candidateDStar->NormalizedDecayLengthXY();
1308  Double_t chi2Vertex = vertexDStar->GetChi2perNDF();
1309 
1310  //Topomatic
1311  Double_t dd0pr1=0.;
1312  Double_t dd0pr2=0.;
1313  Double_t dd0max=0.;
1314  Double_t dd0min=0.;
1315  for(Int_t ipr=0; ipr<2; ipr++)
1316  {
1317  Double_t diffIP, errdiffIP;
1318  candidateDStar->Getd0MeasMinusExpProng(ipr,bz,diffIP,errdiffIP);
1319  Double_t normdd0=0.;
1320  if(errdiffIP>0.) normdd0=diffIP/errdiffIP;
1321  if(ipr==0) dd0pr1=normdd0;
1322  if(ipr==1) dd0pr2=normdd0;
1323  }
1324  if(TMath::Abs(dd0pr1)>TMath::Abs(dd0pr2)) {dd0max=dd0pr1; dd0min=dd0pr2;}
1325  else {dd0max=dd0pr2; dd0min=dd0pr1;}
1326 
1327 
1328  // We apply the cuts
1329  Int_t nCutIndex = 0;
1330  Double_t cutVariableValue = 0.0;
1331 
1332  // "inv. mass width [GeV]" --------------------------------------------
1333  nCutIndex = 39;
1334  cutVariableValue = invMassDifference;
1335  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1336  if(!bPassedCut && !fGetCutInfo) return 0;
1337  //---------------------------------------------------------------------
1338 
1339  // "delta mass width [GeV]" -------------------------------------------
1340  nCutIndex = 40;
1341  cutVariableValue = invMassDelta;
1342  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1343  if(!bPassedCut && !fGetCutInfo) return 0;
1344  //---------------------------------------------------------------------
1345 
1346  // "pointing angle [Cos(theta)]" --------------------------------------
1347  nCutIndex = 41;
1348  cutVariableValue = pointingAngle;
1349  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1350  if(!bPassedCut && !fGetCutInfo) return 0;
1351  //---------------------------------------------------------------------
1352 
1353  // "dca [cm]" ---------------------------------------------------------
1354  nCutIndex = 42;
1355  cutVariableValue = dcaMother;
1356  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1357  if(!bPassedCut && !fGetCutInfo) return 0;
1358  //---------------------------------------------------------------------
1359 
1360  // "Pt DStar [GeV/c]" ----------------------------------------------------
1361  nCutIndex = 43;
1362  cutVariableValue = ptMother;
1363  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1364  if(!bPassedCut && !fGetCutInfo) return 0;
1365  //---------------------------------------------------------------------
1366 
1367  // "Pt D0 [GeV/c]" -------------------------------------------------
1368  nCutIndex = 44;
1369  cutVariableValue = ptD0;
1370  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1371  if(!bPassedCut && !fGetCutInfo) return 0;
1372  //---------------------------------------------------------------------
1373 
1374  // "Pt Pion [GeV/c]" --------------------------------------------------
1375  nCutIndex = 45;
1376  cutVariableValue = ptPion;
1377  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1378  if(!bPassedCut && !fGetCutInfo) return 0;
1379  //---------------------------------------------------------------------
1380 
1381  // "d0 DStar [cm]" -------------------------------------------------------
1382  nCutIndex = 46;
1383  cutVariableValue = d0Mother;
1384  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1385  if(!bPassedCut && !fGetCutInfo) return 0;
1386  //---------------------------------------------------------------------
1387 
1388  // "d0 D0 [cm]"-----------------------------------------------------
1389  nCutIndex = 47;
1390  cutVariableValue = d0firstTrack;
1391  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1392  if(!bPassedCut && !fGetCutInfo) return 0;
1393  //---------------------------------------------------------------------
1394 
1395  // "d0 Pion [cm]" -----------------------------------------------------
1396  nCutIndex = 48;
1397  cutVariableValue = d0secondTrack;
1398  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1399  if(!bPassedCut && !fGetCutInfo) return 0;
1400  //---------------------------------------------------------------------
1401 
1402  // "d0d0 [cm^2]" ------------------------------------------------------
1403  nCutIndex = 49;
1404  cutVariableValue = impactProduct;
1405  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1406  if(!bPassedCut && !fGetCutInfo) return 0;
1407  //---------------------------------------------------------------------
1408 
1409  // "d0d0 XY [cm^2]" ---------------------------------------------------
1410  nCutIndex = 50;
1411  cutVariableValue = impactProductXY;
1412  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1413  if(!bPassedCut && !fGetCutInfo) return 0;
1414  //---------------------------------------------------------------------
1415 
1416  // "angle between both daughters" -------------------------------------
1417  nCutIndex = 51;
1418  cutVariableValue = angleBetweenBothDaughters;
1419  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1420  if(!bPassedCut && !fGetCutInfo) return 0;
1421  //---------------------------------------------------------------------
1422 
1423  // "angle mother with first daughter" ---------------------------------
1424  nCutIndex = 52;
1425  cutVariableValue = angleMotherFirstDaughter;
1426  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1427  if(!bPassedCut && !fGetCutInfo) return 0;
1428  //---------------------------------------------------------------------
1429 
1430  // "angle mother with second daughter" --------------------------------
1431  nCutIndex = 53;
1432  cutVariableValue = angleMotherSecondDaughter;
1433  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1434  if(!bPassedCut && !fGetCutInfo) return 0;
1435  //---------------------------------------------------------------------
1436 
1437  // "cosThetaStar" -----------------------------------------------------
1438  nCutIndex = 54;
1439  cutVariableValue = cosThetaStar;
1440  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1441  if(!bPassedCut && !fGetCutInfo) return 0;
1442  //---------------------------------------------------------------------
1443 
1444  // "vertexDistance" ---------------------------------------------------
1445  nCutIndex = 55;
1446  cutVariableValue = vertexDistance;
1447  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1448  if(!bPassedCut && !fGetCutInfo) return 0;
1449  //---------------------------------------------------------------------
1450 
1451  // "pseudoProperDecayTime" --------------------------------------------
1452  nCutIndex = 56;
1453  cutVariableValue = pseudoProperDecayTime;
1454  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1455  if(!bPassedCut && !fGetCutInfo) return 0;
1456  //---------------------------------------------------------------------
1457 
1458  // "DecayTime" --------------------------------------------------------
1459  nCutIndex = 57;
1460  cutVariableValue = decayTime;
1461  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1462  if(!bPassedCut && !fGetCutInfo) return 0;
1463  //---------------------------------------------------------------------
1464 
1465  // "normalizedDecayTime" ----------------------------------------------------
1466  nCutIndex = 58;
1467  cutVariableValue = normalizedDecayTime;
1468  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1469  if(!bPassedCut && !fGetCutInfo) return 0;
1470  //---------------------------------------------------------------------
1471 
1472  // "normDecayLength" --------------------------------------------------
1473  nCutIndex = 59;
1474  cutVariableValue = normDecayLength;
1475  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1476  if(!bPassedCut && !fGetCutInfo) return 0;
1477  //---------------------------------------------------------------------
1478 
1479  // "topomatic first daughter" -----------------------------------------
1480  nCutIndex = 60;
1481  cutVariableValue = dd0pr1;
1482  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1483  if(!bPassedCut && !fGetCutInfo) return 0;
1484  //---------------------------------------------------------------------
1485 
1486  // "topomatic second daughter" ----------------------------------------
1487  nCutIndex = 61;
1488  cutVariableValue = dd0pr2;
1489  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1490  if(!bPassedCut && !fGetCutInfo) return 0;
1491  //---------------------------------------------------------------------
1492 
1493  // "topomatic max" ----------------------------------------------------
1494  nCutIndex = 62;
1495  cutVariableValue = dd0max;
1496  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1497  if(!bPassedCut && !fGetCutInfo) return 0;
1498  //---------------------------------------------------------------------
1499 
1500  // "topomatic min" ----------------------------------------------------
1501  nCutIndex = 63;
1502  cutVariableValue = dd0min;
1503  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1504  if(!bPassedCut && !fGetCutInfo) return 0;
1505  //---------------------------------------------------------------------
1506 
1507  // "pointing angle XY" ----------------------------------------------------
1508  nCutIndex = 64;
1509  cutVariableValue = cosPointingAngleXY;
1510  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1511  if(!bPassedCut && !fGetCutInfo) return 0;
1512  //---------------------------------------------------------------------
1513 
1514  // "vertex distance XY" ----------------------------------------------------
1515  nCutIndex = 65;
1516  cutVariableValue = distanceXYToVertex;
1517  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1518  if(!bPassedCut && !fGetCutInfo) return 0;
1519  //---------------------------------------------------------------------
1520 
1521  // "normalized decay length XY" ----------------------------------------------------
1522  nCutIndex = 66;
1523  cutVariableValue = normalizedDecayLengthXY;
1524  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1525  if(!bPassedCut && !fGetCutInfo) return 0;
1526  //---------------------------------------------------------------------
1527 
1528  // "chi squared per NDF" ----------------------------------------------------
1529  nCutIndex = 67;
1530  cutVariableValue = chi2Vertex;
1531  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1532  if(!bPassedCut && !fGetCutInfo) return 0;
1533  //---------------------------------------------------------------------
1534 
1535  // select D0 - have to pass DStar candidate to get variables w.r.t. DStar vertex.
1536  bPassedCut = IsD0FromDStarSelected(ptB0,candidateDStar,selectionLevel, aod, bCutArray);
1537  if(!bPassedCut && !fGetCutInfo) return 0;
1538  }
1539 
1540  if(bPassedCut==kFALSE)
1541  {
1542  returnvalue = 0;
1543  } else
1544  {
1545  for (Int_t i = 39; i < 68; ++i)
1546  {
1547  if(bCutArray[i]==kTRUE){
1548  returnvalue = 0;
1549  break;
1550  }
1551  }
1552  }
1553 
1554 
1555  return returnvalue;
1556 
1557 }
1558 //_________________________________________________________________________________________________
1560  //
1561  // 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.
1562  //
1563 
1564  if(!fCutsRD){
1565  cout<<"Cut matrice not inizialized. Exit..."<<endl;
1566  return 0;
1567  }
1568 
1569  AliAODRecoDecayHF2Prong* candidateDStar = (AliAODRecoDecayHF2Prong*)obj;
1570  if(!candidateDStar){
1571  cout<<"candidateDStar null"<<endl;
1572  return 0;
1573  }
1574 
1575  AliAODRecoDecayHF2Prong* candidateD0 = (AliAODRecoDecayHF2Prong*)candidateDStar->GetDaughter(1);
1576  if(!candidateD0){
1577  cout<<"candidateD0 null"<<endl;
1578  return 0;
1579  }
1580 
1581  AliAODTrack *candidatePion = (AliAODTrack*)candidateD0->GetDaughter(0);
1582  if(!candidatePion){
1583  cout<<"candidatePion null"<<endl;
1584  return 0;
1585  }
1586 
1587  AliAODTrack *candidateKaon = (AliAODTrack*)candidateD0->GetDaughter(1);
1588  if(!candidateKaon){
1589  cout<<"candidateKaon null"<<endl;
1590  return 0;
1591  }
1592 
1593  AliAODVertex * vertexDStar = candidateDStar->GetSecondaryVtx();
1594  if(!vertexDStar){
1595  cout<<"vertexDStar null"<<endl;
1596  return 0;
1597  }
1598 
1599  AliAODVertex * vertexD0 = candidateD0->GetSecondaryVtx();
1600  if(!vertexD0){
1601  cout<<"vertexD0 null"<<endl;
1602  return 0;
1603  }
1604 
1605  AliAODVertex * primaryVertex = aod->GetPrimaryVertex();
1606  if(!primaryVertex){
1607  cout<<"primaryVertex null"<<endl;
1608  return 0;
1609  }
1610 
1611  Int_t returnvalue=1;
1612  Bool_t bPassedCut = kFALSE;
1613 
1614  //get the magnetic field
1615  Double_t bz = (Double_t)aod->GetMagneticField();
1616 
1617 
1618  // selection on candidate
1619  if(selectionLevel==AliRDHFCuts::kAll ||
1620  selectionLevel==AliRDHFCuts::kCandidate) {
1621 
1622  Int_t ptbin=PtBin(ptB0);
1623 
1624  // D0mass
1625  Double_t mD0PDG = TDatabasePDG::Instance()->GetParticle(421)->Mass();
1626 
1627  // D0 window - invariant mass
1628  Int_t chargeDStar = candidateDStar->Charge();
1629  UInt_t prongs[2];
1630  if(chargeDStar==1)
1631  {
1632  prongs[0] = 211;
1633  prongs[1] = 321;
1634  }
1635  else if (chargeDStar==-1)
1636  {
1637  prongs[1] = 211;
1638  prongs[0] = 321;
1639  }
1640  else
1641  {
1642  cout << "Wrong charge DStar." << endl;
1643  return 0;
1644  }
1645  Double_t invMassD0 = candidateD0->InvMass(2,prongs);
1646  Double_t invMassDifference = TMath::Abs(mD0PDG - invMassD0);
1647 
1648  Double_t pointingAngle = candidateD0->CosPointingAngle();
1649  Double_t dcaMother = candidateD0->GetDCA();
1650  Double_t ptMother = candidateD0->Pt();
1651  Double_t momentumMother = candidateD0->P();
1652  Double_t ptPion = candidatePion->Pt();
1653  Double_t ptKaon = candidateKaon->Pt();
1654 
1655  AliExternalTrackParam motherTrack;
1656  motherTrack.CopyFromVTrack(candidateD0);
1657  Double_t d0z0[2],covd0z0[3],d0[2];
1658  motherTrack.PropagateToDCA(primaryVertex,bz,100.,d0z0,covd0z0);
1659  d0[0] = d0z0[0];
1660  Double_t d0Mother = TMath::Abs(d0[0]);
1661  Double_t d0firstTrack = TMath::Abs(candidateD0->Getd0Prong(0));
1662  Double_t d0secondTrack = TMath::Abs(candidateD0->Getd0Prong(1));
1663 
1664  Double_t impactProduct = candidateD0->Prodd0d0();
1665  Double_t impactProductXY = TMath::Abs(candidateD0->ImpParXY());
1666 
1667  Double_t angleBetweenBothDaughters = (candidateKaon->Px() * candidatePion->Px() + candidateKaon->Py() * candidatePion->Py() + candidateKaon->Pz() * candidatePion->Pz()) /(candidateKaon->P() * candidatePion->P());
1668  Double_t angleMotherFirstDaughter = (candidateD0->Px() * candidatePion->Px() + candidateD0->Py() * candidatePion->Py() + candidateD0->Pz() * candidatePion->Pz()) /(candidateD0->P() * candidatePion->P());
1669  Double_t angleMotherSecondDaughter = (candidateD0->Px() * candidateKaon->Px() + candidateD0->Py() * candidateKaon->Py() + candidateD0->Pz() * candidateKaon->Pz()) /(candidateD0->P() * candidateKaon->P());
1670 
1671  Double_t cosThetaStar = candidateD0->CosThetaStar(0,421,211,321);
1672  Double_t vertexDistance = vertexD0->DistanceToVertex(primaryVertex);
1673  Double_t normDecayLength = candidateD0->NormalizedDecayLength();
1674  Double_t pdgMassMother = TDatabasePDG::Instance()->GetParticle(421)->Mass();
1675  Double_t pseudoProperDecayLength = ((vertexD0->GetX() - primaryVertex->GetX()) * candidateD0->Px() / TMath::Abs(candidateD0->Pt())) + ((vertexD0->GetY() - primaryVertex->GetY()) * candidateD0->Py() / TMath::Abs(candidateD0->Pt()));
1676  Double_t pseudoProperDecayTime = pseudoProperDecayLength * pdgMassMother/ptMother;
1677  Double_t decayTime = vertexDistance / (299792458 * TMath::Sqrt(1/((pdgMassMother*pdgMassMother/(momentumMother*momentumMother)) + 1)));
1678 
1679  Double_t phi = candidateD0->Phi();
1680  Double_t theta = candidateD0->Theta();
1681  Double_t covMatrix[21];
1682  candidateD0->GetCovarianceXYZPxPyPz(covMatrix);
1683 
1684  Double_t cp = TMath::Cos(phi);
1685  Double_t sp = TMath::Sin(phi);
1686  Double_t ct = TMath::Cos(theta);
1687  Double_t st = TMath::Sin(theta);
1688 
1689  Double_t errorMomentum = covMatrix[9]*cp*cp*ct*ct // GetCovPxPx
1690  +covMatrix[13]*2.*cp*sp*ct*ct // GetCovPxPy
1691  +covMatrix[18]*2.*cp*ct*st // GetCovPxPz
1692  +covMatrix[14]*sp*sp*ct*ct // GetCovPyPy
1693  +covMatrix[19]*2.*sp*ct*st // GetCovPyPz
1694  +covMatrix[20]*st*st; // GetCovPzPz
1695  Double_t normalizedDecayTime = candidateD0->NormalizedDecayLength() / (299792458 * TMath::Sqrt(1/((pdgMassMother*pdgMassMother*errorMomentum*errorMomentum/(momentumMother*momentumMother)) + 1)));
1696 
1697  Double_t cosPointingAngleXY = candidateD0->CosPointingAngleXY();
1698  Double_t distanceXYToVertex = vertexD0->DistanceXYToVertex(primaryVertex);
1699  Double_t normalizedDecayLengthXY = candidateD0->NormalizedDecayLengthXY();
1700  Double_t chi2Vertex = vertexD0->GetChi2perNDF();
1701 
1702 
1703  //Topomatic
1704  Double_t dd0pr1=0.;
1705  Double_t dd0pr2=0.;
1706  Double_t dd0max=0.;
1707  Double_t dd0min=0.;
1708  for(Int_t ipr=0; ipr<2; ipr++)
1709  {
1710  Double_t diffIP, errdiffIP;
1711  candidateD0->Getd0MeasMinusExpProng(ipr,bz,diffIP,errdiffIP);
1712  Double_t normdd0=0.;
1713  if(errdiffIP>0.) normdd0=diffIP/errdiffIP;
1714  if(ipr==0) dd0pr1=normdd0;
1715  if(ipr==1) dd0pr2=normdd0;
1716  }
1717  if(TMath::Abs(dd0pr1)>TMath::Abs(dd0pr2)) {dd0max=dd0pr1; dd0min=dd0pr2;}
1718  else {dd0max=dd0pr2; dd0min=dd0pr1;}
1719 
1720 
1721  // We apply the cuts
1722  Int_t nCutIndex = 0;
1723  Double_t cutVariableValue = 0.0;
1724 
1725  // "inv. mass width [GeV]" --------------------------------------------
1726  nCutIndex = 0;
1727  cutVariableValue = invMassDifference;
1728  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1729  if(!bPassedCut && !fGetCutInfo) return 0;
1730  //---------------------------------------------------------------------
1731 
1732  // "delta mass width [GeV]" -------------------------------------------
1733  // nCutIndex = 1; // not used for D0
1734  // cutVariableValue = invMassDelta;
1735  // bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1736  // if(!bPassedCut && !fGetCutInfo) return 0;
1737  //---------------------------------------------------------------------
1738 
1739  // "pointing angle [Cos(theta)]" --------------------------------------
1740  nCutIndex = 2;
1741  cutVariableValue = pointingAngle;
1742  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1743  if(!bPassedCut && !fGetCutInfo) return 0;
1744  //---------------------------------------------------------------------
1745 
1746  // "dca [cm]" ---------------------------------------------------------
1747  nCutIndex = 3;
1748  cutVariableValue = dcaMother;
1749  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1750  if(!bPassedCut && !fGetCutInfo) return 0;
1751  //---------------------------------------------------------------------
1752 
1753  // "Pt D0 [GeV/c]" ----------------------------------------------------
1754  nCutIndex = 4;
1755  cutVariableValue = ptMother;
1756  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1757  if(!bPassedCut && !fGetCutInfo) return 0;
1758  //---------------------------------------------------------------------
1759 
1760  // "Pt Kaon [GeV/c]" -------------------------------------------------
1761  nCutIndex = 5;
1762  cutVariableValue = ptKaon;
1763  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1764  if(!bPassedCut && !fGetCutInfo) return 0;
1765  //---------------------------------------------------------------------
1766 
1767  // "Pt Pion [GeV/c]" --------------------------------------------------
1768  nCutIndex = 6;
1769  cutVariableValue = ptPion;
1770  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1771  if(!bPassedCut && !fGetCutInfo) return 0;
1772  //---------------------------------------------------------------------
1773 
1774  // "d0 D0 [cm]" -------------------------------------------------------
1775  nCutIndex = 7;
1776  cutVariableValue = d0Mother;
1777  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1778  if(!bPassedCut && !fGetCutInfo) return 0;
1779  //---------------------------------------------------------------------
1780 
1781  // "d0 Kaon [cm]"-----------------------------------------------------
1782  nCutIndex = 8;
1783  cutVariableValue = d0firstTrack;
1784  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1785  if(!bPassedCut && !fGetCutInfo) return 0;
1786  //---------------------------------------------------------------------
1787 
1788  // "d0 Pion [cm]" -----------------------------------------------------
1789  nCutIndex = 9;
1790  cutVariableValue = d0secondTrack;
1791  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1792  if(!bPassedCut && !fGetCutInfo) return 0;
1793  //---------------------------------------------------------------------
1794 
1795  // "d0d0 [cm^2]" ------------------------------------------------------
1796  nCutIndex = 10;
1797  cutVariableValue = impactProduct;
1798  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1799  if(!bPassedCut && !fGetCutInfo) return 0;
1800  //---------------------------------------------------------------------
1801 
1802  // "d0d0 XY [cm^2]" ---------------------------------------------------
1803  nCutIndex = 11;
1804  cutVariableValue = impactProductXY;
1805  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1806  if(!bPassedCut && !fGetCutInfo) return 0;
1807  //---------------------------------------------------------------------
1808 
1809  // "angle between both daughters" -------------------------------------
1810  nCutIndex = 12;
1811  cutVariableValue = angleBetweenBothDaughters;
1812  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1813  if(!bPassedCut && !fGetCutInfo) return 0;
1814  //---------------------------------------------------------------------
1815 
1816  // "angle mother with first daughter" ---------------------------------
1817  nCutIndex = 13;
1818  cutVariableValue = angleMotherFirstDaughter;
1819  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1820  if(!bPassedCut && !fGetCutInfo) return 0;
1821  //---------------------------------------------------------------------
1822 
1823  // "angle mother with second daughter" --------------------------------
1824  nCutIndex = 14;
1825  cutVariableValue = angleMotherSecondDaughter;
1826  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1827  if(!bPassedCut && !fGetCutInfo) return 0;
1828  //---------------------------------------------------------------------
1829 
1830  // "cosThetaStar" -----------------------------------------------------
1831  nCutIndex = 15;
1832  cutVariableValue = cosThetaStar;
1833  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1834  if(!bPassedCut && !fGetCutInfo) return 0;
1835  //---------------------------------------------------------------------
1836 
1837  // "vertexDistance" ---------------------------------------------------
1838  nCutIndex = 16;
1839  cutVariableValue = vertexDistance;
1840  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1841  if(!bPassedCut && !fGetCutInfo) return 0;
1842  //---------------------------------------------------------------------
1843 
1844  // "pseudoProperDecayTime" --------------------------------------------
1845  nCutIndex = 17;
1846  cutVariableValue = pseudoProperDecayTime;
1847  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1848  if(!bPassedCut && !fGetCutInfo) return 0;
1849  //---------------------------------------------------------------------
1850 
1851  // "DecayTime" --------------------------------------------------------
1852  nCutIndex = 18;
1853  cutVariableValue = decayTime;
1854  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1855  if(!bPassedCut && !fGetCutInfo) return 0;
1856  //---------------------------------------------------------------------
1857 
1858  // "normalizedDecayTime" ----------------------------------------------------
1859  nCutIndex = 19;
1860  cutVariableValue = normalizedDecayTime;
1861  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1862  if(!bPassedCut && !fGetCutInfo) return 0;
1863  //---------------------------------------------------------------------
1864 
1865  // "normDecayLength" --------------------------------------------------
1866  nCutIndex = 20;
1867  cutVariableValue = normDecayLength;
1868  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1869  if(!bPassedCut && !fGetCutInfo) return 0;
1870  //---------------------------------------------------------------------
1871 
1872  // "topomatic first daughter" -----------------------------------------
1873  nCutIndex = 21;
1874  cutVariableValue = dd0pr1;
1875  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1876  if(!bPassedCut && !fGetCutInfo) return 0;
1877  //---------------------------------------------------------------------
1878 
1879  // "topomatic second daughter" ----------------------------------------
1880  nCutIndex = 22;
1881  cutVariableValue = dd0pr2;
1882  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1883  if(!bPassedCut && !fGetCutInfo) return 0;
1884  //---------------------------------------------------------------------
1885 
1886  // "topomatic max" ----------------------------------------------------
1887  nCutIndex = 23;
1888  cutVariableValue = dd0max;
1889  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1890  if(!bPassedCut && !fGetCutInfo) return 0;
1891  //---------------------------------------------------------------------
1892 
1893  // "topomatic min" ----------------------------------------------------
1894  nCutIndex = 24;
1895  cutVariableValue = dd0min;
1896  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1897  if(!bPassedCut && !fGetCutInfo) return 0;
1898  //---------------------------------------------------------------------
1899 
1900  // "pointing angle XY" ----------------------------------------------------
1901  nCutIndex = 25;
1902  cutVariableValue = cosPointingAngleXY;
1903  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1904  if(!bPassedCut && !fGetCutInfo) return 0;
1905  //---------------------------------------------------------------------
1906 
1907  // "vertex distance XY" ----------------------------------------------------
1908  nCutIndex = 26;
1909  cutVariableValue = distanceXYToVertex;
1910  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1911  if(!bPassedCut && !fGetCutInfo) return 0;
1912  //---------------------------------------------------------------------
1913 
1914  // "normalized decay length XY" ----------------------------------------------------
1915  nCutIndex = 27;
1916  cutVariableValue = normalizedDecayLengthXY;
1917  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1918  if(!bPassedCut && !fGetCutInfo) return 0;
1919  //---------------------------------------------------------------------
1920 
1921  // "chi squared per NDF" ----------------------------------------------------
1922  nCutIndex = 28;
1923  cutVariableValue = chi2Vertex;
1924  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1925  if(!bPassedCut && !fGetCutInfo) return 0;
1926  //---------------------------------------------------------------------
1927 
1928 
1929 
1930  AliAODRecoDecay* candidateD0toDStar = (AliAODRecoDecay*)candidateD0;
1931  AliExternalTrackParam pionD0Track;
1932  AliExternalTrackParam kaonD0Track;
1933 
1934  Double_t d0z0DSVert[2],covd0z0DSVert[3],d0DSVert[2];
1935 
1936  pionD0Track.CopyFromVTrack(candidatePion);
1937  pionD0Track.PropagateToDCA(vertexDStar,bz,100.,d0z0DSVert,covd0z0DSVert);
1938  d0DSVert[0] = d0z0DSVert[0];
1939 
1940  kaonD0Track.CopyFromVTrack(candidateKaon);
1941  kaonD0Track.PropagateToDCA(vertexDStar,bz,100.,d0z0DSVert,covd0z0DSVert);
1942  d0DSVert[1] = d0z0DSVert[0];
1943 
1944  AliExternalTrackParam D0Track;
1945  D0Track.CopyFromVTrack(candidateD0);
1946  Double_t d0z0D0DSVert[2],covd0z0D0DSVert[3],d0D0DSVert;
1947  motherTrack.PropagateToDCA(vertexDStar,bz,100.,d0z0D0DSVert,covd0z0D0DSVert);
1948  d0D0DSVert = TMath::Abs(d0z0D0DSVert[0]);
1949 
1950  Double_t impactProductToDStar = d0DSVert[0]*d0DSVert[1];
1951  Double_t impactProductXYToDStar = candidateD0toDStar->ImpParXY(vertexDStar);
1952 
1953  Double_t pointingAngleToDStar = candidateD0toDStar->CosPointingAngle(vertexDStar);
1954  Double_t d0FirstDaughterToDStar = TMath::Abs(d0DSVert[0]);
1955  Double_t d0SecondDaughterToDStar = TMath::Abs(d0DSVert[1]);
1956  Double_t normDecayLengthToDStar = candidateD0toDStar->NormalizedDecayLength(vertexDStar);
1957 
1958  Double_t pseudoProperDecayLengthDSVert = ((vertexD0->GetX() - vertexDStar->GetX()) * candidateD0->Px() / TMath::Abs(candidateD0->Pt())) + ((vertexD0->GetY() - vertexDStar->GetY()) * candidateD0->Py() / TMath::Abs(candidateD0->Pt()));
1959  Double_t pseudoProperDecayTimeToDStar = pseudoProperDecayLengthDSVert * pdgMassMother/ptMother;
1960  Double_t DecayTimeToDStar = vertexDistance / (299792458 * TMath::Sqrt(1/((pdgMassMother*pdgMassMother/(momentumMother*momentumMother)) + 1)));
1961 
1962  Double_t phiDSVert = candidateD0->Phi();
1963  Double_t thetaDSVert = candidateD0->Theta();
1964  Double_t covMatrixDSVert[21];
1965  candidateD0->GetCovarianceXYZPxPyPz(covMatrixDSVert);
1966 
1967  cp = TMath::Cos(phiDSVert);
1968  sp = TMath::Sin(phiDSVert);
1969  ct = TMath::Cos(thetaDSVert);
1970  st = TMath::Sin(thetaDSVert);
1971 
1972  errorMomentum = covMatrix[9]*cp*cp*ct*ct // GetCovPxPx
1973  +covMatrix[13]*2.*cp*sp*ct*ct // GetCovPxPy
1974  +covMatrix[18]*2.*cp*ct*st // GetCovPxPz
1975  +covMatrix[14]*sp*sp*ct*ct // GetCovPyPy
1976  +covMatrix[19]*2.*sp*ct*st // GetCovPyPz
1977  +covMatrix[20]*st*st; // GetCovPzPz
1978  Double_t normalizedDecayTimeToDStar = candidateD0toDStar->NormalizedDecayLength(vertexDStar) / (299792458 * TMath::Sqrt(1/((pdgMassMother*pdgMassMother*errorMomentum*errorMomentum/(momentumMother*momentumMother)) + 1)));
1979 
1980  // "pointingAngleToDStar" ---------------------------------------------
1981  nCutIndex = 29;
1982  cutVariableValue = pointingAngleToDStar;
1983  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1984  if(!bPassedCut && !fGetCutInfo) return 0;
1985  //---------------------------------------------------------------------
1986 
1987  // "d0MotherToDStar" --------------------------------------------------
1988  nCutIndex = 30;
1989  cutVariableValue = d0D0DSVert;
1990  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1991  if(!bPassedCut && !fGetCutInfo) return 0;
1992  //---------------------------------------------------------------------
1993 
1994  // "d0FirstDaughterToDStar" -------------------------------------------
1995  nCutIndex = 31;
1996  cutVariableValue = d0FirstDaughterToDStar;
1997  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
1998  if(!bPassedCut && !fGetCutInfo) return 0;
1999  //---------------------------------------------------------------------
2000 
2001  // "d0SecondDaughterToDStar" ------------------------------------------
2002  nCutIndex = 32;
2003  cutVariableValue = d0SecondDaughterToDStar;
2004  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
2005  if(!bPassedCut && !fGetCutInfo) return 0;
2006  //---------------------------------------------------------------------
2007 
2008  // "impactProductToDStar" ---------------------------------------------
2009  nCutIndex = 33;
2010  cutVariableValue = impactProductToDStar;
2011  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
2012  if(!bPassedCut && !fGetCutInfo) return 0;
2013  //---------------------------------------------------------------------
2014 
2015  // "impactProductXYToDStar" -------------------------------------------
2016  nCutIndex = 34;
2017  cutVariableValue = impactProductXYToDStar;
2018  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
2019  if(!bPassedCut && !fGetCutInfo) return 0;
2020  //---------------------------------------------------------------------
2021 
2022  // "normDecayLengthToDStar" -------------------------------------------
2023  nCutIndex = 35;
2024  cutVariableValue = normDecayLengthToDStar;
2025  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
2026  if(!bPassedCut && !fGetCutInfo) return 0;
2027  //---------------------------------------------------------------------
2028 
2029  // "pseudoProperDecayTimeToDStar" -------------------------------------
2030  nCutIndex = 36;
2031  cutVariableValue = pseudoProperDecayTimeToDStar;
2032  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
2033  if(!bPassedCut && !fGetCutInfo) return 0;
2034  //---------------------------------------------------------------------
2035 
2036  // "DecayTimeToDStar" -------------------------------------------------
2037  nCutIndex = 37;
2038  cutVariableValue = DecayTimeToDStar;
2039  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
2040  if(!bPassedCut && !fGetCutInfo) return 0;
2041  //---------------------------------------------------------------------
2042 
2043  // "normalizedDecayTimeToDStar" ---------------------------------------------
2044  nCutIndex = 38;
2045  cutVariableValue = normalizedDecayTimeToDStar;
2046  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
2047  if(!bPassedCut && !fGetCutInfo) return 0;
2048  //---------------------------------------------------------------------
2049  }
2050 
2051  for (Int_t i = 0; i < 39; ++i)
2052  {
2053  if(bCutArray[i]==kTRUE){
2054  returnvalue = 0;
2055  break;
2056  }
2057  }
2058 
2059  return returnvalue;
2060 }
2061 //----------------------------------------------------------------------------------
2063  //
2064  // Apply selection on D0 candidate.
2065  //
2066 
2067  if(!fCutsRDD0forD0ptbin){
2068  cout<<"Cut matrice not inizialized. Exit..."<<endl;
2069  return 0;
2070  }
2071 
2072  AliAODRecoDecayHF2Prong* candidateD0 = (AliAODRecoDecayHF2Prong*)obj;
2073  if(!candidateD0){
2074  cout<<"candidateD0 null"<<endl;
2075  return 0;
2076  }
2077 
2078  AliAODTrack *candidatePion = (AliAODTrack*)candidateD0->GetDaughter(0);
2079  if(!candidatePion){
2080  cout<<"candidatePion null"<<endl;
2081  return 0;
2082  }
2083 
2084  AliAODTrack *candidateKaon = (AliAODTrack*)candidateD0->GetDaughter(1);
2085  if(!candidateKaon){
2086  cout<<"candidateKaon null"<<endl;
2087  return 0;
2088  }
2089 
2090  AliAODVertex * vertexD0 = candidateD0->GetSecondaryVtx();
2091  if(!vertexD0){
2092  cout<<"vertexD0 null"<<endl;
2093  return 0;
2094  }
2095 
2096  AliAODVertex * primaryVertex = aod->GetPrimaryVertex();
2097  if(!primaryVertex){
2098  cout<<"primaryVertex null"<<endl;
2099  return 0;
2100  }
2101 
2102  Int_t returnvalue=1;
2103  Bool_t bPassedCut = kFALSE;
2104 
2105  //get the magnetic field
2106  Double_t bz = (Double_t)aod->GetMagneticField();
2107 
2108 
2109  // selection on candidate
2110  if(selectionLevel==AliRDHFCuts::kAll ||
2111  selectionLevel==AliRDHFCuts::kCandidate) {
2112 
2113  Int_t ptbin=PtBinD0forD0ptbin(candidateD0->Pt());
2114  if(ptbin==-1) return -1;
2115 
2116  // D0mass
2117  Double_t mD0PDG = TDatabasePDG::Instance()->GetParticle(421)->Mass();
2118 
2119  // D0 window - invariant mass
2120  UInt_t prongs[2];
2121  prongs[0] = 211; prongs[1] = 321;
2122  Double_t invMassD0 = candidateD0->InvMass(2,prongs);
2123  Double_t invMassDifference = TMath::Abs(mD0PDG - invMassD0);
2124 
2125  UInt_t prongs2[2];
2126  prongs2[1] = 211; prongs2[0] = 321;
2127  Double_t invMassD02 = candidateD0->InvMass(2,prongs2);
2128  Double_t invMassDifference2 = TMath::Abs(mD0PDG - invMassD02);
2129 
2130  if(invMassDifference > invMassDifference2) invMassDifference = invMassDifference2;
2131 
2132  Double_t pointingAngle = candidateD0->CosPointingAngle();
2133  Double_t dcaMother = candidateD0->GetDCA();
2134  Double_t ptMother = candidateD0->Pt();
2135  Double_t momentumMother = candidateD0->P();
2136  Double_t ptPion = candidatePion->Pt();
2137  Double_t ptKaon = candidateKaon->Pt();
2138 
2139  AliExternalTrackParam motherTrack;
2140  motherTrack.CopyFromVTrack(candidateD0);
2141  Double_t d0z0[2],covd0z0[3],d0[2];
2142  motherTrack.PropagateToDCA(primaryVertex,bz,100.,d0z0,covd0z0);
2143  d0[0] = d0z0[0];
2144  Double_t d0Mother = TMath::Abs(d0[0]);
2145  Double_t d0firstTrack = TMath::Abs(candidateD0->Getd0Prong(0));
2146  Double_t d0secondTrack = TMath::Abs(candidateD0->Getd0Prong(1));
2147 
2148  Double_t impactProduct = candidateD0->Prodd0d0();
2149  Double_t impactProductXY = TMath::Abs(candidateD0->ImpParXY());
2150 
2151  Double_t angleBetweenBothDaughters = (candidateKaon->Px() * candidatePion->Px() + candidateKaon->Py() * candidatePion->Py() + candidateKaon->Pz() * candidatePion->Pz()) /(candidateKaon->P() * candidatePion->P());
2152  Double_t angleMotherFirstDaughter = (candidateD0->Px() * candidatePion->Px() + candidateD0->Py() * candidatePion->Py() + candidateD0->Pz() * candidatePion->Pz()) /(candidateD0->P() * candidatePion->P());
2153  Double_t angleMotherSecondDaughter = (candidateD0->Px() * candidateKaon->Px() + candidateD0->Py() * candidateKaon->Py() + candidateD0->Pz() * candidateKaon->Pz()) /(candidateD0->P() * candidateKaon->P());
2154 
2155  Double_t cosThetaStar = candidateD0->CosThetaStar(0,421,211,321);
2156  Double_t vertexDistance = vertexD0->DistanceToVertex(primaryVertex);
2157  Double_t normDecayLength = candidateD0->NormalizedDecayLength();
2158  Double_t pdgMassMother = TDatabasePDG::Instance()->GetParticle(421)->Mass();
2159  Double_t pseudoProperDecayLength = ((vertexD0->GetX() - primaryVertex->GetX()) * candidateD0->Px() / TMath::Abs(candidateD0->Pt())) + ((vertexD0->GetY() - primaryVertex->GetY()) * candidateD0->Py() / TMath::Abs(candidateD0->Pt()));
2160  Double_t pseudoProperDecayTime = pseudoProperDecayLength * pdgMassMother/ptMother;
2161  Double_t decayTime = vertexDistance / (299792458 * TMath::Sqrt(1/((pdgMassMother*pdgMassMother/(momentumMother*momentumMother)) + 1)));
2162 
2163  Double_t phi = candidateD0->Phi();
2164  Double_t theta = candidateD0->Theta();
2165  Double_t covMatrix[21];
2166  candidateD0->GetCovarianceXYZPxPyPz(covMatrix);
2167 
2168  Double_t cp = TMath::Cos(phi);
2169  Double_t sp = TMath::Sin(phi);
2170  Double_t ct = TMath::Cos(theta);
2171  Double_t st = TMath::Sin(theta);
2172 
2173  Double_t errorMomentum = covMatrix[9]*cp*cp*ct*ct // GetCovPxPx
2174  +covMatrix[13]*2.*cp*sp*ct*ct // GetCovPxPy
2175  +covMatrix[18]*2.*cp*ct*st // GetCovPxPz
2176  +covMatrix[14]*sp*sp*ct*ct // GetCovPyPy
2177  +covMatrix[19]*2.*sp*ct*st // GetCovPyPz
2178  +covMatrix[20]*st*st; // GetCovPzPz
2179  Double_t normalizedDecayTime = candidateD0->NormalizedDecayLength() / (299792458 * TMath::Sqrt(1/((pdgMassMother*pdgMassMother*errorMomentum*errorMomentum/(momentumMother*momentumMother)) + 1)));
2180 
2181  Double_t cosPointingAngleXY = candidateD0->CosPointingAngleXY();
2182  Double_t distanceXYToVertex = vertexD0->DistanceXYToVertex(primaryVertex);
2183  Double_t normalizedDecayLengthXY = candidateD0->NormalizedDecayLengthXY();
2184  Double_t chi2Vertex = vertexD0->GetChi2perNDF();
2185 
2186  //Topomatic
2187  Double_t dd0pr1=0.;
2188  Double_t dd0pr2=0.;
2189  Double_t dd0max=0.;
2190  Double_t dd0min=0.;
2191  for(Int_t ipr=0; ipr<2; ipr++)
2192  {
2193  Double_t diffIP, errdiffIP;
2194  candidateD0->Getd0MeasMinusExpProng(ipr,bz,diffIP,errdiffIP);
2195  Double_t normdd0=0.;
2196  if(errdiffIP>0.) normdd0=diffIP/errdiffIP;
2197  if(ipr==0) dd0pr1=normdd0;
2198  if(ipr==1) dd0pr2=normdd0;
2199  }
2200  if(TMath::Abs(dd0pr1)>TMath::Abs(dd0pr2)) {dd0max=dd0pr1; dd0min=dd0pr2;}
2201  else {dd0max=dd0pr2; dd0min=dd0pr1;}
2202 
2203 
2204  // We apply the cuts
2205  Int_t nCutIndex = 0;
2206  Double_t cutVariableValue = 0.0;
2207 
2208  // "inv. mass width [GeV]" --------------------------------------------
2209  nCutIndex = 0;
2210  cutVariableValue = invMassDifference;
2211  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2212  if(!bPassedCut && !fGetCutInfo) return 0;
2213  //---------------------------------------------------------------------
2214 
2215  // "delta mass width [GeV]" -------------------------------------------
2216  // nCutIndex = 1; // not used for D0
2217  // cutVariableValue = invMassDelta;
2218  // bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2219  // if(!bPassedCut && !fGetCutInfo) return 0;
2220  //---------------------------------------------------------------------
2221 
2222  // "pointing angle [Cos(theta)]" --------------------------------------
2223  nCutIndex = 2;
2224  cutVariableValue = pointingAngle;
2225  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2226  if(!bPassedCut && !fGetCutInfo) return 0;
2227  //---------------------------------------------------------------------
2228 
2229  // "dca [cm]" ---------------------------------------------------------
2230  nCutIndex = 3;
2231  cutVariableValue = dcaMother;
2232  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2233  if(!bPassedCut && !fGetCutInfo) return 0;
2234  //---------------------------------------------------------------------
2235 
2236  // "Pt D0 [GeV/c]" ----------------------------------------------------
2237  nCutIndex = 4;
2238  cutVariableValue = ptMother;
2239  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2240  if(!bPassedCut && !fGetCutInfo) return 0;
2241  //---------------------------------------------------------------------
2242 
2243  // "Pt Kaon [GeV/c]" -------------------------------------------------
2244  nCutIndex = 5;
2245  cutVariableValue = ptKaon;
2246  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2247  if(!bPassedCut && !fGetCutInfo) return 0;
2248  //---------------------------------------------------------------------
2249 
2250  // "Pt Pion [GeV/c]" --------------------------------------------------
2251  nCutIndex = 6;
2252  cutVariableValue = ptPion;
2253  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2254  if(!bPassedCut && !fGetCutInfo) return 0;
2255  //---------------------------------------------------------------------
2256 
2257  // "d0 D0 [cm]" -------------------------------------------------------
2258  nCutIndex = 7;
2259  cutVariableValue = d0Mother;
2260  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2261  if(!bPassedCut && !fGetCutInfo) return 0;
2262  //---------------------------------------------------------------------
2263 
2264  // "d0 Kaon [cm]"-----------------------------------------------------
2265  nCutIndex = 8;
2266  cutVariableValue = d0firstTrack;
2267  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2268  if(!bPassedCut && !fGetCutInfo) return 0;
2269  //---------------------------------------------------------------------
2270 
2271  // "d0 Pion [cm]" -----------------------------------------------------
2272  nCutIndex = 9;
2273  cutVariableValue = d0secondTrack;
2274  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2275  if(!bPassedCut && !fGetCutInfo) return 0;
2276  //---------------------------------------------------------------------
2277 
2278  // "d0d0 [cm^2]" ------------------------------------------------------
2279  nCutIndex = 10;
2280  cutVariableValue = impactProduct;
2281  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2282  if(!bPassedCut && !fGetCutInfo) return 0;
2283  //---------------------------------------------------------------------
2284 
2285  // "d0d0 XY [cm^2]" ---------------------------------------------------
2286  nCutIndex = 11;
2287  cutVariableValue = impactProductXY;
2288  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2289  if(!bPassedCut && !fGetCutInfo) return 0;
2290  //---------------------------------------------------------------------
2291 
2292  // "angle between both daughters" -------------------------------------
2293  nCutIndex = 12;
2294  cutVariableValue = angleBetweenBothDaughters;
2295  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2296  if(!bPassedCut && !fGetCutInfo) return 0;
2297  //---------------------------------------------------------------------
2298 
2299  // "angle mother with first daughter" ---------------------------------
2300  nCutIndex = 13;
2301  cutVariableValue = angleMotherFirstDaughter;
2302  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2303  if(!bPassedCut && !fGetCutInfo) return 0;
2304  //---------------------------------------------------------------------
2305 
2306  // "angle mother with second daughter" --------------------------------
2307  nCutIndex = 14;
2308  cutVariableValue = angleMotherSecondDaughter;
2309  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2310  if(!bPassedCut && !fGetCutInfo) return 0;
2311  //---------------------------------------------------------------------
2312 
2313  // "cosThetaStar" -----------------------------------------------------
2314  nCutIndex = 15;
2315  cutVariableValue = cosThetaStar;
2316  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2317  if(!bPassedCut && !fGetCutInfo) return 0;
2318  //---------------------------------------------------------------------
2319 
2320  // "vertexDistance" ---------------------------------------------------
2321  nCutIndex = 16;
2322  cutVariableValue = vertexDistance;
2323  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2324  if(!bPassedCut && !fGetCutInfo) return 0;
2325  //---------------------------------------------------------------------
2326 
2327  // "pseudoProperDecayTime" --------------------------------------------
2328  nCutIndex = 17;
2329  cutVariableValue = pseudoProperDecayTime;
2330  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2331  if(!bPassedCut && !fGetCutInfo) return 0;
2332  //---------------------------------------------------------------------
2333 
2334  // "DecayTime" --------------------------------------------------------
2335  nCutIndex = 18;
2336  cutVariableValue = decayTime;
2337  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2338  if(!bPassedCut && !fGetCutInfo) return 0;
2339  //---------------------------------------------------------------------
2340 
2341  // "normalizedDecayTime" ----------------------------------------------------
2342  nCutIndex = 19;
2343  cutVariableValue = normalizedDecayTime;
2344  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2345  if(!bPassedCut && !fGetCutInfo) return 0;
2346  //---------------------------------------------------------------------
2347 
2348  // "normDecayLength" --------------------------------------------------
2349  nCutIndex = 20;
2350  cutVariableValue = normDecayLength;
2351  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2352  if(!bPassedCut && !fGetCutInfo) return 0;
2353  //---------------------------------------------------------------------
2354 
2355  // "topomatic first daughter" -----------------------------------------
2356  nCutIndex = 21;
2357  cutVariableValue = dd0pr1;
2358  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2359  if(!bPassedCut && !fGetCutInfo) return 0;
2360  //---------------------------------------------------------------------
2361 
2362  // "topomatic second daughter" ----------------------------------------
2363  nCutIndex = 22;
2364  cutVariableValue = dd0pr2;
2365  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2366  if(!bPassedCut && !fGetCutInfo) return 0;
2367  //---------------------------------------------------------------------
2368 
2369  // "topomatic max" ----------------------------------------------------
2370  nCutIndex = 23;
2371  cutVariableValue = dd0max;
2372  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2373  if(!bPassedCut && !fGetCutInfo) return 0;
2374  //---------------------------------------------------------------------
2375 
2376  // "topomatic min" ----------------------------------------------------
2377  nCutIndex = 24;
2378  cutVariableValue = dd0min;
2379  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2380  if(!bPassedCut && !fGetCutInfo) return 0;
2381  //---------------------------------------------------------------------
2382 
2383  // "pointing angle XY" ----------------------------------------------------
2384  nCutIndex = 25;
2385  cutVariableValue = cosPointingAngleXY;
2386  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2387  if(!bPassedCut && !fGetCutInfo) return 0;
2388  //---------------------------------------------------------------------
2389 
2390  // "vertex distance XY" ----------------------------------------------------
2391  nCutIndex = 26;
2392  cutVariableValue = distanceXYToVertex;
2393  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2394  if(!bPassedCut && !fGetCutInfo) return 0;
2395  //---------------------------------------------------------------------
2396 
2397  // "normalized decay length XY" ----------------------------------------------------
2398  nCutIndex = 27;
2399  cutVariableValue = normalizedDecayLengthXY;
2400  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2401  if(!bPassedCut && !fGetCutInfo) return 0;
2402  //---------------------------------------------------------------------
2403 
2404  // "chi squared per NDF" ----------------------------------------------------
2405  nCutIndex = 28;
2406  cutVariableValue = chi2Vertex;
2407  bPassedCut = ApplyCutOnVariableD0forD0ptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2408  if(!bPassedCut && !fGetCutInfo) return 0;
2409  //---------------------------------------------------------------------
2410 
2411  }
2412 
2413  for (Int_t i = 0; i < 29; ++i)
2414  {
2415  if(bCutArray[i]==kTRUE){
2416  returnvalue = 0;
2417  break;
2418  }
2419  }
2420 
2421  return returnvalue;
2422 }
2423 //----------------------------------------------------------------------------------
2425  //
2426  // 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.
2427  //
2428 
2430  cout<<"Cut matrice not inizialized. Exit..."<<endl;
2431  return 0;
2432  }
2433 
2434  AliAODRecoDecayHF2Prong* candidateDStar = (AliAODRecoDecayHF2Prong*)obj;
2435  if(!candidateDStar){
2436  cout<<"candidateDStar null"<<endl;
2437  return 0;
2438  }
2439 
2440  AliAODRecoDecayHF2Prong* candidateD0 = (AliAODRecoDecayHF2Prong*)candidateDStar->GetDaughter(1);
2441  if(!candidateD0){
2442  cout<<"candidateD0 null"<<endl;
2443  return 0;
2444  }
2445 
2446  AliAODTrack *candidatePion = (AliAODTrack*)candidateD0->GetDaughter(0);
2447  if(!candidatePion){
2448  cout<<"candidatePion null"<<endl;
2449  return 0;
2450  }
2451 
2452  AliAODTrack *candidateKaon = (AliAODTrack*)candidateD0->GetDaughter(1);
2453  if(!candidateKaon){
2454  cout<<"candidateKaon null"<<endl;
2455  return 0;
2456  }
2457 
2458  AliAODVertex * vertexDStar = candidateDStar->GetSecondaryVtx();
2459  if(!vertexDStar){
2460  cout<<"vertexDStar null"<<endl;
2461  return 0;
2462  }
2463 
2464  AliAODVertex * vertexD0 = candidateD0->GetSecondaryVtx();
2465  if(!vertexD0){
2466  cout<<"vertexD0 null"<<endl;
2467  return 0;
2468  }
2469 
2470  AliAODVertex * primaryVertex = aod->GetPrimaryVertex();
2471  if(!primaryVertex){
2472  cout<<"primaryVertex null"<<endl;
2473  return 0;
2474  }
2475 
2476  Int_t returnvalue=1;
2477  Bool_t bPassedCut = kFALSE;
2478 
2479  //get the magnetic field
2480  Double_t bz = (Double_t)aod->GetMagneticField();
2481 
2482 
2483  // selection on candidate
2484  if(selectionLevel==AliRDHFCuts::kAll ||
2485  selectionLevel==AliRDHFCuts::kCandidate) {
2486 
2487  Int_t ptbin=PtBinD0forDStarptbin(candidateDStar->Pt());
2488  if(ptbin==-1) return -1;
2489 
2490  // D0mass
2491  Double_t mD0PDG = TDatabasePDG::Instance()->GetParticle(421)->Mass();
2492 
2493  // D0 window - invariant mass
2494  Int_t chargeDStar = candidateDStar->Charge();
2495  UInt_t prongs[2];
2496  if(chargeDStar==1)
2497  {
2498  prongs[0] = 211;
2499  prongs[1] = 321;
2500  }
2501  else if (chargeDStar==-1)
2502  {
2503  prongs[1] = 211;
2504  prongs[0] = 321;
2505  }
2506  else
2507  {
2508  cout << "Wrong charge DStar." << endl;
2509  return 0;
2510  }
2511  Double_t invMassD0 = candidateD0->InvMass(2,prongs);
2512  Double_t invMassDifference = TMath::Abs(mD0PDG - invMassD0);
2513 
2514  Double_t pointingAngle = candidateD0->CosPointingAngle();
2515  Double_t dcaMother = candidateD0->GetDCA();
2516  Double_t ptMother = candidateD0->Pt();
2517  Double_t momentumMother = candidateD0->P();
2518  Double_t ptPion = candidatePion->Pt();
2519  Double_t ptKaon = candidateKaon->Pt();
2520 
2521  AliExternalTrackParam motherTrack;
2522  motherTrack.CopyFromVTrack(candidateD0);
2523  Double_t d0z0[2],covd0z0[3],d0[2];
2524  motherTrack.PropagateToDCA(primaryVertex,bz,100.,d0z0,covd0z0);
2525  d0[0] = d0z0[0];
2526  Double_t d0Mother = TMath::Abs(d0[0]);
2527  Double_t d0firstTrack = TMath::Abs(candidateD0->Getd0Prong(0));
2528  Double_t d0secondTrack = TMath::Abs(candidateD0->Getd0Prong(1));
2529 
2530  Double_t impactProduct = candidateD0->Prodd0d0();
2531  Double_t impactProductXY = TMath::Abs(candidateD0->ImpParXY());
2532 
2533  Double_t angleBetweenBothDaughters = (candidateKaon->Px() * candidatePion->Px() + candidateKaon->Py() * candidatePion->Py() + candidateKaon->Pz() * candidatePion->Pz()) /(candidateKaon->P() * candidatePion->P());
2534  Double_t angleMotherFirstDaughter = (candidateD0->Px() * candidatePion->Px() + candidateD0->Py() * candidatePion->Py() + candidateD0->Pz() * candidatePion->Pz()) /(candidateD0->P() * candidatePion->P());
2535  Double_t angleMotherSecondDaughter = (candidateD0->Px() * candidateKaon->Px() + candidateD0->Py() * candidateKaon->Py() + candidateD0->Pz() * candidateKaon->Pz()) /(candidateD0->P() * candidateKaon->P());
2536 
2537  Double_t cosThetaStar = candidateD0->CosThetaStar(0,421,211,321);
2538  Double_t vertexDistance = vertexD0->DistanceToVertex(primaryVertex);
2539  Double_t normDecayLength = candidateD0->NormalizedDecayLength();
2540  Double_t pdgMassMother = TDatabasePDG::Instance()->GetParticle(421)->Mass();
2541  Double_t pseudoProperDecayLength = ((vertexD0->GetX() - primaryVertex->GetX()) * candidateD0->Px() / TMath::Abs(candidateD0->Pt())) + ((vertexD0->GetY() - primaryVertex->GetY()) * candidateD0->Py() / TMath::Abs(candidateD0->Pt()));
2542  Double_t pseudoProperDecayTime = pseudoProperDecayLength * pdgMassMother/ptMother;
2543  Double_t decayTime = vertexDistance / (299792458 * TMath::Sqrt(1/((pdgMassMother*pdgMassMother/(momentumMother*momentumMother)) + 1)));
2544 
2545  Double_t phi = candidateD0->Phi();
2546  Double_t theta = candidateD0->Theta();
2547  Double_t covMatrix[21];
2548  candidateD0->GetCovarianceXYZPxPyPz(covMatrix);
2549 
2550  Double_t cp = TMath::Cos(phi);
2551  Double_t sp = TMath::Sin(phi);
2552  Double_t ct = TMath::Cos(theta);
2553  Double_t st = TMath::Sin(theta);
2554 
2555  Double_t errorMomentum = covMatrix[9]*cp*cp*ct*ct // GetCovPxPx
2556  +covMatrix[13]*2.*cp*sp*ct*ct // GetCovPxPy
2557  +covMatrix[18]*2.*cp*ct*st // GetCovPxPz
2558  +covMatrix[14]*sp*sp*ct*ct // GetCovPyPy
2559  +covMatrix[19]*2.*sp*ct*st // GetCovPyPz
2560  +covMatrix[20]*st*st; // GetCovPzPz
2561  Double_t normalizedDecayTime = candidateD0->NormalizedDecayLength() / (299792458 * TMath::Sqrt(1/((pdgMassMother*pdgMassMother*errorMomentum*errorMomentum/(momentumMother*momentumMother)) + 1)));
2562 
2563  Double_t cosPointingAngleXY = candidateD0->CosPointingAngleXY();
2564  Double_t distanceXYToVertex = vertexD0->DistanceXYToVertex(primaryVertex);
2565  Double_t normalizedDecayLengthXY = candidateD0->NormalizedDecayLengthXY();
2566  Double_t chi2Vertex = vertexD0->GetChi2perNDF();
2567 
2568  //Topomatic
2569  Double_t dd0pr1=0.;
2570  Double_t dd0pr2=0.;
2571  Double_t dd0max=0.;
2572  Double_t dd0min=0.;
2573  for(Int_t ipr=0; ipr<2; ipr++)
2574  {
2575  Double_t diffIP, errdiffIP;
2576  candidateD0->Getd0MeasMinusExpProng(ipr,bz,diffIP,errdiffIP);
2577  Double_t normdd0=0.;
2578  if(errdiffIP>0.) normdd0=diffIP/errdiffIP;
2579  if(ipr==0) dd0pr1=normdd0;
2580  if(ipr==1) dd0pr2=normdd0;
2581  }
2582  if(TMath::Abs(dd0pr1)>TMath::Abs(dd0pr2)) {dd0max=dd0pr1; dd0min=dd0pr2;}
2583  else {dd0max=dd0pr2; dd0min=dd0pr1;}
2584 
2585 
2586  // We apply the cuts
2587  Int_t nCutIndex = 0;
2588  Double_t cutVariableValue = 0.0;
2589 
2590  // "inv. mass width [GeV]" --------------------------------------------
2591  nCutIndex = 0;
2592  cutVariableValue = invMassDifference;
2593  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2594  if(!bPassedCut && !fGetCutInfo) return 0;
2595  //---------------------------------------------------------------------
2596 
2597  // "delta mass width [GeV]" -------------------------------------------
2598  // nCutIndex = 1; // not used for D0
2599  // cutVariableValue = invMassDelta;
2600  // bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2601  // if(!bPassedCut && !fGetCutInfo) return 0;
2602  //---------------------------------------------------------------------
2603 
2604  // "pointing angle [Cos(theta)]" --------------------------------------
2605  nCutIndex = 2;
2606  cutVariableValue = pointingAngle;
2607  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2608  if(!bPassedCut && !fGetCutInfo) return 0;
2609  //---------------------------------------------------------------------
2610 
2611  // "dca [cm]" ---------------------------------------------------------
2612  nCutIndex = 3;
2613  cutVariableValue = dcaMother;
2614  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2615  if(!bPassedCut && !fGetCutInfo) return 0;
2616  //---------------------------------------------------------------------
2617 
2618  // "Pt D0 [GeV/c]" ----------------------------------------------------
2619  nCutIndex = 4;
2620  cutVariableValue = ptMother;
2621  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2622  if(!bPassedCut && !fGetCutInfo) return 0;
2623  //---------------------------------------------------------------------
2624 
2625  // "Pt Kaon [GeV/c]" -------------------------------------------------
2626  nCutIndex = 5;
2627  cutVariableValue = ptKaon;
2628  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2629  if(!bPassedCut && !fGetCutInfo) return 0;
2630  //---------------------------------------------------------------------
2631 
2632  // "Pt Pion [GeV/c]" --------------------------------------------------
2633  nCutIndex = 6;
2634  cutVariableValue = ptPion;
2635  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2636  if(!bPassedCut && !fGetCutInfo) return 0;
2637  //---------------------------------------------------------------------
2638 
2639  // "d0 D0 [cm]" -------------------------------------------------------
2640  nCutIndex = 7;
2641  cutVariableValue = d0Mother;
2642  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2643  if(!bPassedCut && !fGetCutInfo) return 0;
2644  //---------------------------------------------------------------------
2645 
2646  // "d0 Kaon [cm]"-----------------------------------------------------
2647  nCutIndex = 8;
2648  cutVariableValue = d0firstTrack;
2649  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2650  if(!bPassedCut && !fGetCutInfo) return 0;
2651  //---------------------------------------------------------------------
2652 
2653  // "d0 Pion [cm]" -----------------------------------------------------
2654  nCutIndex = 9;
2655  cutVariableValue = d0secondTrack;
2656  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2657  if(!bPassedCut && !fGetCutInfo) return 0;
2658  //---------------------------------------------------------------------
2659 
2660  // "d0d0 [cm^2]" ------------------------------------------------------
2661  nCutIndex = 10;
2662  cutVariableValue = impactProduct;
2663  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2664  if(!bPassedCut && !fGetCutInfo) return 0;
2665  //---------------------------------------------------------------------
2666 
2667  // "d0d0 XY [cm^2]" ---------------------------------------------------
2668  nCutIndex = 11;
2669  cutVariableValue = impactProductXY;
2670  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2671  if(!bPassedCut && !fGetCutInfo) return 0;
2672  //---------------------------------------------------------------------
2673 
2674  // "angle between both daughters" -------------------------------------
2675  nCutIndex = 12;
2676  cutVariableValue = angleBetweenBothDaughters;
2677  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2678  if(!bPassedCut && !fGetCutInfo) return 0;
2679  //---------------------------------------------------------------------
2680 
2681  // "angle mother with first daughter" ---------------------------------
2682  nCutIndex = 13;
2683  cutVariableValue = angleMotherFirstDaughter;
2684  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2685  if(!bPassedCut && !fGetCutInfo) return 0;
2686  //---------------------------------------------------------------------
2687 
2688  // "angle mother with second daughter" --------------------------------
2689  nCutIndex = 14;
2690  cutVariableValue = angleMotherSecondDaughter;
2691  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2692  if(!bPassedCut && !fGetCutInfo) return 0;
2693  //---------------------------------------------------------------------
2694 
2695  // "cosThetaStar" -----------------------------------------------------
2696  nCutIndex = 15;
2697  cutVariableValue = cosThetaStar;
2698  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2699  if(!bPassedCut && !fGetCutInfo) return 0;
2700  //---------------------------------------------------------------------
2701 
2702  // "vertexDistance" ---------------------------------------------------
2703  nCutIndex = 16;
2704  cutVariableValue = vertexDistance;
2705  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2706  if(!bPassedCut && !fGetCutInfo) return 0;
2707  //---------------------------------------------------------------------
2708 
2709  // "pseudoProperDecayTime" --------------------------------------------
2710  nCutIndex = 17;
2711  cutVariableValue = pseudoProperDecayTime;
2712  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2713  if(!bPassedCut && !fGetCutInfo) return 0;
2714  //---------------------------------------------------------------------
2715 
2716  // "DecayTime" --------------------------------------------------------
2717  nCutIndex = 18;
2718  cutVariableValue = decayTime;
2719  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2720  if(!bPassedCut && !fGetCutInfo) return 0;
2721  //---------------------------------------------------------------------
2722 
2723  // "normalizedDecayTime" ----------------------------------------------------
2724  nCutIndex = 19;
2725  cutVariableValue = normalizedDecayTime;
2726  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2727  if(!bPassedCut && !fGetCutInfo) return 0;
2728  //---------------------------------------------------------------------
2729 
2730  // "normDecayLength" --------------------------------------------------
2731  nCutIndex = 20;
2732  cutVariableValue = normDecayLength;
2733  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2734  if(!bPassedCut && !fGetCutInfo) return 0;
2735  //---------------------------------------------------------------------
2736 
2737  // "topomatic first daughter" -----------------------------------------
2738  nCutIndex = 21;
2739  cutVariableValue = dd0pr1;
2740  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2741  if(!bPassedCut && !fGetCutInfo) return 0;
2742  //---------------------------------------------------------------------
2743 
2744  // "topomatic second daughter" ----------------------------------------
2745  nCutIndex = 22;
2746  cutVariableValue = dd0pr2;
2747  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2748  if(!bPassedCut && !fGetCutInfo) return 0;
2749  //---------------------------------------------------------------------
2750 
2751  // "topomatic max" ----------------------------------------------------
2752  nCutIndex = 23;
2753  cutVariableValue = dd0max;
2754  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2755  if(!bPassedCut && !fGetCutInfo) return 0;
2756  //---------------------------------------------------------------------
2757 
2758  // "topomatic min" ----------------------------------------------------
2759  nCutIndex = 24;
2760  cutVariableValue = dd0min;
2761  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2762  if(!bPassedCut && !fGetCutInfo) return 0;
2763  //---------------------------------------------------------------------
2764 
2765  // "pointing angle XY" ----------------------------------------------------
2766  nCutIndex = 25;
2767  cutVariableValue = cosPointingAngleXY;
2768  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2769  if(!bPassedCut && !fGetCutInfo) return 0;
2770  //---------------------------------------------------------------------
2771 
2772  // "vertex distance XY" ----------------------------------------------------
2773  nCutIndex = 26;
2774  cutVariableValue = distanceXYToVertex;
2775  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2776  if(!bPassedCut && !fGetCutInfo) return 0;
2777  //---------------------------------------------------------------------
2778 
2779  // "normalized decay length XY" ----------------------------------------------------
2780  nCutIndex = 27;
2781  cutVariableValue = normalizedDecayLengthXY;
2782  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2783  if(!bPassedCut && !fGetCutInfo) return 0;
2784  //---------------------------------------------------------------------
2785 
2786  // "chi squared per NDF" ----------------------------------------------------
2787  nCutIndex = 28;
2788  cutVariableValue = chi2Vertex;
2789  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2790  if(!bPassedCut && !fGetCutInfo) return 0;
2791  //---------------------------------------------------------------------
2792 
2793  AliAODRecoDecay* candidateD0toDStar = (AliAODRecoDecay*)candidateD0;
2794  AliExternalTrackParam pionD0Track;
2795  AliExternalTrackParam kaonD0Track;
2796 
2797  Double_t d0z0DSVert[2],covd0z0DSVert[3],d0DSVert[2];
2798 
2799  pionD0Track.CopyFromVTrack(candidatePion);
2800  pionD0Track.PropagateToDCA(vertexDStar,bz,100.,d0z0DSVert,covd0z0DSVert);
2801  d0DSVert[0] = d0z0DSVert[0];
2802 
2803  kaonD0Track.CopyFromVTrack(candidateKaon);
2804  kaonD0Track.PropagateToDCA(vertexDStar,bz,100.,d0z0DSVert,covd0z0DSVert);
2805  d0DSVert[1] = d0z0DSVert[0];
2806 
2807  AliExternalTrackParam D0Track;
2808  D0Track.CopyFromVTrack(candidateD0);
2809  Double_t d0z0D0DSVert[2],covd0z0D0DSVert[3],d0D0DSVert;
2810  motherTrack.PropagateToDCA(vertexDStar,bz,100.,d0z0D0DSVert,covd0z0D0DSVert);
2811  d0D0DSVert = TMath::Abs(d0z0D0DSVert[0]);
2812 
2813  Double_t impactProductToDStar = d0DSVert[0]*d0DSVert[1];
2814  Double_t impactProductXYToDStar = candidateD0toDStar->ImpParXY(vertexDStar);
2815 
2816  Double_t pointingAngleToDStar = candidateD0toDStar->CosPointingAngle(vertexDStar);
2817  Double_t d0FirstDaughterToDStar = TMath::Abs(d0DSVert[0]);
2818  Double_t d0SecondDaughterToDStar = TMath::Abs(d0DSVert[1]);
2819  Double_t normDecayLengthToDStar = candidateD0toDStar->NormalizedDecayLength(vertexDStar);
2820 
2821  Double_t pseudoProperDecayLengthDSVert = ((vertexD0->GetX() - vertexDStar->GetX()) * candidateD0->Px() / TMath::Abs(candidateD0->Pt())) + ((vertexD0->GetY() - vertexDStar->GetY()) * candidateD0->Py() / TMath::Abs(candidateD0->Pt()));
2822  Double_t pseudoProperDecayTimeToDStar = pseudoProperDecayLengthDSVert * pdgMassMother/ptMother;
2823  Double_t DecayTimeToDStar = vertexDistance / (299792458 * TMath::Sqrt(1/((pdgMassMother*pdgMassMother/(momentumMother*momentumMother)) + 1)));
2824 
2825  Double_t phiDSVert = candidateD0->Phi();
2826  Double_t thetaDSVert = candidateD0->Theta();
2827  Double_t covMatrixDSVert[21];
2828  candidateD0->GetCovarianceXYZPxPyPz(covMatrixDSVert);
2829 
2830  cp = TMath::Cos(phiDSVert);
2831  sp = TMath::Sin(phiDSVert);
2832  ct = TMath::Cos(thetaDSVert);
2833  st = TMath::Sin(thetaDSVert);
2834 
2835  errorMomentum = covMatrix[9]*cp*cp*ct*ct // GetCovPxPx
2836  +covMatrix[13]*2.*cp*sp*ct*ct // GetCovPxPy
2837  +covMatrix[18]*2.*cp*ct*st // GetCovPxPz
2838  +covMatrix[14]*sp*sp*ct*ct // GetCovPyPy
2839  +covMatrix[19]*2.*sp*ct*st // GetCovPyPz
2840  +covMatrix[20]*st*st; // GetCovPzPz
2841  Double_t normalizedDecayTimeToDStar = candidateD0toDStar->NormalizedDecayLength(vertexDStar) / (299792458 * TMath::Sqrt(1/((pdgMassMother*pdgMassMother*errorMomentum*errorMomentum/(momentumMother*momentumMother)) + 1)));
2842 
2843  // "pointingAngleToDStar" ---------------------------------------------
2844  nCutIndex = 29;
2845  cutVariableValue = pointingAngleToDStar;
2846  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2847  if(!bPassedCut && !fGetCutInfo) return 0;
2848  //---------------------------------------------------------------------
2849 
2850  // "d0MotherToDStar" --------------------------------------------------
2851  nCutIndex = 30;
2852  cutVariableValue = d0D0DSVert;
2853  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2854  if(!bPassedCut && !fGetCutInfo) return 0;
2855  //---------------------------------------------------------------------
2856 
2857  // "d0FirstDaughterToDStar" -------------------------------------------
2858  nCutIndex = 31;
2859  cutVariableValue = d0FirstDaughterToDStar;
2860  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2861  if(!bPassedCut && !fGetCutInfo) return 0;
2862  //---------------------------------------------------------------------
2863 
2864  // "d0SecondDaughterToDStar" ------------------------------------------
2865  nCutIndex = 32;
2866  cutVariableValue = d0SecondDaughterToDStar;
2867  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2868  if(!bPassedCut && !fGetCutInfo) return 0;
2869  //---------------------------------------------------------------------
2870 
2871  // "impactProductToDStar" ---------------------------------------------
2872  nCutIndex = 33;
2873  cutVariableValue = impactProductToDStar;
2874  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2875  if(!bPassedCut && !fGetCutInfo) return 0;
2876  //---------------------------------------------------------------------
2877 
2878  // "impactProductXYToDStar" -------------------------------------------
2879  nCutIndex = 34;
2880  cutVariableValue = impactProductXYToDStar;
2881  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2882  if(!bPassedCut && !fGetCutInfo) return 0;
2883  //---------------------------------------------------------------------
2884 
2885  // "normDecayLengthToDStar" -------------------------------------------
2886  nCutIndex = 35;
2887  cutVariableValue = normDecayLengthToDStar;
2888  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2889  if(!bPassedCut && !fGetCutInfo) return 0;
2890  //---------------------------------------------------------------------
2891 
2892  // "pseudoProperDecayTimeToDStar" -------------------------------------
2893  nCutIndex = 36;
2894  cutVariableValue = pseudoProperDecayTimeToDStar;
2895  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2896  if(!bPassedCut && !fGetCutInfo) return 0;
2897  //---------------------------------------------------------------------
2898 
2899  // "DecayTimeToDStar" -------------------------------------------------
2900  nCutIndex = 37;
2901  cutVariableValue = DecayTimeToDStar;
2902  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2903  if(!bPassedCut && !fGetCutInfo) return 0;
2904  //---------------------------------------------------------------------
2905 
2906  // "normalizedDecayTimeToDStar" ---------------------------------------------
2907  nCutIndex = 38;
2908  cutVariableValue = normalizedDecayTimeToDStar;
2909  bPassedCut = ApplyCutOnVariableD0forDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
2910  if(!bPassedCut && !fGetCutInfo) return 0;
2911  //---------------------------------------------------------------------
2912  }
2913 
2914  for (Int_t i = 0; i < 39; ++i)
2915  {
2916  if(bCutArray[i]==kTRUE){
2917  returnvalue = 0;
2918  break;
2919  }
2920  }
2921 
2922  return returnvalue;
2923 }
2924 //---------------------------------------------------------------------------
2926  //
2927  // Apply selection for DStar candidate
2928  //
2929 
2931  cout<<"Cut matrice not inizialized. Exit..."<<endl;
2932  return 0;
2933  }
2934 
2935  AliAODRecoDecayHF2Prong* candidateDStar = (AliAODRecoDecayHF2Prong*)obj;
2936  if(!candidateDStar){
2937  cout<<"candidateDStar null"<<endl;
2938  return 0;
2939  }
2940 
2941  AliAODRecoDecayHF2Prong* candidateD0 = (AliAODRecoDecayHF2Prong*)candidateDStar->GetDaughter(1);
2942  if(!candidateD0){
2943  cout<<"candidateD0 null"<<endl;
2944  return 0;
2945  }
2946 
2947  AliAODTrack *candidatePion = (AliAODTrack*)candidateDStar->GetDaughter(0);
2948  if(!candidatePion){
2949  cout<<"candidatePion null"<<endl;
2950  return 0;
2951  }
2952 
2953  AliAODVertex * vertexDStar = candidateDStar->GetSecondaryVtx();
2954  if(!vertexDStar){
2955  cout<<"vertexDStar null"<<endl;
2956  return 0;
2957  }
2958 
2959  AliAODVertex * primaryVertex = aod->GetPrimaryVertex();
2960  if(!primaryVertex){
2961  cout<<"primaryVertex null"<<endl;
2962  return 0;
2963  }
2964 
2965  Int_t returnvalue=1;
2966  Bool_t bPassedCut = kFALSE;
2967 
2968  //get the magnetic field
2969  Double_t bz = (Double_t)aod->GetMagneticField();
2970 
2971  // selection on candidate
2972  if(selectionLevel==AliRDHFCuts::kAll ||
2973  selectionLevel==AliRDHFCuts::kCandidate) {
2974 
2975  Int_t ptbin=PtBinDStarforDStarptbin(candidateDStar->Pt());
2976  if(ptbin==-1) return -1;
2977 
2978  // DStarMass and D0mass
2979  Double_t mDSPDG = TDatabasePDG::Instance()->GetParticle(413)->Mass();
2980  Double_t mD0PDG = TDatabasePDG::Instance()->GetParticle(421)->Mass();
2981 
2982  // delta mass PDG
2983  Double_t deltaPDG = mDSPDG-mD0PDG;
2984 
2985  // Half width DStar mass
2986  UInt_t prongs[2];
2987  prongs[0] = 211; prongs[1] = 421;
2988  Double_t invMassDStar = candidateDStar->InvMass(2,prongs);
2989  Double_t invMassDifference = TMath::Abs(mDSPDG - invMassDStar);
2990  Double_t invMassDelta = TMath::Abs(deltaPDG-(DeltaInvMassDStarKpipi(candidateDStar)));
2991 
2992  Double_t pointingAngle = candidateDStar->CosPointingAngle();
2993  Double_t dcaMother = candidateDStar->GetDCA();
2994  Double_t ptMother = candidateDStar->Pt();
2995  Double_t momentumMother = candidateDStar->P();
2996  Double_t ptD0 = candidateD0->Pt();
2997  Double_t ptPion = candidatePion->Pt();
2998 
2999  AliExternalTrackParam motherTrack;
3000  motherTrack.CopyFromVTrack(candidateDStar);
3001  Double_t d0z0[2],covd0z0[3],d0[2];
3002  motherTrack.PropagateToDCA(primaryVertex,bz,100.,d0z0,covd0z0);
3003  d0[0] = d0z0[0];
3004  Double_t d0Mother = TMath::Abs(d0[0]);
3005  Double_t d0firstTrack = TMath::Abs(candidateDStar->Getd0Prong(0));
3006  Double_t d0secondTrack = TMath::Abs(candidateDStar->Getd0Prong(1));
3007 
3008  Double_t impactProduct = candidateDStar->Prodd0d0();
3009  Double_t impactProductXY = TMath::Abs(candidateDStar->ImpParXY());
3010 
3011  Double_t angleBetweenBothDaughters = (candidateD0->Px() * candidatePion->Px() + candidateD0->Py() * candidatePion->Py() + candidateD0->Pz() * candidatePion->Pz()) /(candidateD0->P() * candidatePion->P());
3012  Double_t angleMotherFirstDaughter = (candidateDStar->Px() * candidatePion->Px() + candidateDStar->Py() * candidatePion->Py() + candidateDStar->Pz() * candidatePion->Pz()) /(candidateDStar->P() * candidatePion->P());
3013  Double_t angleMotherSecondDaughter = (candidateDStar->Px() * candidateD0->Px() + candidateDStar->Py() * candidateD0->Py() + candidateDStar->Pz() * candidateD0->Pz()) /(candidateDStar->P() * candidateD0->P());
3014 
3015  Double_t cosThetaStar = candidateDStar->CosThetaStar(0,413,211,421);
3016  Double_t vertexDistance = vertexDStar->DistanceToVertex(primaryVertex);
3017  Double_t normDecayLength = candidateDStar->NormalizedDecayLength();
3018  Double_t pdgMassMother = TDatabasePDG::Instance()->GetParticle(413)->Mass();
3019  Double_t pseudoProperDecayLength = ((vertexDStar->GetX() - primaryVertex->GetX()) * candidateDStar->Px() / TMath::Abs(candidateDStar->Pt())) + ((vertexDStar->GetY() - primaryVertex->GetY()) * candidateDStar->Py() / TMath::Abs(candidateDStar->Pt()));
3020  Double_t pseudoProperDecayTime = pseudoProperDecayLength * pdgMassMother/ptMother;
3021  Double_t decayTime = vertexDistance / (299792458 * TMath::Sqrt(1/((pdgMassMother*pdgMassMother/(momentumMother*momentumMother)) + 1)));
3022 
3023  Double_t phi = candidateDStar->Phi();
3024  Double_t theta = candidateDStar->Theta();
3025  Double_t covMatrix[21];
3026  candidateDStar->GetCovarianceXYZPxPyPz(covMatrix);
3027 
3028  Double_t cp = TMath::Cos(phi);
3029  Double_t sp = TMath::Sin(phi);
3030  Double_t ct = TMath::Cos(theta);
3031  Double_t st = TMath::Sin(theta);
3032 
3033  Double_t errorMomentum = covMatrix[9]*cp*cp*ct*ct // GetCovPxPx
3034  +covMatrix[13]*2.*cp*sp*ct*ct // GetCovPxPy
3035  +covMatrix[18]*2.*cp*ct*st // GetCovPxPz
3036  +covMatrix[14]*sp*sp*ct*ct // GetCovPyPy
3037  +covMatrix[19]*2.*sp*ct*st // GetCovPyPz
3038  +covMatrix[20]*st*st; // GetCovPzPz
3039  Double_t normalizedDecayTime = candidateDStar->NormalizedDecayLength() / (299792458 * TMath::Sqrt(1/((pdgMassMother*pdgMassMother*errorMomentum*errorMomentum/(momentumMother*momentumMother)) + 1)));
3040 
3041  Double_t cosPointingAngleXY = candidateDStar->CosPointingAngleXY();
3042  Double_t distanceXYToVertex = vertexDStar->DistanceXYToVertex(primaryVertex);
3043  Double_t normalizedDecayLengthXY = candidateDStar->NormalizedDecayLengthXY();
3044  Double_t chi2Vertex = vertexDStar->GetChi2perNDF();
3045 
3046  //Topomatic
3047  Double_t dd0pr1=0.;
3048  Double_t dd0pr2=0.;
3049  Double_t dd0max=0.;
3050  Double_t dd0min=0.;
3051  for(Int_t ipr=0; ipr<2; ipr++)
3052  {
3053  Double_t diffIP, errdiffIP;
3054  candidateDStar->Getd0MeasMinusExpProng(ipr,bz,diffIP,errdiffIP);
3055  Double_t normdd0=0.;
3056  if(errdiffIP>0.) normdd0=diffIP/errdiffIP;
3057  if(ipr==0) dd0pr1=normdd0;
3058  if(ipr==1) dd0pr2=normdd0;
3059  }
3060  if(TMath::Abs(dd0pr1)>TMath::Abs(dd0pr2)) {dd0max=dd0pr1; dd0min=dd0pr2;}
3061  else {dd0max=dd0pr2; dd0min=dd0pr1;}
3062 
3063 
3064  // We apply the cuts
3065  Int_t nCutIndex = 0;
3066  Double_t cutVariableValue = 0.0;
3067 
3068  // "inv. mass width [GeV]" --------------------------------------------
3069  nCutIndex = 0;
3070  cutVariableValue = invMassDifference;
3071  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
3072  if(!bPassedCut && !fGetCutInfo) return 0;
3073  //---------------------------------------------------------------------
3074 
3075  // "delta mass width [GeV]" -------------------------------------------
3076  nCutIndex = 1;
3077  cutVariableValue = invMassDelta;
3078  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
3079  if(!bPassedCut && !fGetCutInfo) return 0;
3080  //---------------------------------------------------------------------
3081 
3082  // "pointing angle [Cos(theta)]" --------------------------------------
3083  nCutIndex = 2;
3084  cutVariableValue = pointingAngle;
3085  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
3086  if(!bPassedCut && !fGetCutInfo) return 0;
3087  //---------------------------------------------------------------------
3088 
3089  // "dca [cm]" ---------------------------------------------------------
3090  nCutIndex = 3;
3091  cutVariableValue = dcaMother;
3092  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
3093  if(!bPassedCut && !fGetCutInfo) return 0;
3094  //---------------------------------------------------------------------
3095 
3096  // "Pt DStar [GeV/c]" ----------------------------------------------------
3097  nCutIndex = 4;
3098  cutVariableValue = ptMother;
3099  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
3100  if(!bPassedCut && !fGetCutInfo) return 0;
3101  //---------------------------------------------------------------------
3102 
3103  // "Pt D0 [GeV/c]" -------------------------------------------------
3104  nCutIndex = 5;
3105  cutVariableValue = ptD0;
3106  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
3107  if(!bPassedCut && !fGetCutInfo) return 0;
3108  //---------------------------------------------------------------------
3109 
3110  // "Pt Pion [GeV/c]" --------------------------------------------------
3111  nCutIndex = 6;
3112  cutVariableValue = ptPion;
3113  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
3114  if(!bPassedCut && !fGetCutInfo) return 0;
3115  //---------------------------------------------------------------------
3116 
3117  // "d0 DStar [cm]" -------------------------------------------------------
3118  nCutIndex = 7;
3119  cutVariableValue = d0Mother;
3120  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
3121  if(!bPassedCut && !fGetCutInfo) return 0;
3122  //---------------------------------------------------------------------
3123 
3124  // "d0 D0 [cm]"-----------------------------------------------------
3125  nCutIndex = 8;
3126  cutVariableValue = d0firstTrack;
3127  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
3128  if(!bPassedCut && !fGetCutInfo) return 0;
3129  //---------------------------------------------------------------------
3130 
3131  // "d0 Pion [cm]" -----------------------------------------------------
3132  nCutIndex = 9;
3133  cutVariableValue = d0secondTrack;
3134  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
3135  if(!bPassedCut && !fGetCutInfo) return 0;
3136  //---------------------------------------------------------------------
3137 
3138  // "d0d0 [cm^2]" ------------------------------------------------------
3139  nCutIndex = 10;
3140  cutVariableValue = impactProduct;
3141  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
3142  if(!bPassedCut && !fGetCutInfo) return 0;
3143  //---------------------------------------------------------------------
3144 
3145  // "d0d0 XY [cm^2]" ---------------------------------------------------
3146  nCutIndex = 11;
3147  cutVariableValue = impactProductXY;
3148  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
3149  if(!bPassedCut && !fGetCutInfo) return 0;
3150  //---------------------------------------------------------------------
3151 
3152  // "angle between both daughters" -------------------------------------
3153  nCutIndex = 12;
3154  cutVariableValue = angleBetweenBothDaughters;
3155  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
3156  if(!bPassedCut && !fGetCutInfo) return 0;
3157  //---------------------------------------------------------------------
3158 
3159  // "angle mother with first daughter" ---------------------------------
3160  nCutIndex = 13;
3161  cutVariableValue = angleMotherFirstDaughter;
3162  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
3163  if(!bPassedCut && !fGetCutInfo) return 0;
3164  //---------------------------------------------------------------------
3165 
3166  // "angle mother with second daughter" --------------------------------
3167  nCutIndex = 14;
3168  cutVariableValue = angleMotherSecondDaughter;
3169  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
3170  if(!bPassedCut && !fGetCutInfo) return 0;
3171  //---------------------------------------------------------------------
3172 
3173  // "cosThetaStar" -----------------------------------------------------
3174  nCutIndex = 15;
3175  cutVariableValue = cosThetaStar;
3176  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
3177  if(!bPassedCut && !fGetCutInfo) return 0;
3178  //---------------------------------------------------------------------
3179 
3180  // "vertexDistance" ---------------------------------------------------
3181  nCutIndex = 16;
3182  cutVariableValue = vertexDistance;
3183  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
3184  if(!bPassedCut && !fGetCutInfo) return 0;
3185  //---------------------------------------------------------------------
3186 
3187  // "pseudoProperDecayTime" --------------------------------------------
3188  nCutIndex = 17;
3189  cutVariableValue = pseudoProperDecayTime;
3190  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
3191  if(!bPassedCut && !fGetCutInfo) return 0;
3192  //---------------------------------------------------------------------
3193 
3194  // "DecayTime" --------------------------------------------------------
3195  nCutIndex = 18;
3196  cutVariableValue = decayTime;
3197  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
3198  if(!bPassedCut && !fGetCutInfo) return 0;
3199  //---------------------------------------------------------------------
3200 
3201  // "normalizedDecayTime" ----------------------------------------------------
3202  nCutIndex = 19;
3203  cutVariableValue = normalizedDecayTime;
3204  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
3205  if(!bPassedCut && !fGetCutInfo) return 0;
3206  //---------------------------------------------------------------------
3207 
3208  // "normDecayLength" --------------------------------------------------
3209  nCutIndex = 20;
3210  cutVariableValue = normDecayLength;
3211  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
3212  if(!bPassedCut && !fGetCutInfo) return 0;
3213  //---------------------------------------------------------------------
3214 
3215  // "topomatic first daughter" -----------------------------------------
3216  nCutIndex = 21;
3217  cutVariableValue = dd0pr1;
3218  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
3219  if(!bPassedCut && !fGetCutInfo) return 0;
3220  //---------------------------------------------------------------------
3221 
3222  // "topomatic second daughter" ----------------------------------------
3223  nCutIndex = 22;
3224  cutVariableValue = dd0pr2;
3225  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
3226  if(!bPassedCut && !fGetCutInfo) return 0;
3227  //---------------------------------------------------------------------
3228 
3229  // "topomatic max" ----------------------------------------------------
3230  nCutIndex = 23;
3231  cutVariableValue = dd0max;
3232  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
3233  if(!bPassedCut && !fGetCutInfo) return 0;
3234  //---------------------------------------------------------------------
3235 
3236  // "topomatic min" ----------------------------------------------------
3237  nCutIndex = 24;
3238  cutVariableValue = dd0min;
3239  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
3240  if(!bPassedCut && !fGetCutInfo) return 0;
3241  //---------------------------------------------------------------------
3242 
3243  // "pointing angle XY" ----------------------------------------------------
3244  nCutIndex = 25;
3245  cutVariableValue = cosPointingAngleXY;
3246  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
3247  if(!bPassedCut && !fGetCutInfo) return 0;
3248  //---------------------------------------------------------------------
3249 
3250  // "vertex distance XY" ----------------------------------------------------
3251  nCutIndex = 26;
3252  cutVariableValue = distanceXYToVertex;
3253  bPassedCut = ApplyCutOnVariable(nCutIndex,ptbin,cutVariableValue,bCutArray);
3254  if(!bPassedCut && !fGetCutInfo) return 0;
3255  //---------------------------------------------------------------------
3256 
3257  // "normalized decay length XY" ----------------------------------------------------
3258  nCutIndex = 27;
3259  cutVariableValue = normalizedDecayLengthXY;
3260  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
3261  if(!bPassedCut && !fGetCutInfo) return 0;
3262  //---------------------------------------------------------------------
3263 
3264  // "chi squared per NDF" ----------------------------------------------------
3265  nCutIndex = 28;
3266  cutVariableValue = chi2Vertex;
3267  bPassedCut = ApplyCutOnVariableDStarforDStarptbin(nCutIndex,ptbin,cutVariableValue,bCutArray);
3268  if(!bPassedCut && !fGetCutInfo) return 0;
3269  //---------------------------------------------------------------------
3270 
3271  }
3272 
3273  for (Int_t i = 0; i < 29; ++i)
3274  {
3275  if(bCutArray[i]==kTRUE){
3276  returnvalue = 0;
3277  break;
3278  }
3279  }
3280 
3281  return returnvalue;
3282 }
3283 //----------------------------------------------------------------------------------
3285 {
3286  //
3287  // D* fiducial acceptance region // not (yet) used for the B0
3288  //
3289 
3290  // if(fMaxRapidityCand>-998.){
3291  // if(TMath::Abs(y) > fMaxRapidityCand) return kFALSE;
3292  // else return kTRUE;
3293  // }
3294 
3295  // if(pt > 5.) {
3296  // // applying cut for pt > 5 GeV
3297  // AliDebug(4,Form("pt of D* = %f (> 5), cutting at |y| < 0.8\n",pt));
3298  // if (TMath::Abs(y) > 0.8){
3299  // return kFALSE;
3300  // }
3301  // } else {
3302  // // appliying smooth cut for pt < 5 GeV
3303  // Double_t maxFiducialY = -0.2/15*pt*pt+1.9/15*pt+0.5;
3304  // Double_t minFiducialY = 0.2/15*pt*pt-1.9/15*pt-0.5;
3305  // AliDebug(2,Form("pt of D* = %f (< 5), cutting according to the fiducial zone [%f, %f]\n",pt,minFiducialY,maxFiducialY));
3306  // if (y < minFiducialY || y > maxFiducialY){
3307  // return kFALSE;
3308  // }
3309  // }
3310 
3311  return kTRUE;
3312 }
3313 //_______________________________________________________________________________-
3315 {
3316  //
3317  // PID method, n sigma approach default // not used for B0, done seperately for each daughter
3318  //
3319 
3320  // AliAODRecoDecayHF2Prong* dstar = (AliAODRecoDecayHF2Prong*)obj;
3321  // if(!dstar){
3322  // cout<<"AliAODRecoDecayHF2Prong null"<<endl;
3323  // return 0;
3324  // }
3325 
3326  // if(!fUsePID || dstar->Pt() > fMaxPtPid) return 3;
3327 
3328  // AliAODRecoDecayHF2Prong* d0 = (AliAODRecoDecayHF2Prong*)dstar->Get2Prong();
3329  // if(!d0){
3330  // cout<<"AliAODRecoDecayHF2Prong null"<<endl;
3331  // return 0;
3332  // }
3333 
3334  // // here the PID
3335  // AliAODTrack *pos = (AliAODTrack*)dstar->Get2Prong()->GetDaughter(0);
3336  // AliAODTrack *neg = (AliAODTrack*)dstar->Get2Prong()->GetDaughter(1);
3337 
3338  // if (dstar->Charge()>0){
3339  // if(!SelectPID(pos,2)) return 0;//pion+
3340  // if(!SelectPID(neg,3)) return 0;//kaon-
3341  // }else{
3342  // if(!SelectPID(pos,3)) return 0;//kaon+
3343  // if(!SelectPID(neg,2)) return 0;//pion-
3344  // }
3345 
3346  // if ((fPidHF->GetMatch() == 10 || fPidHF->GetMatch() == 11) && fPidHF->GetITS()) { //ITS n sigma band
3347  // AliAODTrack *softPion = (AliAODTrack*) dstar->GetBachelor();
3348 
3349  // if (fPidHF->CheckBands(AliPID::kPion, AliPIDResponse::kITS, softPion) == -1) {
3350  // return 0;
3351  // }
3352  // }
3353 
3354  return 3;
3355 }
3356 //_______________________________________________________________________________-
3358 {
3359  //
3360  // here the PID
3361 
3362  Bool_t isParticle=kTRUE;
3363  if(!fUsePID) return isParticle;
3364  Int_t match = fPidHF->GetMatch();
3365 
3366  if(match == 1){//n-sigma
3367  Bool_t TPCon=TMath::Abs(2)>1e-4?kTRUE:kFALSE;
3368  Bool_t TOFon=TMath::Abs(3)>1e-4?kTRUE:kFALSE;
3369 
3370  Bool_t isTPC=kTRUE;
3371  Bool_t isTOF=kTRUE;
3372 
3373  if (TPCon){//TPC
3374  if(fPidHF->CheckStatus(track,"TPC")){
3375  if(type==2) isTPC=fPidHF->IsPionRaw(track,"TPC");
3376  if(type==3) isTPC=fPidHF->IsKaonRaw(track,"TPC");
3377  }
3378  }
3379  if (TOFon){//TOF
3380  if(fPidHF->CheckStatus(track,"TOF")){
3381  if(type==2) isTOF=fPidHF->IsPionRaw(track,"TOF");
3382  if(type==3) isTOF=fPidHF->IsKaonRaw(track,"TOF");
3383  }
3384  }
3385 
3386  //--------------------------------
3387  // cut on high momentum in the TPC
3388  //--------------------------------
3389  Double_t pPIDcut = track->P();
3390  if(pPIDcut>fTPCflag) isTPC=1;
3391 
3392  isParticle = isTPC&&isTOF;
3393  }
3394 
3395  if(match == 2){//bayesian
3396  //Double_t priors[5]={0.01,0.001,0.3,0.3,0.3};
3397  Double_t prob[5]={1.,1.,1.,1.,1.};
3398 
3399  //fPidHF->SetPriors(priors,5);
3400  // fPidHF->BayesianProbability(track,prob);
3401 
3402  Double_t max=0.;
3403  Int_t k=-1;
3404  for (Int_t i=0; i<5; i++) {
3405  if (prob[i]>max) {k=i; max=prob[i];}
3406  }
3407  isParticle = Bool_t(k==type);
3408  }
3409 
3410  if (match == 10 || match == 11) { //Assymetric PID using histograms
3411  Int_t checkTPC = fPidHF->CheckBands((AliPID::EParticleType) type, AliPIDResponse::kTPC, track);
3412  Int_t checkTOF = fPidHF->CheckBands((AliPID::EParticleType) type, AliPIDResponse::kTOF, track);
3413 
3414  isParticle = checkTPC >= 0 && checkTOF >= 0 ? kTRUE : kFALSE; //Standard: both at least compatible
3415  if (match == 11) { //Extra requirement: at least one identified
3416  isParticle = isParticle && checkTPC+checkTOF >= 1 ? kTRUE : kFALSE;
3417  }
3418  }
3419 
3420  if (match == 12) { //Circular cut
3421  Double_t nSigmaTOF = 0;
3422  Double_t nSigmaTPC = 0;
3423 
3424  Double_t radius = fCircRadius;
3425 
3426  isParticle = kTRUE;
3427  if (radius > 0) {
3428  Int_t TPCok = fPidHF->GetnSigmaTPC(track, type, nSigmaTPC);
3429  Int_t TOFok = fPidHF->GetnSigmaTOF(track, type, nSigmaTOF);
3430  if (TPCok != -1 && TOFok != -1) {
3431  //Both detectors gave PID information
3432  isParticle = TMath::Sqrt(nSigmaTPC*nSigmaTPC + nSigmaTOF*nSigmaTOF) <= radius ? kTRUE : kFALSE;
3433  }
3434  else {
3435  //Maximum one detector gave PID information
3436  if (TPCok != -1) {
3437  isParticle = nSigmaTPC <= radius ? kTRUE : kFALSE;
3438  }
3439  if (TOFok != -1) {
3440  isParticle = nSigmaTOF <= radius ? kTRUE : kFALSE;
3441  }
3442  }
3443  }
3444  }
3445 
3446  return isParticle;
3447 
3448 }
3449 //-------------------------------------------------------------------------------------
3451 {
3455  Int_t chargeDStar = DStar->Charge();
3456 
3457  Double_t e[3];
3458  UInt_t prongs[2];
3459  if(chargeDStar==1){
3460  e[0]=((AliAODRecoDecayHF2Prong*)DStar->GetDaughter(1))->EProng(0,211);
3461  e[1]=((AliAODRecoDecayHF2Prong*)DStar->GetDaughter(1))->EProng(1,321);
3462  prongs[0] = 211;
3463  prongs[1] = 321;
3464  }
3465  else if (chargeDStar==-1)
3466  {
3467  e[0]=((AliAODRecoDecayHF2Prong*)DStar->GetDaughter(1))->EProng(1,211);
3468  e[1]=((AliAODRecoDecayHF2Prong*)DStar->GetDaughter(1))->EProng(0,321);
3469  prongs[1] = 211;
3470  prongs[0] = 321;
3471  }
3472  else
3473  {
3474  cout << "Wrong charge DStar." << endl;
3475  return 0;
3476  }
3477  e[2]=DStar->EProng(0,211);
3478 
3479  Double_t esum = e[0]+e[1]+e[2];
3480  Double_t invMassDStar = TMath::Sqrt(esum*esum-DStar->P2());
3481  Double_t invMassD0 = ((AliAODRecoDecayHF2Prong*)DStar->GetDaughter(1))->InvMass(2,prongs);
3482 
3483  return invMassDStar - invMassD0;
3484 }
3485 //-------------------------------------------------------------------------------------
3487 {
3491 
3492  AliAODRecoDecayHF2Prong * DStar = (AliAODRecoDecayHF2Prong*)B0->GetDaughter(1);
3493  Int_t chargeDStar = DStar->Charge();
3494 
3495  Double_t e[4];
3496  UInt_t prongs[2];
3497  if(chargeDStar==1){
3498  e[1]=((AliAODRecoDecayHF2Prong*)DStar->GetDaughter(1))->EProng(0,211);
3499  e[2]=((AliAODRecoDecayHF2Prong*)DStar->GetDaughter(1))->EProng(1,321);
3500  prongs[0] = 211;
3501  prongs[1] = 321;
3502  }
3503  else if (chargeDStar==-1)
3504  {
3505  e[1]=((AliAODRecoDecayHF2Prong*)DStar->GetDaughter(1))->EProng(1,211);
3506  e[2]=((AliAODRecoDecayHF2Prong*)DStar->GetDaughter(1))->EProng(0,321);
3507  prongs[1] = 211;
3508  prongs[0] = 321;
3509  }
3510  else
3511  {
3512  cout << "Wrong charge DStar." << endl;
3513  return 0;
3514  }
3515  e[0]=DStar->EProng(0,211);
3516  e[3]=B0->EProng(0,211);
3517 
3518  Double_t esum = e[0]+e[1]+e[2]+e[3];
3519  Double_t invMassB0 = TMath::Sqrt(esum*esum-B0->P2());
3520 
3521  Double_t invMassD0 = ((AliAODRecoDecayHF2Prong*)DStar->GetDaughter(1))->InvMass(2,prongs);
3522 
3523  return invMassB0 - invMassD0;
3524 }
3525 
3526 
3527 //---------------------------------------------------------------------------
3528 //
3529 // DO for D0 pt bin functions
3530 //
3531 //---------------------------------------------------------------------------
3532 
3534  //
3535  // store the cuts
3536  //
3537 
3538  if(nVars!=fnVarsD0forD0ptbin) {
3539  printf("Wrong number of variables: it has to be %d\n",fnVarsD0forD0ptbin);
3540  AliFatal("exiting");
3541  }
3542  if(nPtBins!=fnPtBinsD0forD0ptbin) {
3543  printf("Wrong number of pt bins: it has to be %d\n",fnPtBinsD0forD0ptbin);
3544  AliFatal("exiting");
3545  }
3546 
3548 
3549 
3550  for(Int_t iv=0; iv<fnVarsD0forD0ptbin; iv++)
3551  {
3552  for(Int_t ib=0; ib<fnPtBinsD0forD0ptbin; ib++)
3553  {
3554  //check
3555 
3557  {
3558  cout<<"Overflow, exit..."<<endl;
3559  return;
3560  }
3561 
3562  fCutsRDD0forD0ptbin[GetGlobalIndexD0forD0ptbin(iv,ib)] = cutsRDD0forD0ptbin[iv][ib];
3563 
3564  }
3565  }
3566 
3567  return;
3568 }
3569 //---------------------------------------------------------------------------
3571  //
3572  // store the cuts
3573  //
3574  if(glIndex != fGlobalIndexD0forD0ptbin){
3575  cout<<"Wrong array size: it has to be "<<fGlobalIndexD0forD0ptbin<<endl;
3576  AliFatal("exiting");
3577  }
3579 
3580  for(Int_t iGl=0;iGl<fGlobalIndexD0forD0ptbin;iGl++){
3581  fCutsRDD0forD0ptbin[iGl] = cutsRDD0forD0ptbin[iGl];
3582  }
3583  return;
3584 }
3585 //---------------------------------------------------------------------------
3587  //
3588  //give the pt bin where the pt lies.
3589  //
3590  Int_t ptbin=-1;
3591  if(pt<fPtBinLimitsD0forD0ptbin[0])return ptbin;
3592  for (Int_t i=0;i<fnPtBinsD0forD0ptbin;i++){
3593  if(pt<fPtBinLimitsD0forD0ptbin[i+1]) {
3594  ptbin=i;
3595  break;
3596  }
3597  }
3598  return ptbin;
3599 }
3600 //---------------------------------------------------------------------------
3602  // Set the pt bins
3603 
3605  delete [] fPtBinLimitsD0forD0ptbin;
3606  fPtBinLimitsD0forD0ptbin = NULL;
3607  printf("Changing the pt bins\n");
3608  }
3609 
3610  if(nPtBinLimits != fnPtBinsD0forD0ptbin+1){
3611  cout<<"Warning: ptBinLimits dimension "<<nPtBinLimits<<" != nPtBins+1 ("<<fnPtBinsD0forD0ptbin+1<<")\nSetting nPtBins to "<<nPtBinLimits-1<<endl;
3612  SetNPtBinsD0forD0ptbin(nPtBinLimits-1);
3613  }
3614 
3615  fnPtBinLimitsD0forD0ptbin = nPtBinLimits;
3617  //cout<<"Changing also Global Index -> "<<fGlobalIndex<<endl;
3619  for(Int_t ib=0; ib<nPtBinLimits; ib++) fPtBinLimitsD0forD0ptbin[ib]=ptBinLimits[ib];
3620  for(Int_t ib=0; ib<nPtBinLimits; ib++) std::cout << "limit " << ib << " = " << fPtBinLimitsD0forD0ptbin[ib] << std::endl;
3621 
3622  return;
3623 }
3624 
3625 
3626 
3627 //---------------------------------------------------------------------------
3628 //
3629 // DO for DStar pt bin functions
3630 //
3631 //---------------------------------------------------------------------------
3632 
3633 
3635  //
3636  // store the cuts
3637  //
3638  if(nVars!=fnVarsD0forDStarptbin) {
3639  printf("Wrong number of variables: it has to be %d\n",fnVarsD0forDStarptbin);
3640  AliFatal("exiting");
3641  }
3642  if(nPtBins!=fnPtBinsD0forDStarptbin) {
3643  printf("Wrong number of pt bins: it has to be %d\n",fnPtBinsD0forDStarptbin);
3644  AliFatal("exiting");
3645  }
3646 
3648 
3649 
3650  for(Int_t iv=0; iv<fnVarsD0forDStarptbin; iv++)
3651  {
3652  for(Int_t ib=0; ib<fnPtBinsD0forDStarptbin; ib++)
3653  {
3654  //check
3656  {
3657  cout<<"Overflow, exit..."<<endl;
3658  return;
3659  }
3660 
3661  fCutsRDD0forDStarptbin[GetGlobalIndexD0forDStarptbin(iv,ib)] = cutsRDD0forDStarptbin[iv][ib];
3662 
3663  }
3664  }
3665  return;
3666 }
3667 //---------------------------------------------------------------------------
3668 void AliRDHFCutsB0toDStarPi::SetCutsD0forDStarptbin(Int_t glIndex,Float_t *cutsRDD0forDStarptbin){
3669  //
3670  // store the cuts
3671  //
3672  if(glIndex != fGlobalIndexD0forDStarptbin){
3673  cout<<"Wrong array size: it has to be "<<fGlobalIndexD0forDStarptbin<<endl;
3674  AliFatal("exiting");
3675  }
3677 
3678  for(Int_t iGl=0;iGl<fGlobalIndexD0forDStarptbin;iGl++){
3679  fCutsRDD0forDStarptbin[iGl] = cutsRDD0forDStarptbin[iGl];
3680  }
3681  return;
3682 }
3683 //---------------------------------------------------------------------------
3685  //
3686  //give the pt bin where the pt lies.
3687  //
3688  Int_t ptbin=-1;
3689  if(pt<fPtBinLimitsD0forDStarptbin[0])return ptbin;
3690  for (Int_t i=0;i<fnPtBinsD0forDStarptbin;i++){
3691  if(pt<fPtBinLimitsD0forDStarptbin[i+1]) {
3692  ptbin=i;
3693  break;
3694  }
3695  }
3696  return ptbin;
3697 }
3698 //---------------------------------------------------------------------------
3700  // Set the pt bins
3701 
3703  delete [] fPtBinLimitsD0forDStarptbin;
3705  printf("Changing the pt bins\n");
3706  }
3707 
3708  if(nPtBinLimits != fnPtBinsD0forDStarptbin+1){
3709  cout<<"Warning: ptBinLimits dimension "<<nPtBinLimits<<" != nPtBins+1 ("<<fnPtBinsD0forDStarptbin+1<<")\nSetting nPtBins to "<<nPtBinLimits-1<<endl;
3710  SetNPtBinsD0forDStarptbin(nPtBinLimits-1);
3711  }
3712 
3713  fnPtBinLimitsD0forDStarptbin = nPtBinLimits;
3715  //cout<<"Changing also Global Index -> "<<fGlobalIndex<<endl;
3717  for(Int_t ib=0; ib<nPtBinLimits; ib++) fPtBinLimitsD0forDStarptbin[ib]=ptBinLimits[ib];
3718 
3719  return;
3720 }
3721 
3722 
3723 
3724 
3725 //---------------------------------------------------------------------------
3726 //
3727 // DStar for DStar pt bin functions
3728 //
3729 //---------------------------------------------------------------------------
3730 
3731 
3732 
3734  //
3735  // store the cuts
3736  //
3737  if(nVars!=fnVarsDStarforDStarptbin) {
3738  printf("Wrong number of variables: it has to be %d\n",fnVarsDStarforDStarptbin);
3739  AliFatal("exiting");
3740  }
3741  if(nPtBins!=fnPtBinsDStarforDStarptbin) {
3742  printf("Wrong number of pt bins: it has to be %d\n",fnPtBinsDStarforDStarptbin);
3743  AliFatal("exiting");
3744  }
3745 
3747 
3748 
3749  for(Int_t iv=0; iv<fnVarsDStarforDStarptbin; iv++)
3750  {
3751  for(Int_t ib=0; ib<fnPtBinsDStarforDStarptbin; ib++)
3752  {
3753  //check
3755  {
3756  cout<<"Overflow, exit..."<<endl;
3757  return;
3758  }
3759 
3760  fCutsRDDStarforDStarptbin[GetGlobalIndexDStarforDStarptbin(iv,ib)] = cutsRDDStarforDStarptbin[iv][ib];
3761 
3762  }
3763  }
3764  return;
3765 }
3766 //---------------------------------------------------------------------------
3767 void AliRDHFCutsB0toDStarPi::SetCutsDStarforDStarptbin(Int_t glIndex,Float_t *cutsRDDStarforDStarptbin){
3768  //
3769  // store the cuts
3770  //
3771  if(glIndex != fGlobalIndexDStarforDStarptbin){
3772  cout<<"Wrong array size: it has to be "<<fGlobalIndexDStarforDStarptbin<<endl;
3773  AliFatal("exiting");
3774  }
3776 
3777  for(Int_t iGl=0;iGl<fGlobalIndexDStarforDStarptbin;iGl++){
3778  fCutsRDDStarforDStarptbin[iGl] = cutsRDDStarforDStarptbin[iGl];
3779  }
3780  return;
3781 }
3782 //---------------------------------------------------------------------------
3784  //
3785  //give the pt bin where the pt lies.
3786  //
3787  Int_t ptbin=-1;
3788  if(pt<fPtBinLimitsDStarforDStarptbin[0])return ptbin;
3789  for (Int_t i=0;i<fnPtBinsDStarforDStarptbin;i++){
3790  if(pt<fPtBinLimitsDStarforDStarptbin[i+1]) {
3791  ptbin=i;
3792  break;
3793  }
3794  }
3795  return ptbin;
3796 }
3797 //---------------------------------------------------------------------------
3799  // Set the pt bins and initialize the cut values to 0 and use of cuts to kFALSE
3800 
3804  printf("Changing the pt bins\n");
3805  }
3806 
3807  if(nPtBinLimits != fnPtBinsDStarforDStarptbin+1){
3808  cout<<"Warning: ptBinLimits dimension "<<nPtBinLimits<<" != nPtBins+1 ("<<fnPtBinsDStarforDStarptbin+1<<")\nSetting nPtBins to "<<nPtBinLimits-1<<endl;
3809  SetNPtBinsDStarforDStarptbin(nPtBinLimits-1);
3810  }
3811 
3812  fnPtBinLimitsDStarforDStarptbin = nPtBinLimits;
3814 
3816  for(Int_t ib=0; ib<nPtBinLimits; ib++) fPtBinLimitsDStarforDStarptbin[ib]=ptBinLimits[ib];
3817 
3818  return;
3819 }
3820 //---------------------------------------------------------------------------
3821 Int_t AliRDHFCutsB0toDStarPi::ApplyCutOnVariable(Int_t nCutIndex, Int_t ptbin, Float_t cutVariableValue, Bool_t bCutArray[97]){
3822 
3823  if(GetIsCutUsed(nCutIndex,ptbin)==kTRUE)
3824  {
3825  Bool_t bCut = kFALSE;
3826  if(GetIsUpperCut(nCutIndex)==kTRUE)
3827  {
3828  if(cutVariableValue > fCutsRD[GetGlobalIndex(nCutIndex,ptbin)]) bCut = kTRUE;
3829  } else
3830  {
3831  if(cutVariableValue < fCutsRD[GetGlobalIndex(nCutIndex,ptbin)]) bCut = kTRUE;
3832  }
3833  if(bCut == kTRUE) {bCutArray[nCutIndex] = 1; return 0;}
3834  }
3835  return 1;
3836 }
3837 //---------------------------------------------------------------------------
3838 Int_t AliRDHFCutsB0toDStarPi::ApplyCutOnVariableD0forD0ptbin(Int_t nCutIndex, Int_t ptbin, Float_t cutVariableValue, Bool_t bCutArray[29]){
3839 
3840  // std::cout << "index: " << nCutIndex << ", ptbin: " << ptbin << ", used: " << GetIsCutUsedD0forD0ptbin(nCutIndex,ptbin) << ", upper: " << GetIsUpperCutD0forD0ptbin(nCutIndex) << ", value: " << cutVariableValue << ", cutvalue: " << fCutsRDD0forD0ptbin[GetGlobalIndexD0forD0ptbin(nCutIndex,ptbin)] << std::endl;
3841  if(GetIsCutUsedD0forD0ptbin(nCutIndex,ptbin)==kTRUE)
3842  {
3843  Bool_t bCut = kFALSE;
3844  if(GetIsUpperCutD0forD0ptbin(nCutIndex)==kTRUE)
3845  {
3846  if(cutVariableValue > fCutsRDD0forD0ptbin[GetGlobalIndexD0forD0ptbin(nCutIndex,ptbin)]) bCut = kTRUE;
3847  } else
3848  {
3849  if(cutVariableValue < fCutsRDD0forD0ptbin[GetGlobalIndexD0forD0ptbin(nCutIndex,ptbin)]) bCut = kTRUE;
3850  }
3851  if(bCut == kTRUE) {bCutArray[nCutIndex] = 1; return 0;}
3852  }
3853  return 1;
3854 }
3855 //---------------------------------------------------------------------------
3857 
3858  if(GetIsCutUsedD0forDStarptbin(nCutIndex,ptbin)==kTRUE)
3859  {
3860  Bool_t bCut = kFALSE;
3861  if(GetIsUpperCutD0forDStarptbin(nCutIndex)==kTRUE)
3862  {
3863  if(cutVariableValue > fCutsRDD0forDStarptbin[GetGlobalIndexD0forDStarptbin(nCutIndex,ptbin)]) bCut = kTRUE;
3864  } else
3865  {
3866  if(cutVariableValue < fCutsRDD0forDStarptbin[GetGlobalIndexD0forDStarptbin(nCutIndex,ptbin)]) bCut = kTRUE;
3867  }
3868  if(bCut == kTRUE) {bCutArray[nCutIndex] = 1; return 0;}
3869  }
3870  return 1;
3871 }
3872 //---------------------------------------------------------------------------
3874 
3875  if(GetIsCutUsedDStarforDStarptbin(nCutIndex,ptbin)==kTRUE)
3876  {
3877  Bool_t bCut = kFALSE;
3878  if(GetIsUpperCutDStarforDStarptbin(nCutIndex)==kTRUE)
3879  {
3880  if(cutVariableValue > fCutsRDDStarforDStarptbin[GetGlobalIndexDStarforDStarptbin(nCutIndex,ptbin)]) bCut = kTRUE;
3881  } else
3882  {
3883  if(cutVariableValue < fCutsRDDStarforDStarptbin[GetGlobalIndexDStarforDStarptbin(nCutIndex,ptbin)]) bCut = kTRUE;
3884  }
3885  if(bCut == kTRUE) {bCutArray[nCutIndex] = 1; return 0;}
3886  }
3887  return 1;
3888 }
3889 //---------------------------------------------------------------------------
3891  // Set the variable names
3892 
3893  if(fVarNamesD0forD0ptbin) {
3894  delete [] fVarNamesD0forD0ptbin;
3895  fVarNamesD0forD0ptbin = NULL;
3896  //printf("Changing the variable names\n");
3897  }
3898  if(nVars!=fnVarsD0forD0ptbin){
3899  printf("Wrong number of variables: it has to be %d\n",fnVarsD0forD0ptbin);
3900  return;
3901  }
3902  //fnVars=nVars;
3903  fVarNamesD0forD0ptbin = new TString[nVars];
3904  fIsUpperCutD0forD0ptbin = new Bool_t[nVars];
3905  for(Int_t iv=0; iv<nVars; iv++) {
3906  fVarNamesD0forD0ptbin[iv] = varNames[iv];
3907  fIsUpperCutD0forD0ptbin[iv] = isUpperCut[iv];
3908  }
3909 
3910  return;
3911 }
3912 //---------------------------------------------------------------------------
3914  // Set the variable names
3915 
3917  delete [] fVarNamesD0forDStarptbin;
3918  fVarNamesD0forDStarptbin = NULL;
3919  //printf("Changing the variable names\n");
3920  }
3921  if(nVars!=fnVarsD0forDStarptbin){
3922  printf("Wrong number of variables: it has to be %d\n",fnVarsD0forDStarptbin);
3923  return;
3924  }
3925  //fnVars=nVars;
3926  fVarNamesD0forDStarptbin = new TString[nVars];
3927  fIsUpperCutD0forDStarptbin = new Bool_t[nVars];
3928  for(Int_t iv=0; iv<nVars; iv++) {
3929  fVarNamesD0forDStarptbin[iv] = varNames[iv];
3930  fIsUpperCutD0forDStarptbin[iv] = isUpperCut[iv];
3931  }
3932 
3933  return;
3934 }
3935 //---------------------------------------------------------------------------
3937  // Set the variable names
3938 
3940  delete [] fVarNamesDStarforDStarptbin;
3942  //printf("Changing the variable names\n");
3943  }
3944  if(nVars!=fnVarsDStarforDStarptbin){
3945  printf("Wrong number of variables: it has to be %d\n",fnVarsDStarforDStarptbin);
3946  return;
3947  }
3948  //fnVars=nVars;
3949  fVarNamesDStarforDStarptbin = new TString[nVars];
3951  for(Int_t iv=0; iv<nVars; iv++) {
3952  fVarNamesDStarforDStarptbin[iv] = varNames[iv];
3953  fIsUpperCutDStarforDStarptbin[iv] = isUpperCut[iv];
3954  }
3955 
3956  return;
3957 }
3958 //---------------------------------------------------------------------------
3960  // 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.
3961 
3962  if(fIsCutUsed) {
3963  delete [] fIsCutUsed;
3964  fIsCutUsed = NULL;
3965  }
3966 
3967  fIsCutUsed = new Bool_t[(GetNPtBins())*(GetNVars())];
3968  for(Int_t iv=0; iv<(GetNPtBins())*(GetNVars()); iv++) {
3969  fIsCutUsed[iv] = kFALSE;
3970  }
3971 
3972  if(!fCutsRD) fCutsRD = new Float_t[fGlobalIndex];
3973 
3974 
3975  for(Int_t iv=0; iv<fnVars; iv++) {
3976 
3977  for(Int_t ib=0; ib<fnPtBins; ib++) {
3978 
3979  //check
3980  if(GetGlobalIndex(iv,ib)>=fGlobalIndex) {
3981  cout<<"Overflow, exit..."<<endl;
3982  return;
3983  }
3984 
3985  fCutsRD[GetGlobalIndex(iv,ib)] = 0;
3986 
3987  }
3988  }
3989 
3990  // D0 for D0 pt bin
3991 
3993  delete [] fIsCutUsedD0forD0ptbin;
3994  fIsCutUsedD0forD0ptbin = NULL;
3995  }
3996 
3998  for(Int_t iv=0; iv<(GetNPtBinsD0forD0ptbin())*(GetNVarsD0forD0ptbin()); iv++) {
3999  fIsCutUsedD0forD0ptbin[iv] = kFALSE;
4000 
4001  }
4002 
4004 
4005  for(Int_t iv=0; iv<fnVarsD0forD0ptbin; iv++)
4006  {
4007  for(Int_t ib=0; ib<fnPtBinsD0forD0ptbin; ib++)
4008  {
4009  //check
4010 
4012  {
4013  cout<<"Overflow, exit..."<<endl;
4014  return;
4015  }
4016 
4018  }
4019  }
4020 
4021  // D0 for DStar pt bin
4022 
4024  delete [] fIsCutUsedD0forDStarptbin;
4026  }
4027 
4029  for(Int_t iv=0; iv<(GetNPtBinsD0forDStarptbin())*(GetNVarsD0forDStarptbin()); iv++) {
4030  fIsCutUsedD0forDStarptbin[iv] = kFALSE;
4031  }
4032 
4034 
4035 
4036  for(Int_t iv=0; iv<fnVarsD0forDStarptbin; iv++)
4037  {
4038  for(Int_t ib=0; ib<fnPtBinsD0forDStarptbin; ib++)
4039  {
4040  //check
4042  {
4043  cout<<"Overflow, exit..."<<endl;
4044  return;
4045  }
4046 
4048 
4049  }
4050  }
4051 
4052  // DStar for DStar pt bin
4053 
4055  delete [] fIsCutUsedDStarforDStarptbin;
4057  }
4058 
4060  for(Int_t iv=0; iv<(GetNPtBinsDStarforDStarptbin())*(GetNVarsDStarforDStarptbin()); iv++) {
4061  fIsCutUsedDStarforDStarptbin[iv] = kFALSE;
4062  }
4063 
4065 
4066 
4067  for(Int_t iv=0; iv<fnVarsDStarforDStarptbin; iv++)
4068  {
4069  for(Int_t ib=0; ib<fnPtBinsDStarforDStarptbin; ib++)
4070  {
4071  //check
4073  {
4074  cout<<"Overflow, exit..."<<endl;
4075  return;
4076  }
4077 
4079 
4080  }
4081  }
4082 
4083  return;
4084 }
4085 //---------------------------------------------------------------------------
4087  // Set the cut value and direction
4088 
4089  fIsCutUsed[GetGlobalIndex(nCutIndex,ptBin)] = kTRUE;
4090  fIsUpperCut[nCutIndex] = cutDirection;
4091  fCutsRD[GetGlobalIndex(nCutIndex,ptBin)] = cutValue;
4092 
4093  return;
4094 }
4095 //---------------------------------------------------------------------------
4097  // Set the cut value and direction
4098 
4099  fIsCutUsedD0forD0ptbin[GetGlobalIndexD0forD0ptbin(nCutIndex,ptBin)] = kTRUE;
4100  fIsUpperCutD0forD0ptbin[nCutIndex] = cutDirection;
4101  fCutsRDD0forD0ptbin[GetGlobalIndexD0forD0ptbin(nCutIndex,ptBin)] = cutValue;
4102 
4103  return;
4104 }
4105 //---------------------------------------------------------------------------
4107  // Set the cut value and direction
4108 
4109  fIsCutUsedD0forDStarptbin[GetGlobalIndexD0forDStarptbin(nCutIndex,ptBin)] = kTRUE;
4110  fIsUpperCutD0forDStarptbin[nCutIndex] = cutDirection;
4111  fCutsRDD0forDStarptbin[GetGlobalIndexD0forDStarptbin(nCutIndex,ptBin)] = cutValue;
4112 
4113  return;
4114 }
4115 //---------------------------------------------------------------------------
4117  // Set the cut value and direction
4118 
4120  fIsUpperCutDStarforDStarptbin[nCutIndex] = cutDirection;
4121  fCutsRDDStarforDStarptbin[GetGlobalIndexDStarforDStarptbin(nCutIndex,ptBin)] = cutValue;
4122 
4123  return;
4124 }
4125 //---------------------------------------------------------------------------
Double_t NormalizedDecayLengthXY() const
Int_t fIsSelectedCuts
fix the daughter track references
Definition: AliRDHFCuts.h:476
void SetVarNamesDStarforDStarptbin(Int_t nVars, TString *varNames, Bool_t *isUpperCut)
Double_t NormalizedDecayLength() const
Int_t GetGlobalIndexDStarforDStarptbin(Int_t iVar, Int_t iPtBin) const
void SetSoftSelectionArrayITSDStarPion(const Bool_t array[7]=0)
Bool_t GetIsUpperCutDStarforDStarptbin(Int_t nCutIndex)
Int_t GetNVars() const
Definition: AliRDHFCuts.h:264
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)
Int_t ApplyCutOnVariable(Int_t nCutIndex, Int_t ptbin, Float_t cutVariableValue, Bool_t bCutArray[97])
void SetCutsD0forDStarptbin(Int_t nVars, Int_t nPtBins, Float_t **cutsRDD0forDStarptbin)
void SetSoftSelectionArrayITSB0Pion(const Bool_t array[7]=0)
Bool_t fHardSelectionArrayITSD0SecondDaughter[7]
virtual Int_t IsSelectedPID(AliAODRecoDecayHF *rd)
void SetCutsDStarforDStarptbin(Int_t nVars, Int_t nPtBins, Float_t **cutsRDDStarforDStarptbin)
Bool_t * fIsUpperCut
Definition: AliRDHFCuts.h:454
Bool_t IsKaonRaw(AliAODTrack *track, TString detector) const
Bool_t GetIsCutUsedD0forD0ptbin(Int_t nCutIndex, Int_t ptbin) const
Double_t DeltaInvMassDStarKpipi(AliAODRecoDecayHF2Prong *DStar) const
Int_t GetnSigmaTPC(AliAODTrack *track, Int_t species, Double_t &sigma) const
Int_t GetNVarsDStarforDStarptbin() const
Double_t bz
void SetHardSelectionArrayITSB0Pion(const Bool_t array[7]=0)
void SetIsCutUsedD0forDStarptbin(Int_t nCutIndex, Int_t ptbin, Bool_t isCutUsed)
Double_t ImpParXY() const
Int_t IsDStarFromB0Selected(Double_t pt, TObject *obj, Int_t selectionLevel, AliAODEvent *aod, Bool_t *bCutArray)
Bool_t GetIsUpperCutD0forD0ptbin(Int_t nCutIndex)
void InvMass(Int_t icalo, TString particle, TString fileName)
void SetNVars(Int_t nVars)
Definition: AliRDHFCuts.h:424
Int_t PtBinDStarforDStarptbin(Double_t pt) const
Double_t CosPointingAngleXY() 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)
Bool_t GetIsCutUsedD0forDStarptbin(Int_t nCutIndex, Int_t ptbin) const
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)
Bool_t fUsePID
Definition: AliRDHFCuts.h:455
Int_t PtBinD0forDStarptbin(Double_t pt) const
void SetPtBinsD0forD0ptbin(Int_t nPtBinLimits, Float_t *ptBinLimits)
Int_t ApplyCutOnVariableD0forD0ptbin(Int_t nCutIndex, Int_t ptbin, Float_t cutVariableValue, Bool_t bCutArray[29])
const Int_t nPtBins
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:275
void SetCut(Int_t nCutIndex, Int_t ptBin, AliRDHFCutsB0toDStarPi::EUpperCut cutDirection, Float_t cutValue)
void SetIsCutUsedDStarforDStarptbin(Int_t nCutIndex, Int_t ptbin, Bool_t isCutUsed)
Bool_t GetIsCutUsed(Int_t nCutIndex, Int_t ptbin) const
unsigned int UInt_t
Definition: External.C:33
void SetHardSelectionArrayITSD0FirstDaughter(const Bool_t array[7]=0)
float Float_t
Definition: External.C:68
void SetHardSelectionArrayITSD0SecondDaughter(const Bool_t array[7]=0)
void SetIsCutUsedD0forD0ptbin(Int_t nCutIndex, Int_t ptbin, Bool_t isCutUsed)
void SetIsCutUsed(Int_t nCutIndex, Int_t ptbin, Bool_t isCutUsed)
virtual Int_t IsSelected(TObject *obj, Int_t selectionLevel, AliAODEvent *aod, Bool_t *bCutArray)
void SetPtBinsD0forDStarptbin(Int_t nPtBinLimits, Float_t *ptBinLimits)
AliRDHFCutsB0toDStarPi & operator=(const AliRDHFCutsB0toDStarPi &source)
Bool_t CheckStatus(AliAODTrack *track, TString detectors) const
Int_t IsDStarforDStarptbinSelected(TObject *obj, Int_t selectionLevel, AliAODEvent *aod, Bool_t *bCutArray)
Bool_t GetIsCutUsedDStarforDStarptbin(Int_t nCutIndex, Int_t ptbin) const
Int_t GetNPtBinsD0forD0ptbin() const
void SetNVarsDStarforDStarptbin(Int_t nVars)
void SetSoftSelectionArrayITSD0SecondDaughter(const Bool_t array[7]=0)
Int_t fIsSelectedPID
outcome of cuts selection
Definition: AliRDHFCuts.h:477
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:453
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 ApplyCutOnVariableDStarforDStarptbin(Int_t nCutIndex, Int_t ptbin, Float_t cutVariableValue, Bool_t bCutArray[29])
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
void SetSoftSelectionArrayITSD0FirstDaughter(const Bool_t array[7]=0)
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:263
bool Bool_t
Definition: External.C:53
Double_t CosPointingAngle() const
Int_t fnPtBins
cuts on the candidate
Definition: AliRDHFCuts.h:445
Double_t DeltaInvMassB0Kpipipi(AliAODRecoDecayHF2Prong *B0) const
Bool_t fGetCutInfo
Radius for circular PID nsigma cut.
AliAODPidHF * fPidHF
enable AOD049 centrality cleanup
Definition: AliRDHFCuts.h:457
Int_t fGlobalIndex
Definition: AliRDHFCuts.h:452
Int_t PtBin(Double_t pt) const
Bool_t fSoftSelectionArrayITSD0SecondDaughter[7]
Int_t GetGlobalIndex(Int_t iVar, Int_t iPtBin) const
Int_t ApplyCutOnVariableD0forDStarptbin(Int_t nCutIndex, Int_t ptbin, Float_t cutVariableValue, Bool_t bCutArray[39])
AliRDHFCutsB0toDStarPi(const char *name="B0toDStarPiCuts")
void SetHardSelectionArrayITSDStarPion(const Bool_t array[7]=0)
Int_t fnVars
Definition: AliRDHFCuts.h:448