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