AliPhysics  a0db429 (a0db429)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
AliAnalysisVertexingHF.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-2007, 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$ */
17 
18 //----------------------------------------------------------------------------
19 // Implementation of the heavy-flavour vertexing analysis class
20 // Candidates are stored in the AOD as objects deriving from AliAODRecoDecay.
21 // To be used as a task of AliAnalysisManager by means of the interface
22 // class AliAnalysisTaskSEVertexingHF.
23 // An example of usage in the macro AliAnalysisTaskSEVertexingHFTest.C.
24 //
25 // Contact: andrea.dainese@pd.infn.it
26 // Contributors: E.Bruna, G.E.Bruno, A.Dainese, C.Di Gliglio,
27 // F.Prino, R.Romita, X.M.Zhang
28 //----------------------------------------------------------------------------
29 #include <Riostream.h>
30 #include <TFile.h>
31 #include <TDatabasePDG.h>
32 #include <TString.h>
33 #include <TList.h>
34 #include "AliLog.h"
35 #include "AliVEvent.h"
36 #include "AliVVertex.h"
37 #include "AliVTrack.h"
38 #include "AliVertexerTracks.h"
39 #include "AliKFVertex.h"
40 #include "AliESDEvent.h"
41 #include "AliESDVertex.h"
42 #include "AliExternalTrackParam.h"
43 #include "AliNeutralTrackParam.h"
44 #include "AliESDtrack.h"
45 #include "AliESDtrackCuts.h"
46 #include "AliAODEvent.h"
47 #include "AliPIDResponse.h"
48 #include "AliAODRecoDecay.h"
49 #include "AliAODRecoDecayHF.h"
53 #include "AliAODRecoCascadeHF.h"
54 #include "AliRDHFCutsD0toKpi.h"
55 #include "AliRDHFCutsJpsitoee.h"
57 #include "AliRDHFCutsDstoKKpi.h"
58 #include "AliRDHFCutsLctopKpi.h"
59 #include "AliRDHFCutsLctoV0.h"
60 #include "AliRDHFCutsD0toKpipipi.h"
62 #include "AliAnalysisFilter.h"
63 #include "AliAnalysisVertexingHF.h"
64 #include "AliMixedEvent.h"
65 #include "AliESDv0.h"
66 #include "AliAODv0.h"
67 #include "AliCodeTimer.h"
68 #include "AliMultSelection.h"
69 #include <cstring>
70 
74 
75 //----------------------------------------------------------------------------
77 fInputAOD(kFALSE),
78 fAODMapSize(0),
79 fAODMap(0),
80 fVertexerTracks(0x0),
81 fBzkG(0.),
82 fSecVtxWithKF(kFALSE),
83 fRecoPrimVtxSkippingTrks(kFALSE),
84 fRmTrksFromPrimVtx(kFALSE),
85 fV1(0x0),
86 fD0toKpi(kTRUE),
87 fJPSItoEle(kTRUE),
88 f3Prong(kTRUE),
89 f4Prong(kTRUE),
90 fDstar(kTRUE),
91 fCascades(kTRUE),
92 fLikeSign(kFALSE),
93 fLikeSign3prong(kFALSE),
94 fMixEvent(kFALSE),
95 fPidResponse(0x0),
96 fUseKaonPIDfor3Prong(kFALSE),
97 fUsePIDforLc(0),
98 fUsePIDforLc2V0(0),
99 fUseKaonPIDforDs(kFALSE),
100 fUseTPCPID(kFALSE),
101 fUseTOFPID(kFALSE),
102 fUseTPCPIDOnlyIfNoTOF(kFALSE),
103 fMaxMomForTPCPid(1.),
104 fUsePidTag(kFALSE),
105 fnSigmaTPCPionLow(5.),
106 fnSigmaTPCPionHi(5.),
107 fnSigmaTOFPionLow(5.),
108 fnSigmaTOFPionHi(5.),
109 fnSigmaTPCKaonLow(5.),
110 fnSigmaTPCKaonHi(5.),
111 fnSigmaTOFKaonLow(5.),
112 fnSigmaTOFKaonHi(5.),
113 fnSigmaTPCProtonLow(5.),
114 fnSigmaTPCProtonHi(5.),
115 fnSigmaTOFProtonLow(5.),
116 fnSigmaTOFProtonHi(5.),
117 fMaxCentPercentileForTightCuts(-9999),
118 fTrackFilter(0x0),
119 fTrackFilter2prongCentral(0x0),
120 fTrackFilter3prongCentral(0x0),
121 fTrackFilterSoftPi(0x0),
122 fCutsD0toKpi(0x0),
123 fCutsJpsitoee(0x0),
124 fCutsDplustoKpipi(0x0),
125 fCutsDstoKKpi(0x0),
126 fCutsLctopKpi(0x0),
127 fCutsLctoV0(0x0),
128 fCutsD0toKpipipi(0x0),
129 fCutsDStartoKpipi(0x0),
130 fListOfCuts(0x0),
131 fFindVertexForDstar(kTRUE),
132 fFindVertexForCascades(kTRUE),
133 fV0TypeForCascadeVertex(0),
134 fMassCutBeforeVertexing(kFALSE),
135 fMassCalc2(0),
136 fMassCalc3(0),
137 fMassCalc4(0),
138 fOKInvMassD0(kFALSE),
139 fOKInvMassJpsi(kFALSE),
140 fOKInvMassDplus(kFALSE),
141 fOKInvMassDs(kFALSE),
142 fOKInvMassLc(kFALSE),
143 fOKInvMassDstar(kFALSE),
144 fOKInvMassD0to4p(kFALSE),
145 fOKInvMassLctoV0(kFALSE),
146 fnTrksTotal(0),
147 fnSeleTrksTotal(0),
148 fMakeReducedRHF(kFALSE),
149 fMassDzero(0.),
150 fMassDplus(0.),
151 fMassDs(0.),
152 fMassLambdaC(0.),
153 fMassDstar(0.),
154 fMassJpsi(0.)
155 {
157 
158  Double_t d02[2]={0.,0.};
159  Double_t d03[3]={0.,0.,0.};
160  Double_t d04[4]={0.,0.,0.,0.};
161  fMassCalc2 = new AliAODRecoDecay(0x0,2,0,d02);
162  fMassCalc3 = new AliAODRecoDecay(0x0,3,1,d03);
163  fMassCalc4 = new AliAODRecoDecay(0x0,4,0,d04);
164  SetMasses();
165 }
166 //--------------------------------------------------------------------------
168 TNamed(source),
169 fInputAOD(source.fInputAOD),
170 fAODMapSize(source.fAODMapSize),
171 fAODMap(source.fAODMap),
172 fVertexerTracks(source.fVertexerTracks),
173 fBzkG(source.fBzkG),
174 fSecVtxWithKF(source.fSecVtxWithKF),
175 fRecoPrimVtxSkippingTrks(source.fRecoPrimVtxSkippingTrks),
176 fRmTrksFromPrimVtx(source.fRmTrksFromPrimVtx),
177 fV1(source.fV1),
178 fD0toKpi(source.fD0toKpi),
179 fJPSItoEle(source.fJPSItoEle),
180 f3Prong(source.f3Prong),
181 f4Prong(source.f4Prong),
182 fDstar(source.fDstar),
183 fCascades(source.fCascades),
184 fLikeSign(source.fLikeSign),
185 fLikeSign3prong(source.fLikeSign3prong),
186 fMixEvent(source.fMixEvent),
187 fPidResponse(source.fPidResponse),
188 fUseKaonPIDfor3Prong(source.fUseKaonPIDfor3Prong),
189 fUsePIDforLc(source.fUsePIDforLc),
190 fUsePIDforLc2V0(source.fUsePIDforLc2V0),
191 fUseKaonPIDforDs(source.fUseKaonPIDforDs),
192 fUseTPCPID(source.fUseTPCPID),
193 fUseTOFPID(source.fUseTOFPID),
194 fUseTPCPIDOnlyIfNoTOF(source.fUseTPCPIDOnlyIfNoTOF),
195 fMaxMomForTPCPid(source.fMaxMomForTPCPid),
196 fUsePidTag(source.fUsePidTag),
197 fnSigmaTPCPionLow(source.fnSigmaTPCPionLow),
198 fnSigmaTPCPionHi(source.fnSigmaTPCPionHi),
199 fnSigmaTOFPionLow(source.fnSigmaTOFPionLow),
200 fnSigmaTOFPionHi(source.fnSigmaTOFPionHi),
201 fnSigmaTPCKaonLow(source.fnSigmaTPCKaonLow),
202 fnSigmaTPCKaonHi(source.fnSigmaTPCKaonHi),
203 fnSigmaTOFKaonLow(source.fnSigmaTOFKaonLow),
204 fnSigmaTOFKaonHi(source.fnSigmaTOFKaonHi),
205 fnSigmaTPCProtonLow(source.fnSigmaTPCProtonLow),
206 fnSigmaTPCProtonHi(source.fnSigmaTPCProtonHi),
207 fnSigmaTOFProtonLow(source.fnSigmaTOFProtonLow),
208 fnSigmaTOFProtonHi(source.fnSigmaTOFProtonHi),
209 fMaxCentPercentileForTightCuts(source.fMaxCentPercentileForTightCuts),
210 fTrackFilter(source.fTrackFilter),
211 fTrackFilter2prongCentral(source.fTrackFilter2prongCentral),
212 fTrackFilter3prongCentral(source.fTrackFilter3prongCentral),
213 fTrackFilterSoftPi(source.fTrackFilterSoftPi),
214 fCutsD0toKpi(source.fCutsD0toKpi),
215 fCutsJpsitoee(source.fCutsJpsitoee),
216 fCutsDplustoKpipi(source.fCutsDplustoKpipi),
217 fCutsDstoKKpi(source.fCutsDstoKKpi),
218 fCutsLctopKpi(source.fCutsLctopKpi),
219 fCutsLctoV0(source.fCutsLctoV0),
220 fCutsD0toKpipipi(source.fCutsD0toKpipipi),
221 fCutsDStartoKpipi(source.fCutsDStartoKpipi),
222 fListOfCuts(source.fListOfCuts),
223 fFindVertexForDstar(source.fFindVertexForDstar),
224 fFindVertexForCascades(source.fFindVertexForCascades),
225 fV0TypeForCascadeVertex(source.fV0TypeForCascadeVertex),
226 fMassCutBeforeVertexing(source.fMassCutBeforeVertexing),
227 fMassCalc2(source.fMassCalc2),
228 fMassCalc3(source.fMassCalc3),
229 fMassCalc4(source.fMassCalc4),
230 fOKInvMassD0(source.fOKInvMassD0),
231 fOKInvMassJpsi(source.fOKInvMassJpsi),
232 fOKInvMassDplus(source.fOKInvMassDplus),
233 fOKInvMassDs(source.fOKInvMassDs),
234 fOKInvMassLc(source.fOKInvMassLc),
235 fOKInvMassDstar(source.fOKInvMassDstar),
236 fOKInvMassD0to4p(source.fOKInvMassD0to4p),
237 fOKInvMassLctoV0(source.fOKInvMassLctoV0),
238 fnTrksTotal(0),
239 fnSeleTrksTotal(0),
240 fMakeReducedRHF(kFALSE),
241 fMassDzero(source.fMassDzero),
242 fMassDplus(source.fMassDplus),
243 fMassDs(source.fMassDs),
244 fMassLambdaC(source.fMassLambdaC),
245 fMassDstar(source.fMassDstar),
246 fMassJpsi(source.fMassJpsi)
247 {
251 }
252 //--------------------------------------------------------------------------
254 {
258  if(&source == this) return *this;
259  fInputAOD = source.fInputAOD;
260  fAODMapSize = source.fAODMapSize;
262  fBzkG = source.fBzkG;
263  fSecVtxWithKF = source.fSecVtxWithKF;
266  fV1 = source.fV1;
267  fD0toKpi = source.fD0toKpi;
268  fJPSItoEle = source.fJPSItoEle;
269  f3Prong = source.f3Prong;
270  f4Prong = source.f4Prong;
271  fDstar = source.fDstar;
272  fCascades = source.fCascades;
273  fLikeSign = source.fLikeSign;
275  fMixEvent = source.fMixEvent;
276  fPidResponse = source.fPidResponse;
278  fUsePIDforLc = source.fUsePIDforLc;
281  fUseTPCPID = source.fUseTPCPID;
282  fUseTOFPID = source.fUseTOFPID;
285  fUsePidTag = source.fUsePidTag;
301  fTrackFilter = source.fTrackFilter;
305  fCutsD0toKpi = source.fCutsD0toKpi;
306  fCutsJpsitoee = source.fCutsJpsitoee;
308  fCutsDstoKKpi = source.fCutsDstoKKpi;
309  fCutsLctopKpi = source.fCutsLctopKpi;
310  fCutsLctoV0 = source.fCutsLctoV0;
313  fListOfCuts = source.fListOfCuts;
318  fMassCalc2 = source.fMassCalc2;
319  fMassCalc3 = source.fMassCalc3;
320  fMassCalc4 = source.fMassCalc4;
321  fOKInvMassD0 = source.fOKInvMassD0;
324  fOKInvMassDs = source.fOKInvMassDs;
325  fOKInvMassLc = source.fOKInvMassLc;
329  fMassDzero = source.fMassDzero;
330  fMassDplus = source.fMassDplus;
331  fMassDs = source.fMassDs;
332  fMassLambdaC = source.fMassLambdaC;
333  fMassDstar = source.fMassDstar;
334  fMassJpsi = source.fMassJpsi;
335 
336  return *this;
337 }
338 //----------------------------------------------------------------------------
341  if(fV1) { delete fV1; fV1=0; }
342  delete fVertexerTracks;
343  if(fTrackFilter) { delete fTrackFilter; fTrackFilter=0; }
347  if(fCutsD0toKpi) { delete fCutsD0toKpi; fCutsD0toKpi=0; }
348  if(fCutsJpsitoee) { delete fCutsJpsitoee; fCutsJpsitoee=0; }
350  if(fCutsDstoKKpi) { delete fCutsDstoKKpi; fCutsDstoKKpi=0; }
351  if(fCutsLctopKpi) { delete fCutsLctopKpi; fCutsLctopKpi=0; }
352  if(fCutsLctoV0) { delete fCutsLctoV0; fCutsLctoV0=0; }
355  if(fAODMap) { delete [] fAODMap; fAODMap=0; }
356  if(fMassCalc2) { delete fMassCalc2; fMassCalc2=0; }
357  if(fMassCalc3) { delete fMassCalc3; fMassCalc3=0; }
358  if(fMassCalc4) { delete fMassCalc4; fMassCalc4=0; }
359 }
360 //----------------------------------------------------------------------------
363 
364  TList *list = new TList();
365  list->SetOwner();
366  list->SetName("ListOfCuts");
367 
368  if(fCutsD0toKpi) {
370  list->Add(cutsD0toKpi);
371  }
372  if(fCutsJpsitoee) {
374  list->Add(cutsJpsitoee);
375  }
376  if(fCutsDplustoKpipi) {
378  list->Add(cutsDplustoKpipi);
379  }
380  if(fCutsDstoKKpi) {
382  list->Add(cutsDstoKKpi);
383  }
384  if(fCutsLctopKpi) {
386  list->Add(cutsLctopKpi);
387  }
388  if(fCutsLctoV0){
389  AliRDHFCutsLctoV0 *cutsLctoV0 = new AliRDHFCutsLctoV0(*fCutsLctoV0);
390  list->Add(cutsLctoV0);
391  }
392  if(fCutsD0toKpipipi) {
394  list->Add(cutsD0toKpipipi);
395  }
396  if(fCutsDStartoKpipi) {
398  list->Add(cutsDStartoKpipi);
399  }
400 
401  //___ Check consitstency of cuts between vertexer and analysis tasks
402  Bool_t bCutsOk = CheckCutsConsistency();
403  if (bCutsOk == kFALSE) {AliFatal("AliAnalysisVertexingHF::FillListOfCuts vertexing and the analysis task cuts are not consistent!");}
404 
405  // keep a pointer to the list
406  fListOfCuts = list;
407 
408  return list;
409 }
410 //----------------------------------------------------------------------------
412  TClonesArray *aodVerticesHFTClArr,
413  TClonesArray *aodD0toKpiTClArr,
414  TClonesArray *aodJPSItoEleTClArr,
415  TClonesArray *aodCharm3ProngTClArr,
416  TClonesArray *aodCharm4ProngTClArr,
417  TClonesArray *aodDstarTClArr,
418  TClonesArray *aodCascadesTClArr,
419  TClonesArray *aodLikeSign2ProngTClArr,
420  TClonesArray *aodLikeSign3ProngTClArr)
421 {
425  //AliCodeTimerAuto("",0);
426 
427  if(!fMixEvent){
428  TString evtype = event->IsA()->GetName();
429  fInputAOD = ((evtype=="AliAODEvent") ? kTRUE : kFALSE);
430  } // if we do mixing AliVEvent is a AliMixedEvent
431 
432  if(fInputAOD) {
433  AliDebug(2,"Creating HF candidates from AOD");
434  } else {
435  AliDebug(2,"Creating HF candidates from ESD");
436  }
437 
438  if(!aodVerticesHFTClArr) {
439  printf("ERROR: no aodVerticesHFTClArr");
440  return;
441  }
442  if((fD0toKpi || fDstar) && !aodD0toKpiTClArr) {
443  printf("ERROR: no aodD0toKpiTClArr");
444  return;
445  }
446  if(fJPSItoEle && !aodJPSItoEleTClArr) {
447  printf("ERROR: no aodJPSItoEleTClArr");
448  return;
449  }
450  if(f3Prong && !aodCharm3ProngTClArr) {
451  printf("ERROR: no aodCharm3ProngTClArr");
452  return;
453  }
454  if(f4Prong && !aodCharm4ProngTClArr) {
455  printf("ERROR: no aodCharm4ProngTClArr");
456  return;
457  }
458  if(fDstar && !aodDstarTClArr) {
459  printf("ERROR: no aodDstarTClArr");
460  return;
461  }
462  if(fCascades && !aodCascadesTClArr){
463  printf("ERROR: no aodCascadesTClArr ");
464  return;
465  }
466  if(fLikeSign && !aodLikeSign2ProngTClArr) {
467  printf("ERROR: no aodLikeSign2ProngTClArr");
468  return;
469  }
470  if(fLikeSign3prong && f3Prong && !aodLikeSign3ProngTClArr) {
471  printf("ERROR: no aodLikeSign3ProngTClArr");
472  return;
473  }
474 
475  // delete candidates from previous event and create references
476  Int_t iVerticesHF=0,iD0toKpi=0,iJPSItoEle=0,i3Prong=0,i4Prong=0,iDstar=0,iCascades=0,iLikeSign2Prong=0,iLikeSign3Prong=0;
477  aodVerticesHFTClArr->Delete();
478  iVerticesHF = aodVerticesHFTClArr->GetEntriesFast();
479  TClonesArray &verticesHFRef = *aodVerticesHFTClArr;
480  if(fD0toKpi || fDstar) {
481  aodD0toKpiTClArr->Delete();
482  iD0toKpi = aodD0toKpiTClArr->GetEntriesFast();
483  }
484  if(fJPSItoEle) {
485  aodJPSItoEleTClArr->Delete();
486  iJPSItoEle = aodJPSItoEleTClArr->GetEntriesFast();
487  }
488  if(f3Prong) {
489  aodCharm3ProngTClArr->Delete();
490  i3Prong = aodCharm3ProngTClArr->GetEntriesFast();
491  }
492  if(f4Prong) {
493  aodCharm4ProngTClArr->Delete();
494  i4Prong = aodCharm4ProngTClArr->GetEntriesFast();
495  }
496  if(fDstar) {
497  aodDstarTClArr->Delete();
498  iDstar = aodDstarTClArr->GetEntriesFast();
499  }
500  if(fCascades) {
501  aodCascadesTClArr->Delete();
502  iCascades = aodCascadesTClArr->GetEntriesFast();
503  }
504  if(fLikeSign) {
505  aodLikeSign2ProngTClArr->Delete();
506  iLikeSign2Prong = aodLikeSign2ProngTClArr->GetEntriesFast();
507  }
508  if(fLikeSign3prong && f3Prong) {
509  aodLikeSign3ProngTClArr->Delete();
510  iLikeSign3Prong = aodLikeSign3ProngTClArr->GetEntriesFast();
511  }
512 
513  TClonesArray &aodD0toKpiRef = *aodD0toKpiTClArr;
514  TClonesArray &aodJPSItoEleRef = *aodJPSItoEleTClArr;
515  TClonesArray &aodCharm3ProngRef = *aodCharm3ProngTClArr;
516  TClonesArray &aodCharm4ProngRef = *aodCharm4ProngTClArr;
517  TClonesArray &aodDstarRef = *aodDstarTClArr;
518  TClonesArray &aodCascadesRef = *aodCascadesTClArr;
519  TClonesArray &aodLikeSign2ProngRef = *aodLikeSign2ProngTClArr;
520  TClonesArray &aodLikeSign3ProngRef = *aodLikeSign3ProngTClArr;
521 
522 
523  AliAODRecoDecayHF2Prong *io2Prong = 0;
524  AliAODRecoDecayHF3Prong *io3Prong = 0;
525  AliAODRecoDecayHF4Prong *io4Prong = 0;
526  AliAODRecoCascadeHF *ioCascade = 0;
527 
528  Int_t iTrkP1,iTrkP2,iTrkN1,iTrkN2,iTrkSoftPi,trkEntries,iv0,nv0;
529  Double_t xdummy,ydummy,dcap1n1,dcap1n2,dcap2n1,dcap1p2,dcan1n2,dcap2n2,dcaV0,dcaCasc;
530  Bool_t okD0=kFALSE,okJPSI=kFALSE,ok3Prong=kFALSE,ok4Prong=kFALSE;
531  Bool_t okDstar=kFALSE,okD0fromDstar=kFALSE;
532  Bool_t okCascades=kFALSE;
533  AliESDtrack *postrack1 = 0;
534  AliESDtrack *postrack2 = 0;
535  AliESDtrack *negtrack1 = 0;
536  AliESDtrack *negtrack2 = 0;
537  AliESDtrack *trackPi = 0;
538  Double_t mompos1[3],mompos2[3],momneg1[3],momneg2[3];
539  // AliESDtrack *posV0track = 0;
540  // AliESDtrack *negV0track = 0;
541  Float_t dcaMax = fCutsD0toKpi->GetDCACut();
542  if(fCutsJpsitoee) dcaMax=TMath::Max(dcaMax,fCutsJpsitoee->GetDCACut());
543  if(fCutsDplustoKpipi) dcaMax=TMath::Max(dcaMax,fCutsDplustoKpipi->GetDCACut());
544  if(fCutsDstoKKpi) dcaMax=TMath::Max(dcaMax,fCutsDstoKKpi->GetDCACut());
545  if(fCutsLctopKpi) dcaMax=TMath::Max(dcaMax,fCutsLctopKpi->GetDCACut());
546  if(fCutsD0toKpipipi) dcaMax=TMath::Max(dcaMax,fCutsD0toKpipipi->GetDCACut());
547  if(fCutsDStartoKpipi) dcaMax=TMath::Max(dcaMax,fCutsDStartoKpipi->GetDCACut());
548 
549  AliDebug(2,Form(" dca cut set to %f cm",dcaMax));
550 
551 
552  // get Bz
553  fBzkG = (Double_t)event->GetMagneticField();
554  if(!fVertexerTracks){
555  fVertexerTracks=new AliVertexerTracks(fBzkG);
556  }else{
557  Double_t oldField=fVertexerTracks->GetFieldkG();
558  if(oldField!=fBzkG) fVertexerTracks->SetFieldkG(fBzkG);
559  }
560 
561  trkEntries = (Int_t)event->GetNumberOfTracks();
562  AliDebug(1,Form(" Number of tracks: %d",trkEntries));
563  fnTrksTotal += trkEntries;
564 
565  nv0 = (Int_t)event->GetNumberOfV0s();
566  AliDebug(1,Form(" Number of V0s: %d",nv0));
567 
568  if( trkEntries<2 && (trkEntries<1 || nv0<1) ) {
569  AliDebug(1,Form(" Not enough tracks: %d",trkEntries));
570  return;
571  }
572 
573  // event selection + PID configuration
574  if(!fCutsD0toKpi->IsEventSelected(event)) return;
579  if(fCutsLctoV0) fCutsLctoV0->SetupPID(event);
582 
583  // call function that applies sigle-track selection,
584  // for displaced tracks and soft pions (both charges) for D*,
585  // and retrieves primary vertex
586  TObjArray seleTrksArray(trkEntries);
587  TObjArray tracksAtVertex(trkEntries);
588  UChar_t *seleFlags = new UChar_t[trkEntries]; // bit 0: displaced, bit 1: softpi, bit 2: 3 prong, bits 3-4-5: for PID
589  Int_t nSeleTrks=0;
590  Int_t *evtNumber = new Int_t[trkEntries];
591  SelectTracksAndCopyVertex(event,trkEntries,seleTrksArray,tracksAtVertex,nSeleTrks,seleFlags,evtNumber);
592 
593  AliDebug(1,Form(" Selected tracks: %d",nSeleTrks));
594  fnSeleTrksTotal += nSeleTrks;
595 
596 
597  TObjArray *twoTrackArray1 = new TObjArray(2);
598  TObjArray *twoTrackArray2 = new TObjArray(2);
599  TObjArray *twoTrackArrayV0 = new TObjArray(2);
600  TObjArray *twoTrackArrayCasc = new TObjArray(2);
601  TObjArray *threeTrackArray = new TObjArray(3);
602  TObjArray *fourTrackArray = new TObjArray(4);
603 
604  Double_t dispersion;
605  Bool_t isLikeSign2Prong=kFALSE,isLikeSign3Prong=kFALSE;
606 
607  AliAODRecoDecayHF *rd = 0;
608  AliAODRecoCascadeHF *rc = 0;
609  AliAODv0 *v0 = 0;
610  AliESDv0 *esdV0 = 0;
611 
612  Bool_t massCutOK=kTRUE;
613 
614  // LOOP ON POSITIVE TRACKS
615  for(iTrkP1=0; iTrkP1<nSeleTrks; iTrkP1++) {
616 
617  //if(iTrkP1%1==0) AliDebug(1,Form(" 1st loop on pos: track number %d of %d",iTrkP1,nSeleTrks));
618  //if(iTrkP1%1==0) printf(" 1st loop on pos: track number %d of %d\n",iTrkP1,nSeleTrks);
619 
620  // get track from tracks array
621  postrack1 = (AliESDtrack*)seleTrksArray.UncheckedAt(iTrkP1);
622  if(!TESTBIT(seleFlags[iTrkP1],kBitDispl)) continue;
623  postrack1->GetPxPyPz(mompos1);
624 
625  // Make cascades with V0+track
626  //
627  if(fCascades) {
628  // loop on V0's
629  for(iv0=0; iv0<nv0; iv0++){
630 
631  //AliDebug(1,Form(" loop on v0s for track number %d and v0 number %d",iTrkP1,iv0));
632 
633  if ( fUsePIDforLc2V0 && !TESTBIT(seleFlags[iTrkP1],kBitProtonCompat) ) continue; //clm
634 
635  // Get the V0
636  if(fInputAOD) {
637  v0 = ((AliAODEvent*)event)->GetV0(iv0);
638  } else {
639  esdV0 = ((AliESDEvent*)event)->GetV0(iv0);
640  }
641  if ( (!v0 || !v0->IsA()->InheritsFrom("AliAODv0") ) &&
642  (!esdV0 || !esdV0->IsA()->InheritsFrom("AliESDv0") ) ) continue;
643 
644  if ( v0 && ((v0->GetOnFlyStatus() == kTRUE && fV0TypeForCascadeVertex == AliRDHFCuts::kOnlyOfflineV0s) ||
645  (v0->GetOnFlyStatus() == kFALSE && fV0TypeForCascadeVertex == AliRDHFCuts::kOnlyOnTheFlyV0s)) ) continue;
646 
647  if ( esdV0 && ((esdV0->GetOnFlyStatus() == kTRUE && fV0TypeForCascadeVertex == AliRDHFCuts::kOnlyOfflineV0s) ||
648  ( esdV0->GetOnFlyStatus() == kFALSE && fV0TypeForCascadeVertex == AliRDHFCuts::kOnlyOnTheFlyV0s)) ) continue;
649 
650  // Get the tracks that form the V0
651  // ( parameters at primary vertex )
652  // and define an AliExternalTrackParam out of them
653  AliExternalTrackParam * posV0track;
654  AliExternalTrackParam * negV0track;
655 
656  if(fInputAOD){
657  AliAODTrack *posVV0track = (AliAODTrack*)(v0->GetDaughter(0));
658  AliAODTrack *negVV0track = (AliAODTrack*)(v0->GetDaughter(1));
659  if( !posVV0track || !negVV0track ) continue;
660  //
661  // Apply some basic V0 daughter criteria
662  //
663  // bachelor must not be a v0-track
664  if (posVV0track->GetID() == postrack1->GetID() ||
665  negVV0track->GetID() == postrack1->GetID()) continue;
666  // reject like-sign v0
667  if ( posVV0track->Charge() == negVV0track->Charge() ) continue;
668  // avoid ghost TPC tracks
669  if(!(posVV0track->GetStatus() & AliESDtrack::kTPCrefit) ||
670  !(negVV0track->GetStatus() & AliESDtrack::kTPCrefit)) continue;
671  // Get AliExternalTrackParam out of the AliAODTracks
672  Double_t xyz[3], pxpypz[3], cv[21]; Short_t sign;
673  posVV0track->PxPyPz(pxpypz); posVV0track->XvYvZv(xyz);
674  posVV0track->GetCovarianceXYZPxPyPz(cv); sign=posVV0track->Charge();
675  posV0track = new AliExternalTrackParam(xyz,pxpypz,cv,sign);
676  negVV0track->PxPyPz(pxpypz); negVV0track->XvYvZv(xyz);
677  negVV0track->GetCovarianceXYZPxPyPz(cv); sign=negVV0track->Charge();
678  negV0track = new AliExternalTrackParam(xyz,pxpypz,cv,sign);
679  } else {
680  AliESDtrack *posVV0track = (AliESDtrack*)(event->GetTrack( esdV0->GetPindex() ));
681  AliESDtrack *negVV0track = (AliESDtrack*)(event->GetTrack( esdV0->GetNindex() ));
682  if( !posVV0track || !negVV0track ) continue;
683  //
684  // Apply some basic V0 daughter criteria
685  //
686  // bachelor must not be a v0-track
687  if (posVV0track->GetID() == postrack1->GetID() ||
688  negVV0track->GetID() == postrack1->GetID()) continue;
689  // reject like-sign v0
690  if ( posVV0track->Charge() == negVV0track->Charge() ) continue;
691  // avoid ghost TPC tracks
692  if(!(posVV0track->GetStatus() & AliESDtrack::kTPCrefit) ||
693  !(negVV0track->GetStatus() & AliESDtrack::kTPCrefit)) continue;
694  // reject kinks (only necessary on AliESDtracks)
695  if (posVV0track->GetKinkIndex(0)>0 || negVV0track->GetKinkIndex(0)>0) continue;
696  // Get AliExternalTrackParam out of the AliESDtracks
697  posV0track = new AliExternalTrackParam(*posVV0track);
698  negV0track = new AliExternalTrackParam(*negVV0track);
699 
700  // Define the AODv0 from ESDv0 if reading ESDs
701  v0 = TransformESDv0toAODv0(esdV0,twoTrackArrayV0);
702  }
703  if( !posV0track || !negV0track ){
704  AliDebug(1,Form(" Couldn't get the V0 daughters"));
705  continue;
706  }
707 
708  // fill in the v0 two-external-track-param array
709  twoTrackArrayV0->AddAt(posV0track,0);
710  twoTrackArrayV0->AddAt(negV0track,1);
711 
712  // Get the V0 dca
713  dcaV0 = v0->DcaV0Daughters();
714 
715  // Define the V0 (neutral) track
716  AliNeutralTrackParam *trackV0=NULL;
717  if(fInputAOD) {
718  const AliVTrack *trackVV0 = dynamic_cast<const AliVTrack*>(v0);
719  if(trackVV0) trackV0 = new AliNeutralTrackParam(trackVV0);
720  } else {
721  Double_t xyz[3], pxpypz[3];
722  esdV0->XvYvZv(xyz);
723  esdV0->PxPyPz(pxpypz);
724  Double_t cv[21]; for(int i=0; i<21; i++) cv[i]=0;
725  trackV0 = new AliNeutralTrackParam(xyz,pxpypz,cv,0);
726  }
727 
728 
729  // Fill in the object array to create the cascade
730  twoTrackArrayCasc->AddAt(postrack1,0);
731  twoTrackArrayCasc->AddAt(trackV0,1);
732  // Compute the cascade vertex
733  AliAODVertex *vertexCasc = 0;
735  // DCA between the two tracks
736  dcaCasc = postrack1->GetDCA(trackV0,fBzkG,xdummy,ydummy);
737  // Vertexing+
738  vertexCasc = ReconstructSecondaryVertex(twoTrackArrayCasc,dispersion,kFALSE);
739  } else {
740  // assume Cascade decays at the primary vertex
741  Double_t pos[3],cov[6],chi2perNDF;
742  fV1->GetXYZ(pos);
743  fV1->GetCovMatrix(cov);
744  chi2perNDF = fV1->GetChi2toNDF();
745  vertexCasc = new AliAODVertex(pos,cov,chi2perNDF,0x0,-1,AliAODVertex::kUndef,2);
746  dcaCasc = 0.;
747  }
748  if(!vertexCasc) {
749  delete posV0track; posV0track=NULL;
750  delete negV0track; negV0track=NULL;
751  delete trackV0; trackV0=NULL;
752  if(!fInputAOD) {delete v0; v0=NULL;}
753  twoTrackArrayV0->Clear();
754  twoTrackArrayCasc->Clear();
755  continue;
756  }
757 
758  // Create and store the Cascade if passed the cuts
759  ioCascade = MakeCascade(twoTrackArrayCasc,event,vertexCasc,v0,dcaCasc,okCascades);
760  if(okCascades && ioCascade) {
761  //AliDebug(1,Form("Storing a cascade object... "));
762  // add the vertex and the cascade to the AOD
763  rc = new(aodCascadesRef[iCascades++])AliAODRecoCascadeHF(*ioCascade);
764  if(fMakeReducedRHF){
765  UShort_t id[2]={(UShort_t)postrack1->GetID(),(UShort_t)iv0};
766  rc->SetProngIDs(2,id);
767  rc->DeleteRecoD();
768  }else{
769  AliAODVertex *vCasc = new(verticesHFRef[iVerticesHF++])AliAODVertex(*vertexCasc);
770  rc->SetSecondaryVtx(vCasc);
771  vCasc->SetParent(rc);
772  if(!fInputAOD) vCasc->AddDaughter(v0); // just to fill ref #0 ??
773  AddRefs(vCasc,rc,event,twoTrackArrayCasc); // add the track (proton)
774  vCasc->AddDaughter(v0); // fill the 2prong V0
775  }
776  rc->SetPrimaryVtxRef((AliAODVertex*)event->GetPrimaryVertex());
777  }
778 
779 
780  // Clean up
781  delete posV0track; posV0track=NULL;
782  delete negV0track; negV0track=NULL;
783  delete trackV0; trackV0=NULL;
784  twoTrackArrayV0->Clear();
785  twoTrackArrayCasc->Clear();
786  if(ioCascade) { delete ioCascade; ioCascade=NULL; }
787  if(vertexCasc) { delete vertexCasc; vertexCasc=NULL; }
788  if(!fInputAOD) {delete v0; v0=NULL;}
789 
790  } // end loop on V0's
791  }
792 
793  // If there is less than 2 particles continue
794  if(trkEntries<2) {
795  AliDebug(1,Form(" Not enough tracks: %d",trkEntries));
796  continue;
797  }
798 
799  if(postrack1->Charge()<0 && !fLikeSign) continue;
800 
801  // LOOP ON NEGATIVE TRACKS
802  for(iTrkN1=0; iTrkN1<nSeleTrks; iTrkN1++) {
803 
804  //if(iTrkN1%1==0) AliDebug(1,Form(" 1st loop on neg: track number %d of %d",iTrkN1,nSeleTrks));
805  //if(iTrkN1%1==0) printf(" 1st loop on neg: track number %d of %d\n",iTrkN1,nSeleTrks);
806 
807  if(iTrkN1==iTrkP1) continue;
808 
809  // get track from tracks array
810  negtrack1 = (AliESDtrack*)seleTrksArray.UncheckedAt(iTrkN1);
811 
812  if(negtrack1->Charge()>0 && !fLikeSign) continue;
813 
814  if(!TESTBIT(seleFlags[iTrkN1],kBitDispl)) continue;
815 
816  if(fMixEvent) {
817  if(evtNumber[iTrkP1]==evtNumber[iTrkN1]) continue;
818  }
819 
820  if(postrack1->Charge()==negtrack1->Charge()) { // like-sign
821  isLikeSign2Prong=kTRUE;
822  if(!fLikeSign) continue;
823  if(iTrkN1<iTrkP1) continue; // this is needed to avoid double-counting of like-sign
824  } else { // unlike-sign
825  isLikeSign2Prong=kFALSE;
826  if(postrack1->Charge()<0 || negtrack1->Charge()>0) continue; // this is needed to avoid double-counting of unlike-sign
827  if(fMixEvent) {
828  if(evtNumber[iTrkP1]==evtNumber[iTrkN1]) continue;
829  }
830 
831  }
832 
833  // back to primary vertex
834  // postrack1->PropagateToDCA(fV1,fBzkG,kVeryBig);
835  // negtrack1->PropagateToDCA(fV1,fBzkG,kVeryBig);
836  SetParametersAtVertex(postrack1,(AliExternalTrackParam*)tracksAtVertex.UncheckedAt(iTrkP1));
837  SetParametersAtVertex(negtrack1,(AliExternalTrackParam*)tracksAtVertex.UncheckedAt(iTrkN1));
838  negtrack1->GetPxPyPz(momneg1);
839 
840  // DCA between the two tracks
841  dcap1n1 = postrack1->GetDCA(negtrack1,fBzkG,xdummy,ydummy);
842  if(dcap1n1>dcaMax) { negtrack1=0; continue; }
843 
844  // Vertexing
845  twoTrackArray1->AddAt(postrack1,0);
846  twoTrackArray1->AddAt(negtrack1,1);
847  AliAODVertex *vertexp1n1 = ReconstructSecondaryVertex(twoTrackArray1,dispersion);
848  if(!vertexp1n1) {
849  twoTrackArray1->Clear();
850  negtrack1=0;
851  continue;
852  }
853  // 2 prong candidate
854  if(fD0toKpi || fJPSItoEle || fDstar || fLikeSign) {
855 
856  io2Prong = Make2Prong(twoTrackArray1,event,vertexp1n1,dcap1n1,okD0,okJPSI,okD0fromDstar);
857 
858  if((fD0toKpi && okD0) || (fJPSItoEle && okJPSI) || (isLikeSign2Prong && (okD0 || okJPSI))) {
859  // add the vertex and the decay to the AOD
860  AliAODVertex *v2Prong =0x0;
861  if(!fMakeReducedRHF)v2Prong = new(verticesHFRef[iVerticesHF++])AliAODVertex(*vertexp1n1);
862  if(!isLikeSign2Prong) {
863  if(okD0) {
864  rd = new(aodD0toKpiRef[iD0toKpi++])AliAODRecoDecayHF2Prong(*io2Prong);
866 
867  if(fMakeReducedRHF){
868  rd->DeleteRecoD();
869  rd->SetPrimaryVtxRef((AliAODVertex*)event->GetPrimaryVertex());
870  }else{
871  rd->SetSecondaryVtx(v2Prong);
872  v2Prong->SetParent(rd);
873  AddRefs(v2Prong,rd,event,twoTrackArray1);
874  }
875  }
876  if(okJPSI) {
877  rd = new(aodJPSItoEleRef[iJPSItoEle++])AliAODRecoDecayHF2Prong(*io2Prong);
878  if(fMakeReducedRHF){
879  rd->DeleteRecoD();
880  rd->SetPrimaryVtxRef((AliAODVertex*)event->GetPrimaryVertex());
881  }else{
882  if(!okD0) v2Prong->SetParent(rd); // it cannot have two mothers ...
883  AddRefs(v2Prong,rd,event,twoTrackArray1);
884  }
885  }
886  } else { // isLikeSign2Prong
887  rd = new(aodLikeSign2ProngRef[iLikeSign2Prong++])AliAODRecoDecayHF2Prong(*io2Prong);
888  //Set selection bit for PID
890  if(fMakeReducedRHF){
891  rd->DeleteRecoD();
892  rd->SetPrimaryVtxRef((AliAODVertex*)event->GetPrimaryVertex());
893  }else{
894  rd->SetSecondaryVtx(v2Prong);
895  v2Prong->SetParent(rd);
896  AddRefs(v2Prong,rd,event,twoTrackArray1);
897  }
898  }
899  }
900  // D* candidates
901  if(fDstar && okD0fromDstar && !isLikeSign2Prong) {
902  // write references in io2Prong
903  if(fInputAOD) {
904  AddDaughterRefs(vertexp1n1,event,twoTrackArray1);
905  } else {
906  vertexp1n1->AddDaughter(postrack1);
907  vertexp1n1->AddDaughter(negtrack1);
908  }
909  io2Prong->SetSecondaryVtx(vertexp1n1);
910  //printf("---> %d %d %d %d %d\n",vertexp1n1->GetNDaughters(),iTrkP1,iTrkN1,postrack1->Charge(),negtrack1->Charge());
911  // create a track from the D0
912  AliNeutralTrackParam *trackD0 = new AliNeutralTrackParam(io2Prong);
913 
914  // LOOP ON TRACKS THAT PASSED THE SOFT PION CUTS
915  for(iTrkSoftPi=0; iTrkSoftPi<nSeleTrks; iTrkSoftPi++) {
916 
917  if(iTrkSoftPi==iTrkP1 || iTrkSoftPi==iTrkN1) continue;
918 
919  if(!TESTBIT(seleFlags[iTrkSoftPi],kBitSoftPi)) continue;
920 
921  if(fMixEvent) {
922  if(evtNumber[iTrkP1]==evtNumber[iTrkSoftPi] ||
923  evtNumber[iTrkN1]==evtNumber[iTrkSoftPi] ||
924  evtNumber[iTrkP1]==evtNumber[iTrkN1]) continue;
925  }
926 
927  //if(iTrkSoftPi%1==0) AliDebug(1,Form(" 1st loop on pi_s: track number %d of %d",iTrkSoftPi,nSeleTrks));
928 
929  trackD0->PropagateToDCA(fV1,fBzkG,kVeryBig);
930  if(trackD0->GetSigmaY2()<0. || trackD0->GetSigmaZ2()<0.) continue; // this is insipired by the AliITStrackV2::Invariant() checks
931 
932  // get track from tracks array
933  trackPi = (AliESDtrack*)seleTrksArray.UncheckedAt(iTrkSoftPi);
934  // trackPi->PropagateToDCA(fV1,fBzkG,kVeryBig);
935  SetParametersAtVertex(trackPi,(AliExternalTrackParam*)tracksAtVertex.UncheckedAt(iTrkSoftPi));
936  twoTrackArrayCasc->AddAt(trackPi,0);
937  twoTrackArrayCasc->AddAt(trackD0,1);
938  if(!SelectInvMassAndPtDstarD0pi(twoTrackArrayCasc)){
939  twoTrackArrayCasc->Clear();
940  trackPi=0;
941  continue;
942  }
943 
944  AliAODVertex *vertexCasc = 0;
945 
946  if(fFindVertexForDstar) {
947  // DCA between the two tracks
948  dcaCasc = trackPi->GetDCA(trackD0,fBzkG,xdummy,ydummy);
949  // Vertexing
950  vertexCasc = ReconstructSecondaryVertex(twoTrackArrayCasc,dispersion,kFALSE);
951  } else {
952  // assume Dstar decays at the primary vertex
953  Double_t pos[3],cov[6],chi2perNDF;
954  fV1->GetXYZ(pos);
955  fV1->GetCovMatrix(cov);
956  chi2perNDF = fV1->GetChi2toNDF();
957  vertexCasc = new AliAODVertex(pos,cov,chi2perNDF,0x0,-1,AliAODVertex::kUndef,2);
958  dcaCasc = 0.;
959  }
960  if(!vertexCasc) {
961  twoTrackArrayCasc->Clear();
962  trackPi=0;
963  continue;
964  }
965 
966  ioCascade = MakeCascade(twoTrackArrayCasc,event,vertexCasc,io2Prong,dcaCasc,okDstar);
967  if(okDstar) {
968  // add the D0 to the AOD (if not already done)
969  if(!okD0) {
970  rd = new(aodD0toKpiRef[iD0toKpi++])AliAODRecoDecayHF2Prong(*io2Prong);
971  if(fMakeReducedRHF){
972  rd->DeleteRecoD();
973  rd->SetPrimaryVtxRef((AliAODVertex*)event->GetPrimaryVertex());
974  }else{
975  AliAODVertex *v2Prong = new (verticesHFRef[iVerticesHF++])AliAODVertex(*vertexp1n1);
976  rd->SetSecondaryVtx(v2Prong);
977  v2Prong->SetParent(rd);
978  AddRefs(v2Prong,rd,event,twoTrackArray1);
979  }
980  okD0=kTRUE; // this is done to add it only once
981  }
982  // add the vertex and the cascade to the AOD
983  rc = new(aodDstarRef[iDstar++])AliAODRecoCascadeHF(*ioCascade);
984  // Set selection bit for PID
986  AliAODVertex *vCasc = 0x0;
987  if(fMakeReducedRHF){
988  //assign a ID to the D0 candidate, daughter of the Cascade. ID = position in the D0toKpi array
989  UShort_t idCasc[2]={(UShort_t)trackPi->GetID(),(UShort_t)(iD0toKpi-1)};
990  rc->SetProngIDs(2,idCasc);
991  rc->DeleteRecoD();
992  rc->SetPrimaryVtxRef((AliAODVertex*)event->GetPrimaryVertex());
993  }else{
994  AliAODVertex *vCasc = new(verticesHFRef[iVerticesHF++])AliAODVertex(*vertexCasc);
995  rc->SetSecondaryVtx(vCasc);
996  vCasc->SetParent(rc);
997  if(!fInputAOD) vCasc->AddDaughter(rd); // just to fill ref #0
998  AddRefs(vCasc,rc,event,twoTrackArrayCasc);
999  vCasc->AddDaughter(rd); // add the D0 (in ref #1)
1000  }
1001  }
1002  twoTrackArrayCasc->Clear();
1003  trackPi=0;
1004  if(ioCascade) {delete ioCascade; ioCascade=NULL;}
1005  delete vertexCasc; vertexCasc=NULL;
1006  } // end loop on soft pi tracks
1007 
1008  if(trackD0) {delete trackD0; trackD0=NULL;}
1009 
1010  }
1011  if(io2Prong) {delete io2Prong; io2Prong=NULL;}
1012  }
1013 
1014  twoTrackArray1->Clear();
1015  if( (!f3Prong && !f4Prong) ||
1016  (isLikeSign2Prong && !f3Prong) ) {
1017  negtrack1=0;
1018  delete vertexp1n1;
1019  continue;
1020  }
1021 
1022 
1023  // 2nd LOOP ON POSITIVE TRACKS
1024  for(iTrkP2=iTrkP1+1; iTrkP2<nSeleTrks; iTrkP2++) {
1025 
1026  if(iTrkP2==iTrkP1 || iTrkP2==iTrkN1) continue;
1027 
1028  //if(iTrkP2%1==0) AliDebug(1,Form(" 2nd loop on pos: track number %d of %d",iTrkP2,nSeleTrks));
1029 
1030  // get track from tracks array
1031  postrack2 = (AliESDtrack*)seleTrksArray.UncheckedAt(iTrkP2);
1032 
1033  if(postrack2->Charge()<0) continue;
1034 
1035  if(!TESTBIT(seleFlags[iTrkP2],kBitDispl)) continue;
1036 
1037  // Check single tracks cuts specific for 3 prongs
1038  if(!TESTBIT(seleFlags[iTrkP2],kBit3Prong)) continue;
1039  if(!TESTBIT(seleFlags[iTrkP1],kBit3Prong)) continue;
1040  if(!TESTBIT(seleFlags[iTrkN1],kBit3Prong)) continue;
1041 
1042  if(fMixEvent) {
1043  if(evtNumber[iTrkP1]==evtNumber[iTrkP2] ||
1044  evtNumber[iTrkN1]==evtNumber[iTrkP2] ||
1045  evtNumber[iTrkP1]==evtNumber[iTrkN1]) continue;
1046  }
1047 
1048  if(isLikeSign2Prong) { // like-sign pair -> have to build only like-sign triplet
1049  if(!fLikeSign3prong) continue;
1050  if(postrack1->Charge()>0) { // ok: like-sign triplet (+++)
1051  isLikeSign3Prong=kTRUE;
1052  } else { // not ok
1053  continue;
1054  }
1055  } else { // normal triplet (+-+)
1056  isLikeSign3Prong=kFALSE;
1057  if(fMixEvent) {
1058  if(evtNumber[iTrkP1]==evtNumber[iTrkP2] ||
1059  evtNumber[iTrkN1]==evtNumber[iTrkP2] ||
1060  evtNumber[iTrkP1]==evtNumber[iTrkN1]) continue;
1061  }
1062  }
1063 
1065  if(!TESTBIT(seleFlags[iTrkN1],kBitKaonCompat)) continue;
1066  }
1067  Bool_t okForLcTopKpi=kTRUE;
1068  Int_t pidLcStatus=3; // 3= OK as pKpi and Kpipi
1069  if(fUsePIDforLc>0){
1070  if(!TESTBIT(seleFlags[iTrkP1],kBitProtonCompat) &&
1071  !TESTBIT(seleFlags[iTrkP2],kBitProtonCompat) ){
1072  okForLcTopKpi=kFALSE;
1073  pidLcStatus=0;
1074  }
1075  if(okForLcTopKpi && fUsePIDforLc>1){
1076  okForLcTopKpi=kFALSE;
1077  pidLcStatus=0;
1078  if(TESTBIT(seleFlags[iTrkP1],kBitProtonCompat) &&
1079  TESTBIT(seleFlags[iTrkP2],kBitPionCompat) ){
1080  okForLcTopKpi=kTRUE;
1081  pidLcStatus+=1; // 1= OK as pKpi
1082  }
1083  if(TESTBIT(seleFlags[iTrkP2],kBitProtonCompat) &&
1084  TESTBIT(seleFlags[iTrkP1],kBitPionCompat) ){
1085  okForLcTopKpi=kTRUE;
1086  pidLcStatus+=2; // 2= OK as piKp
1087  }
1088  }
1089  }
1090  Bool_t okForDsToKKpi=kTRUE;
1091  if(fUseKaonPIDforDs){
1092  if(!TESTBIT(seleFlags[iTrkP1],kBitKaonCompat) &&
1093  !TESTBIT(seleFlags[iTrkP2],kBitKaonCompat) ) okForDsToKKpi=kFALSE;
1094  }
1095  // back to primary vertex
1096  // postrack1->PropagateToDCA(fV1,fBzkG,kVeryBig);
1097  // postrack2->PropagateToDCA(fV1,fBzkG,kVeryBig);
1098  // negtrack1->PropagateToDCA(fV1,fBzkG,kVeryBig);
1099  SetParametersAtVertex(postrack1,(AliExternalTrackParam*)tracksAtVertex.UncheckedAt(iTrkP1));
1100  SetParametersAtVertex(negtrack1,(AliExternalTrackParam*)tracksAtVertex.UncheckedAt(iTrkN1));
1101  SetParametersAtVertex(postrack2,(AliExternalTrackParam*)tracksAtVertex.UncheckedAt(iTrkP2));
1102 
1103  //printf("********** %d %d %d\n",postrack1->GetID(),postrack2->GetID(),negtrack1->GetID());
1104 
1105  dcap2n1 = postrack2->GetDCA(negtrack1,fBzkG,xdummy,ydummy);
1106  if(dcap2n1>dcaMax) { postrack2=0; continue; }
1107  dcap1p2 = postrack2->GetDCA(postrack1,fBzkG,xdummy,ydummy);
1108  if(dcap1p2>dcaMax) { postrack2=0; continue; }
1109 
1110  // check invariant mass cuts for D+,Ds,Lc
1111  massCutOK=kTRUE;
1112  if(f3Prong) {
1113  if(postrack2->Charge()>0) {
1114  threeTrackArray->AddAt(postrack1,0);
1115  threeTrackArray->AddAt(negtrack1,1);
1116  threeTrackArray->AddAt(postrack2,2);
1117  } else {
1118  threeTrackArray->AddAt(negtrack1,0);
1119  threeTrackArray->AddAt(postrack1,1);
1120  threeTrackArray->AddAt(postrack2,2);
1121  }
1123  postrack2->GetPxPyPz(mompos2);
1124  Double_t pxDau[3]={mompos1[0],momneg1[0],mompos2[0]};
1125  Double_t pyDau[3]={mompos1[1],momneg1[1],mompos2[1]};
1126  Double_t pzDau[3]={mompos1[2],momneg1[2],mompos2[2]};
1127  // massCutOK = SelectInvMassAndPt3prong(threeTrackArray);
1128  massCutOK = SelectInvMassAndPt3prong(pxDau,pyDau,pzDau,pidLcStatus);
1129  }
1130  }
1131 
1132  if(f3Prong && !massCutOK) {
1133  threeTrackArray->Clear();
1134  if(!f4Prong) {
1135  postrack2=0;
1136  continue;
1137  }
1138  }
1139 
1140  // Vertexing
1141  twoTrackArray2->AddAt(postrack2,0);
1142  twoTrackArray2->AddAt(negtrack1,1);
1143  AliAODVertex *vertexp2n1 = ReconstructSecondaryVertex(twoTrackArray2,dispersion);
1144  if(!vertexp2n1) {
1145  twoTrackArray2->Clear();
1146  postrack2=0;
1147  continue;
1148  }
1149 
1150  // 3 prong candidates
1151  if(f3Prong && massCutOK) {
1152 
1153  AliAODVertex* secVert3PrAOD = ReconstructSecondaryVertex(threeTrackArray,dispersion);
1154  io3Prong = Make3Prong(threeTrackArray,event,secVert3PrAOD,dispersion,vertexp1n1,vertexp2n1,dcap1n1,dcap2n1,dcap1p2,okForLcTopKpi,okForDsToKKpi,ok3Prong);
1155  if(ok3Prong) {
1156  AliAODVertex *v3Prong=0x0;
1157  if(!fMakeReducedRHF)v3Prong = new (verticesHFRef[iVerticesHF++])AliAODVertex(*secVert3PrAOD);
1158  if(!isLikeSign3Prong) {
1159  rd = new(aodCharm3ProngRef[i3Prong++])AliAODRecoDecayHF3Prong(*io3Prong);
1160  // Set selection bit for PID
1164  if(fMakeReducedRHF){
1165  rd->SetPrimaryVtxRef((AliAODVertex*)event->GetPrimaryVertex());
1166  ((AliAODRecoDecayHF3Prong*)rd)->DeleteRecoD();
1167  }else{
1168  v3Prong = new (verticesHFRef[iVerticesHF++])AliAODVertex(*secVert3PrAOD);
1169  rd->SetSecondaryVtx(v3Prong);
1170  v3Prong->SetParent(rd);
1171  AddRefs(v3Prong,rd,event,threeTrackArray);
1172  }
1173  } else { // isLikeSign3Prong
1174  if(fLikeSign3prong){
1175  rd = new(aodLikeSign3ProngRef[iLikeSign3Prong++])AliAODRecoDecayHF3Prong(*io3Prong);
1176  // Set selection bit for PID
1180  if(fMakeReducedRHF){
1181  rd->SetPrimaryVtxRef((AliAODVertex*)event->GetPrimaryVertex());
1182  ((AliAODRecoDecayHF3Prong*)rd)->DeleteRecoD();
1183  }else{
1184  rd->SetSecondaryVtx(v3Prong);
1185  v3Prong->SetParent(rd);
1186  AddRefs(v3Prong,rd,event,threeTrackArray);
1187  }
1188  }
1189  }
1190 
1191  }
1192  if(io3Prong) {delete io3Prong; io3Prong=NULL;}
1193  if(secVert3PrAOD) {delete secVert3PrAOD; secVert3PrAOD=NULL;}
1194  }
1195 
1196  // 4 prong candidates
1197  if(f4Prong
1198  // don't make 4 prong with like-sign pairs and triplets
1199  && !isLikeSign2Prong && !isLikeSign3Prong
1200  // track-to-track dca cuts already now
1201  && dcap1n1 < fCutsD0toKpipipi->GetDCACut()
1202  && dcap2n1 < fCutsD0toKpipipi->GetDCACut()) {
1203  // back to primary vertex
1204  // postrack1->PropagateToDCA(fV1,fBzkG,kVeryBig);
1205  // postrack2->PropagateToDCA(fV1,fBzkG,kVeryBig);
1206  // negtrack1->PropagateToDCA(fV1,fBzkG,kVeryBig);
1207  SetParametersAtVertex(postrack1,(AliExternalTrackParam*)tracksAtVertex.UncheckedAt(iTrkP1));
1208  SetParametersAtVertex(negtrack1,(AliExternalTrackParam*)tracksAtVertex.UncheckedAt(iTrkN1));
1209  SetParametersAtVertex(postrack2,(AliExternalTrackParam*)tracksAtVertex.UncheckedAt(iTrkP2));
1210 
1211  // Vertexing for these 3 (can be taken from above?)
1212  threeTrackArray->AddAt(postrack1,0);
1213  threeTrackArray->AddAt(negtrack1,1);
1214  threeTrackArray->AddAt(postrack2,2);
1215  AliAODVertex* vertexp1n1p2 = ReconstructSecondaryVertex(threeTrackArray,dispersion);
1216 
1217  // 3rd LOOP ON NEGATIVE TRACKS (for 4 prong)
1218  for(iTrkN2=iTrkN1+1; iTrkN2<nSeleTrks; iTrkN2++) {
1219 
1220  if(iTrkN2==iTrkP1 || iTrkN2==iTrkP2 || iTrkN2==iTrkN1) continue;
1221 
1222  //if(iTrkN2%1==0) AliDebug(1,Form(" 3rd loop on neg: track number %d of %d",iTrkN2,nSeleTrks));
1223 
1224  // get track from tracks array
1225  negtrack2 = (AliESDtrack*)seleTrksArray.UncheckedAt(iTrkN2);
1226 
1227  if(negtrack2->Charge()>0) continue;
1228 
1229  if(!TESTBIT(seleFlags[iTrkN2],kBitDispl)) continue;
1230  if(fMixEvent){
1231  if(evtNumber[iTrkP1]==evtNumber[iTrkN2] ||
1232  evtNumber[iTrkN1]==evtNumber[iTrkN2] ||
1233  evtNumber[iTrkP2]==evtNumber[iTrkN2] ||
1234  evtNumber[iTrkP1]==evtNumber[iTrkN1] ||
1235  evtNumber[iTrkP1]==evtNumber[iTrkP2] ||
1236  evtNumber[iTrkN1]==evtNumber[iTrkP2]) continue;
1237  }
1238 
1239  // back to primary vertex
1240  // postrack1->PropagateToDCA(fV1,fBzkG,kVeryBig);
1241  // postrack2->PropagateToDCA(fV1,fBzkG,kVeryBig);
1242  // negtrack1->PropagateToDCA(fV1,fBzkG,kVeryBig);
1243  // negtrack2->PropagateToDCA(fV1,fBzkG,kVeryBig);
1244  SetParametersAtVertex(postrack1,(AliExternalTrackParam*)tracksAtVertex.UncheckedAt(iTrkP1));
1245  SetParametersAtVertex(negtrack1,(AliExternalTrackParam*)tracksAtVertex.UncheckedAt(iTrkN1));
1246  SetParametersAtVertex(postrack2,(AliExternalTrackParam*)tracksAtVertex.UncheckedAt(iTrkP2));
1247  SetParametersAtVertex(negtrack2,(AliExternalTrackParam*)tracksAtVertex.UncheckedAt(iTrkN2));
1248 
1249  dcap1n2 = postrack1->GetDCA(negtrack2,fBzkG,xdummy,ydummy);
1250  if(dcap1n2 > fCutsD0toKpipipi->GetDCACut()) { negtrack2=0; continue; }
1251  dcap2n2 = postrack2->GetDCA(negtrack2,fBzkG,xdummy,ydummy);
1252  if(dcap2n2 > fCutsD0toKpipipi->GetDCACut()) { negtrack2=0; continue; }
1253 
1254 
1255  fourTrackArray->AddAt(postrack1,0);
1256  fourTrackArray->AddAt(negtrack1,1);
1257  fourTrackArray->AddAt(postrack2,2);
1258  fourTrackArray->AddAt(negtrack2,3);
1259 
1260  // check invariant mass cuts for D0
1261  massCutOK=kTRUE;
1263  massCutOK = SelectInvMassAndPt4prong(fourTrackArray);
1264 
1265  if(!massCutOK) {
1266  fourTrackArray->Clear();
1267  negtrack2=0;
1268  continue;
1269  }
1270 
1271  // Vertexing
1272  AliAODVertex* secVert4PrAOD = ReconstructSecondaryVertex(fourTrackArray,dispersion);
1273  io4Prong = Make4Prong(fourTrackArray,event,secVert4PrAOD,vertexp1n1,vertexp1n1p2,dcap1n1,dcap1n2,dcap2n1,dcap2n2,ok4Prong);
1274  if(ok4Prong) {
1275  rd = new(aodCharm4ProngRef[i4Prong++])AliAODRecoDecayHF4Prong(*io4Prong);
1276  if(fMakeReducedRHF){
1277  rd->DeleteRecoD();
1278  rd->SetPrimaryVtxRef((AliAODVertex*)event->GetPrimaryVertex());
1279  }else{
1280  AliAODVertex *v4Prong = new(verticesHFRef[iVerticesHF++])AliAODVertex(*secVert4PrAOD);
1281  rd->SetSecondaryVtx(v4Prong);
1282  v4Prong->SetParent(rd);
1283  AddRefs(v4Prong,rd,event,fourTrackArray);
1284  }
1285  }
1286 
1287  if(io4Prong) {delete io4Prong; io4Prong=NULL;}
1288  if(secVert4PrAOD) {delete secVert4PrAOD; secVert4PrAOD=NULL;}
1289  fourTrackArray->Clear();
1290  negtrack2 = 0;
1291 
1292  } // end loop on negative tracks
1293 
1294  threeTrackArray->Clear();
1295  delete vertexp1n1p2;
1296 
1297  }
1298 
1299  postrack2 = 0;
1300  delete vertexp2n1;
1301 
1302  } // end 2nd loop on positive tracks
1303 
1304  twoTrackArray2->Clear();
1305 
1306  // 2nd LOOP ON NEGATIVE TRACKS (for 3 prong -+-)
1307  for(iTrkN2=iTrkN1+1; iTrkN2<nSeleTrks; iTrkN2++) {
1308 
1309  if(iTrkN2==iTrkP1 || iTrkN2==iTrkP2 || iTrkN2==iTrkN1) continue;
1310 
1311  //if(iTrkN2%1==0) AliDebug(1,Form(" 2nd loop on neg: track number %d of %d",iTrkN2,nSeleTrks));
1312 
1313  // get track from tracks array
1314  negtrack2 = (AliESDtrack*)seleTrksArray.UncheckedAt(iTrkN2);
1315 
1316  if(negtrack2->Charge()>0) continue;
1317 
1318  if(!TESTBIT(seleFlags[iTrkN2],kBitDispl)) continue;
1319 
1320  // Check single tracks cuts specific for 3 prongs
1321  if(!TESTBIT(seleFlags[iTrkN2],kBit3Prong)) continue;
1322  if(!TESTBIT(seleFlags[iTrkP1],kBit3Prong)) continue;
1323  if(!TESTBIT(seleFlags[iTrkN1],kBit3Prong)) continue;
1324 
1325  if(fMixEvent) {
1326  if(evtNumber[iTrkP1]==evtNumber[iTrkN2] ||
1327  evtNumber[iTrkN1]==evtNumber[iTrkN2] ||
1328  evtNumber[iTrkP1]==evtNumber[iTrkN1]) continue;
1329  }
1330 
1331  if(isLikeSign2Prong) { // like-sign pair -> have to build only like-sign triplet
1332  if(!fLikeSign3prong) continue;
1333  if(postrack1->Charge()<0) { // ok: like-sign triplet (---)
1334  isLikeSign3Prong=kTRUE;
1335  } else { // not ok
1336  continue;
1337  }
1338  } else { // normal triplet (-+-)
1339  isLikeSign3Prong=kFALSE;
1340  }
1341 
1343  if(!TESTBIT(seleFlags[iTrkP1],kBitKaonCompat)) continue;
1344  }
1345  Bool_t okForLcTopKpi=kTRUE;
1346  Int_t pidLcStatus=3; // 3= OK as pKpi and Kpipi
1347  if(fUsePIDforLc>0){
1348  if(!TESTBIT(seleFlags[iTrkN1],kBitProtonCompat) &&
1349  !TESTBIT(seleFlags[iTrkN2],kBitProtonCompat) ){
1350  okForLcTopKpi=kFALSE;
1351  pidLcStatus=0;
1352  }
1353  if(okForLcTopKpi && fUsePIDforLc>1){
1354  okForLcTopKpi=kFALSE;
1355  pidLcStatus=0;
1356  if(TESTBIT(seleFlags[iTrkN1],kBitProtonCompat) &&
1357  TESTBIT(seleFlags[iTrkN2],kBitPionCompat) ){
1358  okForLcTopKpi=kTRUE;
1359  pidLcStatus+=1; // 1= OK as pKpi
1360  }
1361  if(TESTBIT(seleFlags[iTrkN2],kBitProtonCompat) &&
1362  TESTBIT(seleFlags[iTrkN1],kBitPionCompat) ){
1363  okForLcTopKpi=kTRUE;
1364  pidLcStatus+=2; // 2= OK as piKp
1365  }
1366  }
1367  }
1368  Bool_t okForDsToKKpi=kTRUE;
1369  if(fUseKaonPIDforDs){
1370  if(!TESTBIT(seleFlags[iTrkN1],kBitKaonCompat) &&
1371  !TESTBIT(seleFlags[iTrkN2],kBitKaonCompat) ) okForDsToKKpi=kFALSE;
1372  }
1373 
1374  // back to primary vertex
1375  // postrack1->PropagateToDCA(fV1,fBzkG,kVeryBig);
1376  // negtrack1->PropagateToDCA(fV1,fBzkG,kVeryBig);
1377  // negtrack2->PropagateToDCA(fV1,fBzkG,kVeryBig);
1378  SetParametersAtVertex(postrack1,(AliExternalTrackParam*)tracksAtVertex.UncheckedAt(iTrkP1));
1379  SetParametersAtVertex(negtrack1,(AliExternalTrackParam*)tracksAtVertex.UncheckedAt(iTrkN1));
1380  SetParametersAtVertex(negtrack2,(AliExternalTrackParam*)tracksAtVertex.UncheckedAt(iTrkN2));
1381  //printf("********** %d %d %d\n",postrack1->GetID(),negtrack1->GetID(),negtrack2->GetID());
1382 
1383  dcap1n2 = postrack1->GetDCA(negtrack2,fBzkG,xdummy,ydummy);
1384  if(dcap1n2>dcaMax) { negtrack2=0; continue; }
1385  dcan1n2 = negtrack1->GetDCA(negtrack2,fBzkG,xdummy,ydummy);
1386  if(dcan1n2>dcaMax) { negtrack2=0; continue; }
1387 
1388  threeTrackArray->AddAt(negtrack1,0);
1389  threeTrackArray->AddAt(postrack1,1);
1390  threeTrackArray->AddAt(negtrack2,2);
1391 
1392  // check invariant mass cuts for D+,Ds,Lc
1393  massCutOK=kTRUE;
1395  negtrack2->GetPxPyPz(momneg2);
1396  Double_t pxDau[3]={momneg1[0],mompos1[0],momneg2[0]};
1397  Double_t pyDau[3]={momneg1[1],mompos1[1],momneg2[1]};
1398  Double_t pzDau[3]={momneg1[2],mompos1[2],momneg2[2]};
1399  // massCutOK = SelectInvMassAndPt3prong(threeTrackArray);
1400  massCutOK = SelectInvMassAndPt3prong(pxDau,pyDau,pzDau,pidLcStatus);
1401  }
1402  if(!massCutOK) {
1403  threeTrackArray->Clear();
1404  negtrack2=0;
1405  continue;
1406  }
1407 
1408  // Vertexing
1409  twoTrackArray2->AddAt(postrack1,0);
1410  twoTrackArray2->AddAt(negtrack2,1);
1411 
1412  AliAODVertex *vertexp1n2 = ReconstructSecondaryVertex(twoTrackArray2,dispersion);
1413  if(!vertexp1n2) {
1414  twoTrackArray2->Clear();
1415  negtrack2=0;
1416  continue;
1417  }
1418 
1419  if(f3Prong) {
1420  AliAODVertex* secVert3PrAOD = ReconstructSecondaryVertex(threeTrackArray,dispersion);
1421  io3Prong = Make3Prong(threeTrackArray,event,secVert3PrAOD,dispersion,vertexp1n1,vertexp1n2,dcap1n1,dcap1n2,dcan1n2,okForLcTopKpi,okForDsToKKpi,ok3Prong);
1422  if(ok3Prong) {
1423  AliAODVertex *v3Prong = 0x0;
1424  if(!fMakeReducedRHF) v3Prong = new(verticesHFRef[iVerticesHF++])AliAODVertex(*secVert3PrAOD);
1425  if(!isLikeSign3Prong) {
1426  rd = new(aodCharm3ProngRef[i3Prong++])AliAODRecoDecayHF3Prong(*io3Prong);
1430  if(fMakeReducedRHF){
1431  rd->SetPrimaryVtxRef((AliAODVertex*)event->GetPrimaryVertex());
1432  ((AliAODRecoDecayHF3Prong*)rd)->DeleteRecoD();
1433  }else{
1434  rd->SetSecondaryVtx(v3Prong);
1435  v3Prong->SetParent(rd);
1436  AddRefs(v3Prong,rd,event,threeTrackArray);
1437  }
1438  } else { // isLikeSign3Prong
1439  if(fLikeSign3prong){
1440  rd = new(aodLikeSign3ProngRef[iLikeSign3Prong++])AliAODRecoDecayHF3Prong(*io3Prong);
1444  if(fMakeReducedRHF){
1445  rd->SetPrimaryVtxRef((AliAODVertex*)event->GetPrimaryVertex());
1446  ((AliAODRecoDecayHF3Prong*)rd)->DeleteRecoD();
1447  }else{
1448  rd->SetSecondaryVtx(v3Prong);
1449  v3Prong->SetParent(rd);
1450  AddRefs(v3Prong,rd,event,threeTrackArray);
1451  }
1452  }
1453 
1454  }
1455  }
1456  if(io3Prong) {delete io3Prong; io3Prong=NULL;}
1457  if(secVert3PrAOD) {delete secVert3PrAOD; secVert3PrAOD=NULL;}
1458  }
1459  threeTrackArray->Clear();
1460  negtrack2 = 0;
1461  delete vertexp1n2;
1462 
1463  } // end 2nd loop on negative tracks
1464 
1465  twoTrackArray2->Clear();
1466 
1467  negtrack1 = 0;
1468  delete vertexp1n1;
1469  } // end 1st loop on negative tracks
1470 
1471  postrack1 = 0;
1472  } // end 1st loop on positive tracks
1473 
1474 
1475  // AliDebug(1,Form(" Total HF vertices in event = %d;",
1476  // (Int_t)aodVerticesHFTClArr->GetEntriesFast()));
1477  if(fD0toKpi) {
1478  AliDebug(1,Form(" D0->Kpi in event = %d;",
1479  (Int_t)aodD0toKpiTClArr->GetEntriesFast()));
1480  }
1481  if(fJPSItoEle) {
1482  AliDebug(1,Form(" JPSI->ee in event = %d;",
1483  (Int_t)aodJPSItoEleTClArr->GetEntriesFast()));
1484  }
1485  if(f3Prong) {
1486  AliDebug(1,Form(" Charm->3Prong in event = %d;",
1487  (Int_t)aodCharm3ProngTClArr->GetEntriesFast()));
1488  }
1489  if(f4Prong) {
1490  AliDebug(1,Form(" Charm->4Prong in event = %d;\n",
1491  (Int_t)aodCharm4ProngTClArr->GetEntriesFast()));
1492  }
1493  if(fDstar) {
1494  AliDebug(1,Form(" D*->D0pi in event = %d;\n",
1495  (Int_t)aodDstarTClArr->GetEntriesFast()));
1496  }
1497  if(fCascades){
1498  AliDebug(1,Form(" cascades -> v0 + track in event = %d;\n",
1499  (Int_t)aodCascadesTClArr->GetEntriesFast()));
1500  }
1501  if(fLikeSign) {
1502  AliDebug(1,Form(" Like-sign 2Prong in event = %d;\n",
1503  (Int_t)aodLikeSign2ProngTClArr->GetEntriesFast()));
1504  }
1505  if(fLikeSign3prong && f3Prong) {
1506  AliDebug(1,Form(" Like-sign 3Prong in event = %d;\n",
1507  (Int_t)aodLikeSign3ProngTClArr->GetEntriesFast()));
1508  }
1509 
1510 
1511  twoTrackArray1->Delete(); delete twoTrackArray1;
1512  twoTrackArray2->Delete(); delete twoTrackArray2;
1513  twoTrackArrayCasc->Delete(); delete twoTrackArrayCasc;
1514  twoTrackArrayV0->Delete(); delete twoTrackArrayV0;
1515  threeTrackArray->Clear();
1516  threeTrackArray->Delete(); delete threeTrackArray;
1517  fourTrackArray->Delete(); delete fourTrackArray;
1518  delete [] seleFlags; seleFlags=NULL;
1519  if(evtNumber) {delete [] evtNumber; evtNumber=NULL;}
1520  tracksAtVertex.Delete();
1521 
1522  if(fInputAOD) {
1523  seleTrksArray.Delete();
1524  if(fAODMap) { delete [] fAODMap; fAODMap=NULL; }
1525  }
1526 
1527 
1528  //printf("Trks: total %d sele %d\n",fnTrksTotal,fnSeleTrksTotal);
1529 
1530  return;
1531 }
1532 //----------------------------------------------------------------------------
1534  const AliVEvent *event,
1535  const TObjArray *trkArray) const
1536 {
1539  //AliCodeTimerAuto("",0);
1540 
1541  if(fInputAOD) {
1542  AddDaughterRefs(v,event,trkArray);
1543  rd->SetPrimaryVtxRef((AliAODVertex*)event->GetPrimaryVertex());
1544  }
1545 
1546  /*
1547  rd->SetListOfCutsRef((TList*)fListOfCuts);
1548  //fListOfCuts->Print();
1549  cout<<fListOfCuts<<endl;
1550  TList *l=(TList*)rd->GetListOfCuts();
1551  cout<<l<<endl;
1552  if(l) {l->Print(); }else{printf("error\n");}
1553  */
1554 
1555  return;
1556 }
1557 //---------------------------------------------------------------------------
1559  const AliVEvent *event,
1560  const TObjArray *trkArray) const
1561 {
1563  //AliCodeTimerAuto("",0);
1564 
1565  Int_t nDg = v->GetNDaughters();
1566  TObject *dg = 0;
1567  if(nDg) dg = v->GetDaughter(0);
1568 
1569  if(dg) return; // daughters already added
1570 
1571  Int_t nTrks = trkArray->GetEntriesFast();
1572 
1573  AliExternalTrackParam *track = 0;
1574  AliAODTrack *aodTrack = 0;
1575  Int_t id;
1576 
1577  for(Int_t i=0; i<nTrks; i++) {
1578  track = (AliExternalTrackParam*)trkArray->UncheckedAt(i);
1579  id = (Int_t)track->GetID();
1580  //printf("---> %d\n",id);
1581  if(id<0) continue; // this track is a AliAODRecoDecay
1582  aodTrack = dynamic_cast<AliAODTrack*>(event->GetTrack(fAODMap[id]));
1583  if(!aodTrack) AliFatal("Not a standard AOD");
1584  v->AddDaughter(aodTrack);
1585  }
1586 
1587  return;
1588 }
1589 //----------------------------------------------------------------------------
1591 {
1594  //
1595  //AliCodeTimerAuto("",0);
1596 
1597 
1598  TClonesArray *inputArray=(TClonesArray*)aod->GetList()->FindObject("VerticesHF");
1599  if(!inputArray) return;
1600 
1601  AliAODTrack *track = 0;
1602  AliAODVertex *vertex = 0;
1603 
1604  Bool_t needtofix=kFALSE;
1605  for(Int_t iv=0; iv<inputArray->GetEntriesFast(); iv++) {
1606  vertex = (AliAODVertex*)inputArray->UncheckedAt(iv);
1607  for(Int_t id=0; id<vertex->GetNDaughters(); id++) {
1608  track = (AliAODTrack*)vertex->GetDaughter(id);
1609  if(!track->GetStatus()) needtofix=kTRUE;
1610  }
1611  if(needtofix) break;
1612  }
1613 
1614  if(!needtofix) return;
1615 
1616 
1617  printf("Fixing references\n");
1618 
1619  fAODMapSize = 100000;
1620  fAODMap = new Int_t[fAODMapSize];
1621  memset(fAODMap,0,sizeof(Int_t)*fAODMapSize);
1622 
1623  for(Int_t i=0; i<aod->GetNumberOfTracks(); i++) {
1624  track = dynamic_cast<AliAODTrack*>(aod->GetTrack(i));
1625  if(!track) AliFatal("Not a standard AOD");
1626 
1627  // skip pure ITS SA tracks
1628  if(track->GetStatus()&AliESDtrack::kITSpureSA) continue;
1629 
1630  // skip tracks without ITS
1631  if(!(track->GetStatus()&AliESDtrack::kITSin)) continue;
1632 
1633  // TEMPORARY: check that the cov matrix is there
1634  Double_t covtest[21];
1635  if(!track->GetCovarianceXYZPxPyPz(covtest)) continue;
1636  //
1637 
1638  Int_t ind = (Int_t)track->GetID();
1639  if (ind>-1 && ind < fAODMapSize) fAODMap[ind] = i;
1640  }
1641 
1642 
1643  Int_t ids[4]={-1,-1,-1,-1};
1644  for(Int_t iv=0; iv<inputArray->GetEntriesFast(); iv++) {
1645  Bool_t cascade=kFALSE;
1646  vertex = (AliAODVertex*)inputArray->UncheckedAt(iv);
1647  Int_t id=0;
1648  Int_t nDgs = vertex->GetNDaughters();
1649  for(id=0; id<nDgs; id++) {
1650  track = (AliAODTrack*)vertex->GetDaughter(id);
1651  if(track->Charge()==0) {cascade=kTRUE; continue;} // cascade
1652  ids[id]=(Int_t)track->GetID();
1653  vertex->RemoveDaughter(track);
1654  }
1655  if(cascade) continue;
1656  for(id=0; id<nDgs; id++) {
1657  if (ids[id]>-1 && ids[id] < fAODMapSize) {
1658  track = dynamic_cast<AliAODTrack*>(aod->GetTrack(fAODMap[ids[id]]));
1659  if(!track) AliFatal("Not a standard AOD");
1660  vertex->AddDaughter(track);
1661  }
1662  }
1663 
1664  }
1665 
1666  return;
1667 }
1668 //----------------------------------------------------------------------------
1670  // method to retrieve daughters from trackID and reconstruct secondary vertex
1671  // save the TRefs to the candidate AliAODRecoDecayHF3Prong rd
1672  // and fill on-the-fly the data member of rd
1673  if(rd->GetIsFilled()!=0)return kTRUE;//if 0: reduced dAOD. skip if rd is already filled (1: standard dAOD, 2 already refilled)
1674  if(!fAODMap)MapAODtracks(event);//fill the AOD index map if it is not yet done
1675 
1676  TObjArray *threeTrackArray = new TObjArray(3);
1677 
1678  AliAODTrack *track1 =(AliAODTrack*)event->GetTrack(fAODMap[rd->GetProngID(0)]);//retrieve daughter from the trackID through the AOD index map
1679  if(!track1)return kFALSE;
1680  AliAODTrack *track2 =(AliAODTrack*)event->GetTrack(fAODMap[rd->GetProngID(1)]);
1681  if(!track2)return kFALSE;
1682  AliESDtrack *postrack1 = 0;
1683  AliESDtrack *negtrack1 = 0;
1684  postrack1 = new AliESDtrack(track1);
1685  negtrack1 = new AliESDtrack(track2);
1686 
1687  // DCA between the two tracks
1688  Double_t xdummy, ydummy;
1689  fBzkG = (Double_t)event->GetMagneticField();
1690  Double_t dca12 = postrack1->GetDCA(negtrack1,fBzkG,xdummy,ydummy);
1691 
1692  const AliVVertex *vprimary = event->GetPrimaryVertex();
1693  Double_t pos[3];
1694  Double_t cov[6];
1695  vprimary->GetXYZ(pos);
1696  vprimary->GetCovarianceMatrix(cov);
1697  fV1 = new AliESDVertex(pos,cov,100.,100,vprimary->GetName());
1698  fV1->GetCovMatrix(cov);
1699  if(!fVertexerTracks)fVertexerTracks=new AliVertexerTracks(fBzkG);
1700 
1701  AliAODTrack *track3 =(AliAODTrack*)event->GetTrack(fAODMap[rd->GetProngID(2)]);
1702  if(!track3)return kFALSE;
1703  AliESDtrack *esdt3 = new AliESDtrack(track3);
1704 
1705  Double_t dca2;
1706  Double_t dca3;
1707  threeTrackArray->AddAt(postrack1,0);
1708  threeTrackArray->AddAt(negtrack1,1);
1709  threeTrackArray->AddAt(esdt3,2);
1710  dca2 = esdt3->GetDCA(negtrack1,fBzkG,xdummy,ydummy);
1711  dca3 = esdt3->GetDCA(postrack1,fBzkG,xdummy,ydummy);
1712  Double_t dispersion;
1713 
1714  AliAODVertex* secVert3PrAOD = ReconstructSecondaryVertex(threeTrackArray, dispersion);
1715  if (!secVert3PrAOD) {
1716  threeTrackArray->Clear();
1717  threeTrackArray->Delete(); delete threeTrackArray;
1718  delete fV1; fV1=0;
1719  delete postrack1; postrack1=NULL;
1720  delete negtrack1; negtrack1=NULL;
1721  delete esdt3; esdt3=NULL;
1722  return kFALSE;
1723  }
1724 
1725  Double_t vtxRec=rd->GetDist12toPrim();
1726  Double_t vertexp2n1=rd->GetDist23toPrim();
1727  rd= Make3Prong(threeTrackArray, event, secVert3PrAOD,dispersion, vtxRec, vertexp2n1, dca12, dca2, dca3, rd);
1728  rd->SetPrimaryVtxRef((AliAODVertex*)event->GetPrimaryVertex());
1729  rd->SetIsFilled(2);
1730  threeTrackArray->Clear();
1731  threeTrackArray->Delete(); delete threeTrackArray;
1732  delete fV1; fV1=0;
1733  delete postrack1; postrack1=NULL;
1734  delete negtrack1; negtrack1=NULL;
1735  delete esdt3; esdt3=NULL;
1736  return kTRUE;
1737 }
1738 //___________________________
1740  // method to retrieve daughters from trackID and reconstruct secondary vertex
1741  // save the TRefs to the candidate AliAODRecoDecayHF2Prong rd
1742  // and fill on-the-fly the data member of rd
1743  if(rd->GetIsFilled()!=0)return kTRUE;//if 0: reduced dAOD. skip if rd is already filled (1:standard dAOD, 2 already refilled)
1744  if(!fAODMap)MapAODtracks(event);//fill the AOD index map if it is not yet done
1745 
1746  Double_t dispersion;
1747  TObjArray *twoTrackArray1 = new TObjArray(2);
1748 
1749  AliAODTrack *track1 =(AliAODTrack*)event->GetTrack(fAODMap[rd->GetProngID(0)]);//retrieve daughter from the trackID through the AOD index map
1750  if(!track1)return kFALSE;
1751  AliAODTrack *track2 =(AliAODTrack*)event->GetTrack(fAODMap[rd->GetProngID(1)]);
1752  if(!track2)return kFALSE;
1753 
1754  AliESDtrack *esdt1 = 0;
1755  AliESDtrack *esdt2 = 0;
1756  esdt1 = new AliESDtrack(track1);
1757  esdt2 = new AliESDtrack(track2);
1758 
1759  twoTrackArray1->AddAt(esdt1,0);
1760  twoTrackArray1->AddAt(esdt2,1);
1761  // DCA between the two tracks
1762  Double_t xdummy, ydummy;
1763  fBzkG = (Double_t)event->GetMagneticField();
1764  Double_t dca12 = esdt1->GetDCA(esdt2,fBzkG,xdummy,ydummy);
1765  const AliVVertex *vprimary = event->GetPrimaryVertex();
1766  Double_t pos[3];
1767  Double_t cov[6];
1768  vprimary->GetXYZ(pos);
1769  vprimary->GetCovarianceMatrix(cov);
1770  fV1 = new AliESDVertex(pos,cov,100.,100,vprimary->GetName());
1771  fV1->GetCovMatrix(cov);
1772  if(!fVertexerTracks)fVertexerTracks=new AliVertexerTracks(fBzkG);
1773 
1774 
1775  AliAODVertex *vtxRec = ReconstructSecondaryVertex(twoTrackArray1, dispersion);
1776  if(!vtxRec) {
1777  twoTrackArray1->Clear();
1778  twoTrackArray1->Delete(); delete twoTrackArray1;
1779  delete fV1; fV1=0;
1780  delete esdt1; esdt1=NULL;
1781  delete esdt2; esdt2=NULL;
1782  return kFALSE; }
1783  Bool_t okD0=kFALSE;
1784  Bool_t okJPSI=kFALSE;
1785  Bool_t okD0FromDstar=kFALSE;
1786  Bool_t refill =kTRUE;
1787  rd= Make2Prong(twoTrackArray1, event, vtxRec, dca12, okD0, okJPSI, okD0FromDstar,refill,rd);
1788  rd->SetPrimaryVtxRef((AliAODVertex*)event->GetPrimaryVertex());
1789  rd->SetIsFilled(2);
1790  delete fV1; fV1=0;
1791  twoTrackArray1->Clear();
1792  twoTrackArray1->Delete(); delete twoTrackArray1;
1793  delete esdt1; esdt1=NULL;
1794  delete esdt2; esdt2=NULL;
1795  return kTRUE;
1796 }
1797 //----------------------------------------------------------------------------
1798 Bool_t AliAnalysisVertexingHF::FillRecoCasc(AliVEvent *event,AliAODRecoCascadeHF *rCasc, Bool_t DStar){
1799  // method to retrieve daughters from trackID
1800  // and fill on-the-fly the data member of rCasc and their AliAODRecoDecayHF2Prong daughters
1801  if(rCasc->GetIsFilled()!=0) return kTRUE;//if 0: reduced dAOD. skip if rd is already filled (1: standard dAOD, 2: already refilled)
1802  if(!fAODMap)MapAODtracks(event);//fill the AOD index map if it is not yet done
1803  TObjArray *twoTrackArrayCasc = new TObjArray(2);
1804 
1805  AliAODTrack *trackB =(AliAODTrack*)event->GetTrack(fAODMap[rCasc->GetProngID(0)]);//retrieve bachelor from the trackID through the AOD index map
1806  if(!trackB)return kFALSE;
1807 
1808  AliNeutralTrackParam *trackV0=NULL;
1809  AliAODv0 *v0 =NULL;
1810  AliAODRecoDecayHF2Prong *trackD0=NULL;
1811 
1812  if(DStar){
1813  TClonesArray *inputArrayD0=(TClonesArray*)event->GetList()->FindObject("D0toKpi");
1814  if(!inputArrayD0) return kFALSE;
1815  trackD0=(AliAODRecoDecayHF2Prong*)inputArrayD0->At(rCasc->GetProngID(1));
1816  if(!trackD0)return kFALSE;
1817  FillRecoCand(event,trackD0);//fill missing info of the corresponding D0 daughter
1818 
1819  trackV0 = new AliNeutralTrackParam(trackD0);
1820 
1821  }else{//is a V0 candidate
1822  v0 = ((AliAODEvent*)event)->GetV0(rCasc->GetProngID(1));
1823  if(!v0) return kFALSE;
1824  // Define the V0 (neutral) track
1825  const AliVTrack *trackVV0 = dynamic_cast<const AliVTrack*>(v0);
1826  if(trackVV0) trackV0 = new AliNeutralTrackParam(trackVV0);
1827  }
1828 
1829  AliESDtrack *esdB = new AliESDtrack(trackB);
1830 
1831  twoTrackArrayCasc->AddAt(esdB,0);
1832  twoTrackArrayCasc->AddAt(trackV0,1);
1833 
1834  fBzkG = (Double_t)event->GetMagneticField();
1835  const AliVVertex *vprimary = event->GetPrimaryVertex();
1836 
1837  Double_t pos[3];
1838  Double_t cov[6];
1839  vprimary->GetXYZ(pos);
1840  vprimary->GetCovarianceMatrix(cov);
1841  fV1 = new AliESDVertex(pos,cov,100.,100,vprimary->GetName());
1842  fV1->GetCovMatrix(cov);
1843 
1844  Double_t dca = 0.;
1845  AliAODVertex *vtxCasc = 0x0;
1846  Double_t chi2perNDF = fV1->GetChi2toNDF();
1847  vtxCasc = new AliAODVertex(pos,cov,chi2perNDF,0x0,-1,AliAODVertex::kUndef,2);
1848  if(!vtxCasc) {
1849  twoTrackArrayCasc->Clear();
1850  twoTrackArrayCasc->Delete(); delete twoTrackArrayCasc;
1851  delete fV1; fV1=0;
1852  delete esdB; esdB=NULL;
1853  delete vtxCasc;vtxCasc=NULL;
1854  delete trackB; trackB=NULL;
1855  delete trackV0; trackV0=NULL;
1856  if(!DStar){
1857  v0=NULL;
1858  }
1859  return kFALSE;
1860  }
1861  vtxCasc->SetParent(rCasc);
1862  rCasc->SetSecondaryVtx(vtxCasc);
1863  AddDaughterRefs(vtxCasc,(AliAODEvent*)event,twoTrackArrayCasc);
1864  if(DStar)vtxCasc->AddDaughter(trackD0);
1865  else vtxCasc->AddDaughter(v0);
1866  rCasc->SetPrimaryVtxRef((AliAODVertex*)event->GetPrimaryVertex());
1867 
1868  Bool_t refill =kTRUE;
1869  Bool_t dummy1, dummy2, dummy3;
1870 
1871  Double_t px[2],py[2],pz[2],d0[2],d0err[2];
1872  // propagate tracks to secondary vertex, to compute inv. mass
1873  esdB->PropagateToDCA(vtxCasc,fBzkG,kVeryBig);
1874  trackV0->PropagateToDCA(vtxCasc,fBzkG,kVeryBig);
1875  Double_t momentum[3];
1876  esdB->GetPxPyPz(momentum);
1877  px[0] = momentum[0]; py[0] = momentum[1]; pz[0] = momentum[2];
1878  trackV0->GetPxPyPz(momentum);
1879  px[1] = momentum[0]; py[1] = momentum[1]; pz[1] = momentum[2];
1880 
1881  AliAODVertex *primVertexAOD = PrimaryVertex(twoTrackArrayCasc,event);
1882  if(!primVertexAOD){
1883  delete fV1; fV1=0;
1884  delete vtxCasc; vtxCasc=NULL;
1885  twoTrackArrayCasc->Clear();
1886  twoTrackArrayCasc->Delete(); delete twoTrackArrayCasc;
1887  delete esdB; esdB=NULL;
1888  delete trackV0; trackV0=NULL;
1889  if(!DStar)v0=NULL;
1890  return kFALSE;
1891  }
1892  Double_t d0z0[2],covd0z0[3];
1893  esdB->PropagateToDCA(primVertexAOD,fBzkG,kVeryBig,d0z0,covd0z0);
1894  d0[0] = d0z0[0];
1895  d0err[0] = TMath::Sqrt(covd0z0[0]);
1896  trackV0->PropagateToDCA(primVertexAOD,fBzkG,kVeryBig,d0z0,covd0z0);
1897  d0[1] = d0z0[0];
1898  d0err[1] = TMath::Sqrt(covd0z0[0]);
1899  rCasc->SetPxPyPzProngs(2,px,py,pz);
1900  rCasc->SetDCA(dca);
1901  rCasc->Setd0Prongs(2,d0);
1902  rCasc->Setd0errProngs(2,d0err);
1903  rCasc->SetCharge(esdB->Charge());
1904  // get PID info from ESD
1905  Double_t esdpid0[5]={0.,0.,0.,0.,0.};
1906  if(esdB->GetStatus()&AliESDtrack::kESDpid) esdB->GetESDpid(esdpid0);
1907  Double_t esdpid1[5]={0.,0.,0.,0.,0.};
1908  Double_t esdpid[10];
1909  for(Int_t i=0;i<5;i++) {
1910  esdpid[i] = esdpid0[i];
1911  esdpid[5+i] = esdpid1[i];
1912  }
1913  rCasc->SetPID(2,esdpid);
1914  rCasc->SetIsFilled(2);
1915 
1916 
1917  delete fV1; fV1=0;
1918  if(primVertexAOD) {delete primVertexAOD; primVertexAOD=NULL;}
1919  twoTrackArrayCasc->Clear();
1920  twoTrackArrayCasc->Delete(); delete twoTrackArrayCasc;
1921  delete esdB; esdB=NULL;
1922  delete trackV0; trackV0=NULL;
1923  if(!DStar)v0=NULL;
1924  return kTRUE;
1925 }
1926 //---------------------------------------------------------------------------
1928  TObjArray *twoTrackArray,AliVEvent *event,
1929  AliAODVertex *secVert,
1930  AliAODRecoDecayHF2Prong *rd2Prong,
1931  Double_t dca,
1932  Bool_t &okDstar)
1933 {
1936  //AliCodeTimerAuto("",0);
1937 
1938  okDstar = kFALSE;
1939 
1940  Bool_t dummy1,dummy2,dummy3;
1941 
1942  // We use Make2Prong to construct the AliAODRecoCascadeHF
1943  // (which inherits from AliAODRecoDecayHF2Prong)
1944  AliAODRecoCascadeHF *theCascade =
1945  (AliAODRecoCascadeHF*)Make2Prong(twoTrackArray,event,secVert,dca,
1946  dummy1,dummy2,dummy3);
1947  if(!theCascade) return 0x0;
1948 
1949  // charge
1950  AliESDtrack *trackPi = (AliESDtrack*)twoTrackArray->UncheckedAt(0);
1951  theCascade->SetCharge(trackPi->Charge());
1952 
1953  //--- selection cuts
1954  //
1955  AliAODRecoCascadeHF *tmpCascade = new AliAODRecoCascadeHF(*theCascade);
1956  if(fInputAOD){
1957  Int_t idSoftPi=(Int_t)trackPi->GetID();
1958  if (idSoftPi > -1 && idSoftPi < fAODMapSize) {
1959  AliAODTrack* trackPiAOD=dynamic_cast<AliAODTrack*>(event->GetTrack(fAODMap[idSoftPi]));
1960  if(!trackPiAOD) AliFatal("Not a standard AOD");
1961  tmpCascade->GetSecondaryVtx()->AddDaughter(trackPiAOD);
1962  }
1963  }else{
1964  tmpCascade->GetSecondaryVtx()->AddDaughter(trackPi);
1965  }
1966  tmpCascade->GetSecondaryVtx()->AddDaughter(rd2Prong);
1967 
1968  AliAODVertex *primVertexAOD=0;
1970  // take event primary vertex
1971  primVertexAOD = PrimaryVertex();
1972  tmpCascade->SetOwnPrimaryVtx(primVertexAOD);
1973  rd2Prong->SetOwnPrimaryVtx(primVertexAOD);
1974  }
1975  // select D*->D0pi
1976  if(fDstar) {
1977  okDstar = (Bool_t)fCutsDStartoKpipi->IsSelected(tmpCascade,AliRDHFCuts::kCandidate);
1978  if(okDstar) theCascade->SetSelectionBit(AliRDHFCuts::kDstarCuts);
1979  }
1980  tmpCascade->GetSecondaryVtx()->RemoveDaughters();
1981  tmpCascade->UnsetOwnPrimaryVtx();
1982  delete tmpCascade; tmpCascade=NULL;
1984  rd2Prong->UnsetOwnPrimaryVtx();
1985  }
1986  if(primVertexAOD) {delete primVertexAOD; primVertexAOD=NULL;}
1987  //---
1988 
1989 
1990  return theCascade;
1991 }
1992 
1993 
1994 //----------------------------------------------------------------------------
1996  TObjArray *twoTrackArray,AliVEvent *event,
1997  AliAODVertex *secVert,
1998  AliAODv0 *v0,
1999  Double_t dca,
2000  Bool_t &okCascades)
2001 {
2004  //AliCodeTimerAuto("",0);
2005 
2006  // AliDebug(2,Form(" building the cascade"));
2007  okCascades= kFALSE;
2008  Bool_t dummy1,dummy2,dummy3;
2009 
2010  // We use Make2Prong to construct the AliAODRecoCascadeHF
2011  // (which inherits from AliAODRecoDecayHF2Prong)
2012  AliAODRecoCascadeHF *theCascade =
2013  (AliAODRecoCascadeHF*)Make2Prong(twoTrackArray,event,secVert,dca,
2014  dummy1,dummy2,dummy3);
2015  if(!theCascade) return 0x0;
2016 
2017  // bachelor track and charge
2018  AliESDtrack *trackBachelor = (AliESDtrack*)twoTrackArray->UncheckedAt(0);
2019  theCascade->SetCharge(trackBachelor->Charge());
2020 
2021  //--- selection cuts
2022  //
2023 
2024  AliAODRecoCascadeHF *tmpCascade = new AliAODRecoCascadeHF(*theCascade);
2025  if(fInputAOD){
2026  Int_t idBachelor=(Int_t)trackBachelor->GetID();
2027  if (idBachelor > -1 && idBachelor < fAODMapSize) {
2028  AliAODTrack* trackBachelorAOD=dynamic_cast<AliAODTrack*>(event->GetTrack(fAODMap[idBachelor]));
2029  if(!trackBachelorAOD) AliFatal("Not a standard AOD");
2030  tmpCascade->GetSecondaryVtx()->AddDaughter(trackBachelorAOD);
2031  }
2032  }else{
2033  tmpCascade->GetSecondaryVtx()->AddDaughter(trackBachelor);
2034  }
2035  tmpCascade->GetSecondaryVtx()->AddDaughter(v0);
2036 
2037  AliAODVertex *primVertexAOD=0;
2039  // take event primary vertex
2040  primVertexAOD = PrimaryVertex();
2041  if(!primVertexAOD) primVertexAOD = (AliAODVertex*)event->GetPrimaryVertex();
2042  tmpCascade->SetOwnPrimaryVtx(primVertexAOD);
2043  }
2044 
2045  // select Cascades
2046  if(fCascades && fInputAOD){
2047  okCascades = (Bool_t)fCutsLctoV0->IsSelected(tmpCascade,AliRDHFCuts::kCandidate);
2048  }
2049  else {
2050  //AliDebug(2,Form("The cascade is contructed from ESDs, no cuts are applied"));
2051  okCascades=kTRUE;
2052  }// no cuts implemented from ESDs
2053  tmpCascade->GetSecondaryVtx()->RemoveDaughters();
2054  tmpCascade->UnsetOwnPrimaryVtx();
2055  delete tmpCascade; tmpCascade=NULL;
2056  if(primVertexAOD) {delete primVertexAOD; primVertexAOD=NULL;}
2057  //---
2058 
2059  return theCascade;
2060 }
2061 
2062 //-----------------------------------------------------------------------------
2064  TObjArray *twoTrackArray,AliVEvent *event,
2065  AliAODVertex *secVert,Double_t dca,
2066  Bool_t &okD0,Bool_t &okJPSI,
2067  Bool_t &okD0fromDstar, Bool_t refill, AliAODRecoDecayHF2Prong *rd)
2068 {
2071  // G.E.Bruno (J/psi), A.Dainese (D0->Kpi)
2072  // AliCodeTimerAuto("",0);
2073  okD0=kFALSE; okJPSI=kFALSE; okD0fromDstar=kFALSE;
2074 
2075  Double_t px[2],py[2],pz[2],d0[2],d0err[2];
2076  AliESDtrack *postrack = (AliESDtrack*)twoTrackArray->UncheckedAt(0);
2077  AliESDtrack *negtrack = (AliESDtrack*)twoTrackArray->UncheckedAt(1);
2078 
2079  // propagate tracks to secondary vertex, to compute inv. mass
2080  postrack->PropagateToDCA(secVert,fBzkG,kVeryBig);
2081  negtrack->PropagateToDCA(secVert,fBzkG,kVeryBig);
2082 
2083  Double_t momentum[3];
2084  postrack->GetPxPyPz(momentum);
2085  px[0] = momentum[0]; py[0] = momentum[1]; pz[0] = momentum[2];
2086  negtrack->GetPxPyPz(momentum);
2087  px[1] = momentum[0]; py[1] = momentum[1]; pz[1] = momentum[2];
2088 
2089  if(!refill){//skip if it is called in refill step because already checked
2090  // invariant mass cut (try to improve coding here..)
2091  Bool_t okMassCut=kFALSE;
2092  if(!okMassCut && fD0toKpi) if(SelectInvMassAndPtD0Kpi(px,py,pz)) okMassCut=kTRUE;
2093  if(!okMassCut && fJPSItoEle) if(SelectInvMassAndPtJpsiee(px,py,pz)) okMassCut=kTRUE;
2094  if(!okMassCut && fDstar) if(SelectInvMassAndPtDstarD0pi(px,py,pz)) okMassCut=kTRUE;
2095  if(!okMassCut && fCascades) if(SelectInvMassAndPtCascade(px,py,pz)) okMassCut=kTRUE;
2096  if(!okMassCut) {
2097  //AliDebug(2," candidate didn't pass mass cut");
2098  return 0x0;
2099  }
2100  }
2101  // primary vertex to be used by this candidate
2102  AliAODVertex *primVertexAOD = PrimaryVertex(twoTrackArray,event);
2103  if(!primVertexAOD) return 0x0;
2104 
2105  Double_t d0z0[2],covd0z0[3];
2106  postrack->PropagateToDCA(primVertexAOD,fBzkG,kVeryBig,d0z0,covd0z0);
2107  d0[0] = d0z0[0];
2108  d0err[0] = TMath::Sqrt(covd0z0[0]);
2109  negtrack->PropagateToDCA(primVertexAOD,fBzkG,kVeryBig,d0z0,covd0z0);
2110  d0[1] = d0z0[0];
2111  d0err[1] = TMath::Sqrt(covd0z0[0]);
2112  AliAODRecoDecayHF2Prong *the2Prong;
2113  // create the object AliAODRecoDecayHF2Prong
2114  if(!refill){
2115  the2Prong = new AliAODRecoDecayHF2Prong(secVert,px,py,pz,d0,d0err,dca);
2116  the2Prong->SetOwnPrimaryVtx(primVertexAOD);
2117  UShort_t id[2]={(UShort_t)postrack->GetID(),(UShort_t)negtrack->GetID()};
2118  the2Prong->SetProngIDs(2,id);
2119  if(postrack->Charge()!=0 && negtrack->Charge()!=0) { // don't apply these cuts if it's a Dstar
2120  // Add daughter references already here
2121  if(fInputAOD) AddDaughterRefs(secVert,(AliAODEvent*)event,twoTrackArray);
2122 
2123  // select D0->Kpi
2124  if(fD0toKpi) {
2125  okD0 = (Bool_t)fCutsD0toKpi->IsSelected(the2Prong,AliRDHFCuts::kCandidate,(AliAODEvent*)event);
2126  if(okD0) the2Prong->SetSelectionBit(AliRDHFCuts::kD0toKpiCuts);
2127  }
2128  //if(fDebug && fD0toKpi) printf(" %d\n",(Int_t)okD0);
2129  // select J/psi from B
2130  if(fJPSItoEle) {
2131  okJPSI = (Bool_t)fCutsJpsitoee->IsSelected(the2Prong,AliRDHFCuts::kCandidate);
2132  }
2133  //if(fDebug && fJPSItoEle) printf(" %d\n",(Int_t)okJPSI);
2134  // select D0->Kpi from Dstar
2135  if(fDstar) {
2136  okD0fromDstar = (Bool_t)fCutsDStartoKpipi->IsD0FromDStarSelected(the2Prong->Pt(),the2Prong,AliRDHFCuts::kCandidate);
2137  if(okD0fromDstar) the2Prong->SetSelectionBit(AliRDHFCuts::kD0fromDstarCuts);
2138  }
2139  //if(fDebug && fDstar) printf(" %d\n",(Int_t)okD0fromDstar);
2140  }
2141  }else{
2142  the2Prong =rd;
2143  the2Prong->SetSecondaryVtx(secVert);
2144  secVert->SetParent(the2Prong);
2145  AddDaughterRefs(secVert,(AliAODEvent*)event,twoTrackArray);
2146  the2Prong->SetOwnPrimaryVtx(primVertexAOD);
2147  the2Prong->SetPxPyPzProngs(2,px,py,pz);
2148  the2Prong->SetDCA(dca);
2149  the2Prong->Setd0Prongs(2,d0);
2150  the2Prong->Setd0errProngs(2,d0err);
2151  the2Prong->SetCharge(0);
2152  }
2153  delete primVertexAOD; primVertexAOD=NULL;
2154 
2155  // remove the primary vertex (was used only for selection)
2157  the2Prong->UnsetOwnPrimaryVtx();
2158  }
2159 
2160  // get PID info from ESD
2161  Double_t esdpid0[5]={0.,0.,0.,0.,0.};
2162  if(postrack->GetStatus()&AliESDtrack::kESDpid) postrack->GetESDpid(esdpid0);
2163  Double_t esdpid1[5]={0.,0.,0.,0.,0.};
2164  if(negtrack->GetStatus()&AliESDtrack::kESDpid) negtrack->GetESDpid(esdpid1);
2165  Double_t esdpid[10];
2166  for(Int_t i=0;i<5;i++) {
2167  esdpid[i] = esdpid0[i];
2168  esdpid[5+i] = esdpid1[i];
2169  }
2170  the2Prong->SetPID(2,esdpid);
2171  return the2Prong;
2172 }
2173 //----------------------------------------------------------------------------
2175  TObjArray *threeTrackArray,AliVEvent *event,
2176  AliAODVertex *secVert,Double_t dispersion,
2177  const AliAODVertex *vertexp1n1,const AliAODVertex *vertexp2n1,
2178  Double_t dcap1n1,Double_t dcap2n1,Double_t dcap1p2,
2179  Bool_t useForLc, Bool_t useForDs, Bool_t &ok3Prong)
2180 {
2183  // E.Bruna, F.Prino
2184  // AliCodeTimerAuto("",0);
2185 
2186  ok3Prong=kFALSE;
2187  if(!secVert || !vertexp1n1 || !vertexp2n1) return 0x0;
2188 
2189  Double_t px[3],py[3],pz[3],d0[3],d0err[3];
2190  Double_t momentum[3];
2191 
2192 
2193  AliESDtrack *postrack1 = (AliESDtrack*)threeTrackArray->UncheckedAt(0);
2194  AliESDtrack *negtrack = (AliESDtrack*)threeTrackArray->UncheckedAt(1);
2195  AliESDtrack *postrack2 = (AliESDtrack*)threeTrackArray->UncheckedAt(2);
2196 
2197  postrack1->PropagateToDCA(secVert,fBzkG,kVeryBig);
2198  negtrack->PropagateToDCA(secVert,fBzkG,kVeryBig);
2199  postrack2->PropagateToDCA(secVert,fBzkG,kVeryBig);
2200  postrack1->GetPxPyPz(momentum);
2201  px[0] = momentum[0]; py[0] = momentum[1]; pz[0] = momentum[2];
2202  negtrack->GetPxPyPz(momentum);
2203  px[1] = momentum[0]; py[1] = momentum[1]; pz[1] = momentum[2];
2204  postrack2->GetPxPyPz(momentum);
2205  px[2] = momentum[0]; py[2] = momentum[1]; pz[2] = momentum[2];
2206 
2207  // invariant mass cut for D+, Ds, Lc
2208  Bool_t okMassCut=kFALSE;
2209  if(fMassCutBeforeVertexing) okMassCut=kTRUE; // mass cut already done and passed
2210  if(!okMassCut && f3Prong) if(SelectInvMassAndPt3prong(px,py,pz)) okMassCut=kTRUE;
2211  if(!okMassCut) {
2212  //AliDebug(2," candidate didn't pass mass cut");
2213  return 0x0;
2214  }
2215 
2216  // primary vertex to be used by this candidate
2217  AliAODVertex *primVertexAOD = PrimaryVertex(threeTrackArray,event);
2218  if(!primVertexAOD) return 0x0;
2219 
2220  Double_t d0z0[2],covd0z0[3];
2221  postrack1->PropagateToDCA(primVertexAOD,fBzkG,kVeryBig,d0z0,covd0z0);
2222  d0[0]=d0z0[0];
2223  d0err[0] = TMath::Sqrt(covd0z0[0]);
2224  negtrack->PropagateToDCA(primVertexAOD,fBzkG,kVeryBig,d0z0,covd0z0);
2225  d0[1]=d0z0[0];
2226  d0err[1] = TMath::Sqrt(covd0z0[0]);
2227  postrack2->PropagateToDCA(primVertexAOD,fBzkG,kVeryBig,d0z0,covd0z0);
2228  d0[2]=d0z0[0];
2229  d0err[2] = TMath::Sqrt(covd0z0[0]);
2230 
2231 
2232  // create the object AliAODRecoDecayHF3Prong
2233  Double_t pos[3]; primVertexAOD->GetXYZ(pos);
2234  Double_t dca[3]={dcap1n1,dcap2n1,dcap1p2};
2235  Double_t dist12=TMath::Sqrt((vertexp1n1->GetX()-pos[0])*(vertexp1n1->GetX()-pos[0])+(vertexp1n1->GetY()-pos[1])*(vertexp1n1->GetY()-pos[1])+(vertexp1n1->GetZ()-pos[2])*(vertexp1n1->GetZ()-pos[2]));
2236  Double_t dist23=TMath::Sqrt((vertexp2n1->GetX()-pos[0])*(vertexp2n1->GetX()-pos[0])+(vertexp2n1->GetY()-pos[1])*(vertexp2n1->GetY()-pos[1])+(vertexp2n1->GetZ()-pos[2])*(vertexp2n1->GetZ()-pos[2]));
2237  Short_t charge=(Short_t)(postrack1->Charge()+postrack2->Charge()+negtrack->Charge());
2238  AliAODRecoDecayHF3Prong *the3Prong = new AliAODRecoDecayHF3Prong(secVert,px,py,pz,d0,d0err,dca,dispersion,dist12,dist23,charge);
2239  the3Prong->SetOwnPrimaryVtx(primVertexAOD);
2240  UShort_t id[3]={(UShort_t)postrack1->GetID(),(UShort_t)negtrack->GetID(),(UShort_t)postrack2->GetID()};
2241  the3Prong->SetProngIDs(3,id);
2242 
2243  delete primVertexAOD; primVertexAOD=NULL;
2244 
2245  // Add daughter references already here
2246  if(fInputAOD) AddDaughterRefs(secVert,(AliAODEvent*)event,threeTrackArray);
2247 
2248  // select D+->Kpipi, Ds->KKpi, Lc->pKpi
2249  if(f3Prong) {
2250  ok3Prong = kFALSE;
2251 
2252  if(fOKInvMassDplus && fCutsDplustoKpipi->IsSelected(the3Prong,AliRDHFCuts::kCandidate,(AliAODEvent*)event)) {
2253  ok3Prong = kTRUE;
2255  }
2256  if(useForDs && fOKInvMassDs){
2257  if(fCutsDstoKKpi->IsSelected(the3Prong,AliRDHFCuts::kCandidate,(AliAODEvent*)event)) {
2258  ok3Prong = kTRUE;
2260  }
2261  }
2262  if(useForLc && fOKInvMassLc){
2263  if(fCutsLctopKpi->IsSelected(the3Prong,AliRDHFCuts::kCandidate,(AliAODEvent*)event)) {
2264  ok3Prong = kTRUE;
2266  }
2267  }
2268  }
2269  //if(fDebug) printf("ok3Prong: %d\n",(Int_t)ok3Prong);
2270 
2272  the3Prong->UnsetOwnPrimaryVtx();
2273  }
2274 
2275  // get PID info from ESD
2276  Double_t esdpid0[5]={0.,0.,0.,0.,0.};
2277  if(postrack1->GetStatus()&AliESDtrack::kESDpid) postrack1->GetESDpid(esdpid0);
2278  Double_t esdpid1[5]={0.,0.,0.,0.,0.};
2279  if(negtrack->GetStatus()&AliESDtrack::kESDpid) negtrack->GetESDpid(esdpid1);
2280  Double_t esdpid2[5]={0.,0.,0.,0.,0.};
2281  if(postrack2->GetStatus()&AliESDtrack::kESDpid) postrack2->GetESDpid(esdpid2);
2282 
2283  Double_t esdpid[15];
2284  for(Int_t i=0;i<5;i++) {
2285  esdpid[i] = esdpid0[i];
2286  esdpid[5+i] = esdpid1[i];
2287  esdpid[10+i] = esdpid2[i];
2288  }
2289  the3Prong->SetPID(3,esdpid);
2290 
2291  return the3Prong;
2292 }
2293 //----------------------------------------------------------------------------
2295  TObjArray *threeTrackArray,AliVEvent *event,
2296  AliAODVertex *secVert,Double_t dispersion,
2297  Double32_t dist12, Double32_t dist23,
2298  Double_t dcap1n1,Double_t dcap2n1,Double_t dcap1p2,
2300 {
2301  // Fill on-the-fly the 3prong data member missing info
2302  // set TRef of vertex and daughters
2303  // do not recalculate the two-track secondary vertex dist12 and dist23
2304  // because they are stored in the AliAODRecoDecayHF3Prong candidate
2305  // reconstructed in the FindCandidate step
2306  // do not check if it is a Lambdac, Ds or Dplus because it is already check in the FindCandidate step
2307  // and the info is stored
2308  // AliCodeTimerAuto("",0);
2309 
2310  Double_t px[3],py[3],pz[3],d0[3],d0err[3];
2311  Double_t momentum[3];
2312 
2313 
2314  AliESDtrack *postrack1 = (AliESDtrack*)threeTrackArray->UncheckedAt(0);
2315  AliESDtrack *negtrack = (AliESDtrack*)threeTrackArray->UncheckedAt(1);
2316  AliESDtrack *postrack2 = (AliESDtrack*)threeTrackArray->UncheckedAt(2);
2317 
2318  postrack1->PropagateToDCA(secVert,fBzkG,kVeryBig);
2319  negtrack->PropagateToDCA(secVert,fBzkG,kVeryBig);
2320  postrack2->PropagateToDCA(secVert,fBzkG,kVeryBig);
2321  postrack1->GetPxPyPz(momentum);
2322  px[0] = momentum[0]; py[0] = momentum[1]; pz[0] = momentum[2];
2323  negtrack->GetPxPyPz(momentum);
2324  px[1] = momentum[0]; py[1] = momentum[1]; pz[1] = momentum[2];
2325  postrack2->GetPxPyPz(momentum);
2326  px[2] = momentum[0]; py[2] = momentum[1]; pz[2] = momentum[2];
2327  // primary vertex to be used by this candidate
2328  AliAODVertex *primVertexAOD = PrimaryVertex(threeTrackArray,event);
2329  if(!primVertexAOD) return 0x0;
2330  Double_t d0z0[2],covd0z0[3];
2331  postrack1->PropagateToDCA(primVertexAOD,fBzkG,kVeryBig,d0z0,covd0z0);
2332  d0[0]=d0z0[0];
2333  d0err[0] = TMath::Sqrt(covd0z0[0]);
2334  negtrack->PropagateToDCA(primVertexAOD,fBzkG,kVeryBig,d0z0,covd0z0);
2335  d0[1]=d0z0[0];
2336  d0err[1] = TMath::Sqrt(covd0z0[0]);
2337  postrack2->PropagateToDCA(primVertexAOD,fBzkG,kVeryBig,d0z0,covd0z0);
2338  d0[2]=d0z0[0];
2339  d0err[2] = TMath::Sqrt(covd0z0[0]);
2340 
2341  Double_t pos[3]; primVertexAOD->GetXYZ(pos);
2342  Double_t dca[3]={dcap1n1,dcap2n1,dcap1p2};
2343  Short_t charge=(Short_t)(postrack1->Charge()+postrack2->Charge()+negtrack->Charge());
2344 
2345  rd->SetSecondaryVtx(secVert);
2346  secVert->SetParent(rd);
2347  AddDaughterRefs(secVert,(AliAODEvent*)event,threeTrackArray);
2348 
2349  rd->SetPxPyPzProngs(3,px,py,pz);
2350  rd->SetDCAs(3,dca);
2351  rd->Setd0Prongs(3,d0);
2352  rd->Setd0errProngs(3,d0err);
2353  rd->SetCharge(charge);
2354  rd->SetOwnPrimaryVtx(primVertexAOD);
2355  rd->SetSigmaVert(dispersion);
2356  delete primVertexAOD; primVertexAOD=NULL;
2357 
2359  rd->UnsetOwnPrimaryVtx();
2360  }
2361 
2362  // get PID info from ESD
2363  Double_t esdpid0[5]={0.,0.,0.,0.,0.};
2364  if(postrack1->GetStatus()&AliESDtrack::kESDpid) postrack1->GetESDpid(esdpid0);
2365  Double_t esdpid1[5]={0.,0.,0.,0.,0.};
2366  if(negtrack->GetStatus()&AliESDtrack::kESDpid) negtrack->GetESDpid(esdpid1);
2367  Double_t esdpid2[5]={0.,0.,0.,0.,0.};
2368  if(postrack2->GetStatus()&AliESDtrack::kESDpid) postrack2->GetESDpid(esdpid2);
2369 
2370  Double_t esdpid[15];
2371  for(Int_t i=0;i<5;i++) {
2372  esdpid[i] = esdpid0[i];
2373  esdpid[5+i] = esdpid1[i];
2374  esdpid[10+i] = esdpid2[i];
2375  }
2376  rd->SetPID(3,esdpid);
2377  return rd;
2378 }
2379 //----------------------------------------------------------------------------
2381  TObjArray *fourTrackArray,AliVEvent *event,
2382  AliAODVertex *secVert,
2383  const AliAODVertex *vertexp1n1,
2384  const AliAODVertex *vertexp1n1p2,
2385  Double_t dcap1n1,Double_t dcap1n2,
2386  Double_t dcap2n1,Double_t dcap2n2,
2387  Bool_t &ok4Prong)
2388 {
2391  // G.E.Bruno, R.Romita
2392  // AliCodeTimerAuto("",0);
2393 
2394  ok4Prong=kFALSE;
2395  if(!secVert || !vertexp1n1 || !vertexp1n1p2) return 0x0;
2396 
2397  Double_t px[4],py[4],pz[4],d0[4],d0err[4];//d0z[3];
2398 
2399  AliESDtrack *postrack1 = (AliESDtrack*)fourTrackArray->UncheckedAt(0);
2400  AliESDtrack *negtrack1 = (AliESDtrack*)fourTrackArray->UncheckedAt(1);
2401  AliESDtrack *postrack2 = (AliESDtrack*)fourTrackArray->UncheckedAt(2);
2402  AliESDtrack *negtrack2 = (AliESDtrack*)fourTrackArray->UncheckedAt(3);
2403 
2404  postrack1->PropagateToDCA(secVert,fBzkG,kVeryBig);
2405  negtrack1->PropagateToDCA(secVert,fBzkG,kVeryBig);
2406  postrack2->PropagateToDCA(secVert,fBzkG,kVeryBig);
2407  negtrack2->PropagateToDCA(secVert,fBzkG,kVeryBig);
2408 
2409  Double_t momentum[3];
2410  postrack1->GetPxPyPz(momentum);
2411  px[0] = momentum[0]; py[0] = momentum[1]; pz[0] = momentum[2];
2412  negtrack1->GetPxPyPz(momentum);
2413  px[1] = momentum[0]; py[1] = momentum[1]; pz[1] = momentum[2];
2414  postrack2->GetPxPyPz(momentum);
2415  px[2] = momentum[0]; py[2] = momentum[1]; pz[2] = momentum[2];
2416  negtrack2->GetPxPyPz(momentum);
2417  px[3] = momentum[0]; py[3] = momentum[1]; pz[3] = momentum[2];
2418 
2419  // invariant mass cut for rho or D0 (try to improve coding here..)
2420  Bool_t okMassCut=kFALSE;
2421  if(fMassCutBeforeVertexing) okMassCut=kTRUE; // mass cut already done and passed
2422  if(!okMassCut && !(fCutsD0toKpipipi->GetUsePID())) { //no PID, to be implemented with PID
2423  if(SelectInvMassAndPt4prong(px,py,pz)) okMassCut=kTRUE;
2424  }
2425  if(!okMassCut) {
2426  //if(fDebug) printf(" candidate didn't pass mass cut\n");
2427  //printf(" candidate didn't pass mass cut\n");
2428  return 0x0;
2429  }
2430 
2431  // primary vertex to be used by this candidate
2432  AliAODVertex *primVertexAOD = PrimaryVertex(fourTrackArray,event);
2433  if(!primVertexAOD) return 0x0;
2434 
2435  Double_t d0z0[2],covd0z0[3];
2436  postrack1->PropagateToDCA(primVertexAOD,fBzkG,kVeryBig,d0z0,covd0z0);
2437  d0[0]=d0z0[0];
2438  d0err[0] = TMath::Sqrt(covd0z0[0]);
2439  negtrack1->PropagateToDCA(primVertexAOD,fBzkG,kVeryBig,d0z0,covd0z0);
2440  d0[1]=d0z0[0];
2441  d0err[1] = TMath::Sqrt(covd0z0[0]);
2442  postrack2->PropagateToDCA(primVertexAOD,fBzkG,kVeryBig,d0z0,covd0z0);
2443  d0[2]=d0z0[0];
2444  d0err[2] = TMath::Sqrt(covd0z0[0]);
2445  negtrack2->PropagateToDCA(primVertexAOD,fBzkG,kVeryBig,d0z0,covd0z0);
2446  d0[3]=d0z0[0];
2447  d0err[3] = TMath::Sqrt(covd0z0[0]);
2448 
2449 
2450  // create the object AliAODRecoDecayHF4Prong
2451  Double_t pos[3]; primVertexAOD->GetXYZ(pos);
2452  Double_t dca[6]={dcap1n1,0.,dcap1n2,dcap2n1,0.,dcap2n2};
2453  Double_t dist12=TMath::Sqrt((vertexp1n1->GetX()-pos[0])*(vertexp1n1->GetX()-pos[0])+(vertexp1n1->GetY()-pos[1])*(vertexp1n1->GetY()-pos[1])+(vertexp1n1->GetZ()-pos[2])*(vertexp1n1->GetZ()-pos[2]));
2454  Double_t dist3=TMath::Sqrt((vertexp1n1p2->GetX()-pos[0])*(vertexp1n1p2->GetX()-pos[0])+(vertexp1n1p2->GetY()-pos[1])*(vertexp1n1p2->GetY()-pos[1])+(vertexp1n1p2->GetZ()-pos[2])*(vertexp1n1p2->GetZ()-pos[2]));
2455  Double_t dist4=TMath::Sqrt((secVert->GetX()-pos[0])*(secVert->GetX()-pos[0])+(secVert->GetY()-pos[1])*(secVert->GetY()-pos[1])+(secVert->GetZ()-pos[2])*(secVert->GetZ()-pos[2]));
2456  Short_t charge=0;
2457  AliAODRecoDecayHF4Prong *the4Prong = new AliAODRecoDecayHF4Prong(secVert,px,py,pz,d0,d0err,dca,dist12,dist3,dist4,charge);
2458  the4Prong->SetOwnPrimaryVtx(primVertexAOD);
2459  UShort_t id[4]={(UShort_t)postrack1->GetID(),(UShort_t)negtrack1->GetID(),(UShort_t)postrack2->GetID(),(UShort_t)negtrack2->GetID()};
2460  the4Prong->SetProngIDs(4,id);
2461 
2462  delete primVertexAOD; primVertexAOD=NULL;
2463 
2464  ok4Prong=(Bool_t)fCutsD0toKpipipi->IsSelected(the4Prong,AliRDHFCuts::kCandidate);
2465 
2466 
2468  the4Prong->UnsetOwnPrimaryVtx();
2469  }
2470 
2471 
2472  // get PID info from ESD
2473  Double_t esdpid0[5]={0.,0.,0.,0.,0.};
2474  if(postrack1->GetStatus()&AliESDtrack::kESDpid) postrack1->GetESDpid(esdpid0);
2475  Double_t esdpid1[5]={0.,0.,0.,0.,0.};
2476  if(negtrack1->GetStatus()&AliESDtrack::kESDpid) negtrack1->GetESDpid(esdpid1);
2477  Double_t esdpid2[5]={0.,0.,0.,0.,0.};
2478  if(postrack2->GetStatus()&AliESDtrack::kESDpid) postrack2->GetESDpid(esdpid2);
2479  Double_t esdpid3[5]={0.,0.,0.,0.,0.};
2480  if(negtrack2->GetStatus()&AliESDtrack::kESDpid) negtrack2->GetESDpid(esdpid3);
2481 
2482  Double_t esdpid[20];
2483  for(Int_t i=0;i<5;i++) {
2484  esdpid[i] = esdpid0[i];
2485  esdpid[5+i] = esdpid1[i];
2486  esdpid[10+i] = esdpid2[i];
2487  esdpid[15+i] = esdpid3[i];
2488  }
2489  the4Prong->SetPID(4,esdpid);
2490 
2491  return the4Prong;
2492 }
2493 //----------------------------------------------------------------------------------
2495  //assign and save in fAODMap the index of the AliAODTrack track
2496  //ordering them on the basis of selected criteria
2497 
2498  fAODMapSize = 100000;
2499  fAODMap = new Int_t[fAODMapSize];
2500  AliAODTrack *track=0;
2501  memset(fAODMap,0,sizeof(Int_t)*fAODMapSize);
2502  for(Int_t i=0; i<aod->GetNumberOfTracks(); i++) {
2503  track = dynamic_cast<AliAODTrack*>(aod->GetTrack(i));
2504  if(!track) AliFatal("Not a standard AOD");
2505  // skip pure ITS SA tracks
2506  if(track->GetStatus()&AliESDtrack::kITSpureSA) continue;
2507 
2508  // skip tracks without ITS
2509  if(!(track->GetStatus()&AliESDtrack::kITSin)) continue;
2510 
2511  // TEMPORARY: check that the cov matrix is there
2512  Double_t covtest[21];
2513  if(!track->GetCovarianceXYZPxPyPz(covtest)) continue;
2514  //
2515 
2516  Int_t ind = (Int_t)track->GetID();
2517  if (ind>-1 && ind < fAODMapSize) fAODMap[ind] = i;
2518  }
2519  return;
2520 }
2521 //-----------------------------------------------------------------------------
2522 AliAODVertex* AliAnalysisVertexingHF::PrimaryVertex(const TObjArray *trkArray,
2523  AliVEvent *event) const
2524 {
2526  //AliCodeTimerAuto("",0);
2527 
2528  AliESDVertex *vertexESD = 0;
2529  AliAODVertex *vertexAOD = 0;
2530 
2531 
2533  // primary vertex from the input event
2534 
2535  vertexESD = new AliESDVertex(*fV1);
2536 
2537  } else {
2538  // primary vertex specific to this candidate
2539 
2540  Int_t nTrks = trkArray->GetEntriesFast();
2541  AliVertexerTracks *vertexer = new AliVertexerTracks(event->GetMagneticField());
2542 
2544  // recalculating the vertex
2545 
2546  if(strstr(fV1->GetTitle(),"VertexerTracksWithConstraint")) {
2547  Float_t diamondcovxy[3];
2548  event->GetDiamondCovXY(diamondcovxy);
2549  Double_t pos[3]={event->GetDiamondX(),event->GetDiamondY(),0.};
2550  Double_t cov[6]={diamondcovxy[0],diamondcovxy[1],diamondcovxy[2],0.,0.,10.*10.};
2551  AliESDVertex *diamond = new AliESDVertex(pos,cov,1.,1);
2552  vertexer->SetVtxStart(diamond);
2553  delete diamond; diamond=NULL;
2554  if(strstr(fV1->GetTitle(),"VertexerTracksWithConstraintOnlyFitter"))
2555  vertexer->SetOnlyFitter();
2556  }
2557  Int_t skipped[1000];
2558  Int_t nTrksToSkip=0,id;
2559  AliExternalTrackParam *t = 0;
2560  for(Int_t i=0; i<nTrks; i++) {
2561  t = (AliExternalTrackParam*)trkArray->UncheckedAt(i);
2562  id = (Int_t)t->GetID();
2563  if(id<0) continue;
2564  skipped[nTrksToSkip++] = id;
2565  }
2566  // TEMPORARY FIX
2567  // For AOD, skip also tracks without covariance matrix
2568  if(fInputAOD) {
2569  Double_t covtest[21];
2570  for(Int_t j=0; j<event->GetNumberOfTracks(); j++) {
2571  AliVTrack *vtrack = (AliVTrack*)event->GetTrack(j);
2572  if(!vtrack->GetCovarianceXYZPxPyPz(covtest)) {
2573  id = (Int_t)vtrack->GetID();
2574  if(id<0) continue;
2575  skipped[nTrksToSkip++] = id;
2576  }
2577  }
2578  }
2579  for(Int_t ijk=nTrksToSkip; ijk<1000; ijk++) skipped[ijk]=-1;
2580  //
2581  vertexer->SetSkipTracks(nTrksToSkip,skipped);
2582  vertexESD = (AliESDVertex*)vertexer->FindPrimaryVertex(event);
2583 
2584  } else if(fRmTrksFromPrimVtx && nTrks>0) {
2585  // removing the prongs tracks
2586 
2587  TObjArray rmArray(nTrks);
2588  UShort_t *rmId = new UShort_t[nTrks];
2589  AliESDtrack *esdTrack = 0;
2590  AliESDtrack *t = 0;
2591  for(Int_t i=0; i<nTrks; i++) {
2592  t = (AliESDtrack*)trkArray->UncheckedAt(i);
2593  esdTrack = new AliESDtrack(*t);
2594  rmArray.AddLast(esdTrack);
2595  if(esdTrack->GetID()>=0) {
2596  rmId[i]=(UShort_t)esdTrack->GetID();
2597  } else {
2598  rmId[i]=9999;
2599  }
2600  }
2601  Float_t diamondxy[2]={static_cast<Float_t>(event->GetDiamondX()),static_cast<Float_t>(event->GetDiamondY())};
2602  vertexESD = vertexer->RemoveTracksFromVertex(fV1,&rmArray,rmId,diamondxy);
2603  delete [] rmId; rmId=NULL;
2604  rmArray.Delete();
2605 
2606  }
2607 
2608  if(!vertexESD) return vertexAOD;
2609  if(vertexESD->GetNContributors()<=0) {
2610  //AliDebug(2,"vertexing failed");
2611  delete vertexESD; vertexESD=NULL;
2612  return vertexAOD;
2613  }
2614 
2615  delete vertexer; vertexer=NULL;
2616 
2617  }
2618 
2619  // convert to AliAODVertex
2620  Double_t pos[3],cov[6],chi2perNDF;
2621  vertexESD->GetXYZ(pos); // position
2622  vertexESD->GetCovMatrix(cov); //covariance matrix
2623  chi2perNDF = vertexESD->GetChi2toNDF();
2624  delete vertexESD; vertexESD=NULL;
2625 
2626  vertexAOD = new AliAODVertex(pos,cov,chi2perNDF);
2627 
2628  return vertexAOD;
2629 }
2630 //-----------------------------------------------------------------------------
2633 
2634  //printf("Preselections:\n");
2635  // fTrackFilter->Dump();
2636  if(fSecVtxWithKF) {
2637  printf("Secondary vertex with Kalman filter package (AliKFParticle)\n");
2638  } else {
2639  printf("Secondary vertex with AliVertexerTracks\n");
2640  }
2641  if(fRecoPrimVtxSkippingTrks) printf("RecoPrimVtxSkippingTrks\n");
2642  if(fRmTrksFromPrimVtx) printf("RmTrksFromPrimVtx\n");
2643  if(fD0toKpi) {
2644  printf("Reconstruct D0->Kpi candidates with cuts:\n");
2646  }
2647  if(fDstar) {
2648  printf("Reconstruct D*->D0pi candidates with cuts:\n");
2649  if(fFindVertexForDstar) {
2650  printf(" Reconstruct a secondary vertex for the D*\n");
2651  } else {
2652  printf(" Assume the D* comes from the primary vertex\n");
2653  }
2655  }
2656  if(fJPSItoEle) {
2657  printf("Reconstruct J/psi from B candidates with cuts:\n");
2659  }
2660  if(f3Prong) {
2661  printf("Reconstruct 3 prong candidates.\n");
2662  printf(" D+->Kpipi cuts:\n");
2664  printf(" Ds->KKpi cuts:\n");
2666  printf(" Lc->pKpi cuts:\n");
2668  }
2669  if(f4Prong) {
2670  printf("Reconstruct 4 prong candidates.\n");
2671  printf(" D0->Kpipipi cuts:\n");
2673  }
2674  if(fCascades) {
2675  printf("Reconstruct cascades candidates formed with v0s.\n");
2676  printf(" Lc -> k0s P & Lc -> L Pi cuts:\n");
2678  }
2679 
2680  return;
2681 }
2682 //-----------------------------------------------------------------------------
2683 AliAODVertex* AliAnalysisVertexingHF::ReconstructSecondaryVertex(TObjArray *trkArray,
2684  Double_t &dispersion,Bool_t useTRefArray) const
2685 {
2687  //AliCodeTimerAuto("",0);
2688 
2689  AliESDVertex *vertexESD = 0;
2690  AliAODVertex *vertexAOD = 0;
2691 
2692  if(!fSecVtxWithKF) { // AliVertexerTracks
2693 
2694  fVertexerTracks->SetVtxStart(fV1);
2695  vertexESD = (AliESDVertex*)fVertexerTracks->VertexForSelectedESDTracks(trkArray);
2696 
2697  if(!vertexESD) return vertexAOD;
2698 
2699  if(vertexESD->GetNContributors()!=trkArray->GetEntriesFast()) {
2700  //AliDebug(2,"vertexing failed");
2701  delete vertexESD; vertexESD=NULL;
2702  return vertexAOD;
2703  }
2704 
2705  Double_t vertRadius2=vertexESD->GetX()*vertexESD->GetX()+vertexESD->GetY()*vertexESD->GetY();
2706  if(vertRadius2>8.){
2707  // vertex outside beam pipe, reject candidate to avoid propagation through material
2708  delete vertexESD; vertexESD=NULL;
2709  return vertexAOD;
2710  }
2711 
2712  } else { // Kalman Filter vertexer (AliKFParticle)
2713 
2714  AliKFParticle::SetField(fBzkG);
2715 
2716  AliKFVertex vertexKF;
2717 
2718  Int_t nTrks = trkArray->GetEntriesFast();
2719  for(Int_t i=0; i<nTrks; i++) {
2720  AliESDtrack *esdTrack = (AliESDtrack*)trkArray->At(i);
2721  AliKFParticle daughterKF(*esdTrack,211);
2722  vertexKF.AddDaughter(daughterKF);
2723  }
2724  vertexESD = new AliESDVertex(vertexKF.Parameters(),
2725  vertexKF.CovarianceMatrix(),
2726  vertexKF.GetChi2(),
2727  vertexKF.GetNContributors());
2728 
2729  }
2730 
2731  // convert to AliAODVertex
2732  Double_t pos[3],cov[6],chi2perNDF;
2733  vertexESD->GetXYZ(pos); // position
2734  vertexESD->GetCovMatrix(cov); //covariance matrix
2735  chi2perNDF = vertexESD->GetChi2toNDF();
2736  dispersion = vertexESD->GetDispersion();
2737  delete vertexESD; vertexESD=NULL;
2738 
2739  Int_t nprongs= (useTRefArray ? 0 : trkArray->GetEntriesFast());
2740  vertexAOD = new AliAODVertex(pos,cov,chi2perNDF,0x0,-1,AliAODVertex::kUndef,nprongs);
2741 
2742  return vertexAOD;
2743 }
2744 //-----------------------------------------------------------------------------
2747  //AliCodeTimerAuto("",0);
2748 
2749  Int_t retval=kFALSE;
2750  Double_t momentum[3];
2751  Double_t px[3],py[3],pz[3];
2752  for(Int_t iTrack=0; iTrack<3; iTrack++){
2753  AliESDtrack *track = (AliESDtrack*)trkArray->UncheckedAt(iTrack);
2754  track->GetPxPyPz(momentum);
2755  px[iTrack] = momentum[0]; py[iTrack] = momentum[1]; pz[iTrack] = momentum[2];
2756  }
2757  retval = SelectInvMassAndPt3prong(px,py,pz);
2758 
2759  return retval;
2760 }
2761 
2762 //-----------------------------------------------------------------------------
2765  //AliCodeTimerAuto("",0);
2766 
2767  Int_t retval=kFALSE;
2768  Double_t momentum[3];
2769  Double_t px[4],py[4],pz[4];
2770 
2771  for(Int_t iTrack=0; iTrack<4; iTrack++){
2772  AliESDtrack *track = (AliESDtrack*)trkArray->UncheckedAt(iTrack);
2773  track->GetPxPyPz(momentum);
2774  px[iTrack] = momentum[0]; py[iTrack] = momentum[1]; pz[iTrack] = momentum[2];
2775  }
2776 
2777  retval = SelectInvMassAndPt4prong(px,py,pz);
2778 
2779  return retval;
2780 }
2781 //-----------------------------------------------------------------------------
2784  //AliCodeTimerAuto("",0);
2785 
2786  Int_t retval=kFALSE;
2787  Double_t momentum[3];
2788  Double_t px[2],py[2],pz[2];
2789 
2790  for(Int_t iTrack=0; iTrack<2; iTrack++){
2791  AliESDtrack *track = (AliESDtrack*)trkArray->UncheckedAt(iTrack);
2792  track->GetPxPyPz(momentum);
2793  px[iTrack] = momentum[0]; py[iTrack] = momentum[1]; pz[iTrack] = momentum[2];
2794  }
2795  retval = SelectInvMassAndPtDstarD0pi(px,py,pz);
2796 
2797  return retval;
2798 }
2799 //-----------------------------------------------------------------------------
2801  Double_t *py,
2802  Double_t *pz){
2804  //AliCodeTimerAuto("",0);
2805 
2806  UInt_t pdg2[2];
2807  Int_t nprongs=2;
2808  Double_t minv2,mrange;
2809  Double_t lolim,hilim;
2810  Double_t minPt=0;
2811  Bool_t retval=kFALSE;
2812 
2813  fMassCalc2->SetPxPyPzProngs(nprongs,px,py,pz);
2814  fOKInvMassD0=kFALSE;
2815  // pt cut
2817  if(minPt>0.1)
2818  if(fMassCalc2->Pt2() < minPt*minPt) return retval;
2819  // mass cut
2820  mrange=fCutsD0toKpi->GetMassCut();
2821  lolim=fMassDzero-mrange;
2822  hilim=fMassDzero+mrange;
2823  pdg2[0]=211; pdg2[1]=321;
2824  minv2 = fMassCalc2->InvMass2(nprongs,pdg2);
2825  if(minv2>lolim*lolim && minv2<hilim*hilim ){
2826  retval=kTRUE;
2827  fOKInvMassD0=kTRUE;
2828  }
2829  pdg2[0]=321; pdg2[1]=211;
2830  minv2 = fMassCalc2->InvMass2(nprongs,pdg2);
2831  if(minv2>lolim*lolim && minv2<hilim*hilim ){
2832  retval=kTRUE;
2833  fOKInvMassD0=kTRUE;
2834  }
2835  return retval;
2836 }
2837 
2838 //-----------------------------------------------------------------------------
2840  Double_t *py,
2841  Double_t *pz){
2843  //AliCodeTimerAuto("",0);
2844 
2845  UInt_t pdg2[2];
2846  Int_t nprongs=2;
2847  Double_t minv2,mrange;
2848  Double_t lolim,hilim;
2849  Double_t minPt=0;
2850  Bool_t retval=kFALSE;
2851 
2852  fMassCalc2->SetPxPyPzProngs(nprongs,px,py,pz);
2853  fOKInvMassJpsi=kFALSE;
2854  // pt cut
2856  if(minPt>0.1)
2857  if(fMassCalc2->Pt2() < minPt*minPt) return retval;
2858  // mass cut
2859  mrange=fCutsJpsitoee->GetMassCut();
2860  lolim=fMassJpsi-mrange;
2861  hilim=fMassJpsi+mrange;
2862 
2863  pdg2[0]=11; pdg2[1]=11;
2864  minv2 = fMassCalc2->InvMass2(nprongs,pdg2);
2865  if(minv2>lolim*lolim && minv2<hilim*hilim ){
2866  retval=kTRUE;
2867  fOKInvMassJpsi=kTRUE;
2868  }
2869 
2870  return retval;
2871 }
2872 //-----------------------------------------------------------------------------
2874  Double_t *py,
2875  Double_t *pz,
2876  Int_t pidLcStatus){
2878  //AliCodeTimerAuto("",0);
2879 
2880  UInt_t pdg3[3];
2881  Int_t nprongs=3;
2882  Double_t minv2,mrange;
2883  Double_t lolim,hilim;
2884  Double_t minPt=0;
2885  Bool_t retval=kFALSE;
2886 
2887 
2888  fMassCalc3->SetPxPyPzProngs(nprongs,px,py,pz);
2889  fOKInvMassDplus=kFALSE;
2890  fOKInvMassDs=kFALSE;
2891  fOKInvMassLc=kFALSE;
2892  // pt cut
2894  minPt=TMath::Min(minPt,fCutsLctopKpi->GetMinPtCandidate());
2895  if(minPt>0.1)
2896  if(fMassCalc3->Pt2() < minPt*minPt) return retval;
2897  // D+->Kpipi
2898  mrange=fCutsDplustoKpipi->GetMassCut();
2899  lolim=fMassDplus-mrange;
2900  hilim=fMassDplus+mrange;
2901  pdg3[0]=211; pdg3[1]=321; pdg3[2]=211;
2902  minv2 = fMassCalc3->InvMass2(nprongs,pdg3);
2903  if(minv2>lolim*lolim && minv2<hilim*hilim ){
2904  retval=kTRUE;
2905  fOKInvMassDplus=kTRUE;
2906  }
2907  // Ds+->KKpi
2908  mrange=fCutsDstoKKpi->GetMassCut();
2909  lolim=fMassDs-mrange;
2910  hilim=fMassDs+mrange;
2911  pdg3[0]=321; pdg3[1]=321; pdg3[2]=211;
2912  minv2 = fMassCalc3->InvMass2(nprongs,pdg3);
2913  if(minv2>lolim*lolim && minv2<hilim*hilim ){
2914  retval=kTRUE;
2915  fOKInvMassDs=kTRUE;
2916  }
2917  pdg3[0]=211; pdg3[1]=321; pdg3[2]=321;
2918  minv2 = fMassCalc3->InvMass2(nprongs,pdg3);
2919  if(minv2>lolim*lolim && minv2<hilim*hilim ){
2920  retval=kTRUE;
2921  fOKInvMassDs=kTRUE;
2922  }
2923  // Lc->pKpi
2924  mrange=fCutsLctopKpi->GetMassCut();
2925  lolim=fMassLambdaC-mrange;
2926  hilim=fMassLambdaC+mrange;
2927  if(pidLcStatus&1){
2928  pdg3[0]=2212; pdg3[1]=321; pdg3[2]=211;
2929  minv2 = fMassCalc3->InvMass2(nprongs,pdg3);
2930  if(minv2>lolim*lolim && minv2<hilim*hilim ){
2931  retval=kTRUE;
2932  fOKInvMassLc=kTRUE;
2933  }
2934  }
2935  if(pidLcStatus&2){
2936  pdg3[0]=211; pdg3[1]=321; pdg3[2]=2212;
2937  minv2 = fMassCalc3->InvMass2(nprongs,pdg3);
2938  if(minv2>lolim*lolim && minv2<hilim*hilim ){
2939  retval=kTRUE;
2940  fOKInvMassLc=kTRUE;
2941  }
2942  }
2943 
2944  return retval;
2945 }
2946 
2947 //-----------------------------------------------------------------------------
2949  Double_t *py,
2950  Double_t *pz){
2952  //AliCodeTimerAuto("",0);
2953 
2954  UInt_t pdg2[2];
2955  Int_t nprongs=2;
2956  Double_t minv2,mrange;
2957  Double_t lolim,hilim;
2958  Double_t minPt=0;
2959  Bool_t retval=kFALSE;
2960 
2961  fMassCalc2->SetPxPyPzProngs(nprongs,px,py,pz);
2962  fOKInvMassDstar=kFALSE;
2963  // pt cut
2965  if(minPt>0.1)
2966  if(fMassCalc2->Pt2() < minPt*minPt) return retval;
2967  // mass cut
2968  pdg2[0]=211; pdg2[1]=421; // in twoTrackArrayCasc we put the pion first
2969  mrange=fCutsDStartoKpipi->GetMassCut();
2970  lolim=fMassDstar-mrange;
2971  hilim=fMassDstar+mrange;
2972  minv2 = fMassCalc2->InvMass2(nprongs,pdg2);
2973  if(minv2>lolim*lolim && minv2<hilim*hilim ){
2974  retval=kTRUE;
2975  fOKInvMassDstar=kTRUE;
2976  }
2977 
2978  return retval;
2979 }
2980 
2981 //-----------------------------------------------------------------------------
2983  Double_t *py,
2984  Double_t *pz){
2986  //AliCodeTimerAuto("",0);
2987 
2988  UInt_t pdg4[4];
2989  Int_t nprongs=4;
2990  Double_t minv2,mrange;
2991  Double_t lolim,hilim;
2992  Double_t minPt=0;
2993  Bool_t retval=kFALSE;
2994 
2995  // D0->Kpipipi without PID
2996  fMassCalc4->SetPxPyPzProngs(nprongs,px,py,pz);
2997  fOKInvMassD0to4p=kFALSE;
2998  // pt cut
3000  if(minPt>0.1)
3001  if(fMassCalc4->Pt2() < minPt*minPt) return retval;
3002  // mass cut
3003  mrange=fCutsD0toKpipipi->GetMassCut();
3004  lolim=fMassDzero-mrange;
3005  hilim=fMassDzero+mrange;
3006 
3007  pdg4[0]=321; pdg4[1]=211; pdg4[2]=211; pdg4[3]=211;
3008  minv2 = fMassCalc4->InvMass2(nprongs,pdg4);
3009  if(minv2>lolim*lolim && minv2<hilim*hilim ){
3010  retval=kTRUE;
3011  fOKInvMassD0to4p=kTRUE;
3012  }
3013 
3014  pdg4[0]=211; pdg4[1]=321; pdg4[2]=211; pdg4[3]=211;
3015  minv2 = fMassCalc4->InvMass2(nprongs,pdg4);
3016  if(minv2>lolim*lolim && minv2<hilim*hilim ){
3017  retval=kTRUE;
3018  fOKInvMassD0to4p=kTRUE;
3019  }
3020 
3021  pdg4[0]=211; pdg4[1]=211; pdg4[2]=321; pdg4[3]=211;
3022  minv2 = fMassCalc4->InvMass2(nprongs,pdg4);
3023  if(minv2>lolim*lolim && minv2<hilim*hilim ){
3024  retval=kTRUE;
3025  fOKInvMassD0to4p=kTRUE;
3026  }
3027 
3028  pdg4[0]=211; pdg4[1]=211; pdg4[2]=211; pdg4[3]=321;
3029  minv2 = fMassCalc4->InvMass2(nprongs,pdg4);
3030  if(minv2>lolim*lolim && minv2<hilim*hilim ){
3031  retval=kTRUE;
3032  fOKInvMassD0to4p=kTRUE;
3033  }
3034 
3035  return retval;
3036 }
3037 //-----------------------------------------------------------------------------
3039  Double_t *py,
3040  Double_t *pz){
3042  //AliCodeTimerAuto("",0);
3043 
3044  UInt_t pdg2[2];
3045  Int_t nprongs=2;
3046  Double_t minv2,mrange;
3047  Double_t lolim,hilim;
3048  // Double_t minPt=0;
3049  Bool_t retval=kFALSE;
3050 
3051  fMassCalc2->SetPxPyPzProngs(nprongs,px,py,pz);
3052  // minPt=fCutsLctoV0->GetMinPtCandidate();
3053  fOKInvMassLctoV0=kFALSE;
3054  mrange=fCutsLctoV0->GetMassCut();
3055  lolim=fMassLambdaC-mrange;
3056  hilim=fMassLambdaC+mrange;
3057  pdg2[0]=2212;pdg2[1]=310;
3058  minv2=fMassCalc2->InvMass2(2,pdg2);
3059  if(minv2>lolim*lolim && minv2<hilim*hilim ){
3060  retval=kTRUE;
3061  fOKInvMassLctoV0=kTRUE;
3062  }
3063  pdg2[0]=211;pdg2[1]=3122;
3064  minv2=fMassCalc2->InvMass2(2,pdg2);
3065  if(minv2>lolim*lolim && minv2<hilim*hilim ){
3066  retval=kTRUE;
3067  fOKInvMassLctoV0=kTRUE;
3068  }
3069 
3070  return retval;
3071 }
3072 //-----------------------------------------------------------------------------
3074  Int_t trkEntries,
3075  TObjArray &seleTrksArray,
3076  TObjArray &tracksAtVertex,
3077  Int_t &nSeleTrks,
3078  UChar_t *seleFlags,Int_t *evtNumber)
3079 {
3085  //AliCodeTimerAuto("",0);
3086 
3087  const AliVVertex *vprimary = event->GetPrimaryVertex();
3088 
3089  if(fV1) { delete fV1; fV1=NULL; }
3090  if(fAODMap) { delete [] fAODMap; fAODMap=NULL; }
3091 
3092  Int_t nindices=0;
3093  UShort_t *indices = 0;
3094  Double_t pos[3],cov[6];
3095  const Int_t entries = event->GetNumberOfTracks();
3096  AliCentrality* cent;
3097 
3098  if(!fInputAOD) { // ESD
3099  fV1 = new AliESDVertex(*((AliESDVertex*)vprimary));
3100  cent=((AliESDEvent*)event)->GetCentrality();
3101  } else { // AOD
3102  vprimary->GetXYZ(pos);
3103  vprimary->GetCovarianceMatrix(cov);
3104  fV1 = new AliESDVertex(pos,cov,100.,100,vprimary->GetName());
3105  if(entries<=0) return;
3106  indices = new UShort_t[entries];
3107  memset(indices,0,sizeof(UShort_t)*entries);
3108  fAODMapSize = 100000;
3109  fAODMap = new Int_t[fAODMapSize];
3110  memset(fAODMap,0,sizeof(Int_t)*fAODMapSize);
3111  cent=((AliAODEvent*)event)->GetCentrality();
3112  }
3113  Float_t centperc=99;
3114  if(event->GetRunNumber()<244824){
3115  centperc=cent->GetCentralityPercentile("V0M");
3116  }else{
3117  AliMultSelection *multSelection = (AliMultSelection * ) event->FindListObject("MultSelection");
3118  if(multSelection){
3119  centperc=multSelection->GetMultiplicityPercentile("V0M");
3120  Int_t qual = multSelection->GetEvSelCode();
3121  if(qual == 199 ) centperc=99.;
3122  }
3123  }
3124  Bool_t okDisplaced=kFALSE,okSoftPi=kFALSE,okFor3Prong=kFALSE;
3125  nSeleTrks=0;
3126 
3127  // transfer ITS tracks from event to arrays
3128  for(Int_t i=0; i<entries; i++) {
3129  AliVTrack *track;
3130  track = (AliVTrack*)event->GetTrack(i);
3131 
3132  // skip pure ITS SA tracks
3133  if(track->GetStatus()&AliESDtrack::kITSpureSA) continue;
3134 
3135  // skip tracks without ITS
3136  if(!(track->GetStatus()&AliESDtrack::kITSin)) continue;
3137 
3138  // skip tracks with negative ID
3139  // (these are duplicated TPC-only AOD tracks, for jet analysis...)
3140  if(track->GetID()<0) continue;
3141 
3142  // TEMPORARY: check that the cov matrix is there
3143  Double_t covtest[21];
3144  if(!track->GetCovarianceXYZPxPyPz(covtest)) continue;
3145  //
3146 
3147  if(fInputAOD) {
3148  AliAODTrack *aodt = (AliAODTrack*)track;
3149  if(aodt->GetUsedForPrimVtxFit()) {
3150  indices[nindices]=aodt->GetID(); nindices++;
3151  }
3152  Int_t ind = (Int_t)aodt->GetID();
3153  if (ind>-1 && ind < fAODMapSize) fAODMap[ind] = i;
3154  }
3155 
3156  AliESDtrack *esdt = 0;
3157 
3158  if(!fInputAOD) {
3159  esdt = (AliESDtrack*)track;
3160  } else {
3161  esdt = new AliESDtrack(track);
3162  }
3163 
3164  // single track selection
3165  okDisplaced=kFALSE; okSoftPi=kFALSE; okFor3Prong=kFALSE;
3166  if(fMixEvent && i<trkEntries){
3167  evtNumber[i]=((AliMixedEvent*)event)->EventIndex(i);
3168  const AliVVertex* eventVtx=((AliMixedEvent*)event)->GetEventVertex(i);
3169  Double_t vtxPos[3],primPos[3],primCov[6],trasl[3];
3170  eventVtx->GetXYZ(vtxPos);
3171  vprimary->GetXYZ(primPos);
3172  eventVtx->GetCovarianceMatrix(primCov);
3173  for(Int_t ind=0;ind<3;ind++){
3174  trasl[ind]=vtxPos[ind]-primPos[ind];
3175  }
3176 
3177  Bool_t isTransl=esdt->Translate(trasl,primCov);
3178  if(!isTransl) {
3179  delete esdt;
3180  esdt = NULL;
3181  continue;
3182  }
3183  }
3184 
3185  if(SingleTrkCuts(esdt,centperc,okDisplaced,okSoftPi,okFor3Prong) && nSeleTrks<trkEntries) {
3186  esdt->PropagateToDCA(fV1,fBzkG,kVeryBig);
3187  seleTrksArray.AddLast(esdt);
3188  tracksAtVertex.AddLast(new AliExternalTrackParam(*esdt));
3189  seleFlags[nSeleTrks]=0;
3190  if(okDisplaced) SETBIT(seleFlags[nSeleTrks],kBitDispl);
3191  if(okFor3Prong) SETBIT(seleFlags[nSeleTrks],kBit3Prong);
3192  if(okSoftPi) SETBIT(seleFlags[nSeleTrks],kBitSoftPi);
3193 
3194  // Check the PID
3195  SETBIT(seleFlags[nSeleTrks],kBitPionCompat);
3196  SETBIT(seleFlags[nSeleTrks],kBitKaonCompat);
3197  SETBIT(seleFlags[nSeleTrks],kBitProtonCompat);
3198  Bool_t useTPC=kTRUE;
3199  if(fUseTOFPID){
3200  Double_t nsigmatofPi= fPidResponse->NumberOfSigmasTOF(esdt,AliPID::kPion);
3201  if(nsigmatofPi>-990. && (nsigmatofPi<-fnSigmaTOFPionLow || nsigmatofPi>fnSigmaTOFPionHi)){
3202  CLRBIT(seleFlags[nSeleTrks],kBitPionCompat);
3203  }
3204  Double_t nsigmatofK= fPidResponse->NumberOfSigmasTOF(esdt,AliPID::kKaon);
3205  if(nsigmatofK>-990. && (nsigmatofK<-fnSigmaTOFKaonLow || nsigmatofK>fnSigmaTOFKaonHi)){
3206  CLRBIT(seleFlags[nSeleTrks],kBitKaonCompat);
3207  }
3208  Double_t nsigmatofP= fPidResponse->NumberOfSigmasTOF(esdt,AliPID::kProton);
3209  if(nsigmatofP>-990. && (nsigmatofP<-fnSigmaTOFProtonLow || nsigmatofP>fnSigmaTOFProtonHi)){
3210  CLRBIT(seleFlags[nSeleTrks],kBitProtonCompat);
3211  }
3212  if(fUseTPCPIDOnlyIfNoTOF && nsigmatofPi>-990.) useTPC=kFALSE;
3213  }
3214  if(useTPC && fUseTPCPID && esdt->P()<fMaxMomForTPCPid){
3215  Double_t nsigmatpcPi= fPidResponse->NumberOfSigmasTPC(esdt,AliPID::kPion);
3216  if(nsigmatpcPi>-990. && (nsigmatpcPi<-fnSigmaTPCPionLow || nsigmatpcPi>fnSigmaTPCPionHi)){
3217  CLRBIT(seleFlags[nSeleTrks],kBitPionCompat);
3218  }
3219  Double_t nsigmatpcK= fPidResponse->NumberOfSigmasTPC(esdt,AliPID::kKaon);
3220  if(nsigmatpcK>-990. && (nsigmatpcK<-fnSigmaTPCKaonLow || nsigmatpcK>fnSigmaTPCKaonHi)){
3221  CLRBIT(seleFlags[nSeleTrks],kBitKaonCompat);
3222  }
3223  Double_t nsigmatpcP= fPidResponse->NumberOfSigmasTPC(esdt,AliPID::kProton);
3224  if(nsigmatpcP>-990. && (nsigmatpcP<-fnSigmaTPCProtonLow || nsigmatpcP>fnSigmaTPCProtonHi)){
3225  CLRBIT(seleFlags[nSeleTrks],kBitProtonCompat);
3226  }
3227  }
3228  nSeleTrks++;
3229  } else {
3230  if(fInputAOD) delete esdt;
3231  esdt = NULL;
3232  continue;
3233  }
3234 
3235  } // end loop on tracks
3236 
3237  // primary vertex from AOD
3238  if(fInputAOD) {
3239  delete fV1; fV1=NULL;
3240  vprimary->GetXYZ(pos);
3241  vprimary->GetCovarianceMatrix(cov);
3242  Double_t chi2toNDF = vprimary->GetChi2perNDF();
3243  Int_t ncontr=nindices;
3244  if(!strcmp(vprimary->GetTitle(),"VertexerTracksWithContraint")) ncontr += 1;
3245  Double_t chi2=chi2toNDF*(2.*(Double_t)ncontr-3.);
3246  fV1 = new AliESDVertex(pos,cov,chi2,ncontr,vprimary->GetName());
3247  fV1->SetTitle(vprimary->GetTitle());
3248  fV1->SetIndices(nindices,indices);
3249  }
3250  if(indices) { delete [] indices; indices=NULL; }
3251 
3252 
3253  return;
3254 }
3255 //-----------------------------------------------------------------------------
3257  //
3259  //
3260  if(fUsePidTag && cuts->GetPidHF()) {
3261  Bool_t usepid=cuts->GetIsUsePID();
3262  cuts->SetUsePID(kTRUE);
3263  if(cuts->IsSelectedPID(rd))
3264  rd->SetSelectionBit(bit);
3265  cuts->SetUsePID(usepid);
3266  }
3267  return;
3268 }
3269 //-----------------------------------------------------------------------------
3270 Bool_t AliAnalysisVertexingHF::SingleTrkCuts(AliESDtrack *trk,
3271  Float_t centralityperc,
3272  Bool_t &okDisplaced,
3273  Bool_t &okSoftPi,
3274  Bool_t &okFor3Prong) const
3275 {
3277 
3278  // this is needed to store the impact parameters
3279  //AliCodeTimerAuto("",0);
3280 
3281  trk->RelateToVertex(fV1,fBzkG,kVeryBig);
3282 
3283  UInt_t selectInfo;
3284  //
3285  // Track selection, displaced tracks -- 2 prong
3286  selectInfo = 0;
3287  if(centralityperc>=0 && fMaxCentPercentileForTightCuts>=0
3289  // central PbPb events, tighter cuts
3290  selectInfo = fTrackFilter2prongCentral->IsSelected(trk);
3291  }else{
3292  // standard cuts
3293  if(fTrackFilter) {
3294  selectInfo = fTrackFilter->IsSelected(trk);
3295  }
3296  }
3297  if(selectInfo) okDisplaced=kTRUE;
3298 
3299  // Track selection, displaced tracks -- 3 prong
3300  selectInfo = 0;
3301  if(centralityperc>=0 && fMaxCentPercentileForTightCuts>=0
3303  // central PbPb events, tighter cuts
3304  selectInfo = fTrackFilter3prongCentral->IsSelected(trk);
3305  }else{
3306  // standard cuts
3307  if(fTrackFilter) {
3308  selectInfo = fTrackFilter->IsSelected(trk);
3309  }
3310  }
3311  if(selectInfo) okFor3Prong=kTRUE;
3312 
3313  // Track selection, soft pions
3314  selectInfo = 0;
3315  if(fDstar && fTrackFilterSoftPi) {
3316  selectInfo = fTrackFilterSoftPi->IsSelected(trk);
3317  }
3318  if(selectInfo) okSoftPi=kTRUE;
3319 
3320  if(okDisplaced || okSoftPi || okFor3Prong) return kTRUE;
3321 
3322  return kFALSE;
3323 }
3324 
3325 
3326 //-----------------------------------------------------------------------------
3327 AliAODv0* AliAnalysisVertexingHF::TransformESDv0toAODv0(AliESDv0 *esdV0, TObjArray *twoTrackArrayV0){
3333  //
3334  //AliCodeTimerAuto("",0);
3335  Double_t vertex[3]; esdV0->GetXYZ(vertex[0],vertex[1],vertex[2]);
3336  AliAODVertex *vertexV0 = new AliAODVertex(vertex,esdV0->GetChi2V0(),AliAODVertex::kV0,2);
3337 
3338  // create the v0 neutral track to compute the DCA to the primary vertex
3339  Double_t xyz[3], pxpypz[3];
3340  esdV0->XvYvZv(xyz);
3341  esdV0->PxPyPz(pxpypz);
3342  Double_t cv[21]; for(int i=0; i<21; i++) cv[i]=0;
3343  AliNeutralTrackParam *trackesdV0 = new AliNeutralTrackParam(xyz,pxpypz,cv,0);
3344  if(!trackesdV0) {
3345  delete vertexV0;
3346  return 0;
3347  }
3348  Double_t d0z0[2],covd0z0[3];
3349  AliAODVertex *primVertexAOD = PrimaryVertex();
3350  trackesdV0->PropagateToDCA(primVertexAOD,fBzkG,kVeryBig,d0z0,covd0z0);
3351  Double_t dcaV0ToPrimVertex = TMath::Sqrt(covd0z0[0]);
3352  // get the v0 daughters to compute their DCA to the v0 vertex and get their momentum
3353  Double_t dcaV0DaughterToPrimVertex[2];
3354  AliExternalTrackParam *posV0track = (AliExternalTrackParam*)twoTrackArrayV0->UncheckedAt(0);
3355  AliExternalTrackParam *negV0track = (AliExternalTrackParam*)twoTrackArrayV0->UncheckedAt(1);
3356  if( !posV0track || !negV0track) {
3357  if(trackesdV0) {delete trackesdV0; trackesdV0=NULL;}
3358  delete vertexV0;
3359  delete primVertexAOD;
3360  return 0;
3361  }
3362  posV0track->PropagateToDCA(primVertexAOD,fBzkG,kVeryBig,d0z0,covd0z0);
3363  // if ( covd0z0[0]<=0.) dcaV0DaughterToPrimVertex[0] = 0;
3364  // else
3365  dcaV0DaughterToPrimVertex[0] = TMath::Sqrt(covd0z0[0]);
3366  negV0track->PropagateToDCA(primVertexAOD,fBzkG,kVeryBig,d0z0,covd0z0);
3367  // if ( covd0z0[0]<=0.)dcaV0DaughterToPrimVertex[1] = 0;
3368  // else
3369  dcaV0DaughterToPrimVertex[1] = TMath::Sqrt(covd0z0[0]);
3370  Double_t dcaV0Daughters = esdV0->GetDcaV0Daughters();
3371  Double_t pmom[3],nmom[3];
3372  esdV0->GetNPxPyPz(nmom[0],nmom[1],nmom[2]);
3373  esdV0->GetPPxPyPz(pmom[0],pmom[1],pmom[2]);
3374 
3375  AliAODv0 *aodV0 = new AliAODv0(vertexV0,dcaV0Daughters,dcaV0ToPrimVertex,pmom,nmom,dcaV0DaughterToPrimVertex);
3376  aodV0->SetOnFlyStatus(esdV0->GetOnFlyStatus());
3377 
3378  delete trackesdV0;
3379  delete primVertexAOD;
3380 
3381  return aodV0;
3382 }
3383 //-----------------------------------------------------------------------------
3384 void AliAnalysisVertexingHF::SetParametersAtVertex(AliESDtrack* esdt, const AliExternalTrackParam* extpar) const{
3386  //AliCodeTimerAuto("",0);
3387 
3388  const Double_t *par=extpar->GetParameter();
3389  const Double_t *cov=extpar->GetCovariance();
3390  Double_t alpha=extpar->GetAlpha();
3391  Double_t x=extpar->GetX();
3392  esdt->Set(x,alpha,par,cov);
3393  return;
3394 }
3395 //-----------------------------------------------------------------------------
3398 
3399  fMassDzero=TDatabasePDG::Instance()->GetParticle(421)->Mass();
3400  fMassDplus=TDatabasePDG::Instance()->GetParticle(411)->Mass();
3401  fMassDs=TDatabasePDG::Instance()->GetParticle(431)->Mass();
3402  fMassLambdaC=TDatabasePDG::Instance()->GetParticle(4122)->Mass();
3403  fMassDstar=TDatabasePDG::Instance()->GetParticle(413)->Mass();
3404  fMassJpsi=TDatabasePDG::Instance()->GetParticle(443)->Mass();
3405 }
3406 //-----------------------------------------------------------------------------
3408  //
3410  //
3411 
3412 
3413  //___ Check if the V0 type from AliRDHFCutsLctoV0 is the same as the one set in the ConfigVertexingHF.C for AliAnalysisVertexingHF
3414 
3415 
3417  {
3418  printf("ERROR: V0 type doesn not match in AliAnalysisVertexingHF (%d) required in AliRDHFCutsLctoV0 (%d)\n",fV0TypeForCascadeVertex,fCutsLctoV0->GetV0Type());
3419  return kFALSE;
3420  }
3421  return kTRUE;
3422 }
3423 //-----------------------------------------------------------------------------
3424 
Int_t charge
virtual Int_t IsSelected(TObject *obj, Int_t selectionLevel)
AliAODRecoDecay * fMassCalc4
for 3 prong
Bool_t fUsePidTag
upper momentum limit to apply TPC PID
ClassImp(AliAnalysisTaskTriggerRates) AliAnalysisTaskTriggerRates
void SetSelectionBit(Int_t i)
selection map
void SetupPID(AliVEvent *event)
AliAnalysisFilter * fTrackFilterSoftPi
Track Filter for displaced vertices in PbPb central events (tighter cuts) for 3 prong (D+...
AliVertexerTracks * fVertexerTracks
Float_t GetMassCut(Int_t iPtBin=0) const
AliPIDResponse * fPidResponse
event mixing
AliAODVertex * ReconstructSecondaryVertex(TObjArray *trkArray, Double_t &dispersion, Bool_t useTRefArray=kTRUE) const
Double_t fnSigmaTOFPionHi
Low cut value on n. of sigmas for pi TOF PID.
Double_t fnSigmaTOFProtonHi
Low cut value on n. of sigmas for p TOF PID.
virtual Int_t IsSelected(TObject *obj, Int_t selectionLevel)
AliAODVertex * PrimaryVertex(const TObjArray *trkArray=0x0, AliVEvent *event=0x0) const
AliAnalysisFilter * fTrackFilter3prongCentral
Track Filter for displaced vertices in PbPb central events (tighter cuts) for 2 prong (D0->Kpi) ...
AliAnalysisVertexingHF & operator=(const AliAnalysisVertexingHF &source)
AliRDHFCutsDstoKKpi * fCutsDstoKKpi
D+->Kpipi cuts.
Int_t IsD0FromDStarSelected(Double_t pt, TObject *obj, Int_t selectionLevel, AliAODEvent *aod) const
Bool_t fSecVtxWithKF
z componenent of field in kG
TList * list
AliRDHFCutsLctopKpi * fCutsLctopKpi
Ds->KKpi cuts.
Bool_t SelectInvMassAndPt3prong(Double_t *px, Double_t *py, Double_t *pz, Int_t pidLcStatus=3)
Int_t fnTrksTotal
triplet fullfilling Lc inv mass selection
Double_t fnSigmaTOFProtonLow
High cut value on n. of sigmas for p TPC PID.
Bool_t fOKInvMassDplus
pair fullfilling Jpsi inv mass selection
Double_t fnSigmaTPCKaonLow
High cut value on n. of sigmas for pi TOF PID.
Bool_t FillRecoCand(AliVEvent *event, AliAODRecoDecayHF3Prong *rd3)
Bool_t fUseTPCPIDOnlyIfNoTOF
switch use/not use TOF PID
AliRDHFCutsD0toKpi * fCutsD0toKpi
Track Filter for D* soft pion.
Bool_t fMixEvent
Like-sign triplets.
virtual void DeleteRecoD()
Bool_t fUseTOFPID
switch use/not use TPC PID
Bool_t fOKInvMassD0to4p
combination fullfilling D* inv mass selection
Bool_t fOKInvMassLc
triplet fullfilling Ds inv mass selection
Float_t GetMassCut(Int_t iPtBin=0) const
Int_t * fAODMap
map between index and ID for AOD tracks
Double_t fnSigmaTPCPionLow
flag to control usage of PID tagging
virtual Int_t IsSelectedPID(AliAODRecoDecayHF *)
Definition: AliRDHFCuts.h:281
Bool_t fFindVertexForCascades
reconstruct a secondary vertex or assume it's from the primary vertex
Double_t fnSigmaTPCKaonHi
Low cut value on n. of sigmas for K TPC PID.
AliAODPidHF * GetPidHF() const
Definition: AliRDHFCuts.h:231
Bool_t fUseKaonPIDfor3Prong
PID response.
Bool_t FillRecoCasc(AliVEvent *event, AliAODRecoCascadeHF *rc, Bool_t isDStar)
AliRDHFCutsDplustoKpipi * fCutsDplustoKpipi
J/psi->ee cuts.
AliRDHFCutsD0toKpipipi * fCutsD0toKpipipi
Lc –> v0 + bachelor cuts.
Bool_t fLikeSign3prong
Like-sign pairs.
Bool_t SelectInvMassAndPtCascade(Double_t *px, Double_t *py, Double_t *pz)
AliAODRecoDecayHF4Prong * Make4Prong(TObjArray *fourTrackArray, AliVEvent *event, AliAODVertex *secVert, const AliAODVertex *vertexp1n1, const AliAODVertex *vertexp1n1p2, Double_t dcap1n1, Double_t dcap1n2, Double_t dcap2n1, Double_t dcap2n2, Bool_t &ok4Prong)
Class for cuts on AOD reconstructed D+->Kpipi.
Float_t GetDCACut(Int_t iPtBin=0) const
Double_t fnSigmaTPCProtonLow
High cut value on n. of sigmas for K TOF PID.
void SetParametersAtVertex(AliESDtrack *esdt, const AliExternalTrackParam *extpar) const
Float_t GetMassCut(Int_t iPtBin=0) const
Float_t GetDCACut(Int_t iPtBin=0) const
Double_t fMaxMomForTPCPid
use TPC PID only for tracks that without TOF
virtual Int_t IsSelected(TObject *obj, Int_t selectionLevel)
Int_t GetIsFilled() const
Float_t GetMassCut(Int_t iPtBin=0) const
Float_t GetMassCut(Int_t iPtBin=0) const
AliAnalysisFilter * fTrackFilter2prongCentral
Track Filter for displaced vertices.
Double_t fnSigmaTOFKaonLow
High cut value on n. of sigmas for K TPC PID.
Float_t fMaxCentPercentileForTightCuts
High cut value on n. of sigmas for p TOF PID.
Bool_t fOKInvMassDstar
triplet fullfilling Lc inv mass selection
virtual Int_t IsSelected(TObject *obj, Int_t selectionLevel, AliAODEvent *aod)
virtual Int_t IsSelected(TObject *obj, Int_t selectionLevel)
Double_t fBzkG
vertexer, to compute secondary vertices
Float_t GetDCACut(Int_t iPtBin=0) const
Bool_t fUsePIDforLc2V0
PID for Lambdac: 0=no, 1=proton, 2=p and pi.
void SetProngIDs(Int_t nIDs, UShort_t *id)
virtual void PrintAll() const
UShort_t GetProngID(Int_t ip) const
Float_t GetMassCut(Int_t iPtBin=0) const
Bool_t fUseKaonPIDforDs
PID for Lambdac 2 V0: 0=no, 1=proton,.
virtual Int_t IsSelected(TObject *obj, Int_t selectionLevel)
Bool_t fUseTPCPID
Kaon PID usage for Ds.
Bool_t fOKInvMassLctoV0
4tracks fullfilling D0 inv mass selection
void SetPrimaryVtxRef(TObject *vtx)
primary vertex
void SetOwnPrimaryVtx(const AliAODVertex *vtx)
Bool_t fFindVertexForDstar
pointer to list of cuts for output file
Double_t fnSigmaTOFKaonHi
Low cut value on n. of sigmas for K TOF PID.
AliAODRecoDecay * fMassCalc2
to go faster in PbPb
Float_t GetDCACut(Int_t iPtBin=0) const
void FindCandidates(AliVEvent *event, TClonesArray *aodVerticesHFTClArr, TClonesArray *aodD0toKpiTClArr, TClonesArray *aodJPSItoEleTClArr, TClonesArray *aodCharm3ProngTClArr, TClonesArray *aodCharm4ProngTClArr, TClonesArray *aodDstarTClArr, TClonesArray *aodCascadesTClArr, TClonesArray *aodLikeSign2ProngTClArr, TClonesArray *aodLikeSign3ProngTClArr)
void AddDaughterRefs(AliAODVertex *v, const AliVEvent *event, const TObjArray *trkArray) const
Int_t fUsePIDforLc
Kaon PID usage for 3 prongs.
Bool_t IsEventSelected(AliVEvent *event)
Bool_t fLikeSign
cascades, Lc –> v0+track
virtual Int_t IsSelected(TObject *obj, Int_t selectionLevel)
Bool_t SingleTrkCuts(AliESDtrack *trk, Float_t centralityperc, Bool_t &okDisplaced, Bool_t &okSoftPi, Bool_t &ok3prong) const
void SetUsePID(Bool_t flag=kTRUE)
Definition: AliRDHFCuts.h:204
virtual void PrintAll() const
Float_t GetDCACut(Int_t iPtBin=0) const
AliRDHFCutsJpsitoee * fCutsJpsitoee
D0->Kpi cuts.
Bool_t SelectInvMassAndPtJpsiee(Double_t *px, Double_t *py, Double_t *pz)
Bool_t fOKInvMassD0
for 4 prong
void Setd0errProngs(Int_t nprongs, Double_t *d0)
Bool_t fOKInvMassJpsi
pair fullfilling D0 inv mass selection
Bool_t SelectInvMassAndPtDstarD0pi(Double_t *px, Double_t *py, Double_t *pz)
Int_t fV0TypeForCascadeVertex
reconstruct a secondary vertex or assume it's from the primary vertex
virtual Int_t IsSelected(TObject *obj, Int_t selectionLevel)
Bool_t GetIsUsePID() const
Definition: AliRDHFCuts.h:254
Bool_t fMassCutBeforeVertexing
Select which V0 type we want to use for the cascas.
Int_t fAODMapSize
input from AOD (kTRUE) or ESD (kFALSE)
void FixReferences(AliAODEvent *aod)
void SetSelectionBitForPID(AliRDHFCuts *cuts, AliAODRecoDecayHF *rd, Int_t bit)
AliAODRecoCascadeHF * MakeCascade(TObjArray *twoTrackArray, AliVEvent *event, AliAODVertex *secVert, AliAODRecoDecayHF2Prong *rd2Prong, Double_t dca, Bool_t &okDstar)
void SelectTracksAndCopyVertex(const AliVEvent *event, Int_t trkEntries, TObjArray &seleTrksArray, TObjArray &tracksAtVertex, Int_t &nSeleTrks, UChar_t *seleFlags, Int_t *evtNumber)
void SetSigmaVert(Double_t sigmaVert)
Bool_t fRecoPrimVtxSkippingTrks
if kTRUE use KF vertexer, else AliVertexerTracks
AliAODRecoDecay * fMassCalc3
for 2 prong
TList * fListOfCuts
Dstar->D0pi cuts.
Float_t GetMassCut(Int_t iPtBin=0) const
Double_t fnSigmaTPCProtonHi
Low cut value on n. of sigmas for p TPC PID.
Double_t GetMinPtCandidate() const
Definition: AliRDHFCuts.h:267
Float_t GetMassCut(Int_t iPtBin=0) const
AliRDHFCutsLctoV0 * fCutsLctoV0
Lc->pKpi cuts.
Float_t GetDCACut(Int_t iPtBin=0) const
void MapAODtracks(AliVEvent *aod)
AliAODRecoDecayHF3Prong * Make3Prong(TObjArray *threeTrackArray, AliVEvent *event, AliAODVertex *secVert, Double_t dispersion, const AliAODVertex *vertexp1n1, const AliAODVertex *vertexp2n1, Double_t dcap1n1, Double_t dcap2n1, Double_t dcap1p2, Bool_t useForLc, Bool_t useForDs, Bool_t &ok3Prong)
AliRDHFCutsDStartoKpipi * fCutsDStartoKpipi
D0->Kpipipi cuts.
AliAnalysisFilter * fTrackFilter
max. centrality percentile for using tight cuts
Float_t GetDCACut(Int_t iPtBin=0) const
Bool_t SelectInvMassAndPtD0Kpi(Double_t *px, Double_t *py, Double_t *pz)
Bool_t GetUsePID(Int_t iPtBin=0) const
AliAODv0 * TransformESDv0toAODv0(AliESDv0 *esdv0, TObjArray *twoTrackArrayV0)
Bool_t SelectInvMassAndPt4prong(Double_t *px, Double_t *py, Double_t *pz)
Double_t fnSigmaTPCPionHi
Low cut value on n. of sigmas for pi TPC PID.
Bool_t fD0toKpi
primary vertex
Bool_t fOKInvMassDs
triplet fullfilling D+ inv mass selection
void SetIsFilled(Int_t filled)
void AddRefs(AliAODVertex *v, AliAODRecoDecayHF *rd, const AliVEvent *event, const TObjArray *trkArray) const
AliAODRecoDecayHF2Prong * Make2Prong(TObjArray *twoTrackArray1, AliVEvent *event, AliAODVertex *secVert, Double_t dcap1n1, Bool_t &okD0, Bool_t &okJPSI, Bool_t &okD0fromDstar, Bool_t refill=kFALSE, AliAODRecoDecayHF2Prong *rd=0x0)
Double_t fnSigmaTOFPionLow
High cut value on n. of sigmas for pi TPC PID.