Updated config
[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;
b6e66d86 463 delete ioCascade; ioCascade=NULL;
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 }
dc963de9 470
b6e66d86 471 delete io2Prong; io2Prong=NULL;
2ff20727 472 }
dc963de9 473
b056c5e3 474 twoTrackArray1->Clear();
dc963de9 475 if((!f3Prong && !f4Prong) || isLikeSignPair) {
b056c5e3 476 negtrack1=0;
477 delete vertexp1n1;
478 continue;
479 }
480
481
482 // 2nd LOOP ON POSITIVE TRACKS
2ff20727 483 for(iTrkP2=iTrkP1+1; iTrkP2<nSeleTrks; iTrkP2++) {
dc963de9 484
2ff20727 485 if(iTrkP2==iTrkP1 || iTrkP2==iTrkN1) continue;
dc963de9 486
2ff20727 487 if(iTrkP2%1==0) AliDebug(1,Form(" 2nd loop on pos: track number %d of %d",iTrkP2,nSeleTrks));
dc963de9 488
b056c5e3 489 // get track from tracks array
2ff20727 490 postrack2 = (AliESDtrack*)seleTrksArray.UncheckedAt(iTrkP2);
dc963de9 491
492 if(postrack2->Charge()<0) continue;
493
494 if(!TESTBIT(seleFlags[iTrkP2],kBitDispl)) continue;
495
dcb444c9 496 // back to primary vertex
497 postrack1->PropagateToDCA(fV1,fBzkG,kVeryBig);
498 postrack2->PropagateToDCA(fV1,fBzkG,kVeryBig);
499 negtrack1->PropagateToDCA(fV1,fBzkG,kVeryBig);
2ff20727 500 //printf("********** %d %d %d\n",postrack1->GetID(),postrack2->GetID(),negtrack1->GetID());
dc963de9 501
b056c5e3 502 dcap2n1 = postrack2->GetDCA(negtrack1,fBzkG,xdummy,ydummy);
503 if(dcap2n1>dcaMax) { postrack2=0; continue; }
504 dcap1p2 = postrack2->GetDCA(postrack1,fBzkG,xdummy,ydummy);
505 if(dcap1p2>dcaMax) { postrack2=0; continue; }
506
507 // Vertexing
508 twoTrackArray2->AddAt(postrack2,0);
509 twoTrackArray2->AddAt(negtrack1,1);
dcb444c9 510 AliAODVertex *vertexp2n1 = ReconstructSecondaryVertex(twoTrackArray2,dispersion);
b056c5e3 511 if(!vertexp2n1) {
512 twoTrackArray2->Clear();
513 postrack2=0;
514 continue;
515 }
dc963de9 516
517 // 3 prong candidates
b056c5e3 518 if(f3Prong) {
dc963de9 519
b056c5e3 520 threeTrackArray->AddAt(postrack1,0);
521 threeTrackArray->AddAt(negtrack1,1);
522 threeTrackArray->AddAt(postrack2,2);
dc963de9 523
dcb444c9 524 AliAODVertex* secVert3PrAOD = ReconstructSecondaryVertex(threeTrackArray,dispersion);
525 io3Prong = Make3Prong(threeTrackArray,event,secVert3PrAOD,dispersion,vertexp1n1,vertexp2n1,dcap1n1,dcap2n1,dcap1p2,ok3Prong);
b056c5e3 526 if(ok3Prong) {
2ff20727 527 AliAODVertex *v3Prong = new(verticesHFRef[iVerticesHF++])AliAODVertex(*secVert3PrAOD);
528 if(fInputAOD) AddDaughterRefs(v3Prong,event,threeTrackArray);
529 rd = new(aodCharm3ProngRef[i3Prong++])AliAODRecoDecayHF3Prong(*io3Prong);
530 rd->SetSecondaryVtx(v3Prong);
531 v3Prong->SetParent(rd);
b056c5e3 532 }
b6e66d86 533 if(io3Prong) {delete io3Prong; io3Prong=NULL;}
534 if(secVert3PrAOD) {delete secVert3PrAOD; secVert3PrAOD=NULL;}
b056c5e3 535 }
dc963de9 536
537 // 4 prong candidates
b056c5e3 538 if(f4Prong) {
dc963de9 539
721c0b8f 540 // back to primary vertex
541 postrack1->PropagateToDCA(fV1,fBzkG,kVeryBig);
542 postrack2->PropagateToDCA(fV1,fBzkG,kVeryBig);
543 negtrack1->PropagateToDCA(fV1,fBzkG,kVeryBig);
544 // Vertexing for these 3 (can be taken from above?)
545 threeTrackArray->AddAt(postrack1,0);
546 threeTrackArray->AddAt(negtrack1,1);
547 threeTrackArray->AddAt(postrack2,2);
548 AliAODVertex* vertexp1n1p2 = ReconstructSecondaryVertex(threeTrackArray,dispersion);
549
b056c5e3 550 // 3rd LOOP ON NEGATIVE TRACKS (for 4 prong)
2ff20727 551 for(iTrkN2=iTrkN1+1; iTrkN2<nSeleTrks; iTrkN2++) {
dc963de9 552
2ff20727 553 if(iTrkN2==iTrkP1 || iTrkN2==iTrkP2 || iTrkN2==iTrkN1) continue;
dc963de9 554
2ff20727 555 if(iTrkN2%1==0) AliDebug(1,Form(" 3rd loop on neg: track number %d of %d",iTrkN2,nSeleTrks));
dc963de9 556
b056c5e3 557 // get track from tracks array
2ff20727 558 negtrack2 = (AliESDtrack*)seleTrksArray.UncheckedAt(iTrkN2);
dc963de9 559
560 if(negtrack2->Charge()>0) continue;
561
562 if(!TESTBIT(seleFlags[iTrkN2],kBitDispl)) continue;
563
dcb444c9 564 // back to primary vertex
565 postrack1->PropagateToDCA(fV1,fBzkG,kVeryBig);
566 postrack2->PropagateToDCA(fV1,fBzkG,kVeryBig);
567 negtrack1->PropagateToDCA(fV1,fBzkG,kVeryBig);
568 negtrack2->PropagateToDCA(fV1,fBzkG,kVeryBig);
b056c5e3 569 dcap1n2 = postrack1->GetDCA(negtrack2,fBzkG,xdummy,ydummy);
570 if(dcap1n2>dcaMax) { negtrack2=0; continue; }
721c0b8f 571 dcap2n2 = postrack2->GetDCA(negtrack2,fBzkG,xdummy,ydummy);
572 if(dcap2n2>dcaMax) { negtrack2=0; continue; }
dc963de9 573
b056c5e3 574 // Vertexing
575 fourTrackArray->AddAt(postrack1,0);
576 fourTrackArray->AddAt(negtrack1,1);
577 fourTrackArray->AddAt(postrack2,2);
578 fourTrackArray->AddAt(negtrack2,3);
dc963de9 579
dcb444c9 580 AliAODVertex* secVert4PrAOD = ReconstructSecondaryVertex(fourTrackArray,dispersion);
721c0b8f 581 io4Prong = Make4Prong(fourTrackArray,event,secVert4PrAOD,vertexp1n1,vertexp1n1p2,dcap1n1,dcap1n2,dcap2n1,dcap2n2,ok4Prong);
b056c5e3 582 if(ok4Prong) {
2ff20727 583 AliAODVertex *v4Prong = new(verticesHFRef[iVerticesHF++])AliAODVertex(*secVert4PrAOD);
584 if(fInputAOD) AddDaughterRefs(v4Prong,event,fourTrackArray);
585 rd = new(aodCharm4ProngRef[i4Prong++])AliAODRecoDecayHF4Prong(*io4Prong);
586 rd->SetSecondaryVtx(v4Prong);
587 v4Prong->SetParent(rd);
b056c5e3 588 }
dc963de9 589
b6e66d86 590 if(io4Prong) {delete io4Prong; io4Prong=NULL;}
591 if(secVert4PrAOD) {delete secVert4PrAOD; secVert4PrAOD=NULL;}
b056c5e3 592 fourTrackArray->Clear();
593 negtrack2 = 0;
dc963de9 594
b056c5e3 595 } // end loop on negative tracks
dc963de9 596
721c0b8f 597 threeTrackArray->Clear();
598 delete vertexp1n1p2;
599
b056c5e3 600 }
dc963de9 601
b056c5e3 602 postrack2 = 0;
603 delete vertexp2n1;
dc963de9 604
b056c5e3 605 } // end 2nd loop on positive tracks
dc963de9 606
b056c5e3 607 twoTrackArray2->Clear();
608
dc963de9 609 // 2nd LOOP ON NEGATIVE TRACKS (for 3 prong +--)
2ff20727 610 for(iTrkN2=iTrkN1+1; iTrkN2<nSeleTrks; iTrkN2++) {
dc963de9 611
2ff20727 612 if(iTrkN2==iTrkP1 || iTrkN2==iTrkP2 || iTrkN2==iTrkN1) continue;
dc963de9 613
2ff20727 614 if(iTrkN2%1==0) AliDebug(1,Form(" 2nd loop on neg: track number %d of %d",iTrkN2,nSeleTrks));
dc963de9 615
b056c5e3 616 // get track from tracks array
2ff20727 617 negtrack2 = (AliESDtrack*)seleTrksArray.UncheckedAt(iTrkN2);
dc963de9 618
619 if(negtrack2->Charge()>0) continue;
620
621 if(!TESTBIT(seleFlags[iTrkN2],kBitDispl)) continue;
622
dcb444c9 623 // back to primary vertex
624 postrack1->PropagateToDCA(fV1,fBzkG,kVeryBig);
625 negtrack1->PropagateToDCA(fV1,fBzkG,kVeryBig);
626 negtrack2->PropagateToDCA(fV1,fBzkG,kVeryBig);
2ff20727 627 //printf("********** %d %d %d\n",postrack1->GetID(),negtrack1->GetID(),negtrack2->GetID());
dc963de9 628
b056c5e3 629 dcap1n2 = postrack1->GetDCA(negtrack2,fBzkG,xdummy,ydummy);
630 if(dcap1n2>dcaMax) { negtrack2=0; continue; }
631 dcan1n2 = negtrack1->GetDCA(negtrack2,fBzkG,xdummy,ydummy);
632 if(dcan1n2>dcaMax) { negtrack2=0; continue; }
633
634 // Vertexing
635 twoTrackArray2->AddAt(postrack1,0);
636 twoTrackArray2->AddAt(negtrack2,1);
dcb444c9 637
638 AliAODVertex *vertexp1n2 = ReconstructSecondaryVertex(twoTrackArray2,dispersion);
b056c5e3 639 if(!vertexp1n2) {
640 twoTrackArray2->Clear();
641 negtrack2=0;
642 continue;
643 }
dc963de9 644
b056c5e3 645 if(f3Prong) {
646 threeTrackArray->AddAt(negtrack1,0);
647 threeTrackArray->AddAt(postrack1,1);
648 threeTrackArray->AddAt(negtrack2,2);
dcb444c9 649 AliAODVertex* secVert3PrAOD = ReconstructSecondaryVertex(threeTrackArray,dispersion);
650 io3Prong = Make3Prong(threeTrackArray,event,secVert3PrAOD,dispersion,vertexp1n1,vertexp1n2,dcap1n1,dcap1n2,dcan1n2,ok3Prong);
b056c5e3 651 if(ok3Prong) {
2ff20727 652 AliAODVertex *v3Prong = new(verticesHFRef[iVerticesHF++])AliAODVertex(*secVert3PrAOD);
653 if(fInputAOD) AddDaughterRefs(v3Prong,event,threeTrackArray);
654 rd = new(aodCharm3ProngRef[i3Prong++])AliAODRecoDecayHF3Prong(*io3Prong);
655 rd->SetSecondaryVtx(v3Prong);
656 v3Prong->SetParent(rd);
b056c5e3 657 }
b6e66d86 658 if(io3Prong) {delete io3Prong; io3Prong=NULL;}
659 if(secVert3PrAOD) {delete secVert3PrAOD; secVert3PrAOD=NULL;}
b056c5e3 660 }
dc963de9 661
b056c5e3 662 negtrack2 = 0;
663 delete vertexp1n2;
dc963de9 664
b056c5e3 665 } // end 2nd loop on negative tracks
666 twoTrackArray2->Clear();
667
668 negtrack1 = 0;
669 delete vertexp1n1;
670 } // end 1st loop on negative tracks
671
672 postrack1 = 0;
673 } // end 1st loop on positive tracks
674
675
2ff20727 676 AliDebug(1,Form(" Total HF vertices in event = %d;",
677 (Int_t)aodVerticesHFTClArr->GetEntriesFast()));
b056c5e3 678 if(fD0toKpi) {
dcb444c9 679 AliDebug(1,Form(" D0->Kpi in event = %d;",
680 (Int_t)aodD0toKpiTClArr->GetEntriesFast()));
b056c5e3 681 }
682 if(fJPSItoEle) {
dcb444c9 683 AliDebug(1,Form(" JPSI->ee in event = %d;",
684 (Int_t)aodJPSItoEleTClArr->GetEntriesFast()));
b056c5e3 685 }
686 if(f3Prong) {
dcb444c9 687 AliDebug(1,Form(" Charm->3Prong in event = %d;",
688 (Int_t)aodCharm3ProngTClArr->GetEntriesFast()));
b056c5e3 689 }
690 if(f4Prong) {
dcb444c9 691 AliDebug(1,Form(" Charm->4Prong in event = %d;\n",
692 (Int_t)aodCharm4ProngTClArr->GetEntriesFast()));
b056c5e3 693 }
2ff20727 694 if(fDstar) {
695 AliDebug(1,Form(" D*->D0pi in event = %d;\n",
696 (Int_t)aodDstarTClArr->GetEntriesFast()));
697 }
dc963de9 698 if(fLikeSign) {
699 AliDebug(1,Form(" Like-sign pairs in event = %d;\n",
700 (Int_t)aodLikeSignTClArr->GetEntriesFast()));
701 }
b056c5e3 702
703
dcb444c9 704 twoTrackArray1->Delete(); delete twoTrackArray1;
705 twoTrackArray2->Delete(); delete twoTrackArray2;
2ff20727 706 twoTrackArrayCasc->Delete(); delete twoTrackArrayCasc;
b056c5e3 707 threeTrackArray->Clear();
708 threeTrackArray->Delete(); delete threeTrackArray;
dcb444c9 709 fourTrackArray->Delete(); delete fourTrackArray;
2ff20727 710 delete [] seleFlags; seleFlags=NULL;
b056c5e3 711
dcb444c9 712 if(fInputAOD) {
b6e66d86 713 seleTrksArray.Delete();
714 if(fAODMap) { delete [] fAODMap; fAODMap=NULL; }
dcb444c9 715 }
b056c5e3 716
717 return;
718}
719//----------------------------------------------------------------------------
dcb444c9 720void AliAnalysisVertexingHF::AddDaughterRefs(AliAODVertex *v,AliVEvent *event,
721 TObjArray *trkArray) const
6a213b59 722{
dcb444c9 723 // Add the AOD tracks as daughters of the vertex (TRef)
6a213b59 724
dcb444c9 725 Int_t nTrks = trkArray->GetEntriesFast();
6a213b59 726
e18fbfa7 727 AliExternalTrackParam *track = 0;
dcb444c9 728 AliAODTrack *aodTrack = 0;
729 Int_t id;
6a213b59 730
dcb444c9 731 for(Int_t i=0; i<nTrks; i++) {
e18fbfa7 732 track = (AliExternalTrackParam*)trkArray->UncheckedAt(i);
733 id = (Int_t)track->GetID();
2ff20727 734 //printf("---> %d\n",id);
e18fbfa7 735 if(id<0) continue; // this track is a AliAODRecoDecay
dcb444c9 736 aodTrack = (AliAODTrack*)event->GetTrack(fAODMap[id]);
737 v->AddDaughter(aodTrack);
6a213b59 738 }
6a213b59 739
740 return;
dcb444c9 741}
6a213b59 742//----------------------------------------------------------------------------
2ff20727 743AliAODRecoCascadeHF* AliAnalysisVertexingHF::MakeCascade(
744 TObjArray *twoTrackArray,AliVEvent *event,
745 AliAODVertex *secVert,
746 AliAODRecoDecayHF2Prong *rd2Prong,
747 Double_t dca,
748 Bool_t &okDstar) const
749{
750 // Make the cascade as a 2Prong decay and check if it passes Dstar
751 // reconstruction cuts
752
753 okDstar = kFALSE;
754
755 Bool_t dummy1,dummy2,dummy3;
756
757 // We use Make2Prong to construct the AliAODRecoCascadeHF
758 // (which inherits from AliAODRecoDecayHF2Prong)
759 AliAODRecoCascadeHF *theCascade =
760 (AliAODRecoCascadeHF*)Make2Prong(twoTrackArray,event,secVert,dca,
761 dummy1,dummy2,dummy3);
762 if(!theCascade) return 0x0;
763
764 // charge
765 AliESDtrack *trackPi = (AliESDtrack*)twoTrackArray->UncheckedAt(0);
766 theCascade->SetCharge(trackPi->Charge());
767
768 //--- selection cuts
769 //
770 AliAODRecoCascadeHF *tmpCascade = new AliAODRecoCascadeHF(*theCascade);
dcfa35b3 771 tmpCascade->GetSecondaryVtx()->AddDaughter(trackPi);
772 tmpCascade->GetSecondaryVtx()->AddDaughter(rd2Prong);
2ff20727 773 AliAODVertex *primVertexAOD=0;
774 if(!fRecoPrimVtxSkippingTrks && !fRmTrksFromPrimVtx) {
775 // take event primary vertex
776 primVertexAOD = PrimaryVertex();
777 tmpCascade->SetOwnPrimaryVtx(primVertexAOD);
778 rd2Prong->SetOwnPrimaryVtx(primVertexAOD);
779 }
780 // select D*->D0pi
781 if(fDstar) {
782 Bool_t testD0=kTRUE;
783 okDstar = tmpCascade->SelectDstar(fDstarCuts,fD0fromDstarCuts,testD0);
784 }
dcfa35b3 785 tmpCascade->GetSecondaryVtx()->RemoveDaughters();
2ff20727 786 tmpCascade->UnsetOwnPrimaryVtx();
2ff20727 787 delete tmpCascade; tmpCascade=NULL;
788 if(!fRecoPrimVtxSkippingTrks && !fRmTrksFromPrimVtx) {
789 rd2Prong->UnsetOwnPrimaryVtx();
2ff20727 790 }
b6e66d86 791 if(primVertexAOD) {delete primVertexAOD; primVertexAOD=NULL;}
2ff20727 792 //---
793
794 return theCascade;
795}
796//-----------------------------------------------------------------------------
6a213b59 797AliAODRecoDecayHF2Prong *AliAnalysisVertexingHF::Make2Prong(
2ff20727 798 TObjArray *twoTrackArray,AliVEvent *event,
dcb444c9 799 AliAODVertex *secVert,Double_t dca,
2ff20727 800 Bool_t &okD0,Bool_t &okJPSI,
801 Bool_t &okD0fromDstar) const
6a213b59 802{
803 // Make 2Prong candidates and check if they pass D0toKpi or BtoJPSI
804 // reconstruction cuts
805 // G.E.Bruno (J/psi), A.Dainese (D0->Kpi)
806
2ff20727 807 okD0=kFALSE; okJPSI=kFALSE; okD0fromDstar=kFALSE;
6a213b59 808
809 Double_t px[2],py[2],pz[2],d0[2],d0err[2];
6a213b59 810
2ff20727 811 AliESDtrack *postrack = (AliESDtrack*)twoTrackArray->UncheckedAt(0);
812 AliESDtrack *negtrack = (AliESDtrack*)twoTrackArray->UncheckedAt(1);
6a213b59 813
814 // propagate tracks to secondary vertex, to compute inv. mass
dcb444c9 815 postrack->PropagateToDCA(secVert,fBzkG,kVeryBig);
816 negtrack->PropagateToDCA(secVert,fBzkG,kVeryBig);
6a213b59 817
818 Double_t momentum[3];
819 postrack->GetPxPyPz(momentum);
820 px[0] = momentum[0]; py[0] = momentum[1]; pz[0] = momentum[2];
821 negtrack->GetPxPyPz(momentum);
822 px[1] = momentum[0]; py[1] = momentum[1]; pz[1] = momentum[2];
823
824
825 // invariant mass cut (try to improve coding here..)
826 Bool_t okMassCut=kFALSE;
dcb444c9 827 if(!okMassCut && fD0toKpi) if(SelectInvMass(0,2,px,py,pz)) okMassCut=kTRUE;
6a213b59 828 if(!okMassCut && fJPSItoEle) if(SelectInvMass(1,2,px,py,pz)) okMassCut=kTRUE;
2ff20727 829 if(!okMassCut && fDstar) if(SelectInvMass(3,2,px,py,pz)) okMassCut=kTRUE;
6a213b59 830 if(!okMassCut) {
dcb444c9 831 AliDebug(2," candidate didn't pass mass cut");
6a213b59 832 return 0x0;
833 }
b6e66d86 834
dcb444c9 835 // primary vertex to be used by this candidate
2ff20727 836 AliAODVertex *primVertexAOD = PrimaryVertex(twoTrackArray,event);
dcb444c9 837 if(!primVertexAOD) return 0x0;
6a213b59 838
dcb444c9 839 Double_t d0z0[2],covd0z0[3];
840 postrack->PropagateToDCA(primVertexAOD,fBzkG,kVeryBig,d0z0,covd0z0);
6a213b59 841 d0[0] = d0z0[0];
842 d0err[0] = TMath::Sqrt(covd0z0[0]);
dcb444c9 843 negtrack->PropagateToDCA(primVertexAOD,fBzkG,kVeryBig,d0z0,covd0z0);
6a213b59 844 d0[1] = d0z0[0];
845 d0err[1] = TMath::Sqrt(covd0z0[0]);
b6e66d86 846
6a213b59 847 // create the object AliAODRecoDecayHF2Prong
dcb444c9 848 AliAODRecoDecayHF2Prong *the2Prong = new AliAODRecoDecayHF2Prong(secVert,px,py,pz,d0,d0err,dca);
6a213b59 849 the2Prong->SetOwnPrimaryVtx(primVertexAOD);
dcb444c9 850 UShort_t id[2]={(UShort_t)postrack->GetID(),(UShort_t)negtrack->GetID()};
851 the2Prong->SetProngIDs(2,id);
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();
869 delete primVertexAOD; primVertexAOD=NULL;
870 }
871
2ff20727 872 // get PID info from ESD
5770b08b 873 Double_t esdpid0[5]={0.,0.,0.,0.,0.};
874 if(postrack->GetStatus()&AliESDtrack::kESDpid) postrack->GetESDpid(esdpid0);
875 Double_t esdpid1[5]={0.,0.,0.,0.,0.};
876 if(negtrack->GetStatus()&AliESDtrack::kESDpid) negtrack->GetESDpid(esdpid1);
2ff20727 877 Double_t esdpid[10];
878 for(Int_t i=0;i<5;i++) {
879 esdpid[i] = esdpid0[i];
880 esdpid[5+i] = esdpid1[i];
6a213b59 881 }
2ff20727 882 the2Prong->SetPID(2,esdpid);
6a213b59 883
6a213b59 884 return the2Prong;
885}
886//----------------------------------------------------------------------------
887AliAODRecoDecayHF3Prong* AliAnalysisVertexingHF::Make3Prong(
dcb444c9 888 TObjArray *threeTrackArray,AliVEvent *event,
889 AliAODVertex *secVert,Double_t dispersion,
890 AliAODVertex *vertexp1n1,AliAODVertex *vertexp2n1,
6a213b59 891 Double_t dcap1n1,Double_t dcap2n1,Double_t dcap1p2,
892 Bool_t &ok3Prong) const
893{
894 // Make 3Prong candidates and check if they pass Dplus or Ds or Lambdac
895 // reconstruction cuts
896 // E.Bruna, F.Prino
897
dcb444c9 898
6a213b59 899 ok3Prong=kFALSE;
dcb444c9 900 if(!secVert) return 0x0;
901
902 Double_t px[3],py[3],pz[3],d0[3],d0err[3];
903 Double_t momentum[3];
6a213b59 904
6a213b59 905
906 AliESDtrack *postrack1 = (AliESDtrack*)threeTrackArray->UncheckedAt(0);
dcb444c9 907 AliESDtrack *negtrack = (AliESDtrack*)threeTrackArray->UncheckedAt(1);
6a213b59 908 AliESDtrack *postrack2 = (AliESDtrack*)threeTrackArray->UncheckedAt(2);
909
dcb444c9 910 postrack1->PropagateToDCA(secVert,fBzkG,kVeryBig);
911 negtrack->PropagateToDCA(secVert,fBzkG,kVeryBig);
912 postrack2->PropagateToDCA(secVert,fBzkG,kVeryBig);
6a213b59 913 postrack1->GetPxPyPz(momentum);
914 px[0] = momentum[0]; py[0] = momentum[1]; pz[0] = momentum[2];
915 negtrack->GetPxPyPz(momentum);
916 px[1] = momentum[0]; py[1] = momentum[1]; pz[1] = momentum[2];
917 postrack2->GetPxPyPz(momentum);
918 px[2] = momentum[0]; py[2] = momentum[1]; pz[2] = momentum[2];
919
b82f6d67 920 // invariant mass cut for D+, Ds, Lc
6a213b59 921 Bool_t okMassCut=kFALSE;
922 if(!okMassCut && f3Prong) if(SelectInvMass(2,3,px,py,pz)) okMassCut=kTRUE;
923 if(!okMassCut) {
dcb444c9 924 AliDebug(2," candidate didn't pass mass cut");
6a213b59 925 return 0x0;
926 }
927
dcb444c9 928 // primary vertex to be used by this candidate
2ff20727 929 AliAODVertex *primVertexAOD = PrimaryVertex(threeTrackArray,event);
dcb444c9 930 if(!primVertexAOD) return 0x0;
931
932 Double_t d0z0[2],covd0z0[3];
933 postrack1->PropagateToDCA(primVertexAOD,fBzkG,kVeryBig,d0z0,covd0z0);
934 d0[0]=d0z0[0];
935 d0err[0] = TMath::Sqrt(covd0z0[0]);
936 negtrack->PropagateToDCA(primVertexAOD,fBzkG,kVeryBig,d0z0,covd0z0);
937 d0[1]=d0z0[0];
938 d0err[1] = TMath::Sqrt(covd0z0[0]);
939 postrack2->PropagateToDCA(primVertexAOD,fBzkG,kVeryBig,d0z0,covd0z0);
940 d0[2]=d0z0[0];
941 d0err[2] = TMath::Sqrt(covd0z0[0]);
6a213b59 942
6a213b59 943
944 // create the object AliAODRecoDecayHF3Prong
dcb444c9 945 Double_t pos[3]; primVertexAOD->GetXYZ(pos);
6a213b59 946 Double_t dca[3]={dcap1n1,dcap2n1,dcap1p2};
dcb444c9 947 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]));
948 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]));
949 Short_t charge=(Short_t)(postrack1->Charge()*postrack2->Charge()*negtrack->Charge());
950 AliAODRecoDecayHF3Prong *the3Prong = new AliAODRecoDecayHF3Prong(secVert,px,py,pz,d0,d0err,dca,dispersion,dist12,dist23,charge);
6a213b59 951 the3Prong->SetOwnPrimaryVtx(primVertexAOD);
dcb444c9 952 UShort_t id[3]={(UShort_t)postrack1->GetID(),(UShort_t)negtrack->GetID(),(UShort_t)postrack2->GetID()};
953 the3Prong->SetProngIDs(3,id);
6a213b59 954
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();
968 delete primVertexAOD; primVertexAOD=NULL;
969 }
dcb444c9 970
2ff20727 971 // get PID info from ESD
5770b08b 972 Double_t esdpid0[5]={0.,0.,0.,0.,0.};
973 if(postrack1->GetStatus()&AliESDtrack::kESDpid) postrack1->GetESDpid(esdpid0);
974 Double_t esdpid1[5]={0.,0.,0.,0.,0.};
975 if(negtrack->GetStatus()&AliESDtrack::kESDpid) negtrack->GetESDpid(esdpid1);
976 Double_t esdpid2[5]={0.,0.,0.,0.,0.};
977 if(postrack2->GetStatus()&AliESDtrack::kESDpid) postrack2->GetESDpid(esdpid2);
2ff20727 978
979 Double_t esdpid[15];
980 for(Int_t i=0;i<5;i++) {
981 esdpid[i] = esdpid0[i];
982 esdpid[5+i] = esdpid1[i];
983 esdpid[10+i] = esdpid2[i];
6a213b59 984 }
2ff20727 985 the3Prong->SetPID(3,esdpid);
6a213b59 986
6a213b59 987 return the3Prong;
988}
989//----------------------------------------------------------------------------
990AliAODRecoDecayHF4Prong* AliAnalysisVertexingHF::Make4Prong(
dcb444c9 991 TObjArray *fourTrackArray,AliVEvent *event,
721c0b8f 992 AliAODVertex *secVert,
993 AliAODVertex *vertexp1n1,
994 AliAODVertex *vertexp1n1p2,
995 Double_t dcap1n1,Double_t dcap1n2,
996 Double_t dcap2n1,Double_t dcap2n2,
997 Bool_t &ok4Prong) const
6a213b59 998{
999 // Make 4Prong candidates and check if they pass D0toKpipipi
1000 // reconstruction cuts
1001 // G.E.Bruno, R.Romita
1002
1003 ok4Prong=kFALSE;
dcb444c9 1004 if(!secVert) return 0x0;
6a213b59 1005
1006 Double_t px[4],py[4],pz[4],d0[4],d0err[4];//d0z[3];
6a213b59 1007
6a213b59 1008 AliESDtrack *postrack1 = (AliESDtrack*)fourTrackArray->UncheckedAt(0);
1009 AliESDtrack *negtrack1 = (AliESDtrack*)fourTrackArray->UncheckedAt(1);
1010 AliESDtrack *postrack2 = (AliESDtrack*)fourTrackArray->UncheckedAt(2);
1011 AliESDtrack *negtrack2 = (AliESDtrack*)fourTrackArray->UncheckedAt(3);
1012
dcb444c9 1013 postrack1->PropagateToDCA(secVert,fBzkG,kVeryBig);
1014 negtrack1->PropagateToDCA(secVert,fBzkG,kVeryBig);
1015 postrack2->PropagateToDCA(secVert,fBzkG,kVeryBig);
1016 negtrack2->PropagateToDCA(secVert,fBzkG,kVeryBig);
6a213b59 1017
1018 Double_t momentum[3];
1019 postrack1->GetPxPyPz(momentum);
1020 px[0] = momentum[0]; py[0] = momentum[1]; pz[0] = momentum[2];
1021 negtrack1->GetPxPyPz(momentum);
1022 px[1] = momentum[0]; py[1] = momentum[1]; pz[1] = momentum[2];
1023 postrack2->GetPxPyPz(momentum);
1024 px[2] = momentum[0]; py[2] = momentum[1]; pz[2] = momentum[2];
1025 negtrack2->GetPxPyPz(momentum);
1026 px[3] = momentum[0]; py[3] = momentum[1]; pz[3] = momentum[2];
1027
1028 // invariant mass cut for rho or D0 (try to improve coding here..)
1029 //Bool_t okMassCut=kFALSE;
1030 //if(!okMassCut) if(SelectInvMass(2,3,px,py,pz)) okMassCut=kTRUE;
1031 //if(!okMassCut) {
1032 // if(fDebug) printf(" candidate didn't pass mass cut\n");
1033 // return 0x0;
721c0b8f 1034 // }
6a213b59 1035
dcb444c9 1036 // primary vertex to be used by this candidate
2ff20727 1037 AliAODVertex *primVertexAOD = PrimaryVertex(fourTrackArray,event);
dcb444c9 1038 if(!primVertexAOD) return 0x0;
1039
721c0b8f 1040 Double_t d0z0[2],covd0z0[3];
1041 postrack1->PropagateToDCA(primVertexAOD,fBzkG,kVeryBig,d0z0,covd0z0);
1042 d0[0]=d0z0[0];
1043 d0err[0] = TMath::Sqrt(covd0z0[0]);
1044 negtrack1->PropagateToDCA(primVertexAOD,fBzkG,kVeryBig,d0z0,covd0z0);
1045 d0[1]=d0z0[0];
1046 d0err[1] = TMath::Sqrt(covd0z0[0]);
1047 postrack2->PropagateToDCA(primVertexAOD,fBzkG,kVeryBig,d0z0,covd0z0);
1048 d0[2]=d0z0[0];
1049 d0err[2] = TMath::Sqrt(covd0z0[0]);
1050 negtrack2->PropagateToDCA(primVertexAOD,fBzkG,kVeryBig,d0z0,covd0z0);
1051 d0[3]=d0z0[0];
1052 d0err[3] = TMath::Sqrt(covd0z0[0]);
1053
6a213b59 1054
1055 // create the object AliAODRecoDecayHF4Prong
dcb444c9 1056 Double_t pos[3]; primVertexAOD->GetXYZ(pos);
721c0b8f 1057 Double_t dca[6]={dcap1n1,0.,dcap1n2,dcap2n1,0.,dcap2n2};
dcb444c9 1058 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 1059 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]));
1060 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 1061 Short_t charge=0;
721c0b8f 1062 AliAODRecoDecayHF4Prong *the4Prong = new AliAODRecoDecayHF4Prong(secVert,px,py,pz,d0,d0err,dca,dist12,dist3,dist4,charge);
6a213b59 1063 the4Prong->SetOwnPrimaryVtx(primVertexAOD);
dcb444c9 1064 UShort_t id[4]={(UShort_t)postrack1->GetID(),(UShort_t)negtrack1->GetID(),(UShort_t)postrack2->GetID(),(UShort_t)negtrack2->GetID()};
1065 the4Prong->SetProngIDs(4,id);
6a213b59 1066
721c0b8f 1067 // invariant mass cut for rho or D0 (try to improve coding here..)
1068 Bool_t okMassCut=kFALSE;
1069 if(!okMassCut && fD0to4ProngsCuts[8]==0.){ //no PID, to be implemented with PID
1070 if(SelectInvMass(4,4,px,py,pz)) okMassCut=kTRUE;
1071 }
1072 if(!okMassCut) {
1073 //if(fDebug) printf(" candidate didn't pass mass cut\n");
1074 //printf(" candidate didn't pass mass cut\n");
1075 return 0x0;
1076 }
1077
6a213b59 1078
721c0b8f 1079 Int_t checkD0,checkD0bar;
1080 ok4Prong=the4Prong->SelectD0(fD0to4ProngsCuts,checkD0,checkD0bar);
6a213b59 1081
b6e66d86 1082 if(!fRecoPrimVtxSkippingTrks && !fRmTrksFromPrimVtx) {
1083 the4Prong->UnsetOwnPrimaryVtx();
1084 delete primVertexAOD; primVertexAOD=NULL;
1085 }
6a213b59 1086
721c0b8f 1087
6a213b59 1088 // get PID info from ESD
721c0b8f 1089 Double_t esdpid0[5]={0.,0.,0.,0.,0.};
1090 if(postrack1->GetStatus()&AliESDtrack::kESDpid) postrack1->GetESDpid(esdpid0);
1091 Double_t esdpid1[5]={0.,0.,0.,0.,0.};
1092 if(negtrack1->GetStatus()&AliESDtrack::kESDpid) negtrack1->GetESDpid(esdpid1);
1093 Double_t esdpid2[5]={0.,0.,0.,0.,0.};
1094 if(postrack2->GetStatus()&AliESDtrack::kESDpid) postrack2->GetESDpid(esdpid2);
1095 Double_t esdpid3[5]={0.,0.,0.,0.,0.};
1096 if(negtrack2->GetStatus()&AliESDtrack::kESDpid) negtrack2->GetESDpid(esdpid3);
6a213b59 1097
1098 Double_t esdpid[20];
1099 for(Int_t i=0;i<5;i++) {
2ff20727 1100 esdpid[i] = esdpid0[i];
1101 esdpid[5+i] = esdpid1[i];
6a213b59 1102 esdpid[10+i] = esdpid2[i];
1103 esdpid[15+i] = esdpid3[i];
1104 }
1105 the4Prong->SetPID(4,esdpid);
721c0b8f 1106
6a213b59 1107 return the4Prong;
1108}
1109//-----------------------------------------------------------------------------
2ff20727 1110AliAODVertex* AliAnalysisVertexingHF::PrimaryVertex(TObjArray *trkArray,
1111 AliVEvent *event) const
6a213b59 1112{
2ff20727 1113 // Returns primary vertex to be used for this candidate
6a213b59 1114
dcb444c9 1115 AliESDVertex *vertexESD = 0;
1116 AliAODVertex *vertexAOD = 0;
1117
dcb444c9 1118
1119 if(!fRecoPrimVtxSkippingTrks && !fRmTrksFromPrimVtx) {
1120 // primary vertex from the input event
1121
1122 vertexESD = new AliESDVertex(*fV1);
1123
1124 } else {
1125 // primary vertex specific to this candidate
1126
2ff20727 1127 Int_t nTrks = trkArray->GetEntriesFast();
dcb444c9 1128 AliVertexerTracks *vertexer = new AliVertexerTracks(event->GetMagneticField());
1129
1130 if(fRecoPrimVtxSkippingTrks) {
1131 // recalculating the vertex
1132
1133 if(strstr(fV1->GetTitle(),"VertexerTracksWithConstraint")) {
1134 Float_t diamondcovxy[3];
1135 event->GetDiamondCovXY(diamondcovxy);
1136 Double_t pos[3]={event->GetDiamondX(),event->GetDiamondY(),0.};
1137 Double_t cov[6]={diamondcovxy[0],diamondcovxy[1],diamondcovxy[2],0.,0.,10.};
1138 AliESDVertex *diamond = new AliESDVertex(pos,cov,1.,1);
1139 vertexer->SetVtxStart(diamond);
1140 delete diamond; diamond=NULL;
1141 if(strstr(fV1->GetTitle(),"VertexerTracksWithConstraintOnlyFitter"))
1142 vertexer->SetOnlyFitter();
1143 }
1144 Int_t skipped[10];
e18fbfa7 1145 Int_t nTrksToSkip=0,id;
1146 AliExternalTrackParam *t = 0;
dcb444c9 1147 for(Int_t i=0; i<nTrks; i++) {
e18fbfa7 1148 t = (AliExternalTrackParam*)trkArray->UncheckedAt(i);
1149 id = (Int_t)t->GetID();
1150 if(id<0) continue;
1151 skipped[nTrksToSkip++] = id;
dcb444c9 1152 }
e18fbfa7 1153 vertexer->SetSkipTracks(nTrksToSkip,skipped);
dcb444c9 1154 vertexESD = (AliESDVertex*)vertexer->FindPrimaryVertex(event);
1155
1156 } else if(fRmTrksFromPrimVtx) {
1157 // removing the prongs tracks
1158
1159 TObjArray rmArray(nTrks);
1160 UShort_t *rmId = new UShort_t[nTrks];
1161 AliESDtrack *esdTrack = 0;
1162 AliESDtrack *t = 0;
1163 for(Int_t i=0; i<nTrks; i++) {
1164 t = (AliESDtrack*)trkArray->UncheckedAt(i);
1165 esdTrack = new AliESDtrack(*t);
1166 rmArray.AddLast(esdTrack);
2ff20727 1167 if(esdTrack->GetID()>=0) {
1168 rmId[i]=(UShort_t)esdTrack->GetID();
1169 } else {
1170 rmId[i]=9999;
1171 }
dcb444c9 1172 }
1173 Float_t diamondxy[2]={event->GetDiamondX(),event->GetDiamondY()};
1174 vertexESD = vertexer->RemoveTracksFromVertex(fV1,&rmArray,rmId,diamondxy);
1175 delete [] rmId; rmId=NULL;
1176 rmArray.Delete();
1177
6a213b59 1178 }
6a213b59 1179
dcb444c9 1180 if(!vertexESD) return vertexAOD;
1181 if(vertexESD->GetNContributors()<=0) {
1182 AliDebug(2,"vertexing failed");
1183 delete vertexESD; vertexESD=NULL;
1184 return vertexAOD;
6a213b59 1185 }
dcb444c9 1186
1187 delete vertexer; vertexer=NULL;
1188
6a213b59 1189 }
1190
dcb444c9 1191 // convert to AliAODVertex
1192 Double_t pos[3],cov[6],chi2perNDF;
1193 vertexESD->GetXYZ(pos); // position
1194 vertexESD->GetCovMatrix(cov); //covariance matrix
1195 chi2perNDF = vertexESD->GetChi2toNDF();
1196 delete vertexESD; vertexESD=NULL;
1197
1198 vertexAOD = new AliAODVertex(pos,cov,chi2perNDF);
6a213b59 1199
dcb444c9 1200 return vertexAOD;
6a213b59 1201}
1202//-----------------------------------------------------------------------------
1203void AliAnalysisVertexingHF::PrintStatus() const {
1204 // Print parameters being used
1205
f8fa4595 1206 //printf("Preselections:\n");
1207 // fTrackFilter->Dump();
4d5c9633 1208 if(fSecVtxWithKF) {
1209 printf("Secondary vertex with Kalman filter package (AliKFParticle)\n");
1210 } else {
1211 printf("Secondary vertex with AliVertexerTracks\n");
1212 }
6a213b59 1213 if(fRecoPrimVtxSkippingTrks) printf("RecoPrimVtxSkippingTrks\n");
1214 if(fRmTrksFromPrimVtx) printf("RmTrksFromPrimVtx\n");
1215 if(fD0toKpi) {
1216 printf("Reconstruct D0->Kpi candidates with cuts:\n");
1217 printf(" |M-MD0| [GeV] < %f\n",fD0toKpiCuts[0]);
1218 printf(" dca [cm] < %f\n",fD0toKpiCuts[1]);
1219 printf(" cosThetaStar < %f\n",fD0toKpiCuts[2]);
1220 printf(" pTK [GeV/c] > %f\n",fD0toKpiCuts[3]);
1221 printf(" pTpi [GeV/c] > %f\n",fD0toKpiCuts[4]);
1222 printf(" |d0K| [cm] < %f\n",fD0toKpiCuts[5]);
1223 printf(" |d0pi| [cm] < %f\n",fD0toKpiCuts[6]);
1224 printf(" d0d0 [cm^2] < %f\n",fD0toKpiCuts[7]);
1225 printf(" cosThetaPoint > %f\n",fD0toKpiCuts[8]);
1226 }
2ff20727 1227 if(fDstar) {
eee95e18 1228 if(fFindVertexForDstar) {
1229 printf(" Reconstruct a secondary vertex for the D*\n");
1230 } else {
1231 printf(" Assume the D* comes from the primary vertex\n");
1232 }
2ff20727 1233 printf(" |M-MD*| [GeV] < %f\n",fDstarCuts[0]);
1234 printf(" |M_Kpipi-M_Kpi-(MD*-MD0)| [GeV] < %f\n",fDstarCuts[1]);
1235 printf(" pTpisoft [GeV/c] > %f\n",fDstarCuts[2]);
1236 printf(" pTpisoft [GeV/c] < %f\n",fDstarCuts[3]);
1237 printf(" Theta(pisoft,D0plane) < %f\n",fDstarCuts[4]);
1238 printf("Reconstruct D*->D0pi candidates with cuts:\n");
1239 printf(" D0 from D* cuts:\n");
1240 printf(" |M-MD0| [GeV] < %f\n",fD0fromDstarCuts[0]);
1241 printf(" dca [cm] < %f\n",fD0fromDstarCuts[1]);
1242 printf(" cosThetaStar < %f\n",fD0fromDstarCuts[2]);
1243 printf(" pTK [GeV/c] > %f\n",fD0fromDstarCuts[3]);
1244 printf(" pTpi [GeV/c] > %f\n",fD0fromDstarCuts[4]);
1245 printf(" |d0K| [cm] < %f\n",fD0fromDstarCuts[5]);
1246 printf(" |d0pi| [cm] < %f\n",fD0fromDstarCuts[6]);
1247 printf(" d0d0 [cm^2] < %f\n",fD0fromDstarCuts[7]);
1248 printf(" cosThetaPoint > %f\n",fD0fromDstarCuts[8]);
1249 }
6a213b59 1250 if(fJPSItoEle) {
1251 printf("Reconstruct J/psi from B candidates with cuts:\n");
1252 printf(" |M-MJPSI| [GeV] < %f\n",fBtoJPSICuts[0]);
1253 printf(" dca [cm] < %f\n",fBtoJPSICuts[1]);
1254 printf(" cosThetaStar < %f\n",fBtoJPSICuts[2]);
1255 printf(" pTP [GeV/c] > %f\n",fBtoJPSICuts[3]);
1256 printf(" pTN [GeV/c] > %f\n",fBtoJPSICuts[4]);
1257 printf(" |d0P| [cm] < %f\n",fBtoJPSICuts[5]);
1258 printf(" |d0N| [cm] < %f\n",fBtoJPSICuts[6]);
1259 printf(" d0d0 [cm^2] < %f\n",fBtoJPSICuts[7]);
1260 printf(" cosThetaPoint > %f\n",fBtoJPSICuts[8]);
1261 }
1262 if(f3Prong) {
1263 printf("Reconstruct 3 prong candidates.\n");
4d5c9633 1264 printf(" D+->Kpipi cuts:\n");
6a213b59 1265 printf(" |M-MD+| [GeV] < %f\n",fDplusCuts[0]);
1266 printf(" pTK [GeV/c] > %f\n",fDplusCuts[1]);
1267 printf(" pTPi [GeV/c] > %f\n",fDplusCuts[2]);
1268 printf(" |d0K| [cm] > %f\n",fDplusCuts[3]);
1269 printf(" |d0Pi| [cm] > %f\n",fDplusCuts[4]);
1270 printf(" dist12 [cm] < %f\n",fDplusCuts[5]);
1271 printf(" sigmavert [cm] < %f\n",fDplusCuts[6]);
1272 printf(" dist prim-sec [cm] > %f\n",fDplusCuts[7]);
1273 printf(" pM=Max{pT1,pT2,pT3} [GeV/c] > %f\n",fDplusCuts[8]);
1274 printf(" cosThetaPoint > %f\n",fDplusCuts[9]);
1275 printf(" Sum d0^2 [cm^2] > %f\n",fDplusCuts[10]);
1276 printf(" dca cut [cm] < %f\n",fDplusCuts[11]);
4d5c9633 1277 printf(" Ds->KKpi cuts:\n");
1278 printf(" |M-MDs| [GeV] < %f\n",fDsCuts[0]);
81679460 1279 printf(" pTK [GeV/c] > %f\n",fDsCuts[1]);
1280 printf(" pTPi [GeV/c] > %f\n",fDsCuts[2]);
1281 printf(" |d0K| [cm] > %f\n",fDsCuts[3]);
1282 printf(" |d0Pi| [cm] > %f\n",fDsCuts[4]);
1283 printf(" dist12 [cm] < %f\n",fDsCuts[5]);
1284 printf(" sigmavert [cm] < %f\n",fDsCuts[6]);
1285 printf(" dist prim-sec [cm] > %f\n",fDsCuts[7]);
1286 printf(" pM=Max{pT1,pT2,pT3} [GeV/c] > %f\n",fDsCuts[8]);
1287 printf(" cosThetaPoint > %f\n",fDsCuts[9]);
1288 printf(" Sum d0^2 [cm^2] > %f\n",fDsCuts[10]);
1289 printf(" dca cut [cm] < %f\n",fDsCuts[11]);
1290 printf(" Inv. Mass phi/K0* [GeV] < %f\n",fDsCuts[12]);
6ea608bf 1291 printf(" Lc->pKpi cuts:\n");
1292 printf(" |M-MLc| [GeV] < %f\n",fLcCuts[0]);
81679460 1293 printf(" pTP [GeV/c] > %f\n",fLcCuts[1]);
1294 printf(" pTPi and pTK [GeV/c] > %f\n",fLcCuts[2]);
1295 printf(" |d0P| [cm] > %f\n",fLcCuts[3]);
1296 printf(" |d0Pi| and |d0K| [cm] > %f\n",fLcCuts[4]);
1297 printf(" dist12 [cm] < %f\n",fLcCuts[5]);
1298 printf(" sigmavert [cm] < %f\n",fLcCuts[6]);
1299 printf(" dist prim-sec [cm] > %f\n",fLcCuts[7]);
1300 printf(" pM=Max{pT1,pT2,pT3} [GeV/c] > %f\n",fLcCuts[8]);
1301 printf(" cosThetaPoint > %f\n",fLcCuts[9]);
1302 printf(" Sum d0^2 [cm^2] > %f\n",fLcCuts[10]);
1303 printf(" dca cut [cm] < %f\n",fLcCuts[11]);
6a213b59 1304 }
1305
1306 return;
1307}
1308//-----------------------------------------------------------------------------
dcb444c9 1309AliAODVertex* AliAnalysisVertexingHF::ReconstructSecondaryVertex(TObjArray *trkArray,
dcfa35b3 1310 Double_t &dispersion,Bool_t useTRefArray) const
dcb444c9 1311{
1312 // Secondary vertex reconstruction with AliVertexerTracks or AliKFParticle
1313
1314 AliESDVertex *vertexESD = 0;
1315 AliAODVertex *vertexAOD = 0;
1316
1317 if(!fSecVtxWithKF) { // AliVertexerTracks
1318
1319 AliVertexerTracks *vertexer = new AliVertexerTracks(fBzkG);
1320 vertexer->SetVtxStart(fV1);
1321 vertexESD = (AliESDVertex*)vertexer->VertexForSelectedESDTracks(trkArray);
1322 delete vertexer; vertexer=NULL;
1323
1324 if(!vertexESD) return vertexAOD;
1325
1326 if(vertexESD->GetNContributors()!=trkArray->GetEntriesFast()) {
1327 AliDebug(2,"vertexing failed");
1328 delete vertexESD; vertexESD=NULL;
1329 return vertexAOD;
1330 }
1331
1332 } else { // Kalman Filter vertexer (AliKFParticle)
1333
1334 AliKFParticle::SetField(fBzkG);
1335
a353d2e4 1336 AliKFVertex vertexKF;
dcb444c9 1337
1338 Int_t nTrks = trkArray->GetEntriesFast();
1339 for(Int_t i=0; i<nTrks; i++) {
1340 AliESDtrack *esdTrack = (AliESDtrack*)trkArray->At(i);
1341 AliKFParticle daughterKF(*esdTrack,211);
1342 vertexKF.AddDaughter(daughterKF);
1343 }
a353d2e4 1344 vertexESD = new AliESDVertex(vertexKF.Parameters(),
1345 vertexKF.CovarianceMatrix(),
1346 vertexKF.GetChi2(),
1347 vertexKF.GetNContributors());
dcb444c9 1348
1349 }
1350
1351 // convert to AliAODVertex
1352 Double_t pos[3],cov[6],chi2perNDF;
1353 vertexESD->GetXYZ(pos); // position
1354 vertexESD->GetCovMatrix(cov); //covariance matrix
1355 chi2perNDF = vertexESD->GetChi2toNDF();
1356 dispersion = vertexESD->GetDispersion();
1357 delete vertexESD; vertexESD=NULL;
1358
dcfa35b3 1359 Int_t nprongs= (useTRefArray ? 0 : trkArray->GetEntriesFast());
1360 vertexAOD = new AliAODVertex(pos,cov,chi2perNDF,0x0,-1,AliAODVertex::kUndef,nprongs);
dcb444c9 1361
1362 return vertexAOD;
1363}
1364//-----------------------------------------------------------------------------
6a213b59 1365Bool_t AliAnalysisVertexingHF::SelectInvMass(Int_t decay,
1366 Int_t nprongs,
1367 Double_t *px,
1368 Double_t *py,
1369 Double_t *pz) const {
1370 // Check invariant mass cut
1371
1372 Short_t dummycharge=0;
1373 Double_t *dummyd0 = new Double_t[nprongs];
b056c5e3 1374 for(Int_t ip=0;ip<nprongs;ip++) dummyd0[ip]=0.;
6a213b59 1375 AliAODRecoDecay *rd = new AliAODRecoDecay(0x0,nprongs,dummycharge,px,py,pz,dummyd0);
b6e66d86 1376 delete [] dummyd0; dummyd0=NULL;
6a213b59 1377
721c0b8f 1378 UInt_t pdg2[2],pdg3[3],pdg4[4];
6a213b59 1379 Double_t mPDG,minv;
1380
1381 Bool_t retval=kFALSE;
1382 switch (decay)
1383 {
1384 case 0: // D0->Kpi
1385 pdg2[0]=211; pdg2[1]=321;
1386 mPDG=TDatabasePDG::Instance()->GetParticle(421)->Mass();
1387 minv = rd->InvMass(nprongs,pdg2);
1388 if(TMath::Abs(minv-mPDG)<fD0toKpiCuts[0]) retval=kTRUE;
1389 pdg2[0]=321; pdg2[1]=211;
1390 minv = rd->InvMass(nprongs,pdg2);
1391 if(TMath::Abs(minv-mPDG)<fD0toKpiCuts[0]) retval=kTRUE;
1392 break;
1393 case 1: // JPSI->ee
1394 pdg2[0]=11; pdg2[1]=11;
1395 mPDG=TDatabasePDG::Instance()->GetParticle(443)->Mass();
1396 minv = rd->InvMass(nprongs,pdg2);
1397 if(TMath::Abs(minv-mPDG)<fBtoJPSICuts[0]) retval=kTRUE;
1398 break;
1399 case 2: // D+->Kpipi
1400 pdg3[0]=211; pdg3[1]=321; pdg3[2]=211;
1401 mPDG=TDatabasePDG::Instance()->GetParticle(411)->Mass();
1402 minv = rd->InvMass(nprongs,pdg3);
1403 if(TMath::Abs(minv-mPDG)<fDplusCuts[0]) retval=kTRUE;
b82f6d67 1404 // Ds+->KKpi
1405 pdg3[0]=321; pdg3[1]=321; pdg3[2]=211;
1406 mPDG=TDatabasePDG::Instance()->GetParticle(431)->Mass();
1407 minv = rd->InvMass(nprongs,pdg3);
1408 if(TMath::Abs(minv-mPDG)<fDsCuts[0]) retval=kTRUE;
1409 pdg3[0]=211; pdg3[1]=321; pdg3[2]=321;
1410 minv = rd->InvMass(nprongs,pdg3);
1411 if(TMath::Abs(minv-mPDG)<fDsCuts[0]) retval=kTRUE;
1412 // Lc->pKpi
1413 pdg3[0]=2212; pdg3[1]=321; pdg3[2]=211;
1414 mPDG=TDatabasePDG::Instance()->GetParticle(4122)->Mass();
1415 minv = rd->InvMass(nprongs,pdg3);
1416 if(TMath::Abs(minv-mPDG)<fLcCuts[0]) retval=kTRUE;
1417 pdg3[0]=211; pdg3[1]=321; pdg3[2]=2212;
1418 minv = rd->InvMass(nprongs,pdg3);
1419 if(TMath::Abs(minv-mPDG)<fLcCuts[0]) retval=kTRUE;
6a213b59 1420 break;
2ff20727 1421 case 3: // D*->D0pi
1422 pdg2[0]=421; pdg2[1]=211;
1423 mPDG=TDatabasePDG::Instance()->GetParticle(413)->Mass();
1424 minv = rd->InvMass(nprongs,pdg2);
1425 if(TMath::Abs(minv-mPDG)<fDstarCuts[0]) retval=kTRUE;
1426 break;
721c0b8f 1427 case 4: // D0->K3pi without PID
1428 pdg4[0]=321; pdg4[1]=211; pdg4[2]=211; pdg4[3]=211;
1429 mPDG=TDatabasePDG::Instance()->GetParticle(421)->Mass();
1430 minv = rd->InvMass(nprongs,pdg4);
1431 if(TMath::Abs(minv-mPDG)<fD0to4ProngsCuts[0])
1432 retval=kTRUE;
1433 pdg4[0]=211; pdg4[1]=321; 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]) retval=kTRUE;
1437 pdg4[0]=211; pdg4[1]=211; pdg4[2]=321; pdg4[3]=211;
1438 mPDG=TDatabasePDG::Instance()->GetParticle(421)->Mass();
1439 minv = rd->InvMass(nprongs,pdg4);
1440 if(TMath::Abs(minv-mPDG)<fD0to4ProngsCuts[0]) retval=kTRUE;
1441 pdg4[0]=211; pdg4[1]=211; pdg4[2]=211; pdg4[3]=321;
1442 mPDG=TDatabasePDG::Instance()->GetParticle(421)->Mass();
1443 minv = rd->InvMass(nprongs,pdg4);
1444 if(TMath::Abs(minv-mPDG)<fD0to4ProngsCuts[0]) retval=kTRUE;
1445 break;
6a213b59 1446 default:
2ff20727 1447 printf("SelectInvMass(): wrong decay selection\n");
6a213b59 1448 break;
1449 }
1450
b6e66d86 1451 delete rd; rd=NULL;
6a213b59 1452
1453 return retval;
1454}
1455//-----------------------------------------------------------------------------
dcb444c9 1456void AliAnalysisVertexingHF::SelectTracksAndCopyVertex(AliVEvent *event,
2ff20727 1457 TObjArray &seleTrksArray,Int_t &nSeleTrks,
1458 UChar_t *seleFlags)
6a213b59 1459{
2ff20727 1460 // Apply single-track preselection.
1461 // Fill a TObjArray with selected tracks (for displaced vertices or
1462 // soft pion from D*). Selection flag stored in seleFlags.
dcb444c9 1463 // Create the AliESDVertex object (convert from AliAODVertex if necessary)
1464 // In case of AOD input, also fill fAODMap for track index<->ID
1465
1466 const AliVVertex *vprimary = event->GetPrimaryVertex();
1467
1468 if(fV1) { delete fV1; fV1=NULL; }
1469 if(fAODMap) { delete [] fAODMap; fAODMap=NULL; }
1470
1471 Int_t nindices=0;
1472 UShort_t *indices = 0;
1473 Double_t pos[3],cov[6];
1474
1475 if(!fInputAOD) { // ESD
1476 fV1 = new AliESDVertex(*((AliESDVertex*)vprimary));
1477 } else { // AOD
1478 vprimary->GetXYZ(pos);
1479 vprimary->GetCovarianceMatrix(cov);
1480 fV1 = new AliESDVertex(pos,cov,100.,100,vprimary->GetName());
1481 indices = new UShort_t[event->GetNumberOfTracks()];
1482 fAODMap = new Int_t[100000];
1483 }
1484
1485
dcb444c9 1486 Int_t entries = (Int_t)event->GetNumberOfTracks();
2ff20727 1487 Bool_t okDisplaced=kFALSE,okSoftPi=kFALSE;
1488 nSeleTrks=0;
6a213b59 1489
dcb444c9 1490 // transfer ITS tracks from event to arrays
6a213b59 1491 for(Int_t i=0; i<entries; i++) {
dcb444c9 1492 AliVTrack *track = (AliVTrack*)event->GetTrack(i);
1493
65dad444 1494 // TEMPORARY: check that the cov matrix is there
b6e66d86 1495 Double_t cov[21];
1496 if(!track->GetCovarianceXYZPxPyPz(cov)) continue;
65dad444 1497
dcb444c9 1498 if(fInputAOD) {
1499 AliAODTrack *aodt = (AliAODTrack*)track;
1500 if(aodt->GetUsedForPrimVtxFit()) {
1501 indices[nindices]=aodt->GetID(); nindices++;
1502 }
1503 fAODMap[(Int_t)aodt->GetID()] = i;
1504 }
6a213b59 1505
dcb444c9 1506 AliESDtrack *esdt = 0;
b6e66d86 1507
dcb444c9 1508 if(!fInputAOD) {
1509 esdt = (AliESDtrack*)track;
1510 } else {
1511 esdt = new AliESDtrack(track);
1512 }
6a213b59 1513
1514 // single track selection
2ff20727 1515 okDisplaced=kFALSE; okSoftPi=kFALSE;
1516 if(SingleTrkCuts(esdt,okDisplaced,okSoftPi)) {
1517 seleTrksArray.AddLast(esdt);
1518 seleFlags[nSeleTrks]=0;
1519 if(okDisplaced) SETBIT(seleFlags[nSeleTrks],kBitDispl);
1520 if(okSoftPi) SETBIT(seleFlags[nSeleTrks],kBitSoftPi);
1521 nSeleTrks++;
1522 } else {
dcb444c9 1523 if(fInputAOD) delete esdt;
1524 esdt = NULL;
1525 continue;
2ff20727 1526 }
6a213b59 1527
dcb444c9 1528 } // end loop on tracks
1529
1530 // primary vertex from AOD
1531 if(fInputAOD) {
1532 delete fV1; fV1=NULL;
1533 vprimary->GetXYZ(pos);
1534 vprimary->GetCovarianceMatrix(cov);
1535 Double_t chi2toNDF = vprimary->GetChi2perNDF();
1536 Int_t ncontr=nindices;
a6e0ebfe 1537 if(!strcmp(vprimary->GetTitle(),"VertexerTracksWithContraint")) ncontr += 1;
dcb444c9 1538 Double_t chi2=chi2toNDF*(2.*(Double_t)ncontr-3.);
1539 fV1 = new AliESDVertex(pos,cov,chi2,ncontr,vprimary->GetName());
1540 fV1->SetTitle(vprimary->GetTitle());
1541 fV1->SetIndices(nindices,indices);
1542 }
1543 if(indices) { delete [] indices; indices=NULL; }
1544
6a213b59 1545
1546 return;
1547}
1548//-----------------------------------------------------------------------------
1549void AliAnalysisVertexingHF::SetD0toKpiCuts(Double_t cut0,Double_t cut1,
1550 Double_t cut2,Double_t cut3,Double_t cut4,
1551 Double_t cut5,Double_t cut6,
1552 Double_t cut7,Double_t cut8)
1553{
1554 // Set the cuts for D0 selection
1555 fD0toKpiCuts[0] = cut0;
1556 fD0toKpiCuts[1] = cut1;
1557 fD0toKpiCuts[2] = cut2;
1558 fD0toKpiCuts[3] = cut3;
1559 fD0toKpiCuts[4] = cut4;
1560 fD0toKpiCuts[5] = cut5;
1561 fD0toKpiCuts[6] = cut6;
1562 fD0toKpiCuts[7] = cut7;
1563 fD0toKpiCuts[8] = cut8;
1564
1565 return;
1566}
1567//-----------------------------------------------------------------------------
1568void AliAnalysisVertexingHF::SetD0toKpiCuts(const Double_t cuts[9])
1569{
1570 // Set the cuts for D0 selection
1571
1572 for(Int_t i=0; i<9; i++) fD0toKpiCuts[i] = cuts[i];
1573
1574 return;
1575}
1576//-----------------------------------------------------------------------------
2ff20727 1577void AliAnalysisVertexingHF::SetD0fromDstarCuts(Double_t cut0,Double_t cut1,
1578 Double_t cut2,Double_t cut3,Double_t cut4,
1579 Double_t cut5,Double_t cut6,
1580 Double_t cut7,Double_t cut8)
1581{
1582 // Set the cuts for D0 from D* selection
1583 fD0fromDstarCuts[0] = cut0;
1584 fD0fromDstarCuts[1] = cut1;
1585 fD0fromDstarCuts[2] = cut2;
1586 fD0fromDstarCuts[3] = cut3;
1587 fD0fromDstarCuts[4] = cut4;
1588 fD0fromDstarCuts[5] = cut5;
1589 fD0fromDstarCuts[6] = cut6;
1590 fD0fromDstarCuts[7] = cut7;
1591 fD0fromDstarCuts[8] = cut8;
1592
1593 return;
1594}
1595//-----------------------------------------------------------------------------
1596void AliAnalysisVertexingHF::SetD0fromDstarCuts(const Double_t cuts[9])
1597{
1598 // Set the cuts for D0 from D* selection
1599
1600 for(Int_t i=0; i<9; i++) fD0fromDstarCuts[i] = cuts[i];
1601
1602 return;
1603}
1604//-----------------------------------------------------------------------------
1605void AliAnalysisVertexingHF::SetDstarCuts(Double_t cut0,Double_t cut1,
1606 Double_t cut2,Double_t cut3,
1607 Double_t cut4)
1608{
1609 // Set the cuts for D* selection
1610 fDstarCuts[0] = cut0;
1611 fDstarCuts[1] = cut1;
1612 fDstarCuts[2] = cut2;
1613 fDstarCuts[3] = cut3;
1614 fDstarCuts[4] = cut4;
1615
1616 return;
1617}
1618//-----------------------------------------------------------------------------
1619void AliAnalysisVertexingHF::SetDstarCuts(const Double_t cuts[5])
1620{
1621 // Set the cuts for D* selection
1622
1623 for(Int_t i=0; i<5; i++) fDstarCuts[i] = cuts[i];
1624
1625 return;
1626}
1627//-----------------------------------------------------------------------------
6a213b59 1628void AliAnalysisVertexingHF::SetBtoJPSICuts(Double_t cut0,Double_t cut1,
1629 Double_t cut2,Double_t cut3,Double_t cut4,
1630 Double_t cut5,Double_t cut6,
1631 Double_t cut7,Double_t cut8)
1632{
1633 // Set the cuts for J/psi from B selection
1634 fBtoJPSICuts[0] = cut0;
1635 fBtoJPSICuts[1] = cut1;
1636 fBtoJPSICuts[2] = cut2;
1637 fBtoJPSICuts[3] = cut3;
1638 fBtoJPSICuts[4] = cut4;
1639 fBtoJPSICuts[5] = cut5;
1640 fBtoJPSICuts[6] = cut6;
1641 fBtoJPSICuts[7] = cut7;
1642 fBtoJPSICuts[8] = cut8;
1643
1644 return;
1645}
1646//-----------------------------------------------------------------------------
1647void AliAnalysisVertexingHF::SetBtoJPSICuts(const Double_t cuts[9])
1648{
1649 // Set the cuts for J/psi from B selection
1650
1651 for(Int_t i=0; i<9; i++) fBtoJPSICuts[i] = cuts[i];
1652
1653 return;
1654}
1655//-----------------------------------------------------------------------------
1656void AliAnalysisVertexingHF::SetDplusCuts(Double_t cut0,Double_t cut1,
1657 Double_t cut2,Double_t cut3,Double_t cut4,
1658 Double_t cut5,Double_t cut6,
1659 Double_t cut7,Double_t cut8,
1660 Double_t cut9,Double_t cut10,Double_t cut11)
1661{
1662 // Set the cuts for Dplus->Kpipi selection
1663 fDplusCuts[0] = cut0;
1664 fDplusCuts[1] = cut1;
1665 fDplusCuts[2] = cut2;
1666 fDplusCuts[3] = cut3;
1667 fDplusCuts[4] = cut4;
1668 fDplusCuts[5] = cut5;
1669 fDplusCuts[6] = cut6;
1670 fDplusCuts[7] = cut7;
1671 fDplusCuts[8] = cut8;
1672 fDplusCuts[9] = cut9;
1673 fDplusCuts[10] = cut10;
1674 fDplusCuts[11] = cut11;
1675
1676 return;
1677}
1678//-----------------------------------------------------------------------------
1679void AliAnalysisVertexingHF::SetDplusCuts(const Double_t cuts[12])
1680{
b82f6d67 1681 // Set the cuts for Dplus->Kpipi selection
6a213b59 1682
1683 for(Int_t i=0; i<12; i++) fDplusCuts[i] = cuts[i];
1684
1685 return;
1686}
1687//-----------------------------------------------------------------------------
6ea608bf 1688void AliAnalysisVertexingHF::SetDsCuts(Double_t cut0,Double_t cut1,
1689 Double_t cut2,Double_t cut3,Double_t cut4,
1690 Double_t cut5,Double_t cut6,
1691 Double_t cut7,Double_t cut8,
81679460 1692 Double_t cut9,Double_t cut10,
1693 Double_t cut11,Double_t cut12)
b82f6d67 1694{
1695 // Set the cuts for Ds->KKpi selection
1696 fDsCuts[0] = cut0;
6ea608bf 1697 fDsCuts[1] = cut1;
1698 fDsCuts[2] = cut2;
1699 fDsCuts[3] = cut3;
1700 fDsCuts[4] = cut4;
1701 fDsCuts[5] = cut5;
1702 fDsCuts[6] = cut6;
1703 fDsCuts[7] = cut7;
1704 fDsCuts[8] = cut8;
1705 fDsCuts[9] = cut9;
1706 fDsCuts[10] = cut10;
1707 fDsCuts[11] = cut11;
81679460 1708 fDsCuts[12] = cut12;
b82f6d67 1709
1710 return;
1711}
1712//-----------------------------------------------------------------------------
81679460 1713void AliAnalysisVertexingHF::SetDsCuts(const Double_t cuts[13])
b82f6d67 1714{
1715 // Set the cuts for Ds->KKpi selection
1716
81679460 1717 for(Int_t i=0; i<13; i++) fDsCuts[i] = cuts[i];
b82f6d67 1718
1719 return;
1720}
1721//-----------------------------------------------------------------------------
6ea608bf 1722void AliAnalysisVertexingHF::SetLcCuts(Double_t cut0,Double_t cut1,
1723 Double_t cut2,Double_t cut3,Double_t cut4,
1724 Double_t cut5,Double_t cut6,
1725 Double_t cut7,Double_t cut8,
1726 Double_t cut9,Double_t cut10,Double_t cut11)
b82f6d67 1727{
1728 // Set the cuts for Lc->pKpi selection
1729 fLcCuts[0] = cut0;
6ea608bf 1730 fLcCuts[1] = cut1;
1731 fLcCuts[2] = cut2;
1732 fLcCuts[3] = cut3;
1733 fLcCuts[4] = cut4;
1734 fLcCuts[5] = cut5;
1735 fLcCuts[6] = cut6;
1736 fLcCuts[7] = cut7;
1737 fLcCuts[8] = cut8;
1738 fLcCuts[9] = cut9;
1739 fLcCuts[10] = cut10;
1740 fLcCuts[11] = cut11;
b82f6d67 1741
1742 return;
1743}
1744//-----------------------------------------------------------------------------
6ea608bf 1745void AliAnalysisVertexingHF::SetLcCuts(const Double_t cuts[12])
b82f6d67 1746{
1747 // Set the cuts for Lc->pKpi selection
1748
6ea608bf 1749 for(Int_t i=0; i<12; i++) fLcCuts[i] = cuts[i];
b82f6d67 1750
1751 return;
1752}
1753//-----------------------------------------------------------------------------
721c0b8f 1754void AliAnalysisVertexingHF::SetD0to4ProngsCuts(Double_t cut0,Double_t cut1,
1755 Double_t cut2,Double_t cut3,Double_t cut4,
1756 Double_t cut5,Double_t cut6,
1757 Double_t cut7,Double_t cut8)
1758{
1759 // Set the cuts for D0->Kpipipi selection
1760
1761 fD0to4ProngsCuts[0] = cut0;
1762 fD0to4ProngsCuts[1] = cut1;
1763 fD0to4ProngsCuts[2] = cut2;
1764 fD0to4ProngsCuts[3] = cut3;
1765 fD0to4ProngsCuts[4] = cut4;
1766 fD0to4ProngsCuts[5] = cut5;
1767 fD0to4ProngsCuts[6] = cut6;
1768 fD0to4ProngsCuts[7] = cut7;
1769 fD0to4ProngsCuts[8] = cut8;
1770
1771 return;
1772}
1773//-----------------------------------------------------------------------------
1774void AliAnalysisVertexingHF::SetD0to4ProngsCuts(const Double_t cuts[9])
1775{
1776 // Set the cuts for D0->Kpipipi selection
1777
1778 for(Int_t i=0; i<9; i++) fD0to4ProngsCuts[i] = cuts[i];
1779
1780 return;
1781}
1782//-----------------------------------------------------------------------------
2ff20727 1783Bool_t AliAnalysisVertexingHF::SingleTrkCuts(AliESDtrack *trk,
1784 Bool_t &okDisplaced,Bool_t &okSoftPi) const
6a213b59 1785{
1786 // Check if track passes some kinematical cuts
6a213b59 1787
f8fa4595 1788 // this is needed to store the impact parameters
1789 trk->RelateToVertex(fV1,fBzkG,kVeryBig);
1790
2ff20727 1791 UInt_t selectInfo;
f8fa4595 1792 //
2ff20727 1793 // Track selection, displaced tracks
1794 selectInfo = 0;
f8fa4595 1795 if(fTrackFilter) {
1796 selectInfo = fTrackFilter->IsSelected(trk);
6a213b59 1797 }
2ff20727 1798 if(selectInfo) okDisplaced=kTRUE;
1799 // Track selection, soft pions
1800 selectInfo = 0;
1801 if(fDstar && fTrackFilterSoftPi) {
1802 selectInfo = fTrackFilterSoftPi->IsSelected(trk);
1803 }
1804 if(selectInfo) okSoftPi=kTRUE;
6a213b59 1805
2ff20727 1806 if(okDisplaced || okSoftPi) return kTRUE;
f8fa4595 1807
2ff20727 1808 return kFALSE;
6a213b59 1809}
1810//-----------------------------------------------------------------------------