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