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