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