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