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