Accept all particles from a decay chain, bug fix for Heavy flavor
[u/mrichter/AliRoot.git] / PWG3 / vertexingHF / AliAnalysisVertexingHF.cxx
CommitLineData
6a213b59 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//----------------------------------------------------------------------------
17// Implementation of the heavy-flavour vertexing analysis class
dcb444c9 18// Candidates are stored in the AOD as objects deriving from AliAODRecoDecay.
19// To be used as a task of AliAnalysisManager by means of the interface
20// class AliAnalysisTaskSEVertexingHF.
21// An example of usage in the macro AliAnalysisTaskSEVertexingHFTest.C.
6a213b59 22//
b056c5e3 23// Contact: andrea.dainese@lnl.infn.it
dc963de9 24// Contributors: E.Bruna, G.E.Bruno, A.Dainese, C.Di Gliglio,
25// F.Prino, R.Romita, X.M.Zhang
6a213b59 26//----------------------------------------------------------------------------
b82f6d67 27#include <TFile.h>
6a213b59 28#include <TDatabasePDG.h>
29#include <TString.h>
dcb444c9 30#include "AliLog.h"
31#include "AliVEvent.h"
32#include "AliVVertex.h"
33#include "AliVTrack.h"
6a213b59 34#include "AliVertexerTracks.h"
a353d2e4 35#include "AliKFVertex.h"
dcb444c9 36#include "AliESDEvent.h"
6a213b59 37#include "AliESDVertex.h"
e18fbfa7 38#include "AliExternalTrackParam.h"
dcfa35b3 39#include "AliNeutralTrackParam.h"
dcb444c9 40#include "AliESDtrack.h"
f8fa4595 41#include "AliESDtrackCuts.h"
b056c5e3 42#include "AliAODEvent.h"
6a213b59 43#include "AliAODRecoDecay.h"
44#include "AliAODRecoDecayHF.h"
45#include "AliAODRecoDecayHF2Prong.h"
46#include "AliAODRecoDecayHF3Prong.h"
47#include "AliAODRecoDecayHF4Prong.h"
2ff20727 48#include "AliAODRecoCascadeHF.h"
f8fa4595 49#include "AliAnalysisFilter.h"
6a213b59 50#include "AliAnalysisVertexingHF.h"
51
52ClassImp(AliAnalysisVertexingHF)
53
54//----------------------------------------------------------------------------
55AliAnalysisVertexingHF::AliAnalysisVertexingHF():
dcb444c9 56fInputAOD(kFALSE),
57fAODMap(0),
b82f6d67 58fBzkG(0.),
59fSecVtxWithKF(kFALSE),
6a213b59 60fRecoPrimVtxSkippingTrks(kFALSE),
61fRmTrksFromPrimVtx(kFALSE),
62fV1(0x0),
b82f6d67 63fD0toKpi(kTRUE),
64fJPSItoEle(kTRUE),
65f3Prong(kTRUE),
66f4Prong(kTRUE),
2ff20727 67fDstar(kTRUE),
dc963de9 68fLikeSign(kFALSE),
2ff20727 69fTrackFilter(0x0),
eee95e18 70fTrackFilterSoftPi(0x0),
71fFindVertexForDstar(kTRUE)
6a213b59 72{
73 // Default constructor
74
75 SetD0toKpiCuts();
76 SetBtoJPSICuts();
77 SetDplusCuts();
b82f6d67 78 SetDsCuts();
79 SetLcCuts();
2ff20727 80 SetDstarCuts();
721c0b8f 81 SetD0to4ProngsCuts();
6a213b59 82}
13977a79 83//--------------------------------------------------------------------------
84AliAnalysisVertexingHF::AliAnalysisVertexingHF(const AliAnalysisVertexingHF &source) :
85TNamed(source),
dcb444c9 86fInputAOD(source.fInputAOD),
87fAODMap(source.fAODMap),
b82f6d67 88fBzkG(source.fBzkG),
89fSecVtxWithKF(source.fSecVtxWithKF),
13977a79 90fRecoPrimVtxSkippingTrks(source.fRecoPrimVtxSkippingTrks),
91fRmTrksFromPrimVtx(source.fRmTrksFromPrimVtx),
92fV1(source.fV1),
13977a79 93fD0toKpi(source.fD0toKpi),
94fJPSItoEle(source.fJPSItoEle),
95f3Prong(source.f3Prong),
96f4Prong(source.f4Prong),
2ff20727 97fDstar(source.fDstar),
dc963de9 98fLikeSign(source.fLikeSign),
2ff20727 99fTrackFilter(source.fTrackFilter),
eee95e18 100fTrackFilterSoftPi(source.fTrackFilterSoftPi),
101fFindVertexForDstar(source.fFindVertexForDstar)
13977a79 102{
103 //
104 // Copy constructor
105 //
106 for(Int_t i=0; i<9; i++) fD0toKpiCuts[i]=source.fD0toKpiCuts[i];
107 for(Int_t i=0; i<9; i++) fBtoJPSICuts[i]=source.fBtoJPSICuts[i];
108 for(Int_t i=0; i<12; i++) fDplusCuts[i]=source.fDplusCuts[i];
2ff20727 109 for(Int_t i=0; i<13; i++) fDsCuts[i]=source.fDsCuts[i];
110 for(Int_t i=0; i<12; i++) fLcCuts[i]=source.fLcCuts[i];
111 for(Int_t i=0; i<5; i++) fDstarCuts[i]=source.fDstarCuts[i];
721c0b8f 112 for(Int_t i=0; i<9; i++) fD0to4ProngsCuts[i]=source.fD0to4ProngsCuts[i];
13977a79 113}
114//--------------------------------------------------------------------------
115AliAnalysisVertexingHF &AliAnalysisVertexingHF::operator=(const AliAnalysisVertexingHF &source)
116{
117 //
118 // assignment operator
119 //
120 if(&source == this) return *this;
dcb444c9 121 fInputAOD = source.fInputAOD;
b82f6d67 122 fBzkG = source.fBzkG;
123 fSecVtxWithKF = source.fSecVtxWithKF;
13977a79 124 fRecoPrimVtxSkippingTrks = source.fRecoPrimVtxSkippingTrks;
125 fRmTrksFromPrimVtx = source.fRmTrksFromPrimVtx;
126 fV1 = source.fV1;
13977a79 127 fD0toKpi = source.fD0toKpi;
128 fJPSItoEle = source.fJPSItoEle;
129 f3Prong = source.f3Prong;
130 f4Prong = source.f4Prong;
2ff20727 131 fDstar = source.fDstar;
dc963de9 132 fLikeSign = source.fLikeSign;
f8fa4595 133 fTrackFilter = source.fTrackFilter;
2ff20727 134 fTrackFilterSoftPi = source.fTrackFilterSoftPi;
eee95e18 135 fFindVertexForDstar = source.fFindVertexForDstar;
13977a79 136
137 for(Int_t i=0; i<9; i++) fD0toKpiCuts[i]=source.fD0toKpiCuts[i];
138 for(Int_t i=0; i<9; i++) fBtoJPSICuts[i]=source.fBtoJPSICuts[i];
139 for(Int_t i=0; i<12; i++) fDplusCuts[i]=source.fDplusCuts[i];
2ff20727 140 for(Int_t i=0; i<13; i++) fDsCuts[i]=source.fDsCuts[i];
141 for(Int_t i=0; i<12; i++) fLcCuts[i]=source.fLcCuts[i];
142 for(Int_t i=0; i<5; i++) fDstarCuts[i]=source.fDstarCuts[i];
721c0b8f 143 for(Int_t i=0; i<9; i++) fD0to4ProngsCuts[i]=source.fD0to4ProngsCuts[i];
13977a79 144
145 return *this;
146}
6a213b59 147//----------------------------------------------------------------------------
148AliAnalysisVertexingHF::~AliAnalysisVertexingHF() {
149 // Destructor
13977a79 150 if(fV1) { delete fV1; fV1=0; }
f8fa4595 151 if(fTrackFilter) { delete fTrackFilter; fTrackFilter=0; }
2ff20727 152 if(fTrackFilterSoftPi) { delete fTrackFilterSoftPi; fTrackFilterSoftPi=0; }
6a213b59 153}
154//----------------------------------------------------------------------------
dcb444c9 155void AliAnalysisVertexingHF::FindCandidates(AliVEvent *event,
156 TClonesArray *aodVerticesHFTClArr,
157 TClonesArray *aodD0toKpiTClArr,
158 TClonesArray *aodJPSItoEleTClArr,
159 TClonesArray *aodCharm3ProngTClArr,
2ff20727 160 TClonesArray *aodCharm4ProngTClArr,
dc963de9 161 TClonesArray *aodDstarTClArr,
162 TClonesArray *aodLikeSignTClArr)
b056c5e3 163{
164 // Find heavy-flavour vertex candidates
dcb444c9 165 // Input: ESD or AOD
b056c5e3 166 // Output: AOD (additional branches added)
167
dcb444c9 168
169 TString evtype = event->IsA()->GetName();
170 fInputAOD = ((evtype=="AliAODEvent") ? kTRUE : kFALSE);
171
b056c5e3 172 if(!aodVerticesHFTClArr) {
173 printf("ERROR: no aodVerticesHFTClArr");
174 return;
175 }
fa925a06 176 if((fD0toKpi || fDstar) && !aodD0toKpiTClArr) {
b056c5e3 177 printf("ERROR: no aodD0toKpiTClArr");
178 return;
179 }
180 if(fJPSItoEle && !aodJPSItoEleTClArr) {
181 printf("ERROR: no aodJPSItoEleTClArr");
182 return;
183 }
184 if(f3Prong && !aodCharm3ProngTClArr) {
185 printf("ERROR: no aodCharm3ProngTClArr");
186 return;
187 }
188 if(f4Prong && !aodCharm4ProngTClArr) {
189 printf("ERROR: no aodCharm4ProngTClArr");
190 return;
191 }
2ff20727 192 if(fDstar && !aodDstarTClArr) {
193 printf("ERROR: no aodDstarTClArr");
194 return;
195 }
dc963de9 196 if(fLikeSign && !aodLikeSignTClArr) {
197 printf("ERROR: no aodLikeSignTClArr");
198 return;
199 }
b056c5e3 200
201 // delete candidates from previous event and create references
dc963de9 202 Int_t iVerticesHF=0,iD0toKpi=0,iJPSItoEle=0,i3Prong=0,i4Prong=0,iDstar=0,iLikeSign=0;
b056c5e3 203 aodVerticesHFTClArr->Delete();
204 iVerticesHF = aodVerticesHFTClArr->GetEntriesFast();
205 TClonesArray &verticesHFRef = *aodVerticesHFTClArr;
fa925a06 206 if(fD0toKpi || fDstar) {
b056c5e3 207 aodD0toKpiTClArr->Delete();
208 iD0toKpi = aodD0toKpiTClArr->GetEntriesFast();
209 }
210 if(fJPSItoEle) {
211 aodJPSItoEleTClArr->Delete();
212 iJPSItoEle = aodJPSItoEleTClArr->GetEntriesFast();
213 }
214 if(f3Prong) {
215 aodCharm3ProngTClArr->Delete();
216 i3Prong = aodCharm3ProngTClArr->GetEntriesFast();
217 }
218 if(f4Prong) {
219 aodCharm4ProngTClArr->Delete();
220 i4Prong = aodCharm4ProngTClArr->GetEntriesFast();
221 }
2ff20727 222 if(fDstar) {
223 aodDstarTClArr->Delete();
224 iDstar = aodDstarTClArr->GetEntriesFast();
225 }
dc963de9 226 if(fLikeSign) {
227 aodLikeSignTClArr->Delete();
228 iLikeSign = aodLikeSignTClArr->GetEntriesFast();
229 }
2ff20727 230 TClonesArray &aodD0toKpiRef = *aodD0toKpiTClArr;
231 TClonesArray &aodJPSItoEleRef = *aodJPSItoEleTClArr;
232 TClonesArray &aodCharm3ProngRef = *aodCharm3ProngTClArr;
233 TClonesArray &aodCharm4ProngRef = *aodCharm4ProngTClArr;
234 TClonesArray &aodDstarRef = *aodDstarTClArr;
dc963de9 235 TClonesArray &aodLikeSignRef = *aodLikeSignTClArr;
236
b056c5e3 237
2ff20727 238 AliAODRecoDecayHF2Prong *io2Prong = 0;
239 AliAODRecoDecayHF3Prong *io3Prong = 0;
240 AliAODRecoDecayHF4Prong *io4Prong = 0;
241 AliAODRecoCascadeHF *ioCascade = 0;
b056c5e3 242
2ff20727 243 Int_t iTrkP1,iTrkP2,iTrkN1,iTrkN2,iTrkSoftPi,trkEntries;
721c0b8f 244 Double_t xdummy,ydummy,dcap1n1,dcap1n2,dcap2n1,dcap1p2,dcan1n2,dcap2n2,dcaCasc;
b056c5e3 245 Bool_t okD0=kFALSE,okJPSI=kFALSE,ok3Prong=kFALSE,ok4Prong=kFALSE;
2ff20727 246 Bool_t okDstar=kFALSE,okD0fromDstar=kFALSE;
b056c5e3 247 AliESDtrack *postrack1 = 0;
248 AliESDtrack *postrack2 = 0;
249 AliESDtrack *negtrack1 = 0;
250 AliESDtrack *negtrack2 = 0;
2ff20727 251 AliESDtrack *trackPi = 0;
b056c5e3 252 Double_t dcaMax = fD0toKpiCuts[1];
253 if(dcaMax < fBtoJPSICuts[1]) dcaMax=fBtoJPSICuts[1];
254 if(dcaMax < fDplusCuts[11]) dcaMax=fDplusCuts[11];
721c0b8f 255 if(dcaMax < fD0to4ProngsCuts[1]) dcaMax=fD0to4ProngsCuts[1];
dcb444c9 256 AliDebug(2,Form(" dca cut set to %f cm",dcaMax));
b056c5e3 257
b056c5e3 258
dcb444c9 259 // get Bz
260 fBzkG = (Double_t)event->GetMagneticField();
b056c5e3 261
dcb444c9 262 trkEntries = (Int_t)event->GetNumberOfTracks();
263 AliDebug(1,Form(" Number of tracks: %d",trkEntries));
357cd934 264
265 if(trkEntries<2) {
266 AliDebug(1,Form(" Not enough tracks: %d",trkEntries));
267 return;
268 }
b056c5e3 269
357cd934 270 const AliVVertex *primary = event->GetPrimaryVertex();
271 if(!primary) {
272 AliDebug(1," No primary vertex from tracks");
273 return;
274 }
275 TString primTitle = primary->GetTitle();
b6e66d86 276 if(!primTitle.Contains("VertexerTracks") ||
277 primary->GetNContributors()<=0) {
357cd934 278 AliDebug(1," No primary vertex from tracks");
b056c5e3 279 return;
280 }
281
dcb444c9 282 // call function that applies sigle-track selection,
2ff20727 283 // for displaced tracks and soft pions (both charges) for D*,
dcb444c9 284 // and retrieves primary vertex
2ff20727 285 TObjArray seleTrksArray(trkEntries);
286 UChar_t *seleFlags = new UChar_t[trkEntries]; // bit 0: displaced, bit 1: softpi
287 Int_t nSeleTrks=0;
288 SelectTracksAndCopyVertex(event,seleTrksArray,nSeleTrks,seleFlags);
b056c5e3 289
2ff20727 290 AliDebug(1,Form(" Selected tracks: %d",nSeleTrks));
b056c5e3 291
2ff20727 292 TObjArray *twoTrackArray1 = new TObjArray(2);
293 TObjArray *twoTrackArray2 = new TObjArray(2);
294 TObjArray *twoTrackArrayCasc = new TObjArray(2);
295 TObjArray *threeTrackArray = new TObjArray(3);
296 TObjArray *fourTrackArray = new TObjArray(4);
b056c5e3 297
dcb444c9 298 Double_t dispersion;
dc963de9 299 Bool_t isLikeSignPair=kFALSE;
dcb444c9 300
2ff20727 301 AliAODRecoDecayHF *rd = 0;
302 AliAODRecoCascadeHF *rc = 0;
303
b056c5e3 304 // LOOP ON POSITIVE TRACKS
2ff20727 305 for(iTrkP1=0; iTrkP1<nSeleTrks; iTrkP1++) {
dc963de9 306
2ff20727 307 if(iTrkP1%1==0) AliDebug(1,Form(" 1st loop on pos: track number %d of %d",iTrkP1,nSeleTrks));
dc963de9 308
b056c5e3 309 // get track from tracks array
2ff20727 310 postrack1 = (AliESDtrack*)seleTrksArray.UncheckedAt(iTrkP1);
dc963de9 311
312 if(!TESTBIT(seleFlags[iTrkP1],kBitDispl)) continue;
313
314 if(postrack1->Charge()<0 && !fLikeSign) continue;
315
b056c5e3 316 // LOOP ON NEGATIVE TRACKS
2ff20727 317 for(iTrkN1=0; iTrkN1<nSeleTrks; iTrkN1++) {
dc963de9 318
2ff20727 319 if(iTrkN1%1==0) AliDebug(1,Form(" 1st loop on neg: track number %d of %d",iTrkN1,nSeleTrks));
dc963de9 320
321 if(iTrkN1==iTrkP1) continue;
322
b056c5e3 323 // get track from tracks array
2ff20727 324 negtrack1 = (AliESDtrack*)seleTrksArray.UncheckedAt(iTrkN1);
dc963de9 325
326 if(negtrack1->Charge()>0 && !fLikeSign) continue;
327
328 if(!TESTBIT(seleFlags[iTrkN1],kBitDispl)) continue;
329
330 if(postrack1->Charge()==negtrack1->Charge()) { // like-sign
331 isLikeSignPair=kTRUE;
332 if(!fLikeSign) continue;
333 if(iTrkN1<iTrkP1) continue; // this is needed to avoid double-counting of like-sign
334 } else { // unlike-sign
335 isLikeSignPair=kFALSE;
336 if(postrack1->Charge()<0 || negtrack1->Charge()>0) continue; // this is needed to avoid double-counting of unlike-sign
337 }
338
dcb444c9 339 // back to primary vertex
340 postrack1->PropagateToDCA(fV1,fBzkG,kVeryBig);
341 negtrack1->PropagateToDCA(fV1,fBzkG,kVeryBig);
dc963de9 342
b056c5e3 343 // DCA between the two tracks
344 dcap1n1 = postrack1->GetDCA(negtrack1,fBzkG,xdummy,ydummy);
345 if(dcap1n1>dcaMax) { negtrack1=0; continue; }
dc963de9 346
b056c5e3 347 // Vertexing
348 twoTrackArray1->AddAt(postrack1,0);
349 twoTrackArray1->AddAt(negtrack1,1);
dcb444c9 350 AliAODVertex *vertexp1n1 = ReconstructSecondaryVertex(twoTrackArray1,dispersion);
b056c5e3 351 if(!vertexp1n1) {
352 twoTrackArray1->Clear();
353 negtrack1=0;
354 continue;
355 }
dc963de9 356
357 // 2 prong candidate
358 if(fD0toKpi || fJPSItoEle || fDstar || fLikeSign) {
b6e66d86 359
2ff20727 360 io2Prong = Make2Prong(twoTrackArray1,event,vertexp1n1,dcap1n1,okD0,okJPSI,okD0fromDstar);
b6e66d86 361
dc963de9 362 if((fD0toKpi && okD0) || (fJPSItoEle && okJPSI) || (isLikeSignPair && (okD0 || okJPSI))) {
2ff20727 363 // add the vertex and the decay to the AOD
364 AliAODVertex *v2Prong = new(verticesHFRef[iVerticesHF++])AliAODVertex(*vertexp1n1);
365 if(fInputAOD) AddDaughterRefs(v2Prong,event,twoTrackArray1);
dc963de9 366 if(!isLikeSignPair) {
367 if(okD0) {
368 rd = new(aodD0toKpiRef[iD0toKpi++])AliAODRecoDecayHF2Prong(*io2Prong);
369 rd->SetSecondaryVtx(v2Prong);
370 v2Prong->SetParent(rd);
371 }
372 if(okJPSI) {
373 rd = new(aodJPSItoEleRef[iJPSItoEle++])AliAODRecoDecayHF2Prong(*io2Prong);
374 rd->SetSecondaryVtx(v2Prong);
375 if(!okD0) v2Prong->SetParent(rd); // it cannot have two mothers ...
376 }
377 } else { // isLikeSignPair
378 rd = new(aodLikeSignRef[iLikeSign++])AliAODRecoDecayHF2Prong(*io2Prong);
2ff20727 379 rd->SetSecondaryVtx(v2Prong);
380 v2Prong->SetParent(rd);
dcb444c9 381 }
b056c5e3 382 }
dc963de9 383 // D* candidates
384 if(fDstar && okD0fromDstar && !isLikeSignPair) {
385 // write references in io2Prong
386 if(fInputAOD) {
2ff20727 387 AddDaughterRefs(vertexp1n1,event,twoTrackArray1);
dc963de9 388 } else {
389 vertexp1n1->AddDaughter(postrack1);
390 vertexp1n1->AddDaughter(negtrack1);
2ff20727 391 }
dc963de9 392 io2Prong->SetSecondaryVtx(vertexp1n1);
393 //printf("---> %d %d %d %d %d\n",vertexp1n1->GetNDaughters(),iTrkP1,iTrkN1,postrack1->Charge(),negtrack1->Charge());
2ff20727 394 // create a track from the D0
dcfa35b3 395 AliNeutralTrackParam *trackD0 = new AliNeutralTrackParam(io2Prong);
dc963de9 396
2ff20727 397 // LOOP ON TRACKS THAT PASSED THE SOFT PION CUTS
398 for(iTrkSoftPi=0; iTrkSoftPi<nSeleTrks; iTrkSoftPi++) {
dc963de9 399
2ff20727 400 if(iTrkSoftPi==iTrkP1 || iTrkSoftPi==iTrkN1) continue;
dc963de9 401
2ff20727 402 if(!TESTBIT(seleFlags[iTrkSoftPi],kBitSoftPi)) continue;
dc963de9 403
2ff20727 404 if(iTrkSoftPi%1==0) AliDebug(1,Form(" 1st loop on pi_s: track number %d of %d",iTrkSoftPi,nSeleTrks));
dc963de9 405
eee95e18 406 trackD0->PropagateToDCA(fV1,fBzkG,kVeryBig);
407 if(trackD0->GetSigmaY2()<0. || trackD0->GetSigmaZ2()<0.) continue; // this is insipired by the AliITStrackV2::Invariant() checks
408
2ff20727 409 // get track from tracks array
410 trackPi = (AliESDtrack*)seleTrksArray.UncheckedAt(iTrkSoftPi);
2ff20727 411 trackPi->PropagateToDCA(fV1,fBzkG,kVeryBig);
dc963de9 412
2ff20727 413 twoTrackArrayCasc->AddAt(trackPi,0);
414 twoTrackArrayCasc->AddAt(trackD0,1);
eee95e18 415
416 AliAODVertex *vertexCasc = 0;
417
418 if(fFindVertexForDstar) {
419 // DCA between the two tracks
420 dcaCasc = trackPi->GetDCA(trackD0,fBzkG,xdummy,ydummy);
421 // Vertexing
422 vertexCasc = ReconstructSecondaryVertex(twoTrackArrayCasc,dispersion,kFALSE);
423 } else {
424 // assume Dstar decays at the primary vertex
425 Double_t pos[3],cov[6],chi2perNDF;
426 fV1->GetXYZ(pos);
427 fV1->GetCovMatrix(cov);
428 chi2perNDF = fV1->GetChi2toNDF();
429 vertexCasc = new AliAODVertex(pos,cov,chi2perNDF,0x0,-1,AliAODVertex::kUndef,2);
430 dcaCasc = 0.;
431 }
2ff20727 432 if(!vertexCasc) {
433 twoTrackArrayCasc->Clear();
434 trackPi=0;
435 continue;
436 }
dc963de9 437
2ff20727 438 ioCascade = MakeCascade(twoTrackArrayCasc,event,vertexCasc,io2Prong,dcaCasc,okDstar);
439 if(okDstar) {
dc963de9 440 // add the D0 to the AOD (if not already done)
2ff20727 441 if(!okD0) {
2ff20727 442 AliAODVertex *v2Prong = new(verticesHFRef[iVerticesHF++])AliAODVertex(*vertexp1n1);
443 if(fInputAOD) AddDaughterRefs(v2Prong,event,twoTrackArray1);
444 rd = new(aodD0toKpiRef[iD0toKpi++])AliAODRecoDecayHF2Prong(*io2Prong);
445 rd->SetSecondaryVtx(v2Prong);
446 v2Prong->SetParent(rd);
447 okD0=kTRUE; // this is done to add it only once
448 }
449 // add the vertex and the cascade to the AOD
450 AliAODVertex *vCasc = new(verticesHFRef[iVerticesHF++])AliAODVertex(*vertexCasc);
dcfa35b3 451 if(fInputAOD) {
452 AddDaughterRefs(vCasc,event,twoTrackArrayCasc); // add the pion
453 } else {
454 vCasc->AddDaughter(rd); // just to fill ref #0
455 }
456 vCasc->AddDaughter(rd); // add the D0 (in ref #1)
2ff20727 457 rc = new(aodDstarRef[iDstar++])AliAODRecoCascadeHF(*ioCascade);
2ff20727 458 rc->SetSecondaryVtx(vCasc);
459 vCasc->SetParent(rc);
460 }
461 twoTrackArrayCasc->Clear();
462 trackPi=0;
0a65d33f 463 if(ioCascade) {delete ioCascade; ioCascade=NULL;}
b6e66d86 464 delete vertexCasc; vertexCasc=NULL;
2ff20727 465 } // end loop on soft pi tracks
dc963de9 466
2ff20727 467 if(trackD0) {delete trackD0; trackD0=NULL;}
dc963de9 468
2ff20727 469 }
0a65d33f 470 if(io2Prong) {delete io2Prong; io2Prong=NULL;}
2ff20727 471 }
dc963de9 472
b056c5e3 473 twoTrackArray1->Clear();
dc963de9 474 if((!f3Prong && !f4Prong) || isLikeSignPair) {
b056c5e3 475 negtrack1=0;
476 delete vertexp1n1;
477 continue;
478 }
479
480
481 // 2nd LOOP ON POSITIVE TRACKS
2ff20727 482 for(iTrkP2=iTrkP1+1; iTrkP2<nSeleTrks; iTrkP2++) {
dc963de9 483
2ff20727 484 if(iTrkP2==iTrkP1 || iTrkP2==iTrkN1) continue;
dc963de9 485
2ff20727 486 if(iTrkP2%1==0) AliDebug(1,Form(" 2nd loop on pos: track number %d of %d",iTrkP2,nSeleTrks));
dc963de9 487
b056c5e3 488 // get track from tracks array
2ff20727 489 postrack2 = (AliESDtrack*)seleTrksArray.UncheckedAt(iTrkP2);
dc963de9 490
491 if(postrack2->Charge()<0) continue;
492
493 if(!TESTBIT(seleFlags[iTrkP2],kBitDispl)) continue;
494
dcb444c9 495 // back to primary vertex
496 postrack1->PropagateToDCA(fV1,fBzkG,kVeryBig);
497 postrack2->PropagateToDCA(fV1,fBzkG,kVeryBig);
498 negtrack1->PropagateToDCA(fV1,fBzkG,kVeryBig);
2ff20727 499 //printf("********** %d %d %d\n",postrack1->GetID(),postrack2->GetID(),negtrack1->GetID());
dc963de9 500
b056c5e3 501 dcap2n1 = postrack2->GetDCA(negtrack1,fBzkG,xdummy,ydummy);
502 if(dcap2n1>dcaMax) { postrack2=0; continue; }
503 dcap1p2 = postrack2->GetDCA(postrack1,fBzkG,xdummy,ydummy);
504 if(dcap1p2>dcaMax) { postrack2=0; continue; }
505
506 // Vertexing
507 twoTrackArray2->AddAt(postrack2,0);
508 twoTrackArray2->AddAt(negtrack1,1);
dcb444c9 509 AliAODVertex *vertexp2n1 = ReconstructSecondaryVertex(twoTrackArray2,dispersion);
b056c5e3 510 if(!vertexp2n1) {
511 twoTrackArray2->Clear();
512 postrack2=0;
513 continue;
514 }
dc963de9 515
516 // 3 prong candidates
b056c5e3 517 if(f3Prong) {
dc963de9 518
b056c5e3 519 threeTrackArray->AddAt(postrack1,0);
520 threeTrackArray->AddAt(negtrack1,1);
521 threeTrackArray->AddAt(postrack2,2);
dc963de9 522
dcb444c9 523 AliAODVertex* secVert3PrAOD = ReconstructSecondaryVertex(threeTrackArray,dispersion);
524 io3Prong = Make3Prong(threeTrackArray,event,secVert3PrAOD,dispersion,vertexp1n1,vertexp2n1,dcap1n1,dcap2n1,dcap1p2,ok3Prong);
b056c5e3 525 if(ok3Prong) {
2ff20727 526 AliAODVertex *v3Prong = new(verticesHFRef[iVerticesHF++])AliAODVertex(*secVert3PrAOD);
527 if(fInputAOD) AddDaughterRefs(v3Prong,event,threeTrackArray);
528 rd = new(aodCharm3ProngRef[i3Prong++])AliAODRecoDecayHF3Prong(*io3Prong);
529 rd->SetSecondaryVtx(v3Prong);
530 v3Prong->SetParent(rd);
b056c5e3 531 }
b6e66d86 532 if(io3Prong) {delete io3Prong; io3Prong=NULL;}
533 if(secVert3PrAOD) {delete secVert3PrAOD; secVert3PrAOD=NULL;}
b056c5e3 534 }
dc963de9 535
536 // 4 prong candidates
b056c5e3 537 if(f4Prong) {
dc963de9 538
721c0b8f 539 // back to primary vertex
540 postrack1->PropagateToDCA(fV1,fBzkG,kVeryBig);
541 postrack2->PropagateToDCA(fV1,fBzkG,kVeryBig);
542 negtrack1->PropagateToDCA(fV1,fBzkG,kVeryBig);
543 // Vertexing for these 3 (can be taken from above?)
544 threeTrackArray->AddAt(postrack1,0);
545 threeTrackArray->AddAt(negtrack1,1);
546 threeTrackArray->AddAt(postrack2,2);
547 AliAODVertex* vertexp1n1p2 = ReconstructSecondaryVertex(threeTrackArray,dispersion);
548
b056c5e3 549 // 3rd LOOP ON NEGATIVE TRACKS (for 4 prong)
2ff20727 550 for(iTrkN2=iTrkN1+1; iTrkN2<nSeleTrks; iTrkN2++) {
dc963de9 551
2ff20727 552 if(iTrkN2==iTrkP1 || iTrkN2==iTrkP2 || iTrkN2==iTrkN1) continue;
dc963de9 553
2ff20727 554 if(iTrkN2%1==0) AliDebug(1,Form(" 3rd loop on neg: track number %d of %d",iTrkN2,nSeleTrks));
dc963de9 555
b056c5e3 556 // get track from tracks array
2ff20727 557 negtrack2 = (AliESDtrack*)seleTrksArray.UncheckedAt(iTrkN2);
dc963de9 558
559 if(negtrack2->Charge()>0) continue;
560
561 if(!TESTBIT(seleFlags[iTrkN2],kBitDispl)) continue;
562
dcb444c9 563 // back to primary vertex
564 postrack1->PropagateToDCA(fV1,fBzkG,kVeryBig);
565 postrack2->PropagateToDCA(fV1,fBzkG,kVeryBig);
566 negtrack1->PropagateToDCA(fV1,fBzkG,kVeryBig);
567 negtrack2->PropagateToDCA(fV1,fBzkG,kVeryBig);
b056c5e3 568 dcap1n2 = postrack1->GetDCA(negtrack2,fBzkG,xdummy,ydummy);
569 if(dcap1n2>dcaMax) { negtrack2=0; continue; }
721c0b8f 570 dcap2n2 = postrack2->GetDCA(negtrack2,fBzkG,xdummy,ydummy);
571 if(dcap2n2>dcaMax) { negtrack2=0; continue; }
dc963de9 572
b056c5e3 573 // Vertexing
574 fourTrackArray->AddAt(postrack1,0);
575 fourTrackArray->AddAt(negtrack1,1);
576 fourTrackArray->AddAt(postrack2,2);
577 fourTrackArray->AddAt(negtrack2,3);
dc963de9 578
dcb444c9 579 AliAODVertex* secVert4PrAOD = ReconstructSecondaryVertex(fourTrackArray,dispersion);
721c0b8f 580 io4Prong = Make4Prong(fourTrackArray,event,secVert4PrAOD,vertexp1n1,vertexp1n1p2,dcap1n1,dcap1n2,dcap2n1,dcap2n2,ok4Prong);
b056c5e3 581 if(ok4Prong) {
2ff20727 582 AliAODVertex *v4Prong = new(verticesHFRef[iVerticesHF++])AliAODVertex(*secVert4PrAOD);
583 if(fInputAOD) AddDaughterRefs(v4Prong,event,fourTrackArray);
584 rd = new(aodCharm4ProngRef[i4Prong++])AliAODRecoDecayHF4Prong(*io4Prong);
585 rd->SetSecondaryVtx(v4Prong);
586 v4Prong->SetParent(rd);
b056c5e3 587 }
dc963de9 588
b6e66d86 589 if(io4Prong) {delete io4Prong; io4Prong=NULL;}
590 if(secVert4PrAOD) {delete secVert4PrAOD; secVert4PrAOD=NULL;}
b056c5e3 591 fourTrackArray->Clear();
592 negtrack2 = 0;
dc963de9 593
b056c5e3 594 } // end loop on negative tracks
dc963de9 595
721c0b8f 596 threeTrackArray->Clear();
597 delete vertexp1n1p2;
598
b056c5e3 599 }
dc963de9 600
b056c5e3 601 postrack2 = 0;
602 delete vertexp2n1;
dc963de9 603
b056c5e3 604 } // end 2nd loop on positive tracks
dc963de9 605
b056c5e3 606 twoTrackArray2->Clear();
607
dc963de9 608 // 2nd LOOP ON NEGATIVE TRACKS (for 3 prong +--)
2ff20727 609 for(iTrkN2=iTrkN1+1; iTrkN2<nSeleTrks; iTrkN2++) {
dc963de9 610
2ff20727 611 if(iTrkN2==iTrkP1 || iTrkN2==iTrkP2 || iTrkN2==iTrkN1) continue;
dc963de9 612
2ff20727 613 if(iTrkN2%1==0) AliDebug(1,Form(" 2nd loop on neg: track number %d of %d",iTrkN2,nSeleTrks));
dc963de9 614
b056c5e3 615 // get track from tracks array
2ff20727 616 negtrack2 = (AliESDtrack*)seleTrksArray.UncheckedAt(iTrkN2);
dc963de9 617
618 if(negtrack2->Charge()>0) continue;
619
620 if(!TESTBIT(seleFlags[iTrkN2],kBitDispl)) continue;
621
dcb444c9 622 // back to primary vertex
623 postrack1->PropagateToDCA(fV1,fBzkG,kVeryBig);
624 negtrack1->PropagateToDCA(fV1,fBzkG,kVeryBig);
625 negtrack2->PropagateToDCA(fV1,fBzkG,kVeryBig);
2ff20727 626 //printf("********** %d %d %d\n",postrack1->GetID(),negtrack1->GetID(),negtrack2->GetID());
dc963de9 627
b056c5e3 628 dcap1n2 = postrack1->GetDCA(negtrack2,fBzkG,xdummy,ydummy);
629 if(dcap1n2>dcaMax) { negtrack2=0; continue; }
630 dcan1n2 = negtrack1->GetDCA(negtrack2,fBzkG,xdummy,ydummy);
631 if(dcan1n2>dcaMax) { negtrack2=0; continue; }
632
633 // Vertexing
634 twoTrackArray2->AddAt(postrack1,0);
635 twoTrackArray2->AddAt(negtrack2,1);
dcb444c9 636
637 AliAODVertex *vertexp1n2 = ReconstructSecondaryVertex(twoTrackArray2,dispersion);
b056c5e3 638 if(!vertexp1n2) {
639 twoTrackArray2->Clear();
640 negtrack2=0;
641 continue;
642 }
dc963de9 643
b056c5e3 644 if(f3Prong) {
645 threeTrackArray->AddAt(negtrack1,0);
646 threeTrackArray->AddAt(postrack1,1);
647 threeTrackArray->AddAt(negtrack2,2);
dcb444c9 648 AliAODVertex* secVert3PrAOD = ReconstructSecondaryVertex(threeTrackArray,dispersion);
649 io3Prong = Make3Prong(threeTrackArray,event,secVert3PrAOD,dispersion,vertexp1n1,vertexp1n2,dcap1n1,dcap1n2,dcan1n2,ok3Prong);
b056c5e3 650 if(ok3Prong) {
2ff20727 651 AliAODVertex *v3Prong = new(verticesHFRef[iVerticesHF++])AliAODVertex(*secVert3PrAOD);
652 if(fInputAOD) AddDaughterRefs(v3Prong,event,threeTrackArray);
653 rd = new(aodCharm3ProngRef[i3Prong++])AliAODRecoDecayHF3Prong(*io3Prong);
654 rd->SetSecondaryVtx(v3Prong);
655 v3Prong->SetParent(rd);
b056c5e3 656 }
b6e66d86 657 if(io3Prong) {delete io3Prong; io3Prong=NULL;}
658 if(secVert3PrAOD) {delete secVert3PrAOD; secVert3PrAOD=NULL;}
b056c5e3 659 }
dc963de9 660
b056c5e3 661 negtrack2 = 0;
662 delete vertexp1n2;
dc963de9 663
b056c5e3 664 } // end 2nd loop on negative tracks
665 twoTrackArray2->Clear();
666
667 negtrack1 = 0;
668 delete vertexp1n1;
669 } // end 1st loop on negative tracks
670
671 postrack1 = 0;
672 } // end 1st loop on positive tracks
673
674
2ff20727 675 AliDebug(1,Form(" Total HF vertices in event = %d;",
676 (Int_t)aodVerticesHFTClArr->GetEntriesFast()));
b056c5e3 677 if(fD0toKpi) {
dcb444c9 678 AliDebug(1,Form(" D0->Kpi in event = %d;",
679 (Int_t)aodD0toKpiTClArr->GetEntriesFast()));
b056c5e3 680 }
681 if(fJPSItoEle) {
dcb444c9 682 AliDebug(1,Form(" JPSI->ee in event = %d;",
683 (Int_t)aodJPSItoEleTClArr->GetEntriesFast()));
b056c5e3 684 }
685 if(f3Prong) {
dcb444c9 686 AliDebug(1,Form(" Charm->3Prong in event = %d;",
687 (Int_t)aodCharm3ProngTClArr->GetEntriesFast()));
b056c5e3 688 }
689 if(f4Prong) {
dcb444c9 690 AliDebug(1,Form(" Charm->4Prong in event = %d;\n",
691 (Int_t)aodCharm4ProngTClArr->GetEntriesFast()));
b056c5e3 692 }
2ff20727 693 if(fDstar) {
694 AliDebug(1,Form(" D*->D0pi in event = %d;\n",
695 (Int_t)aodDstarTClArr->GetEntriesFast()));
696 }
dc963de9 697 if(fLikeSign) {
698 AliDebug(1,Form(" Like-sign pairs in event = %d;\n",
699 (Int_t)aodLikeSignTClArr->GetEntriesFast()));
700 }
b056c5e3 701
702
dcb444c9 703 twoTrackArray1->Delete(); delete twoTrackArray1;
704 twoTrackArray2->Delete(); delete twoTrackArray2;
2ff20727 705 twoTrackArrayCasc->Delete(); delete twoTrackArrayCasc;
b056c5e3 706 threeTrackArray->Clear();
707 threeTrackArray->Delete(); delete threeTrackArray;
dcb444c9 708 fourTrackArray->Delete(); delete fourTrackArray;
2ff20727 709 delete [] seleFlags; seleFlags=NULL;
b056c5e3 710
dcb444c9 711 if(fInputAOD) {
b6e66d86 712 seleTrksArray.Delete();
713 if(fAODMap) { delete [] fAODMap; fAODMap=NULL; }
dcb444c9 714 }
b056c5e3 715
716 return;
717}
718//----------------------------------------------------------------------------
dcb444c9 719void AliAnalysisVertexingHF::AddDaughterRefs(AliAODVertex *v,AliVEvent *event,
720 TObjArray *trkArray) const
6a213b59 721{
dcb444c9 722 // Add the AOD tracks as daughters of the vertex (TRef)
6a213b59 723
dcb444c9 724 Int_t nTrks = trkArray->GetEntriesFast();
6a213b59 725
e18fbfa7 726 AliExternalTrackParam *track = 0;
dcb444c9 727 AliAODTrack *aodTrack = 0;
728 Int_t id;
6a213b59 729
dcb444c9 730 for(Int_t i=0; i<nTrks; i++) {
e18fbfa7 731 track = (AliExternalTrackParam*)trkArray->UncheckedAt(i);
732 id = (Int_t)track->GetID();
2ff20727 733 //printf("---> %d\n",id);
e18fbfa7 734 if(id<0) continue; // this track is a AliAODRecoDecay
dcb444c9 735 aodTrack = (AliAODTrack*)event->GetTrack(fAODMap[id]);
736 v->AddDaughter(aodTrack);
6a213b59 737 }
6a213b59 738
739 return;
dcb444c9 740}
6a213b59 741//----------------------------------------------------------------------------
2ff20727 742AliAODRecoCascadeHF* AliAnalysisVertexingHF::MakeCascade(
743 TObjArray *twoTrackArray,AliVEvent *event,
744 AliAODVertex *secVert,
745 AliAODRecoDecayHF2Prong *rd2Prong,
746 Double_t dca,
747 Bool_t &okDstar) const
748{
749 // Make the cascade as a 2Prong decay and check if it passes Dstar
750 // reconstruction cuts
751
752 okDstar = kFALSE;
753
754 Bool_t dummy1,dummy2,dummy3;
755
756 // We use Make2Prong to construct the AliAODRecoCascadeHF
757 // (which inherits from AliAODRecoDecayHF2Prong)
758 AliAODRecoCascadeHF *theCascade =
759 (AliAODRecoCascadeHF*)Make2Prong(twoTrackArray,event,secVert,dca,
760 dummy1,dummy2,dummy3);
761 if(!theCascade) return 0x0;
762
763 // charge
764 AliESDtrack *trackPi = (AliESDtrack*)twoTrackArray->UncheckedAt(0);
765 theCascade->SetCharge(trackPi->Charge());
766
767 //--- selection cuts
768 //
769 AliAODRecoCascadeHF *tmpCascade = new AliAODRecoCascadeHF(*theCascade);
dcfa35b3 770 tmpCascade->GetSecondaryVtx()->AddDaughter(trackPi);
771 tmpCascade->GetSecondaryVtx()->AddDaughter(rd2Prong);
2ff20727 772 AliAODVertex *primVertexAOD=0;
773 if(!fRecoPrimVtxSkippingTrks && !fRmTrksFromPrimVtx) {
774 // take event primary vertex
775 primVertexAOD = PrimaryVertex();
776 tmpCascade->SetOwnPrimaryVtx(primVertexAOD);
777 rd2Prong->SetOwnPrimaryVtx(primVertexAOD);
778 }
779 // select D*->D0pi
780 if(fDstar) {
781 Bool_t testD0=kTRUE;
782 okDstar = tmpCascade->SelectDstar(fDstarCuts,fD0fromDstarCuts,testD0);
783 }
dcfa35b3 784 tmpCascade->GetSecondaryVtx()->RemoveDaughters();
2ff20727 785 tmpCascade->UnsetOwnPrimaryVtx();
2ff20727 786 delete tmpCascade; tmpCascade=NULL;
787 if(!fRecoPrimVtxSkippingTrks && !fRmTrksFromPrimVtx) {
788 rd2Prong->UnsetOwnPrimaryVtx();
2ff20727 789 }
b6e66d86 790 if(primVertexAOD) {delete primVertexAOD; primVertexAOD=NULL;}
2ff20727 791 //---
792
793 return theCascade;
794}
795//-----------------------------------------------------------------------------
6a213b59 796AliAODRecoDecayHF2Prong *AliAnalysisVertexingHF::Make2Prong(
2ff20727 797 TObjArray *twoTrackArray,AliVEvent *event,
dcb444c9 798 AliAODVertex *secVert,Double_t dca,
2ff20727 799 Bool_t &okD0,Bool_t &okJPSI,
800 Bool_t &okD0fromDstar) const
6a213b59 801{
802 // Make 2Prong candidates and check if they pass D0toKpi or BtoJPSI
803 // reconstruction cuts
804 // G.E.Bruno (J/psi), A.Dainese (D0->Kpi)
805
2ff20727 806 okD0=kFALSE; okJPSI=kFALSE; okD0fromDstar=kFALSE;
6a213b59 807
808 Double_t px[2],py[2],pz[2],d0[2],d0err[2];
6a213b59 809
2ff20727 810 AliESDtrack *postrack = (AliESDtrack*)twoTrackArray->UncheckedAt(0);
811 AliESDtrack *negtrack = (AliESDtrack*)twoTrackArray->UncheckedAt(1);
6a213b59 812
813 // propagate tracks to secondary vertex, to compute inv. mass
dcb444c9 814 postrack->PropagateToDCA(secVert,fBzkG,kVeryBig);
815 negtrack->PropagateToDCA(secVert,fBzkG,kVeryBig);
6a213b59 816
817 Double_t momentum[3];
818 postrack->GetPxPyPz(momentum);
819 px[0] = momentum[0]; py[0] = momentum[1]; pz[0] = momentum[2];
820 negtrack->GetPxPyPz(momentum);
821 px[1] = momentum[0]; py[1] = momentum[1]; pz[1] = momentum[2];
822
823
824 // invariant mass cut (try to improve coding here..)
825 Bool_t okMassCut=kFALSE;
dcb444c9 826 if(!okMassCut && fD0toKpi) if(SelectInvMass(0,2,px,py,pz)) okMassCut=kTRUE;
6a213b59 827 if(!okMassCut && fJPSItoEle) if(SelectInvMass(1,2,px,py,pz)) okMassCut=kTRUE;
2ff20727 828 if(!okMassCut && fDstar) if(SelectInvMass(3,2,px,py,pz)) okMassCut=kTRUE;
6a213b59 829 if(!okMassCut) {
dcb444c9 830 AliDebug(2," candidate didn't pass mass cut");
6a213b59 831 return 0x0;
832 }
b6e66d86 833
dcb444c9 834 // primary vertex to be used by this candidate
2ff20727 835 AliAODVertex *primVertexAOD = PrimaryVertex(twoTrackArray,event);
dcb444c9 836 if(!primVertexAOD) return 0x0;
6a213b59 837
dcb444c9 838 Double_t d0z0[2],covd0z0[3];
839 postrack->PropagateToDCA(primVertexAOD,fBzkG,kVeryBig,d0z0,covd0z0);
6a213b59 840 d0[0] = d0z0[0];
841 d0err[0] = TMath::Sqrt(covd0z0[0]);
dcb444c9 842 negtrack->PropagateToDCA(primVertexAOD,fBzkG,kVeryBig,d0z0,covd0z0);
6a213b59 843 d0[1] = d0z0[0];
844 d0err[1] = TMath::Sqrt(covd0z0[0]);
b6e66d86 845
6a213b59 846 // create the object AliAODRecoDecayHF2Prong
dcb444c9 847 AliAODRecoDecayHF2Prong *the2Prong = new AliAODRecoDecayHF2Prong(secVert,px,py,pz,d0,d0err,dca);
6a213b59 848 the2Prong->SetOwnPrimaryVtx(primVertexAOD);
dcb444c9 849 UShort_t id[2]={(UShort_t)postrack->GetID(),(UShort_t)negtrack->GetID()};
850 the2Prong->SetProngIDs(2,id);
0a65d33f 851 delete primVertexAOD; primVertexAOD=NULL;
6a213b59 852
b6e66d86 853
6a213b59 854 // select D0->Kpi
855 Int_t checkD0,checkD0bar;
2ff20727 856 if(fD0toKpi) okD0 = the2Prong->SelectD0(fD0toKpiCuts,checkD0,checkD0bar);
6a213b59 857 //if(fDebug && fD0toKpi) printf(" %d\n",(Int_t)okD0);
858 // select J/psi from B
859 Int_t checkJPSI;
2ff20727 860 if(fJPSItoEle) okJPSI = the2Prong->SelectBtoJPSI(fBtoJPSICuts,checkJPSI);
6a213b59 861 //if(fDebug && fJPSItoEle) printf(" %d\n",(Int_t)okJPSI);
2ff20727 862 // select D0->Kpi from Dstar
863 if(fDstar) okD0fromDstar = the2Prong->SelectD0(fD0fromDstarCuts,checkD0,checkD0bar);
864 //if(fDebug && fDstar) printf(" %d\n",(Int_t)okD0fromDstar);
6a213b59 865
2ff20727 866 // remove the primary vertex (was used only for selection)
b6e66d86 867 if(!fRecoPrimVtxSkippingTrks && !fRmTrksFromPrimVtx) {
868 the2Prong->UnsetOwnPrimaryVtx();
b6e66d86 869 }
870
2ff20727 871 // get PID info from ESD
5770b08b 872 Double_t esdpid0[5]={0.,0.,0.,0.,0.};
873 if(postrack->GetStatus()&AliESDtrack::kESDpid) postrack->GetESDpid(esdpid0);
874 Double_t esdpid1[5]={0.,0.,0.,0.,0.};
875 if(negtrack->GetStatus()&AliESDtrack::kESDpid) negtrack->GetESDpid(esdpid1);
2ff20727 876 Double_t esdpid[10];
877 for(Int_t i=0;i<5;i++) {
878 esdpid[i] = esdpid0[i];
879 esdpid[5+i] = esdpid1[i];
6a213b59 880 }
2ff20727 881 the2Prong->SetPID(2,esdpid);
6a213b59 882
6a213b59 883 return the2Prong;
884}
885//----------------------------------------------------------------------------
886AliAODRecoDecayHF3Prong* AliAnalysisVertexingHF::Make3Prong(
dcb444c9 887 TObjArray *threeTrackArray,AliVEvent *event,
888 AliAODVertex *secVert,Double_t dispersion,
889 AliAODVertex *vertexp1n1,AliAODVertex *vertexp2n1,
6a213b59 890 Double_t dcap1n1,Double_t dcap2n1,Double_t dcap1p2,
891 Bool_t &ok3Prong) const
892{
893 // Make 3Prong candidates and check if they pass Dplus or Ds or Lambdac
894 // reconstruction cuts
895 // E.Bruna, F.Prino
896
dcb444c9 897
6a213b59 898 ok3Prong=kFALSE;
673ac607 899 if(!secVert || !vertexp1n1 || !vertexp2n1) return 0x0;
dcb444c9 900
901 Double_t px[3],py[3],pz[3],d0[3],d0err[3];
902 Double_t momentum[3];
6a213b59 903
6a213b59 904
905 AliESDtrack *postrack1 = (AliESDtrack*)threeTrackArray->UncheckedAt(0);
dcb444c9 906 AliESDtrack *negtrack = (AliESDtrack*)threeTrackArray->UncheckedAt(1);
6a213b59 907 AliESDtrack *postrack2 = (AliESDtrack*)threeTrackArray->UncheckedAt(2);
908
dcb444c9 909 postrack1->PropagateToDCA(secVert,fBzkG,kVeryBig);
910 negtrack->PropagateToDCA(secVert,fBzkG,kVeryBig);
911 postrack2->PropagateToDCA(secVert,fBzkG,kVeryBig);
6a213b59 912 postrack1->GetPxPyPz(momentum);
913 px[0] = momentum[0]; py[0] = momentum[1]; pz[0] = momentum[2];
914 negtrack->GetPxPyPz(momentum);
915 px[1] = momentum[0]; py[1] = momentum[1]; pz[1] = momentum[2];
916 postrack2->GetPxPyPz(momentum);
917 px[2] = momentum[0]; py[2] = momentum[1]; pz[2] = momentum[2];
918
b82f6d67 919 // invariant mass cut for D+, Ds, Lc
6a213b59 920 Bool_t okMassCut=kFALSE;
921 if(!okMassCut && f3Prong) if(SelectInvMass(2,3,px,py,pz)) okMassCut=kTRUE;
922 if(!okMassCut) {
dcb444c9 923 AliDebug(2," candidate didn't pass mass cut");
6a213b59 924 return 0x0;
925 }
926
dcb444c9 927 // primary vertex to be used by this candidate
2ff20727 928 AliAODVertex *primVertexAOD = PrimaryVertex(threeTrackArray,event);
dcb444c9 929 if(!primVertexAOD) return 0x0;
930
931 Double_t d0z0[2],covd0z0[3];
932 postrack1->PropagateToDCA(primVertexAOD,fBzkG,kVeryBig,d0z0,covd0z0);
933 d0[0]=d0z0[0];
934 d0err[0] = TMath::Sqrt(covd0z0[0]);
935 negtrack->PropagateToDCA(primVertexAOD,fBzkG,kVeryBig,d0z0,covd0z0);
936 d0[1]=d0z0[0];
937 d0err[1] = TMath::Sqrt(covd0z0[0]);
938 postrack2->PropagateToDCA(primVertexAOD,fBzkG,kVeryBig,d0z0,covd0z0);
939 d0[2]=d0z0[0];
940 d0err[2] = TMath::Sqrt(covd0z0[0]);
6a213b59 941
6a213b59 942
943 // create the object AliAODRecoDecayHF3Prong
dcb444c9 944 Double_t pos[3]; primVertexAOD->GetXYZ(pos);
6a213b59 945 Double_t dca[3]={dcap1n1,dcap2n1,dcap1p2};
dcb444c9 946 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]));
947 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]));
948 Short_t charge=(Short_t)(postrack1->Charge()*postrack2->Charge()*negtrack->Charge());
949 AliAODRecoDecayHF3Prong *the3Prong = new AliAODRecoDecayHF3Prong(secVert,px,py,pz,d0,d0err,dca,dispersion,dist12,dist23,charge);
6a213b59 950 the3Prong->SetOwnPrimaryVtx(primVertexAOD);
dcb444c9 951 UShort_t id[3]={(UShort_t)postrack1->GetID(),(UShort_t)negtrack->GetID(),(UShort_t)postrack2->GetID()};
952 the3Prong->SetProngIDs(3,id);
6a213b59 953
0a65d33f 954 delete primVertexAOD; primVertexAOD=NULL;
6a213b59 955
b82f6d67 956 // select D+->Kpipi, Ds->KKpi, Lc->pKpi
957 if(f3Prong) {
958 ok3Prong = kFALSE;
959 Int_t ok1,ok2;
960 if(the3Prong->SelectDplus(fDplusCuts)) ok3Prong = kTRUE;
961 if(the3Prong->SelectDs(fDsCuts,ok1,ok2)) ok3Prong = kTRUE;
962 if(the3Prong->SelectLc(fLcCuts,ok1,ok2)) ok3Prong = kTRUE;
963 }
6a213b59 964 //if(fDebug) printf("ok3Prong: %d\n",(Int_t)ok3Prong);
dcb444c9 965
b6e66d86 966 if(!fRecoPrimVtxSkippingTrks && !fRmTrksFromPrimVtx) {
967 the3Prong->UnsetOwnPrimaryVtx();
b6e66d86 968 }
dcb444c9 969
2ff20727 970 // get PID info from ESD
5770b08b 971 Double_t esdpid0[5]={0.,0.,0.,0.,0.};
972 if(postrack1->GetStatus()&AliESDtrack::kESDpid) postrack1->GetESDpid(esdpid0);
973 Double_t esdpid1[5]={0.,0.,0.,0.,0.};
974 if(negtrack->GetStatus()&AliESDtrack::kESDpid) negtrack->GetESDpid(esdpid1);
975 Double_t esdpid2[5]={0.,0.,0.,0.,0.};
976 if(postrack2->GetStatus()&AliESDtrack::kESDpid) postrack2->GetESDpid(esdpid2);
2ff20727 977
978 Double_t esdpid[15];
979 for(Int_t i=0;i<5;i++) {
980 esdpid[i] = esdpid0[i];
981 esdpid[5+i] = esdpid1[i];
982 esdpid[10+i] = esdpid2[i];
6a213b59 983 }
2ff20727 984 the3Prong->SetPID(3,esdpid);
6a213b59 985
6a213b59 986 return the3Prong;
987}
988//----------------------------------------------------------------------------
989AliAODRecoDecayHF4Prong* AliAnalysisVertexingHF::Make4Prong(
dcb444c9 990 TObjArray *fourTrackArray,AliVEvent *event,
721c0b8f 991 AliAODVertex *secVert,
992 AliAODVertex *vertexp1n1,
993 AliAODVertex *vertexp1n1p2,
994 Double_t dcap1n1,Double_t dcap1n2,
995 Double_t dcap2n1,Double_t dcap2n2,
996 Bool_t &ok4Prong) const
6a213b59 997{
998 // Make 4Prong candidates and check if they pass D0toKpipipi
999 // reconstruction cuts
1000 // G.E.Bruno, R.Romita
1001
1002 ok4Prong=kFALSE;
673ac607 1003 if(!secVert || !vertexp1n1 || !vertexp1n1p2) return 0x0;
6a213b59 1004
1005 Double_t px[4],py[4],pz[4],d0[4],d0err[4];//d0z[3];
6a213b59 1006
6a213b59 1007 AliESDtrack *postrack1 = (AliESDtrack*)fourTrackArray->UncheckedAt(0);
1008 AliESDtrack *negtrack1 = (AliESDtrack*)fourTrackArray->UncheckedAt(1);
1009 AliESDtrack *postrack2 = (AliESDtrack*)fourTrackArray->UncheckedAt(2);
1010 AliESDtrack *negtrack2 = (AliESDtrack*)fourTrackArray->UncheckedAt(3);
1011
dcb444c9 1012 postrack1->PropagateToDCA(secVert,fBzkG,kVeryBig);
1013 negtrack1->PropagateToDCA(secVert,fBzkG,kVeryBig);
1014 postrack2->PropagateToDCA(secVert,fBzkG,kVeryBig);
1015 negtrack2->PropagateToDCA(secVert,fBzkG,kVeryBig);
6a213b59 1016
1017 Double_t momentum[3];
1018 postrack1->GetPxPyPz(momentum);
1019 px[0] = momentum[0]; py[0] = momentum[1]; pz[0] = momentum[2];
1020 negtrack1->GetPxPyPz(momentum);
1021 px[1] = momentum[0]; py[1] = momentum[1]; pz[1] = momentum[2];
1022 postrack2->GetPxPyPz(momentum);
1023 px[2] = momentum[0]; py[2] = momentum[1]; pz[2] = momentum[2];
1024 negtrack2->GetPxPyPz(momentum);
1025 px[3] = momentum[0]; py[3] = momentum[1]; pz[3] = momentum[2];
1026
1027 // invariant mass cut for rho or D0 (try to improve coding here..)
0a65d33f 1028 Bool_t okMassCut=kFALSE;
1029 if(!okMassCut && fD0to4ProngsCuts[8]==0.){ //no PID, to be implemented with PID
1030 if(SelectInvMass(4,4,px,py,pz)) okMassCut=kTRUE;
1031 }
1032 if(!okMassCut) {
1033 //if(fDebug) printf(" candidate didn't pass mass cut\n");
1034 //printf(" candidate didn't pass mass cut\n");
1035 return 0x0;
1036 }
6a213b59 1037
dcb444c9 1038 // primary vertex to be used by this candidate
2ff20727 1039 AliAODVertex *primVertexAOD = PrimaryVertex(fourTrackArray,event);
dcb444c9 1040 if(!primVertexAOD) return 0x0;
1041
721c0b8f 1042 Double_t d0z0[2],covd0z0[3];
1043 postrack1->PropagateToDCA(primVertexAOD,fBzkG,kVeryBig,d0z0,covd0z0);
1044 d0[0]=d0z0[0];
1045 d0err[0] = TMath::Sqrt(covd0z0[0]);
1046 negtrack1->PropagateToDCA(primVertexAOD,fBzkG,kVeryBig,d0z0,covd0z0);
1047 d0[1]=d0z0[0];
1048 d0err[1] = TMath::Sqrt(covd0z0[0]);
1049 postrack2->PropagateToDCA(primVertexAOD,fBzkG,kVeryBig,d0z0,covd0z0);
1050 d0[2]=d0z0[0];
1051 d0err[2] = TMath::Sqrt(covd0z0[0]);
1052 negtrack2->PropagateToDCA(primVertexAOD,fBzkG,kVeryBig,d0z0,covd0z0);
1053 d0[3]=d0z0[0];
1054 d0err[3] = TMath::Sqrt(covd0z0[0]);
1055
6a213b59 1056
1057 // create the object AliAODRecoDecayHF4Prong
dcb444c9 1058 Double_t pos[3]; primVertexAOD->GetXYZ(pos);
721c0b8f 1059 Double_t dca[6]={dcap1n1,0.,dcap1n2,dcap2n1,0.,dcap2n2};
dcb444c9 1060 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]));
721c0b8f 1061 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]));
1062 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]));
dcb444c9 1063 Short_t charge=0;
721c0b8f 1064 AliAODRecoDecayHF4Prong *the4Prong = new AliAODRecoDecayHF4Prong(secVert,px,py,pz,d0,d0err,dca,dist12,dist3,dist4,charge);
6a213b59 1065 the4Prong->SetOwnPrimaryVtx(primVertexAOD);
dcb444c9 1066 UShort_t id[4]={(UShort_t)postrack1->GetID(),(UShort_t)negtrack1->GetID(),(UShort_t)postrack2->GetID(),(UShort_t)negtrack2->GetID()};
1067 the4Prong->SetProngIDs(4,id);
6a213b59 1068
0a65d33f 1069 delete primVertexAOD; primVertexAOD=NULL;
6a213b59 1070
721c0b8f 1071 Int_t checkD0,checkD0bar;
1072 ok4Prong=the4Prong->SelectD0(fD0to4ProngsCuts,checkD0,checkD0bar);
6a213b59 1073
b6e66d86 1074 if(!fRecoPrimVtxSkippingTrks && !fRmTrksFromPrimVtx) {
1075 the4Prong->UnsetOwnPrimaryVtx();
b6e66d86 1076 }
6a213b59 1077
721c0b8f 1078
6a213b59 1079 // get PID info from ESD
721c0b8f 1080 Double_t esdpid0[5]={0.,0.,0.,0.,0.};
1081 if(postrack1->GetStatus()&AliESDtrack::kESDpid) postrack1->GetESDpid(esdpid0);
1082 Double_t esdpid1[5]={0.,0.,0.,0.,0.};
1083 if(negtrack1->GetStatus()&AliESDtrack::kESDpid) negtrack1->GetESDpid(esdpid1);
1084 Double_t esdpid2[5]={0.,0.,0.,0.,0.};
1085 if(postrack2->GetStatus()&AliESDtrack::kESDpid) postrack2->GetESDpid(esdpid2);
1086 Double_t esdpid3[5]={0.,0.,0.,0.,0.};
1087 if(negtrack2->GetStatus()&AliESDtrack::kESDpid) negtrack2->GetESDpid(esdpid3);
6a213b59 1088
1089 Double_t esdpid[20];
1090 for(Int_t i=0;i<5;i++) {
2ff20727 1091 esdpid[i] = esdpid0[i];
1092 esdpid[5+i] = esdpid1[i];
6a213b59 1093 esdpid[10+i] = esdpid2[i];
1094 esdpid[15+i] = esdpid3[i];
1095 }
1096 the4Prong->SetPID(4,esdpid);
721c0b8f 1097
6a213b59 1098 return the4Prong;
1099}
1100//-----------------------------------------------------------------------------
2ff20727 1101AliAODVertex* AliAnalysisVertexingHF::PrimaryVertex(TObjArray *trkArray,
1102 AliVEvent *event) const
6a213b59 1103{
2ff20727 1104 // Returns primary vertex to be used for this candidate
6a213b59 1105
dcb444c9 1106 AliESDVertex *vertexESD = 0;
1107 AliAODVertex *vertexAOD = 0;
1108
dcb444c9 1109
1110 if(!fRecoPrimVtxSkippingTrks && !fRmTrksFromPrimVtx) {
1111 // primary vertex from the input event
1112
1113 vertexESD = new AliESDVertex(*fV1);
1114
1115 } else {
1116 // primary vertex specific to this candidate
1117
2ff20727 1118 Int_t nTrks = trkArray->GetEntriesFast();
dcb444c9 1119 AliVertexerTracks *vertexer = new AliVertexerTracks(event->GetMagneticField());
1120
1121 if(fRecoPrimVtxSkippingTrks) {
1122 // recalculating the vertex
1123
1124 if(strstr(fV1->GetTitle(),"VertexerTracksWithConstraint")) {
1125 Float_t diamondcovxy[3];
1126 event->GetDiamondCovXY(diamondcovxy);
1127 Double_t pos[3]={event->GetDiamondX(),event->GetDiamondY(),0.};
1128 Double_t cov[6]={diamondcovxy[0],diamondcovxy[1],diamondcovxy[2],0.,0.,10.};
1129 AliESDVertex *diamond = new AliESDVertex(pos,cov,1.,1);
1130 vertexer->SetVtxStart(diamond);
1131 delete diamond; diamond=NULL;
1132 if(strstr(fV1->GetTitle(),"VertexerTracksWithConstraintOnlyFitter"))
1133 vertexer->SetOnlyFitter();
1134 }
0a65d33f 1135 Int_t skipped[1000];
e18fbfa7 1136 Int_t nTrksToSkip=0,id;
1137 AliExternalTrackParam *t = 0;
dcb444c9 1138 for(Int_t i=0; i<nTrks; i++) {
e18fbfa7 1139 t = (AliExternalTrackParam*)trkArray->UncheckedAt(i);
1140 id = (Int_t)t->GetID();
1141 if(id<0) continue;
1142 skipped[nTrksToSkip++] = id;
dcb444c9 1143 }
0a65d33f 1144 // TEMPORARY FIX
1145 // For AOD, skip also tracks without covariance matrix
1146 if(fInputAOD) {
1147 Double_t covtest[21];
1148 for(Int_t j=0; j<event->GetNumberOfTracks(); j++) {
1149 AliVTrack *vtrack = (AliVTrack*)event->GetTrack(j);
1150 if(!vtrack->GetCovarianceXYZPxPyPz(covtest)) {
1151 id = (Int_t)t->GetID();
1152 if(id<0) continue;
1153 skipped[nTrksToSkip++] = id;
1154 }
1155 }
1156 }
1157 //
e18fbfa7 1158 vertexer->SetSkipTracks(nTrksToSkip,skipped);
dcb444c9 1159 vertexESD = (AliESDVertex*)vertexer->FindPrimaryVertex(event);
1160
1161 } else if(fRmTrksFromPrimVtx) {
1162 // removing the prongs tracks
1163
1164 TObjArray rmArray(nTrks);
1165 UShort_t *rmId = new UShort_t[nTrks];
1166 AliESDtrack *esdTrack = 0;
1167 AliESDtrack *t = 0;
1168 for(Int_t i=0; i<nTrks; i++) {
1169 t = (AliESDtrack*)trkArray->UncheckedAt(i);
1170 esdTrack = new AliESDtrack(*t);
1171 rmArray.AddLast(esdTrack);
2ff20727 1172 if(esdTrack->GetID()>=0) {
1173 rmId[i]=(UShort_t)esdTrack->GetID();
1174 } else {
1175 rmId[i]=9999;
1176 }
dcb444c9 1177 }
1178 Float_t diamondxy[2]={event->GetDiamondX(),event->GetDiamondY()};
1179 vertexESD = vertexer->RemoveTracksFromVertex(fV1,&rmArray,rmId,diamondxy);
1180 delete [] rmId; rmId=NULL;
1181 rmArray.Delete();
1182
6a213b59 1183 }
6a213b59 1184
dcb444c9 1185 if(!vertexESD) return vertexAOD;
1186 if(vertexESD->GetNContributors()<=0) {
1187 AliDebug(2,"vertexing failed");
1188 delete vertexESD; vertexESD=NULL;
1189 return vertexAOD;
6a213b59 1190 }
dcb444c9 1191
1192 delete vertexer; vertexer=NULL;
1193
6a213b59 1194 }
1195
dcb444c9 1196 // convert to AliAODVertex
1197 Double_t pos[3],cov[6],chi2perNDF;
1198 vertexESD->GetXYZ(pos); // position
1199 vertexESD->GetCovMatrix(cov); //covariance matrix
1200 chi2perNDF = vertexESD->GetChi2toNDF();
1201 delete vertexESD; vertexESD=NULL;
1202
1203 vertexAOD = new AliAODVertex(pos,cov,chi2perNDF);
6a213b59 1204
dcb444c9 1205 return vertexAOD;
6a213b59 1206}
1207//-----------------------------------------------------------------------------
1208void AliAnalysisVertexingHF::PrintStatus() const {
1209 // Print parameters being used
1210
f8fa4595 1211 //printf("Preselections:\n");
1212 // fTrackFilter->Dump();
4d5c9633 1213 if(fSecVtxWithKF) {
1214 printf("Secondary vertex with Kalman filter package (AliKFParticle)\n");
1215 } else {
1216 printf("Secondary vertex with AliVertexerTracks\n");
1217 }
6a213b59 1218 if(fRecoPrimVtxSkippingTrks) printf("RecoPrimVtxSkippingTrks\n");
1219 if(fRmTrksFromPrimVtx) printf("RmTrksFromPrimVtx\n");
1220 if(fD0toKpi) {
1221 printf("Reconstruct D0->Kpi candidates with cuts:\n");
1222 printf(" |M-MD0| [GeV] < %f\n",fD0toKpiCuts[0]);
1223 printf(" dca [cm] < %f\n",fD0toKpiCuts[1]);
1224 printf(" cosThetaStar < %f\n",fD0toKpiCuts[2]);
1225 printf(" pTK [GeV/c] > %f\n",fD0toKpiCuts[3]);
1226 printf(" pTpi [GeV/c] > %f\n",fD0toKpiCuts[4]);
1227 printf(" |d0K| [cm] < %f\n",fD0toKpiCuts[5]);
1228 printf(" |d0pi| [cm] < %f\n",fD0toKpiCuts[6]);
1229 printf(" d0d0 [cm^2] < %f\n",fD0toKpiCuts[7]);
1230 printf(" cosThetaPoint > %f\n",fD0toKpiCuts[8]);
1231 }
2ff20727 1232 if(fDstar) {
eee95e18 1233 if(fFindVertexForDstar) {
1234 printf(" Reconstruct a secondary vertex for the D*\n");
1235 } else {
1236 printf(" Assume the D* comes from the primary vertex\n");
1237 }
2ff20727 1238 printf(" |M-MD*| [GeV] < %f\n",fDstarCuts[0]);
1239 printf(" |M_Kpipi-M_Kpi-(MD*-MD0)| [GeV] < %f\n",fDstarCuts[1]);
1240 printf(" pTpisoft [GeV/c] > %f\n",fDstarCuts[2]);
1241 printf(" pTpisoft [GeV/c] < %f\n",fDstarCuts[3]);
1242 printf(" Theta(pisoft,D0plane) < %f\n",fDstarCuts[4]);
1243 printf("Reconstruct D*->D0pi candidates with cuts:\n");
1244 printf(" D0 from D* cuts:\n");
1245 printf(" |M-MD0| [GeV] < %f\n",fD0fromDstarCuts[0]);
1246 printf(" dca [cm] < %f\n",fD0fromDstarCuts[1]);
1247 printf(" cosThetaStar < %f\n",fD0fromDstarCuts[2]);
1248 printf(" pTK [GeV/c] > %f\n",fD0fromDstarCuts[3]);
1249 printf(" pTpi [GeV/c] > %f\n",fD0fromDstarCuts[4]);
1250 printf(" |d0K| [cm] < %f\n",fD0fromDstarCuts[5]);
1251 printf(" |d0pi| [cm] < %f\n",fD0fromDstarCuts[6]);
1252 printf(" d0d0 [cm^2] < %f\n",fD0fromDstarCuts[7]);
1253 printf(" cosThetaPoint > %f\n",fD0fromDstarCuts[8]);
1254 }
6a213b59 1255 if(fJPSItoEle) {
1256 printf("Reconstruct J/psi from B candidates with cuts:\n");
1257 printf(" |M-MJPSI| [GeV] < %f\n",fBtoJPSICuts[0]);
1258 printf(" dca [cm] < %f\n",fBtoJPSICuts[1]);
1259 printf(" cosThetaStar < %f\n",fBtoJPSICuts[2]);
1260 printf(" pTP [GeV/c] > %f\n",fBtoJPSICuts[3]);
1261 printf(" pTN [GeV/c] > %f\n",fBtoJPSICuts[4]);
1262 printf(" |d0P| [cm] < %f\n",fBtoJPSICuts[5]);
1263 printf(" |d0N| [cm] < %f\n",fBtoJPSICuts[6]);
1264 printf(" d0d0 [cm^2] < %f\n",fBtoJPSICuts[7]);
1265 printf(" cosThetaPoint > %f\n",fBtoJPSICuts[8]);
1266 }
1267 if(f3Prong) {
1268 printf("Reconstruct 3 prong candidates.\n");
4d5c9633 1269 printf(" D+->Kpipi cuts:\n");
6a213b59 1270 printf(" |M-MD+| [GeV] < %f\n",fDplusCuts[0]);
1271 printf(" pTK [GeV/c] > %f\n",fDplusCuts[1]);
1272 printf(" pTPi [GeV/c] > %f\n",fDplusCuts[2]);
1273 printf(" |d0K| [cm] > %f\n",fDplusCuts[3]);
1274 printf(" |d0Pi| [cm] > %f\n",fDplusCuts[4]);
1275 printf(" dist12 [cm] < %f\n",fDplusCuts[5]);
1276 printf(" sigmavert [cm] < %f\n",fDplusCuts[6]);
1277 printf(" dist prim-sec [cm] > %f\n",fDplusCuts[7]);
1278 printf(" pM=Max{pT1,pT2,pT3} [GeV/c] > %f\n",fDplusCuts[8]);
1279 printf(" cosThetaPoint > %f\n",fDplusCuts[9]);
1280 printf(" Sum d0^2 [cm^2] > %f\n",fDplusCuts[10]);
1281 printf(" dca cut [cm] < %f\n",fDplusCuts[11]);
4d5c9633 1282 printf(" Ds->KKpi cuts:\n");
1283 printf(" |M-MDs| [GeV] < %f\n",fDsCuts[0]);
81679460 1284 printf(" pTK [GeV/c] > %f\n",fDsCuts[1]);
1285 printf(" pTPi [GeV/c] > %f\n",fDsCuts[2]);
1286 printf(" |d0K| [cm] > %f\n",fDsCuts[3]);
1287 printf(" |d0Pi| [cm] > %f\n",fDsCuts[4]);
1288 printf(" dist12 [cm] < %f\n",fDsCuts[5]);
1289 printf(" sigmavert [cm] < %f\n",fDsCuts[6]);
1290 printf(" dist prim-sec [cm] > %f\n",fDsCuts[7]);
1291 printf(" pM=Max{pT1,pT2,pT3} [GeV/c] > %f\n",fDsCuts[8]);
1292 printf(" cosThetaPoint > %f\n",fDsCuts[9]);
1293 printf(" Sum d0^2 [cm^2] > %f\n",fDsCuts[10]);
1294 printf(" dca cut [cm] < %f\n",fDsCuts[11]);
1295 printf(" Inv. Mass phi/K0* [GeV] < %f\n",fDsCuts[12]);
6ea608bf 1296 printf(" Lc->pKpi cuts:\n");
1297 printf(" |M-MLc| [GeV] < %f\n",fLcCuts[0]);
81679460 1298 printf(" pTP [GeV/c] > %f\n",fLcCuts[1]);
1299 printf(" pTPi and pTK [GeV/c] > %f\n",fLcCuts[2]);
1300 printf(" |d0P| [cm] > %f\n",fLcCuts[3]);
1301 printf(" |d0Pi| and |d0K| [cm] > %f\n",fLcCuts[4]);
1302 printf(" dist12 [cm] < %f\n",fLcCuts[5]);
1303 printf(" sigmavert [cm] < %f\n",fLcCuts[6]);
1304 printf(" dist prim-sec [cm] > %f\n",fLcCuts[7]);
1305 printf(" pM=Max{pT1,pT2,pT3} [GeV/c] > %f\n",fLcCuts[8]);
1306 printf(" cosThetaPoint > %f\n",fLcCuts[9]);
1307 printf(" Sum d0^2 [cm^2] > %f\n",fLcCuts[10]);
1308 printf(" dca cut [cm] < %f\n",fLcCuts[11]);
6a213b59 1309 }
1310
1311 return;
1312}
1313//-----------------------------------------------------------------------------
dcb444c9 1314AliAODVertex* AliAnalysisVertexingHF::ReconstructSecondaryVertex(TObjArray *trkArray,
dcfa35b3 1315 Double_t &dispersion,Bool_t useTRefArray) const
dcb444c9 1316{
1317 // Secondary vertex reconstruction with AliVertexerTracks or AliKFParticle
1318
1319 AliESDVertex *vertexESD = 0;
1320 AliAODVertex *vertexAOD = 0;
1321
1322 if(!fSecVtxWithKF) { // AliVertexerTracks
1323
1324 AliVertexerTracks *vertexer = new AliVertexerTracks(fBzkG);
1325 vertexer->SetVtxStart(fV1);
1326 vertexESD = (AliESDVertex*)vertexer->VertexForSelectedESDTracks(trkArray);
1327 delete vertexer; vertexer=NULL;
1328
1329 if(!vertexESD) return vertexAOD;
1330
1331 if(vertexESD->GetNContributors()!=trkArray->GetEntriesFast()) {
1332 AliDebug(2,"vertexing failed");
1333 delete vertexESD; vertexESD=NULL;
1334 return vertexAOD;
1335 }
1336
1337 } else { // Kalman Filter vertexer (AliKFParticle)
1338
1339 AliKFParticle::SetField(fBzkG);
1340
a353d2e4 1341 AliKFVertex vertexKF;
dcb444c9 1342
1343 Int_t nTrks = trkArray->GetEntriesFast();
1344 for(Int_t i=0; i<nTrks; i++) {
1345 AliESDtrack *esdTrack = (AliESDtrack*)trkArray->At(i);
1346 AliKFParticle daughterKF(*esdTrack,211);
1347 vertexKF.AddDaughter(daughterKF);
1348 }
a353d2e4 1349 vertexESD = new AliESDVertex(vertexKF.Parameters(),
1350 vertexKF.CovarianceMatrix(),
1351 vertexKF.GetChi2(),
1352 vertexKF.GetNContributors());
dcb444c9 1353
1354 }
1355
1356 // convert to AliAODVertex
1357 Double_t pos[3],cov[6],chi2perNDF;
1358 vertexESD->GetXYZ(pos); // position
1359 vertexESD->GetCovMatrix(cov); //covariance matrix
1360 chi2perNDF = vertexESD->GetChi2toNDF();
1361 dispersion = vertexESD->GetDispersion();
1362 delete vertexESD; vertexESD=NULL;
1363
dcfa35b3 1364 Int_t nprongs= (useTRefArray ? 0 : trkArray->GetEntriesFast());
1365 vertexAOD = new AliAODVertex(pos,cov,chi2perNDF,0x0,-1,AliAODVertex::kUndef,nprongs);
dcb444c9 1366
1367 return vertexAOD;
1368}
1369//-----------------------------------------------------------------------------
6a213b59 1370Bool_t AliAnalysisVertexingHF::SelectInvMass(Int_t decay,
1371 Int_t nprongs,
1372 Double_t *px,
1373 Double_t *py,
1374 Double_t *pz) const {
1375 // Check invariant mass cut
1376
1377 Short_t dummycharge=0;
1378 Double_t *dummyd0 = new Double_t[nprongs];
b056c5e3 1379 for(Int_t ip=0;ip<nprongs;ip++) dummyd0[ip]=0.;
6a213b59 1380 AliAODRecoDecay *rd = new AliAODRecoDecay(0x0,nprongs,dummycharge,px,py,pz,dummyd0);
b6e66d86 1381 delete [] dummyd0; dummyd0=NULL;
6a213b59 1382
721c0b8f 1383 UInt_t pdg2[2],pdg3[3],pdg4[4];
6a213b59 1384 Double_t mPDG,minv;
1385
1386 Bool_t retval=kFALSE;
1387 switch (decay)
1388 {
1389 case 0: // D0->Kpi
1390 pdg2[0]=211; pdg2[1]=321;
1391 mPDG=TDatabasePDG::Instance()->GetParticle(421)->Mass();
1392 minv = rd->InvMass(nprongs,pdg2);
1393 if(TMath::Abs(minv-mPDG)<fD0toKpiCuts[0]) retval=kTRUE;
1394 pdg2[0]=321; pdg2[1]=211;
1395 minv = rd->InvMass(nprongs,pdg2);
1396 if(TMath::Abs(minv-mPDG)<fD0toKpiCuts[0]) retval=kTRUE;
1397 break;
1398 case 1: // JPSI->ee
1399 pdg2[0]=11; pdg2[1]=11;
1400 mPDG=TDatabasePDG::Instance()->GetParticle(443)->Mass();
1401 minv = rd->InvMass(nprongs,pdg2);
1402 if(TMath::Abs(minv-mPDG)<fBtoJPSICuts[0]) retval=kTRUE;
1403 break;
1404 case 2: // D+->Kpipi
1405 pdg3[0]=211; pdg3[1]=321; pdg3[2]=211;
1406 mPDG=TDatabasePDG::Instance()->GetParticle(411)->Mass();
1407 minv = rd->InvMass(nprongs,pdg3);
1408 if(TMath::Abs(minv-mPDG)<fDplusCuts[0]) retval=kTRUE;
b82f6d67 1409 // Ds+->KKpi
1410 pdg3[0]=321; pdg3[1]=321; pdg3[2]=211;
1411 mPDG=TDatabasePDG::Instance()->GetParticle(431)->Mass();
1412 minv = rd->InvMass(nprongs,pdg3);
1413 if(TMath::Abs(minv-mPDG)<fDsCuts[0]) retval=kTRUE;
1414 pdg3[0]=211; pdg3[1]=321; pdg3[2]=321;
1415 minv = rd->InvMass(nprongs,pdg3);
1416 if(TMath::Abs(minv-mPDG)<fDsCuts[0]) retval=kTRUE;
1417 // Lc->pKpi
1418 pdg3[0]=2212; pdg3[1]=321; pdg3[2]=211;
1419 mPDG=TDatabasePDG::Instance()->GetParticle(4122)->Mass();
1420 minv = rd->InvMass(nprongs,pdg3);
1421 if(TMath::Abs(minv-mPDG)<fLcCuts[0]) retval=kTRUE;
1422 pdg3[0]=211; pdg3[1]=321; pdg3[2]=2212;
1423 minv = rd->InvMass(nprongs,pdg3);
1424 if(TMath::Abs(minv-mPDG)<fLcCuts[0]) retval=kTRUE;
6a213b59 1425 break;
2ff20727 1426 case 3: // D*->D0pi
1427 pdg2[0]=421; pdg2[1]=211;
1428 mPDG=TDatabasePDG::Instance()->GetParticle(413)->Mass();
1429 minv = rd->InvMass(nprongs,pdg2);
1430 if(TMath::Abs(minv-mPDG)<fDstarCuts[0]) retval=kTRUE;
1431 break;
721c0b8f 1432 case 4: // D0->K3pi without PID
1433 pdg4[0]=321; pdg4[1]=211; pdg4[2]=211; pdg4[3]=211;
1434 mPDG=TDatabasePDG::Instance()->GetParticle(421)->Mass();
1435 minv = rd->InvMass(nprongs,pdg4);
1436 if(TMath::Abs(minv-mPDG)<fD0to4ProngsCuts[0])
1437 retval=kTRUE;
1438 pdg4[0]=211; pdg4[1]=321; pdg4[2]=211; pdg4[3]=211;
1439 mPDG=TDatabasePDG::Instance()->GetParticle(421)->Mass();
1440 minv = rd->InvMass(nprongs,pdg4);
1441 if(TMath::Abs(minv-mPDG)<fD0to4ProngsCuts[0]) retval=kTRUE;
1442 pdg4[0]=211; pdg4[1]=211; pdg4[2]=321; pdg4[3]=211;
1443 mPDG=TDatabasePDG::Instance()->GetParticle(421)->Mass();
1444 minv = rd->InvMass(nprongs,pdg4);
1445 if(TMath::Abs(minv-mPDG)<fD0to4ProngsCuts[0]) retval=kTRUE;
1446 pdg4[0]=211; pdg4[1]=211; pdg4[2]=211; pdg4[3]=321;
1447 mPDG=TDatabasePDG::Instance()->GetParticle(421)->Mass();
1448 minv = rd->InvMass(nprongs,pdg4);
1449 if(TMath::Abs(minv-mPDG)<fD0to4ProngsCuts[0]) retval=kTRUE;
1450 break;
6a213b59 1451 default:
2ff20727 1452 printf("SelectInvMass(): wrong decay selection\n");
6a213b59 1453 break;
1454 }
1455
b6e66d86 1456 delete rd; rd=NULL;
6a213b59 1457
1458 return retval;
1459}
1460//-----------------------------------------------------------------------------
dcb444c9 1461void AliAnalysisVertexingHF::SelectTracksAndCopyVertex(AliVEvent *event,
2ff20727 1462 TObjArray &seleTrksArray,Int_t &nSeleTrks,
1463 UChar_t *seleFlags)
6a213b59 1464{
2ff20727 1465 // Apply single-track preselection.
1466 // Fill a TObjArray with selected tracks (for displaced vertices or
1467 // soft pion from D*). Selection flag stored in seleFlags.
dcb444c9 1468 // Create the AliESDVertex object (convert from AliAODVertex if necessary)
1469 // In case of AOD input, also fill fAODMap for track index<->ID
1470
1471 const AliVVertex *vprimary = event->GetPrimaryVertex();
1472
1473 if(fV1) { delete fV1; fV1=NULL; }
1474 if(fAODMap) { delete [] fAODMap; fAODMap=NULL; }
1475
1476 Int_t nindices=0;
1477 UShort_t *indices = 0;
1478 Double_t pos[3],cov[6];
1479
1480 if(!fInputAOD) { // ESD
1481 fV1 = new AliESDVertex(*((AliESDVertex*)vprimary));
1482 } else { // AOD
1483 vprimary->GetXYZ(pos);
1484 vprimary->GetCovarianceMatrix(cov);
1485 fV1 = new AliESDVertex(pos,cov,100.,100,vprimary->GetName());
1486 indices = new UShort_t[event->GetNumberOfTracks()];
1487 fAODMap = new Int_t[100000];
1488 }
1489
1490
dcb444c9 1491 Int_t entries = (Int_t)event->GetNumberOfTracks();
2ff20727 1492 Bool_t okDisplaced=kFALSE,okSoftPi=kFALSE;
1493 nSeleTrks=0;
6a213b59 1494
dcb444c9 1495 // transfer ITS tracks from event to arrays
6a213b59 1496 for(Int_t i=0; i<entries; i++) {
dcb444c9 1497 AliVTrack *track = (AliVTrack*)event->GetTrack(i);
1498
65dad444 1499 // TEMPORARY: check that the cov matrix is there
0ab1bd93 1500 Double_t covtest[21];
1501 if(!track->GetCovarianceXYZPxPyPz(covtest)) continue;
1502 //
65dad444 1503
dcb444c9 1504 if(fInputAOD) {
1505 AliAODTrack *aodt = (AliAODTrack*)track;
1506 if(aodt->GetUsedForPrimVtxFit()) {
1507 indices[nindices]=aodt->GetID(); nindices++;
1508 }
1509 fAODMap[(Int_t)aodt->GetID()] = i;
1510 }
6a213b59 1511
dcb444c9 1512 AliESDtrack *esdt = 0;
b6e66d86 1513
dcb444c9 1514 if(!fInputAOD) {
1515 esdt = (AliESDtrack*)track;
1516 } else {
1517 esdt = new AliESDtrack(track);
1518 }
6a213b59 1519
1520 // single track selection
2ff20727 1521 okDisplaced=kFALSE; okSoftPi=kFALSE;
1522 if(SingleTrkCuts(esdt,okDisplaced,okSoftPi)) {
1523 seleTrksArray.AddLast(esdt);
1524 seleFlags[nSeleTrks]=0;
1525 if(okDisplaced) SETBIT(seleFlags[nSeleTrks],kBitDispl);
1526 if(okSoftPi) SETBIT(seleFlags[nSeleTrks],kBitSoftPi);
1527 nSeleTrks++;
1528 } else {
dcb444c9 1529 if(fInputAOD) delete esdt;
1530 esdt = NULL;
1531 continue;
2ff20727 1532 }
6a213b59 1533
dcb444c9 1534 } // end loop on tracks
1535
1536 // primary vertex from AOD
1537 if(fInputAOD) {
1538 delete fV1; fV1=NULL;
1539 vprimary->GetXYZ(pos);
1540 vprimary->GetCovarianceMatrix(cov);
1541 Double_t chi2toNDF = vprimary->GetChi2perNDF();
1542 Int_t ncontr=nindices;
a6e0ebfe 1543 if(!strcmp(vprimary->GetTitle(),"VertexerTracksWithContraint")) ncontr += 1;
dcb444c9 1544 Double_t chi2=chi2toNDF*(2.*(Double_t)ncontr-3.);
1545 fV1 = new AliESDVertex(pos,cov,chi2,ncontr,vprimary->GetName());
1546 fV1->SetTitle(vprimary->GetTitle());
1547 fV1->SetIndices(nindices,indices);
1548 }
1549 if(indices) { delete [] indices; indices=NULL; }
1550
6a213b59 1551
1552 return;
1553}
1554//-----------------------------------------------------------------------------
1555void AliAnalysisVertexingHF::SetD0toKpiCuts(Double_t cut0,Double_t cut1,
1556 Double_t cut2,Double_t cut3,Double_t cut4,
1557 Double_t cut5,Double_t cut6,
1558 Double_t cut7,Double_t cut8)
1559{
1560 // Set the cuts for D0 selection
1561 fD0toKpiCuts[0] = cut0;
1562 fD0toKpiCuts[1] = cut1;
1563 fD0toKpiCuts[2] = cut2;
1564 fD0toKpiCuts[3] = cut3;
1565 fD0toKpiCuts[4] = cut4;
1566 fD0toKpiCuts[5] = cut5;
1567 fD0toKpiCuts[6] = cut6;
1568 fD0toKpiCuts[7] = cut7;
1569 fD0toKpiCuts[8] = cut8;
1570
1571 return;
1572}
1573//-----------------------------------------------------------------------------
1574void AliAnalysisVertexingHF::SetD0toKpiCuts(const Double_t cuts[9])
1575{
1576 // Set the cuts for D0 selection
1577
1578 for(Int_t i=0; i<9; i++) fD0toKpiCuts[i] = cuts[i];
1579
1580 return;
1581}
1582//-----------------------------------------------------------------------------
2ff20727 1583void AliAnalysisVertexingHF::SetD0fromDstarCuts(Double_t cut0,Double_t cut1,
1584 Double_t cut2,Double_t cut3,Double_t cut4,
1585 Double_t cut5,Double_t cut6,
1586 Double_t cut7,Double_t cut8)
1587{
1588 // Set the cuts for D0 from D* selection
1589 fD0fromDstarCuts[0] = cut0;
1590 fD0fromDstarCuts[1] = cut1;
1591 fD0fromDstarCuts[2] = cut2;
1592 fD0fromDstarCuts[3] = cut3;
1593 fD0fromDstarCuts[4] = cut4;
1594 fD0fromDstarCuts[5] = cut5;
1595 fD0fromDstarCuts[6] = cut6;
1596 fD0fromDstarCuts[7] = cut7;
1597 fD0fromDstarCuts[8] = cut8;
1598
1599 return;
1600}
1601//-----------------------------------------------------------------------------
1602void AliAnalysisVertexingHF::SetD0fromDstarCuts(const Double_t cuts[9])
1603{
1604 // Set the cuts for D0 from D* selection
1605
1606 for(Int_t i=0; i<9; i++) fD0fromDstarCuts[i] = cuts[i];
1607
1608 return;
1609}
1610//-----------------------------------------------------------------------------
1611void AliAnalysisVertexingHF::SetDstarCuts(Double_t cut0,Double_t cut1,
1612 Double_t cut2,Double_t cut3,
1613 Double_t cut4)
1614{
1615 // Set the cuts for D* selection
1616 fDstarCuts[0] = cut0;
1617 fDstarCuts[1] = cut1;
1618 fDstarCuts[2] = cut2;
1619 fDstarCuts[3] = cut3;
1620 fDstarCuts[4] = cut4;
1621
1622 return;
1623}
1624//-----------------------------------------------------------------------------
1625void AliAnalysisVertexingHF::SetDstarCuts(const Double_t cuts[5])
1626{
1627 // Set the cuts for D* selection
1628
1629 for(Int_t i=0; i<5; i++) fDstarCuts[i] = cuts[i];
1630
1631 return;
1632}
1633//-----------------------------------------------------------------------------
6a213b59 1634void AliAnalysisVertexingHF::SetBtoJPSICuts(Double_t cut0,Double_t cut1,
1635 Double_t cut2,Double_t cut3,Double_t cut4,
1636 Double_t cut5,Double_t cut6,
1637 Double_t cut7,Double_t cut8)
1638{
1639 // Set the cuts for J/psi from B selection
1640 fBtoJPSICuts[0] = cut0;
1641 fBtoJPSICuts[1] = cut1;
1642 fBtoJPSICuts[2] = cut2;
1643 fBtoJPSICuts[3] = cut3;
1644 fBtoJPSICuts[4] = cut4;
1645 fBtoJPSICuts[5] = cut5;
1646 fBtoJPSICuts[6] = cut6;
1647 fBtoJPSICuts[7] = cut7;
1648 fBtoJPSICuts[8] = cut8;
1649
1650 return;
1651}
1652//-----------------------------------------------------------------------------
1653void AliAnalysisVertexingHF::SetBtoJPSICuts(const Double_t cuts[9])
1654{
1655 // Set the cuts for J/psi from B selection
1656
1657 for(Int_t i=0; i<9; i++) fBtoJPSICuts[i] = cuts[i];
1658
1659 return;
1660}
1661//-----------------------------------------------------------------------------
1662void AliAnalysisVertexingHF::SetDplusCuts(Double_t cut0,Double_t cut1,
1663 Double_t cut2,Double_t cut3,Double_t cut4,
1664 Double_t cut5,Double_t cut6,
1665 Double_t cut7,Double_t cut8,
1666 Double_t cut9,Double_t cut10,Double_t cut11)
1667{
1668 // Set the cuts for Dplus->Kpipi selection
1669 fDplusCuts[0] = cut0;
1670 fDplusCuts[1] = cut1;
1671 fDplusCuts[2] = cut2;
1672 fDplusCuts[3] = cut3;
1673 fDplusCuts[4] = cut4;
1674 fDplusCuts[5] = cut5;
1675 fDplusCuts[6] = cut6;
1676 fDplusCuts[7] = cut7;
1677 fDplusCuts[8] = cut8;
1678 fDplusCuts[9] = cut9;
1679 fDplusCuts[10] = cut10;
1680 fDplusCuts[11] = cut11;
1681
1682 return;
1683}
1684//-----------------------------------------------------------------------------
1685void AliAnalysisVertexingHF::SetDplusCuts(const Double_t cuts[12])
1686{
b82f6d67 1687 // Set the cuts for Dplus->Kpipi selection
6a213b59 1688
1689 for(Int_t i=0; i<12; i++) fDplusCuts[i] = cuts[i];
1690
1691 return;
1692}
1693//-----------------------------------------------------------------------------
6ea608bf 1694void AliAnalysisVertexingHF::SetDsCuts(Double_t cut0,Double_t cut1,
1695 Double_t cut2,Double_t cut3,Double_t cut4,
1696 Double_t cut5,Double_t cut6,
1697 Double_t cut7,Double_t cut8,
81679460 1698 Double_t cut9,Double_t cut10,
1699 Double_t cut11,Double_t cut12)
b82f6d67 1700{
1701 // Set the cuts for Ds->KKpi selection
1702 fDsCuts[0] = cut0;
6ea608bf 1703 fDsCuts[1] = cut1;
1704 fDsCuts[2] = cut2;
1705 fDsCuts[3] = cut3;
1706 fDsCuts[4] = cut4;
1707 fDsCuts[5] = cut5;
1708 fDsCuts[6] = cut6;
1709 fDsCuts[7] = cut7;
1710 fDsCuts[8] = cut8;
1711 fDsCuts[9] = cut9;
1712 fDsCuts[10] = cut10;
1713 fDsCuts[11] = cut11;
81679460 1714 fDsCuts[12] = cut12;
b82f6d67 1715
1716 return;
1717}
1718//-----------------------------------------------------------------------------
81679460 1719void AliAnalysisVertexingHF::SetDsCuts(const Double_t cuts[13])
b82f6d67 1720{
1721 // Set the cuts for Ds->KKpi selection
1722
81679460 1723 for(Int_t i=0; i<13; i++) fDsCuts[i] = cuts[i];
b82f6d67 1724
1725 return;
1726}
1727//-----------------------------------------------------------------------------
6ea608bf 1728void AliAnalysisVertexingHF::SetLcCuts(Double_t cut0,Double_t cut1,
1729 Double_t cut2,Double_t cut3,Double_t cut4,
1730 Double_t cut5,Double_t cut6,
1731 Double_t cut7,Double_t cut8,
1732 Double_t cut9,Double_t cut10,Double_t cut11)
b82f6d67 1733{
1734 // Set the cuts for Lc->pKpi selection
1735 fLcCuts[0] = cut0;
6ea608bf 1736 fLcCuts[1] = cut1;
1737 fLcCuts[2] = cut2;
1738 fLcCuts[3] = cut3;
1739 fLcCuts[4] = cut4;
1740 fLcCuts[5] = cut5;
1741 fLcCuts[6] = cut6;
1742 fLcCuts[7] = cut7;
1743 fLcCuts[8] = cut8;
1744 fLcCuts[9] = cut9;
1745 fLcCuts[10] = cut10;
1746 fLcCuts[11] = cut11;
b82f6d67 1747
1748 return;
1749}
1750//-----------------------------------------------------------------------------
6ea608bf 1751void AliAnalysisVertexingHF::SetLcCuts(const Double_t cuts[12])
b82f6d67 1752{
1753 // Set the cuts for Lc->pKpi selection
1754
6ea608bf 1755 for(Int_t i=0; i<12; i++) fLcCuts[i] = cuts[i];
b82f6d67 1756
1757 return;
1758}
1759//-----------------------------------------------------------------------------
721c0b8f 1760void AliAnalysisVertexingHF::SetD0to4ProngsCuts(Double_t cut0,Double_t cut1,
1761 Double_t cut2,Double_t cut3,Double_t cut4,
1762 Double_t cut5,Double_t cut6,
1763 Double_t cut7,Double_t cut8)
1764{
1765 // Set the cuts for D0->Kpipipi selection
1766
1767 fD0to4ProngsCuts[0] = cut0;
1768 fD0to4ProngsCuts[1] = cut1;
1769 fD0to4ProngsCuts[2] = cut2;
1770 fD0to4ProngsCuts[3] = cut3;
1771 fD0to4ProngsCuts[4] = cut4;
1772 fD0to4ProngsCuts[5] = cut5;
1773 fD0to4ProngsCuts[6] = cut6;
1774 fD0to4ProngsCuts[7] = cut7;
1775 fD0to4ProngsCuts[8] = cut8;
1776
1777 return;
1778}
1779//-----------------------------------------------------------------------------
1780void AliAnalysisVertexingHF::SetD0to4ProngsCuts(const Double_t cuts[9])
1781{
1782 // Set the cuts for D0->Kpipipi selection
1783
1784 for(Int_t i=0; i<9; i++) fD0to4ProngsCuts[i] = cuts[i];
1785
1786 return;
1787}
1788//-----------------------------------------------------------------------------
2ff20727 1789Bool_t AliAnalysisVertexingHF::SingleTrkCuts(AliESDtrack *trk,
1790 Bool_t &okDisplaced,Bool_t &okSoftPi) const
6a213b59 1791{
1792 // Check if track passes some kinematical cuts
6a213b59 1793
f8fa4595 1794 // this is needed to store the impact parameters
1795 trk->RelateToVertex(fV1,fBzkG,kVeryBig);
1796
2ff20727 1797 UInt_t selectInfo;
f8fa4595 1798 //
2ff20727 1799 // Track selection, displaced tracks
1800 selectInfo = 0;
f8fa4595 1801 if(fTrackFilter) {
1802 selectInfo = fTrackFilter->IsSelected(trk);
6a213b59 1803 }
2ff20727 1804 if(selectInfo) okDisplaced=kTRUE;
1805 // Track selection, soft pions
1806 selectInfo = 0;
1807 if(fDstar && fTrackFilterSoftPi) {
1808 selectInfo = fTrackFilterSoftPi->IsSelected(trk);
1809 }
1810 if(selectInfo) okSoftPi=kTRUE;
6a213b59 1811
2ff20727 1812 if(okDisplaced || okSoftPi) return kTRUE;
f8fa4595 1813
2ff20727 1814 return kFALSE;
6a213b59 1815}
1816//-----------------------------------------------------------------------------