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