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