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