]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGHF/vertexingHF/AliCFVertexingHFLctoV0bachelor.cxx
Updates in Lc->V0bachelor analysis (Annalisa)
[u/mrichter/AliRoot.git] / PWGHF / vertexingHF / AliCFVertexingHFLctoV0bachelor.cxx
CommitLineData
5cd139bc 1/**************************************************************************
2 * Copyright(c) 1998-2011, 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/* $Id$ */
17
18//-----------------------------------------------------------------------
19// Class for HF corrections as a function of many variables and steps
20// For Lc->V0+bachelor
21//
22// - Based on AliCFVertexingHFCascade -
23//
24// Contact : A.De Caro - decaro@sa.infn.it
25// Centro 'E.Fermi' - Rome (Italy)
26// INFN and University of Salerno (Italy)
27//
28//-----------------------------------------------------------------------
29
5cd139bc 30#include "TDatabasePDG.h"
a578b2da 31#include "TClonesArray.h"
5cd139bc 32#include "AliAODv0.h"
a578b2da 33#include "AliAODMCParticle.h"
34#include "AliAODRecoDecayHF.h"
35#include "AliAODRecoCascadeHF.h"
5cd139bc 36#include "AliCFTaskVertexingHF.h"
a578b2da 37#include "AliCFContainer.h"
38#include "AliCFVertexingHF.h"
39#include "AliCFVertexingHFLctoV0bachelor.h"
5cd139bc 40
41#include <Riostream.h>
42
43using std::cout;
44using std::endl;
45
46ClassImp(AliCFVertexingHFLctoV0bachelor)
47
48//_________________________________________
49AliCFVertexingHFLctoV0bachelor::AliCFVertexingHFLctoV0bachelor():
50fGenLcOption(0)
51{
52 // standard constructor
53}
54
55//_____________________________________
56AliCFVertexingHFLctoV0bachelor::AliCFVertexingHFLctoV0bachelor(TClonesArray *mcArray, UShort_t originDselection, Int_t lcDecay):
57AliCFVertexingHF(mcArray, originDselection),
58 fGenLcOption(lcDecay)
59{
60 // standard constructor
61
62 SetNProngs(3);
63 fPtAccCut=new Float_t[fProngs];
64 fEtaAccCut=new Float_t[fProngs];
65 for(Int_t iP=0; iP<fProngs; iP++){
66 fPtAccCut[iP]=0.1;
67 fEtaAccCut[iP]=0.9;
68 }
69
70}
71
72
73//_____________________________________
74AliCFVertexingHFLctoV0bachelor& AliCFVertexingHFLctoV0bachelor::operator=(const AliCFVertexingHFLctoV0bachelor& c)
75{
76 // operator =
77
78 if (this != &c) {
79 AliCFVertexingHF::operator=(c);
80 }
81
82 return *this;
83
84}
85
86//__________________________________________
87Bool_t AliCFVertexingHFLctoV0bachelor::SetRecoCandidateParam(AliAODRecoDecayHF *recoCand)
88{
89 // set the AliAODRecoDecay candidate
90
91 Bool_t bSignAssoc = kFALSE;
92
93 fRecoCandidate = recoCand;
94 if (!fRecoCandidate) {
95 AliError("fRecoCandidate not found, problem in assignement\n");
96 return bSignAssoc;
97 }
98
a578b2da 99 if (fRecoCandidate->GetPrimaryVtx()) AliDebug(4,"fReco Candidate has a pointer to PrimVtx\n");
5cd139bc 100
ff12b981 101 AliAODRecoCascadeHF* lcV0bachelor = dynamic_cast<AliAODRecoCascadeHF*>(fRecoCandidate);
102 if (!lcV0bachelor) {
103 AliDebug(2,"cascade doesn't exist, skipped!");
104 return bSignAssoc;
105 }
106
107 if (!lcV0bachelor->GetSecondaryVtx()) {
108 AliDebug(2,"No secondary vertex for cascade");
109 return bSignAssoc;
110 }
111
112 if (lcV0bachelor->GetNDaughters()!=2) {
113 AliDebug(2,Form("No 2 daughters for current cascade (nDaughters=%d)",lcV0bachelor->GetNDaughters()));
114 return bSignAssoc;
115 }
116
117 AliVTrack *cascTrk0 = dynamic_cast<AliVTrack*>(lcV0bachelor->GetDaughter(0));
118 AliVTrack *cascTrk1 = dynamic_cast<AliVTrack*>(lcV0bachelor->GetDaughter(1));
119 if (!cascTrk0 || !cascTrk1) {
120 AliDebug(2,"At least one of V0daughters doesn't exist");
121 return bSignAssoc;
122 }
123
124 AliAODv0 * v0part = dynamic_cast<AliAODv0*>(lcV0bachelor->Getv0());
125 AliAODTrack * bachPart = dynamic_cast<AliAODTrack*>(lcV0bachelor->GetBachelor());
126 if (!v0part || !bachPart) {
127 AliDebug(2,"No V0 or no bachelor for current cascade");
128 return bSignAssoc;
129 }
130
131 if (bachPart->GetID()<0) {
132 AliDebug(2,Form("Bachelor has negative ID %d",bachPart->GetID()));
133 return bSignAssoc;
134 }
135
136 if (!v0part->GetSecondaryVtx()) {
137 AliDebug(2,"No secondary vertex for V0 by cascade");
138 return bSignAssoc;
139 }
140
141 if (v0part->GetNDaughters()!=2) {
142 AliDebug(2,Form("No 2 daughters for V0 of current cascade (onTheFly=%d, nDaughters=%d)",v0part->GetOnFlyStatus(),v0part->GetNDaughters()));
143 return bSignAssoc;
144 }
145
146 AliVTrack *trk0 = dynamic_cast<AliVTrack*>(v0part->GetDaughter(0));
147 AliVTrack *trk1 = dynamic_cast<AliVTrack*>(v0part->GetDaughter(1));
148 if (!trk0 || !trk1) {
149 AliDebug(2,"At least one of V0daughters doesn't exist");
150 return bSignAssoc;
151 }
152
153 if (trk0->GetLabel()<0 || trk1->GetLabel()<0) {
154 AliDebug(2,Form("At least one of V0daughters has label negative (%d %d)",trk0->GetLabel(),trk1->GetLabel()));
155 return bSignAssoc;
156 }
157
158 if (trk0->GetID()<0 || trk1->GetID()<0) {
159 AliDebug(2,Form("At least one of V0 daughters has negative ID %d %d",trk0->GetID(),trk1->GetID()));
a578b2da 160 return bSignAssoc;
161 }
5cd139bc 162
5cd139bc 163 Int_t pdgCand = 4122;
164 Int_t mcLabel = -1;
165 Int_t mcLabelK0S = -1;
166 Int_t mcLabelLambda = -1;
167
168 // Lc->K0S+p and cc
a578b2da 169 Int_t pdgDgLctoV0bachelor[2]={2212,310}; // first bachelor, second V0
5cd139bc 170 Int_t pdgDgV0toDaughters[2]={211,211};
a578b2da 171 mcLabelK0S = lcV0bachelor->MatchToMC(pdgCand,pdgDgLctoV0bachelor[1],pdgDgLctoV0bachelor,pdgDgV0toDaughters,fmcArray,kTRUE);
172
5cd139bc 173 // Lc->Lambda+pi and cc
a578b2da 174 pdgDgLctoV0bachelor[0]=211, pdgDgLctoV0bachelor[1]=3122; // first bachelor, second V0
5cd139bc 175 pdgDgV0toDaughters[0]=2212, pdgDgV0toDaughters[1]=211;
a578b2da 176 mcLabelLambda = lcV0bachelor->MatchToMC(pdgCand,pdgDgLctoV0bachelor[1],pdgDgLctoV0bachelor,pdgDgV0toDaughters,fmcArray,kTRUE);
5cd139bc 177
178 if (mcLabelK0S!=-1 && mcLabelLambda!=-1)
a578b2da 179 AliDebug(2,"Strange: current Lc->V0+bachelor candidate has two MC different labels!");
5cd139bc 180
ff12b981 181 if (fGenLcOption==kCountK0Sp) {
5cd139bc 182 if (mcLabelK0S!=-1) mcLabel=mcLabelK0S;
183 if (mcLabelLambda!=-1) {
184 mcLabel=-1;
185 fFake = 0; // fake candidate
186 if (fFakeSelection==1) return bSignAssoc;
187 }
188 }
189 else if (fGenLcOption==kCountLambdapi) {
190 if (mcLabelLambda!=-1) mcLabel=mcLabelLambda;
191 if (mcLabelK0S!=-1) {
192 mcLabel=-1;
193 fFake = 0; // fake candidate
194 if (fFakeSelection==1) return bSignAssoc;
195 }
196 }
197
a578b2da 198 if (mcLabel==-1) {
199 AliDebug(4,"No mcLabel found for current candidate");
200 return bSignAssoc;
201 }
202 AliDebug(1,Form("Found mcLabel (%d) for current candidate",mcLabel));
5cd139bc 203
204 if (fRecoCandidate->NumberOfFakeDaughters()>0){
205 fFake = 0; // fake candidate
206 if (fFakeSelection==1) return bSignAssoc;
207 }
208 if (fRecoCandidate->NumberOfFakeDaughters()==0){
209 fFake = 2; // non-fake candidate
210 if (fFakeSelection==2) return bSignAssoc;
211 }
212
a578b2da 213 SetMCLabel(mcLabel); // fmcLabel=mcLabel
5cd139bc 214 fmcPartCandidate = dynamic_cast<AliAODMCParticle*>(fmcArray->At(fmcLabel));
5cd139bc 215 if (!fmcPartCandidate){
a578b2da 216 AliDebug(3,"No MC object for current candidate");
5cd139bc 217 return bSignAssoc;
218 }
219
220 bSignAssoc = kTRUE;
221 return bSignAssoc;
a578b2da 222
5cd139bc 223}
224
225//______________________________________________
226Bool_t AliCFVertexingHFLctoV0bachelor::GetGeneratedValuesFromMCParticle(Double_t* vectorMC)
227{
228 //
229 // collecting all the necessary info (pt, y, invMassV0, cosPAwrtPVxV0, onTheFlyStatusV0) from MC particle
230 // (additional infos: pTbachelor, pTV0pos, pTV0neg, phi, dcaV0, cTV0, cT, cosPA)
231 //
232
233 Bool_t bGenValues = kFALSE;
234
a578b2da 235 if (fmcPartCandidate->GetNDaughters()!=2) {
236 AliDebug(2,"Lc MC particle doesn't decay in 2 daughters");
237 return bGenValues;
238 }
5cd139bc 239
240 Int_t daughter0lc = fmcPartCandidate->GetDaughter(0);
241 Int_t daughter1lc = fmcPartCandidate->GetDaughter(1);
ff12b981 242 if (daughter0lc<=0 || daughter1lc<=0) {
a578b2da 243 AliDebug(2,"Lc daughters are not in MC array");
5cd139bc 244 return bGenValues;
245 }
246
a578b2da 247 AliAODMCParticle* mcPartDaughter0 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter0lc));
248 AliAODMCParticle* mcPartDaughter1 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter1lc));
249 if (!mcPartDaughter0 || !mcPartDaughter1) {
250 AliDebug(2,"Problems in the MC Daughters\n");
5cd139bc 251 return bGenValues;
252 }
5cd139bc 253
a578b2da 254 if ( fGenLcOption==kCountLambdapi &&
255 !(TMath::Abs(mcPartDaughter0->GetPdgCode())==3122 &&
256 TMath::Abs(mcPartDaughter1->GetPdgCode())==211) &&
257 !(TMath::Abs(mcPartDaughter1->GetPdgCode())==3122 &&
258 TMath::Abs(mcPartDaughter0->GetPdgCode())==211) ) return bGenValues;
259 if ( fGenLcOption==kCountK0Sp &&
260 !(TMath::Abs(mcPartDaughter0->GetPdgCode())==2212 &&
261 TMath::Abs(mcPartDaughter1->GetPdgCode())==311) &&
262 !(TMath::Abs(mcPartDaughter1->GetPdgCode())==2212 &&
263 TMath::Abs(mcPartDaughter0->GetPdgCode())==311) ) return bGenValues;
264
265 if ( (TMath::Abs(mcPartDaughter0->GetPdgCode())==311 &&
266 TMath::Abs(mcPartDaughter1->GetPdgCode())==2212) ||
267 (TMath::Abs(mcPartDaughter0->GetPdgCode())==3122 &&
268 TMath::Abs(mcPartDaughter1->GetPdgCode())==211) )
269 bGenValues = FillVectorFromMCarray(mcPartDaughter1,mcPartDaughter0,vectorMC);
270 else if ( (TMath::Abs(mcPartDaughter1->GetPdgCode())==311 &&
271 TMath::Abs(mcPartDaughter0->GetPdgCode())==2212) ||
272 (TMath::Abs(mcPartDaughter1->GetPdgCode())==3122 &&
273 TMath::Abs(mcPartDaughter0->GetPdgCode())==211) )
274 bGenValues = FillVectorFromMCarray(mcPartDaughter0,mcPartDaughter1,vectorMC);
275
276 if (!bGenValues)
277 AliDebug(2,"There is something wrong in filling MC vector");
5cd139bc 278
5cd139bc 279 return bGenValues;
280
281}
a578b2da 282
5cd139bc 283//____________________________________________
284Bool_t AliCFVertexingHFLctoV0bachelor::GetRecoValuesFromCandidate(Double_t *vectorReco) const
285{
286 // read the variables for the container
287
288 Bool_t bFillRecoValues = kFALSE;
289
290 //Get the Lc and the V0 from Lc
ff12b981 291 AliAODRecoCascadeHF* lcV0bachelor = dynamic_cast<AliAODRecoCascadeHF*>(fRecoCandidate);
5cd139bc 292
ff12b981 293 if (!lcV0bachelor) {
294 AliDebug(2,"Current cascade doesn't exist, skipped");
295 return bFillRecoValues;
296 }
297
298 if (!lcV0bachelor->GetSecondaryVtx()) {
299 AliDebug(2,"No secondary vertex for cascade");
300 return bFillRecoValues;
301 }
302
303 if (lcV0bachelor->GetNDaughters()!=2) {
304 AliDebug(2,Form("No 2 daughters for current cascade (nDaughters=%d)",lcV0bachelor->GetNDaughters()));
305 return bFillRecoValues;
306 }
307
308 AliAODTrack* bachelor = dynamic_cast<AliAODTrack*>(lcV0bachelor->GetBachelor());
309 AliAODv0* v0toDaughters = dynamic_cast<AliAODv0*>(lcV0bachelor->Getv0());
310 if (!bachelor || !v0toDaughters) {
a578b2da 311 AliDebug(2,"No V0 or bachelor in this reco candidate, skipping!");
312 return bFillRecoValues;
313 }
314
ff12b981 315 if (!v0toDaughters->GetSecondaryVtx()) {
316 AliDebug(2,"No secondary vertex for V0 by cascade");
317 return bFillRecoValues;
318 }
319
320 if (v0toDaughters->GetNDaughters()!=2) {
321 AliDebug(2,Form("current V0 has not 2 daughters (onTheFly=%d, nDaughters=%d)",v0toDaughters->GetOnFlyStatus(),v0toDaughters->GetNDaughters()));
322 return bFillRecoValues;
323 }
324
5cd139bc 325 Bool_t onTheFlyStatus = v0toDaughters->GetOnFlyStatus();
ff12b981 326 AliAODTrack* v0positiveTrack;
327 AliAODTrack* v0negativeTrack;
328 if (onTheFlyStatus) {
329 v0positiveTrack = dynamic_cast<AliAODTrack*>(lcV0bachelor->Getv0NegativeTrack());
330 v0negativeTrack = dynamic_cast<AliAODTrack*>(lcV0bachelor->Getv0PositiveTrack());
331 } else {
332 v0positiveTrack = dynamic_cast<AliAODTrack*>(lcV0bachelor->Getv0PositiveTrack());
333 v0negativeTrack = dynamic_cast<AliAODTrack*>(lcV0bachelor->Getv0NegativeTrack());
334 }
335
a578b2da 336 if (!v0positiveTrack || !v0negativeTrack) {
337 AliDebug(2,"No V0daughters in this reco candidate, skipping!");
338 return bFillRecoValues;
339 }
5cd139bc 340
341 Double_t pt = lcV0bachelor->Pt();
342 Double_t rapidity = lcV0bachelor->Y(4122);
a578b2da 343
344 Double_t cosPAwrtPrimVtxV0 = lcV0bachelor->CosV0PointingAngle();
5cd139bc 345
346 Double_t pTbachelor = bachelor->Pt();
347 Double_t pTV0pos = v0positiveTrack->Pt();
348 Double_t pTV0neg = v0negativeTrack->Pt();
349 Double_t phi = lcV0bachelor->Phi();
350 Double_t dcaV0 = v0toDaughters->GetDCA();
351 Double_t cTLc = lcV0bachelor->Ct(4122); // wrt PrimVtx
352 //Double_t dcaLc = lcV0bachelor->GetDCA();
353 Double_t cosPointingAngleLc = lcV0bachelor->CosPointingAngle();
354
a578b2da 355 Double_t cTV0 = 0.;
356 AliAODVertex *vtx0 = (AliAODVertex*)lcV0bachelor->GetPrimaryVtx();
357 if (!vtx0) {
358 AliDebug(2,"Candidate has not primary vtx");
359 } else {
360 Double_t primVtxPos[3] = {0.,0.,0.}; vtx0->GetXYZ(primVtxPos);
361 if (fGenLcOption==kCountK0Sp) {
362 cTV0 = v0toDaughters->Ct(310,primVtxPos);
363 } else if (fGenLcOption==kCountLambdapi) {
364 cTV0 = v0toDaughters->Ct(3122,primVtxPos);
365 }
5cd139bc 366 }
367
a578b2da 368 Double_t invMassV0 = 0.;
5cd139bc 369 if (fGenLcOption==kCountLambdapi) {
a578b2da 370
371 Short_t bachelorCharge = bachelor->Charge();
5cd139bc 372 if (bachelorCharge==1) {
373 invMassV0 = v0toDaughters->MassLambda();
374 } else if (bachelorCharge==-1) {
375 invMassV0 = v0toDaughters->MassAntiLambda();
376 }
377
378 } else if (fGenLcOption==kCountK0Sp) {
a578b2da 379
5cd139bc 380 invMassV0 = v0toDaughters->MassK0Short();
a578b2da 381
5cd139bc 382 }
383
a578b2da 384 vectorReco[0] = pt;
385 vectorReco[1] = rapidity;
386 vectorReco[2] = phi;
387 vectorReco[3] = cosPAwrtPrimVtxV0;
388 vectorReco[4] = onTheFlyStatus;
389 vectorReco[5] = fCentValue;
390 vectorReco[6] = fFake; // whether the reconstructed candidate was a fake (fFake = 0) or not (fFake = 2)
391 vectorReco[7] = fMultiplicity;
5cd139bc 392
a578b2da 393 if (fConfiguration==AliCFTaskVertexingHF::kSnail) {
5cd139bc 394 vectorReco[8] = pTbachelor;
395 vectorReco[9] = pTV0pos;
396 vectorReco[10] = pTV0neg;
397 vectorReco[11] = invMassV0;
398 vectorReco[12] = dcaV0;
399 vectorReco[13] = cTV0*1.E4; // in micron
400 vectorReco[14] = cTLc*1.E4; // in micron
401 vectorReco[15] = cosPointingAngleLc;
5cd139bc 402 }
403
404 bFillRecoValues = kTRUE;
405
406 return bFillRecoValues;
407}
408
409//_____________________________________________________________
410Bool_t AliCFVertexingHFLctoV0bachelor::CheckMCChannelDecay() const
411{
412 // check the required decay channel
413
414 Bool_t checkCD = kFALSE;
415
a578b2da 416 if (fmcPartCandidate->GetNDaughters()!=2) {
417 AliDebug(2, Form("The MC particle doesn't decay in 2 particles, skipping!!"));
418 return checkCD;
419 }
5cd139bc 420
421 Int_t daughter0 = fmcPartCandidate->GetDaughter(0);
422 Int_t daughter1 = fmcPartCandidate->GetDaughter(1);
ff12b981 423 if (daughter0<=0 || daughter1<=0){
a578b2da 424 AliDebug(2, Form("The MC particle doesn't have correct daughters, skipping!!"));
425 return checkCD;
426 }
5cd139bc 427 AliAODMCParticle* mcPartDaughter0 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter0));
428 AliAODMCParticle* mcPartDaughter1 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter1));
5cd139bc 429 if (!mcPartDaughter0 || !mcPartDaughter1) {
a578b2da 430 AliDebug(2,"Problems in the MC Daughters\n");
5cd139bc 431 return checkCD;
432 }
433
434 // Lc -> Lambda + pion AND cc
435 if (fGenLcOption==kCountLambdapi) {
436
437 if (!(TMath::Abs(mcPartDaughter0->GetPdgCode())==3122 &&
438 TMath::Abs(mcPartDaughter1->GetPdgCode())==211) &&
a578b2da 439 !(TMath::Abs(mcPartDaughter0->GetPdgCode())==211 &&
5cd139bc 440 TMath::Abs(mcPartDaughter1->GetPdgCode())==3122)) {
441 AliDebug(2, "The Lc MC doesn't decay in Lambda+pion (or cc), skipping!!");
442 return checkCD;
5cd139bc 443 }
444
a578b2da 445 if (TMath::Abs(mcPartDaughter0->GetPdgCode())==3122) {
446 mcPartDaughter0 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter1)); // the bachelor
447 mcPartDaughter1 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter0)); // the V0
448 }
9e4f1968 449 if (!mcPartDaughter0 || !mcPartDaughter1) {
450 AliDebug(2,"Problems in the MC Daughters\n");
451 return checkCD;
452 }
a578b2da 453
454 if (mcPartDaughter1->GetNDaughters()!=2) {
455 AliDebug(2, "The Lambda MC particle doesn't decay in 2 particles, skipping!!");
456 return checkCD;
457 }
458
459 Int_t daughter1D0 = mcPartDaughter1->GetDaughter(0);
460 Int_t daughter1D1 = mcPartDaughter1->GetDaughter(1);
ff12b981 461 if (daughter1D0<=0 || daughter1D1<=0) {
a578b2da 462 AliDebug(2, Form("The Lambda MC particle doesn't have correct daughters, skipping!!"));
463 return checkCD;
464 }
5cd139bc 465
a578b2da 466 AliAODMCParticle* mcPartDaughter1D0 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter1D0));
467 AliAODMCParticle* mcPartDaughter1D1 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter1D1));
468 if(!mcPartDaughter1D0 || !mcPartDaughter1D1) {
469 AliError("The Lambda daughter particle not found in MC array");
470 return checkCD;
471 }
472
473 if (!(TMath::Abs(mcPartDaughter1D0->GetPdgCode())==211 &&
474 TMath::Abs(mcPartDaughter1D1->GetPdgCode())==2212) &&
475 !(TMath::Abs(mcPartDaughter1D0->GetPdgCode())==2212 &&
476 TMath::Abs(mcPartDaughter1D1->GetPdgCode())==211)) {
477 AliDebug(2, "The Lambda MC doesn't decay in pi+proton (or cc), skipping!!");
478 return checkCD;
479 }
480
481 } else if (fGenLcOption==kCountK0Sp) { // Lc -> K0bar + proton AND cc
482
483 if (!(TMath::Abs(mcPartDaughter0->GetPdgCode())==311 &&
5cd139bc 484 TMath::Abs(mcPartDaughter1->GetPdgCode())==2212) &&
a578b2da 485 !(TMath::Abs(mcPartDaughter0->GetPdgCode())==2212 &&
5cd139bc 486 TMath::Abs(mcPartDaughter1->GetPdgCode())==311)) {
487 AliDebug(2, "The Lc MC doesn't decay in K0+proton (or cc), skipping!!");
488 return checkCD;
489 }
490
491 if (TMath::Abs(mcPartDaughter0->GetPdgCode())==311) {
a578b2da 492 mcPartDaughter0 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter1)); // the bachelor
493 mcPartDaughter1 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter0)); // the V0
5cd139bc 494 }
e1603c28 495 if (!mcPartDaughter0 || !mcPartDaughter1) {
496 AliDebug(2,"Problems in the MC Daughters after swapping V0 and bachelor\n");
497 return checkCD;
498 }
5cd139bc 499
a578b2da 500 Int_t daughter = mcPartDaughter1->GetDaughter(0);
ff12b981 501 if (daughter<=0) {
a578b2da 502 AliDebug(2, Form("The K0/K0bar MC particle doesn't have correct daughter, skipping!!"));
503 return checkCD;
5cd139bc 504 }
505
a578b2da 506 AliAODMCParticle* mcPartDaughter = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter));
507 if(!mcPartDaughter){
508 AliError("The K0/K0bar daughter particle not found in MC array");
509 return checkCD;
5cd139bc 510 }
5cd139bc 511
a578b2da 512 if (!(TMath::Abs(mcPartDaughter->GetPdgCode())==310)) {
513 AliDebug(2, "The K0/K0bar MC doesn't go in K0S, skipping!!");
514 return checkCD;
5cd139bc 515 }
5cd139bc 516
a578b2da 517 if (mcPartDaughter->GetNDaughters()!=2) {
518 AliDebug(2, "The K0S MC doesn't decay in 2 particles, skipping!!");
519 return checkCD;
5cd139bc 520 }
5cd139bc 521
a578b2da 522 Int_t daughterD0 = mcPartDaughter->GetDaughter(0);
523 Int_t daughterD1 = mcPartDaughter->GetDaughter(1);
ff12b981 524 if (daughterD0<=0 || daughterD1<=0) {
a578b2da 525 AliDebug(2, Form("The K0S MC particle doesn't have correct daughters, skipping!!"));
526 return checkCD;
527 }
5cd139bc 528
a578b2da 529 AliAODMCParticle* mcPartDaughterD0 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughterD0));
530 AliAODMCParticle* mcPartDaughterD1 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughterD1));
531 if (!mcPartDaughterD0 || !mcPartDaughterD1) {
532 AliError("Daughter particle not found in MC array");
533 return checkCD;
5cd139bc 534 }
5cd139bc 535
a578b2da 536 if (! ( TMath::Abs(mcPartDaughterD0->GetPdgCode())==211 &&
537 TMath::Abs(mcPartDaughterD1->GetPdgCode())==211 ) ) {
538 AliDebug(2, "The K0S MC doesn't decay in pi+ pi-, skipping!!");
539 return checkCD;
540 }
5cd139bc 541
a578b2da 542 }
543
544 checkCD = kTRUE;
545 return checkCD;
546
547}
5cd139bc 548
549//_____________________________________________________________
550Double_t AliCFVertexingHFLctoV0bachelor::GetEtaProng(Int_t iProng) const
551{
552 //
553 // getting eta of the prong - overload the mother class method
554 //
555
a578b2da 556 Double_t etaProng =-9999;
5cd139bc 557
a578b2da 558 if (!fRecoCandidate) {
559 AliDebug(2,"No reco candidate selected");
560 return etaProng;
561 }
5cd139bc 562
a578b2da 563 AliAODRecoCascadeHF* lcV0bachelor = (AliAODRecoCascadeHF*)fRecoCandidate;
564 AliAODTrack* bachelor = (AliAODTrack*)lcV0bachelor->GetBachelor();
565 AliAODTrack* v0Pos = (AliAODTrack*)lcV0bachelor->Getv0PositiveTrack();
566 AliAODTrack* v0Neg = (AliAODTrack*)lcV0bachelor->Getv0NegativeTrack();
567 if (!(lcV0bachelor->Getv0()) || !bachelor || !v0Pos || !v0Neg) {
568 AliDebug(2,"No V0 for this reco candidate selected");
5cd139bc 569 return etaProng;
5cd139bc 570 }
a578b2da 571
572 if (iProng==0) etaProng = bachelor->Eta();
573 else if (iProng==1) etaProng = v0Pos->Eta();
574 else if (iProng==2) etaProng = v0Neg->Eta();
575
576 AliDebug(4,Form("Eta value for prong number %1d = %f",iProng,etaProng));
577
578 return etaProng;
579
5cd139bc 580}
581
582//_____________________________________________________________
583
584Double_t AliCFVertexingHFLctoV0bachelor::GetPtProng(Int_t iProng) const
585{
586 //
587 // getting pt of the prong
588 //
589
590 Double_t ptProng=-9999.;
591
a578b2da 592 if (!fRecoCandidate) {
593 AliDebug(2,"No reco candidate selected");
594 return ptProng;
595 }
5cd139bc 596
597 AliAODRecoCascadeHF* lcV0bachelor = (AliAODRecoCascadeHF*)fRecoCandidate;
a578b2da 598 AliAODTrack* bachelor = (AliAODTrack*)lcV0bachelor->GetBachelor();
599 AliAODTrack* v0Pos = (AliAODTrack*)lcV0bachelor->Getv0PositiveTrack();
600 AliAODTrack* v0Neg = (AliAODTrack*)lcV0bachelor->Getv0NegativeTrack();
601 if (!(lcV0bachelor->Getv0()) || !bachelor || !v0Pos || !v0Neg) {
602 AliDebug(2,"No V0 for this reco candidate selected");
603 return ptProng;
604 }
5cd139bc 605
a578b2da 606 if (iProng==0) ptProng = bachelor->Pt();
607 else if (iProng==1) ptProng = v0Pos->Pt();
608 else if (iProng==2) ptProng = v0Neg->Pt();
5cd139bc 609
a578b2da 610 AliDebug(4,Form("Pt value for prong number %1d = %f",iProng,ptProng));
611
5cd139bc 612 return ptProng;
613
614}
615
616//_____________________________________________________________
617
618Double_t AliCFVertexingHFLctoV0bachelor::Ctau(AliAODMCParticle *mcPartCandidate)
619{
620
621 Double_t cTau = 999999.;
622
a578b2da 623 Int_t daughterD0 = mcPartCandidate->GetDaughter(0);
624 Int_t daughterD1 = mcPartCandidate->GetDaughter(1);
ff12b981 625 if (daughterD0<=0 || daughterD1<=0) {
a578b2da 626 AliDebug(2, Form("The Lc MC particle doesn't have correct daughters, skipping!!"));
627 return cTau;
628 }
5cd139bc 629
ff12b981 630 AliAODMCParticle *mcPartDaughter0 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughterD0));
631 AliAODMCParticle *mcPartDaughter1 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughterD1));
a578b2da 632 if (!mcPartDaughter0 || !mcPartDaughter1) {
633 AliDebug(2,"The candidate daughter particles not found in MC array");
634 return cTau;
635 }
636
637 Double_t vtx1[3] = {0,0,0}; // primary vertex
638 Bool_t hasProdVertex = mcPartCandidate->XvYvZv(vtx1); // cm
639
5cd139bc 640 Double_t vtx1daughter[3] = {0,0,0}; // secondary vertex
a578b2da 641 Bool_t v0Vertex = mcPartDaughter0->XvYvZv(vtx1daughter); //cm
642 Double_t vtx2daughter[3] = {0,0,0}; // secondary vertex
643 Bool_t bachVertex = hasProdVertex && mcPartDaughter1->XvYvZv(vtx2daughter); //cm
5cd139bc 644
a578b2da 645 if (!hasProdVertex || !v0Vertex || !bachVertex) {
646 AliDebug(2,"At least one of Prim.vtx, V0vtx, BachelorVtx doesn't exist!");
647 return cTau;
648 }
649
650 if (TMath::Abs(vtx1daughter[0]-vtx2daughter[0])>1E-5 ||
651 TMath::Abs(vtx1daughter[1]-vtx2daughter[1])>1E-5 ||
652 TMath::Abs(vtx1daughter[2]-vtx2daughter[2])>1E-5) {
653 AliDebug(2,"Bachelor and V0 haven't common vtx!");
654 return cTau;
655 }
5cd139bc 656
657 Double_t decayLength = 0.;
658 for (Int_t ii=0; ii<3; ii++) decayLength += (vtx1daughter[ii]-vtx1[ii])*(vtx1daughter[ii]-vtx1[ii]);
659 decayLength = TMath::Sqrt(decayLength);
660
661 cTau = decayLength * mcPartCandidate->M()/mcPartCandidate->P();
a578b2da 662
5cd139bc 663 AliDebug(2,Form(" cTau(4122)=%f",cTau));
a578b2da 664
5cd139bc 665 return cTau;
666
667}
a578b2da 668
669//------------
670Bool_t AliCFVertexingHFLctoV0bachelor::SetLabelArray()
671{
672 //
673 // setting the label arrays
674 //
675
676 Bool_t checkCD = kFALSE;
677
678 if (fmcPartCandidate->GetNDaughters()!=2) {
ff12b981 679 AliDebug(2, Form("The MC particle have %d daughters (not 2), skipping!!",fmcPartCandidate->GetNDaughters()));
680 fmcPartCandidate->Print();
a578b2da 681 return checkCD;
682 }
683
684 Int_t daughter0 = fmcPartCandidate->GetDaughter(0);
685 Int_t daughter1 = fmcPartCandidate->GetDaughter(1);
ff12b981 686 if (daughter0<=0 || daughter1<=0){
a578b2da 687 AliDebug(2, Form("The MC particle doesn't have correct daughters, skipping!!"));
688 return checkCD;
689 }
690
691 AliAODMCParticle* mcPartDaughter0 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter0));
692 AliAODMCParticle* mcPartDaughter1 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter1));
693 if (!mcPartDaughter0 || !mcPartDaughter1) {
694 AliDebug(2,"Problems in the MC Daughters\n");
695 return checkCD;
696 }
697
698
699 fLabelArray = new Int_t[fProngs];
700
701 if (fGenLcOption==kCountLambdapi) { // Lc -> Lambda + pion OR cc
702
703 if (!(TMath::Abs(mcPartDaughter0->GetPdgCode())==3122 &&
704 TMath::Abs(mcPartDaughter1->GetPdgCode())==211) &&
705 !(TMath::Abs(mcPartDaughter0->GetPdgCode())==211 &&
706 TMath::Abs(mcPartDaughter1->GetPdgCode())==3122)) {
707 AliDebug(2, "The Lc MC doesn't decay in Lambda+pion (or cc), skipping!!");
708 delete [] fLabelArray;
709 fLabelArray = 0x0;
710 return checkCD;
711 }
712
713 // it is Lc -> Lambda + pion OR cc
714 if (TMath::Abs(mcPartDaughter0->GetPdgCode())==3122) {
715 mcPartDaughter0 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter1)); // the bachelor
716 mcPartDaughter1 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter0)); // the V0
717 Int_t daughterTemp = daughter0;
718 daughter0 = daughter1; // the bachelor label
719 daughter1 = daughterTemp; // the V0 label
720 }
721
722 if (mcPartDaughter1->GetNDaughters()!=2) {
723 AliDebug(2, "The Lambda MC particle doesn't decay in 2 particles, skipping!!");
724 delete [] fLabelArray;
725 fLabelArray = 0x0;
726 return checkCD;
727 }
728
729 Int_t daughter1D0 = mcPartDaughter1->GetDaughter(0);
730 Int_t daughter1D1 = mcPartDaughter1->GetDaughter(1);
ff12b981 731 if (daughter1D0<=0 || daughter1D1<=0) {
a578b2da 732 AliDebug(2, Form("The Lambda MC particle doesn't have correct daughters, skipping!!"));
733 delete [] fLabelArray;
734 fLabelArray = 0x0;
735 return checkCD;
736 }
737
738 AliAODMCParticle* mcPartDaughter1D0 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter1D0));
739 AliAODMCParticle* mcPartDaughter1D1 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter1D1));
740 if (!mcPartDaughter1D0 || !mcPartDaughter1D1) {
741 AliError("The Lambda daughter particles not found in MC array");
742 delete [] fLabelArray;
743 fLabelArray = 0x0;
744 return checkCD;
745 }
746
747 if (!(TMath::Abs(mcPartDaughter1D0->GetPdgCode())==211 &&
748 TMath::Abs(mcPartDaughter1D1->GetPdgCode())==2212) &&
749 !(TMath::Abs(mcPartDaughter1D0->GetPdgCode())==2212 &&
750 TMath::Abs(mcPartDaughter1D1->GetPdgCode())==211)) {
751 AliDebug(2, "The Lambda MC doesn't decay in pi+proton (or cc), skipping!!");
752 delete [] fLabelArray;
753 fLabelArray = 0x0;
754 return checkCD;
755 }
756
757 // Lambda -> p+pi OR cc
758
759 fLabelArray[0] = daughter0;//mcPartDaughter0->GetLabel(); // bachelor
760
761 if (fmcPartCandidate->Charge()>0) {
762
763 if (mcPartDaughter1D0->GetPdgCode()==2212) {
764 fLabelArray[1] = daughter1D0;//mcPartDaughter1D0->GetLabel(); // proton
765 fLabelArray[2] = daughter1D1;//mcPartDaughter1D1->GetLabel(); // pion
766 } else if (mcPartDaughter1D1->GetPdgCode()==2212) {
767 fLabelArray[1] = daughter1D1;//mcPartDaughter1D1->GetLabel(); // proton
768 fLabelArray[2] = daughter1D0;//mcPartDaughter1D0->GetLabel(); // pion
769 }
770
771 } else if (fmcPartCandidate->Charge()<0) {
772
773 if (mcPartDaughter1D0->GetPdgCode()==211) {
774 fLabelArray[1] = daughter1D0;//mcPartDaughter1D0->GetLabel(); // pion
775 fLabelArray[2] = daughter1D1;//mcPartDaughter1D1->GetLabel(); // proton
776 } else if (mcPartDaughter1D1->GetPdgCode()==211) {
777 fLabelArray[1] = daughter1D1;//mcPartDaughter1D1->GetLabel(); // pion
778 fLabelArray[2] = daughter1D0;//mcPartDaughter1D0->GetLabel(); // proton
779 }
780
781 }
782
783 } else if (fGenLcOption==kCountK0Sp) { // Lc -> K0bar + proton OR cc
784
785 if (!(TMath::Abs(mcPartDaughter0->GetPdgCode())==311 &&
786 TMath::Abs(mcPartDaughter1->GetPdgCode())==2212) &&
787 !(TMath::Abs(mcPartDaughter0->GetPdgCode())==2212 &&
788 TMath::Abs(mcPartDaughter1->GetPdgCode())==311)) {
789 AliDebug(2, "The Lc MC doesn't decay in K0bar+proton (or cc), skipping!!");
790 delete [] fLabelArray;
791 fLabelArray = 0x0;
792 return checkCD;
793 }
794
795 if (TMath::Abs(mcPartDaughter0->GetPdgCode())==311) {
796 mcPartDaughter0 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter1)); // the bachelor
797 mcPartDaughter1 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter0)); // the V0
798 Int_t daughterTemp = daughter0;
799 daughter0 = daughter1; // the bachelor label
800 daughter1 = daughterTemp; // the V0 label
801 }
802
ff12b981 803 if (mcPartDaughter1->GetNDaughters()!=1) {
804 AliDebug(2, "The K0/K0bar MC particle doesn't decay in 1 particles, skipping!!");
805 delete [] fLabelArray;
806 fLabelArray = 0x0;
807 return checkCD;
808 }
809
a578b2da 810 Int_t daughter = mcPartDaughter1->GetDaughter(0);
ff12b981 811 if (daughter<=0) {
a578b2da 812 AliDebug(2, Form("The K0/K0bar MC particle doesn't have correct daughter, skipping!!"));
813 delete [] fLabelArray;
814 fLabelArray = 0x0;
815 return checkCD;
816 }
817
818 AliAODMCParticle* mcPartDaughter = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter));
819 if (!mcPartDaughter) {
820 AliError("The K0/K0bar daughter particle not found in MC array");
821 delete [] fLabelArray;
822 fLabelArray = 0x0;
823 return checkCD;
824 }
825
826 if (!(TMath::Abs(mcPartDaughter->GetPdgCode())==310)) {
827 AliDebug(2, "The K0/K0bar MC doesn't go in K0S, skipping!!");
828 delete [] fLabelArray;
829 fLabelArray = 0x0;
830 return checkCD;
831 }
832
833 if (mcPartDaughter->GetNDaughters()!=2) {
834 AliDebug(2, "The K0S MC doesn't decay in 2 particles, skipping!!");
835 delete [] fLabelArray;
836 fLabelArray = 0x0;
837 return checkCD;
838 }
839
840 Int_t daughterD0 = mcPartDaughter->GetDaughter(0);
841 Int_t daughterD1 = mcPartDaughter->GetDaughter(1);
ff12b981 842 if (daughterD0<=0 || daughterD1<=0) {
a578b2da 843 AliDebug(2, Form("The K0S MC particle doesn't have correct daughters, skipping!!"));
844 delete [] fLabelArray;
845 fLabelArray = 0x0;
846 return checkCD;
847 }
848
849 AliAODMCParticle* mcPartDaughterD0 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughterD0));
850 AliAODMCParticle* mcPartDaughterD1 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughterD1));
851 if (!mcPartDaughterD0 || !mcPartDaughterD1) {
852 AliError("The K0S daughter particles not found in MC array");
853 delete [] fLabelArray;
854 fLabelArray = 0x0;
855 return checkCD;
856 }
857
858 if (! ( TMath::Abs(mcPartDaughterD0->GetPdgCode())==211 &&
859 TMath::Abs(mcPartDaughterD1->GetPdgCode())==211 ) ) {
860 AliDebug(2, "The K0S MC doesn't decay in pi+ pi-, skipping!!");
861 delete [] fLabelArray;
862 fLabelArray = 0x0;
863 return checkCD;
864 }
865
866 // K0S -> pi+ pi-
867
868 fLabelArray[0] = daughter0;//mcPartDaughter0->GetLabel(); // bachelor
869
870 if (mcPartDaughterD0->GetPdgCode()==211) {
871 fLabelArray[1] = daughterD0;//mcPartDaughterD0->GetLabel(); // pi+
872 fLabelArray[2] = daughterD1;//mcPartDaughterD1->GetLabel(); // pi-
873 AliDebug(2,Form(" daughter0=%d ------ daughter1=%d ------ dg0->GetLabel()=%d ------ dg1->GetLabel()=%d ",daughterD0,daughterD1,mcPartDaughterD0->GetLabel(),mcPartDaughterD1->GetLabel()));
874 } else if (mcPartDaughterD1->GetPdgCode()==211) {
875 fLabelArray[1] = daughterD1;//mcPartDaughterD1->GetLabel(); // pi+
876 fLabelArray[2] = daughterD0;//mcPartDaughterD0->GetLabel(); // pi-
877 AliDebug(2,Form(" daughter0=%d ------ daughter1=%d ------ dg0->GetLabel()=%d ------ dg1->GetLabel()=%d ",daughterD1,daughterD0,mcPartDaughterD1->GetLabel(),mcPartDaughterD0->GetLabel()));
878 }
879 }
880
881 AliDebug(2,Form(" label0=%d, label1=%d, label2=%d",fLabelArray[0],fLabelArray[1],fLabelArray[2]));
882
883 SetAccCut(); // setting the pt and eta acceptance cuts
884
885 checkCD = kTRUE;
886 return checkCD;
887
888}
889//____________________________________________
890Bool_t AliCFVertexingHFLctoV0bachelor::FillVectorFromMCarray(AliAODMCParticle *mcPartDaughterBachelor,
891 AliAODMCParticle *mcPartDaughterK0,
892 Double_t *vectorMC)
893{
894 // fill the vector
895
896 Bool_t bGenValues = kFALSE;
897
898 AliAODMCParticle *mcPartV0DaughterPos = dynamic_cast<AliAODMCParticle*>(fmcArray->At(fLabelArray[1]));
899 AliAODMCParticle *mcPartV0DaughterNeg = dynamic_cast<AliAODMCParticle*>(fmcArray->At(fLabelArray[2]));
900 AliAODMCParticle *mcPartDaughterV0 = 0x0;
901
902 if(!mcPartV0DaughterPos && !mcPartV0DaughterNeg) return bGenValues;
903
904 if (TMath::Abs(mcPartDaughterK0->GetPdgCode())==311) {
905 Int_t daughterK0 = mcPartDaughterK0->GetDaughter(0);
ff12b981 906 if (daughterK0<=0) {
a578b2da 907 AliDebug(2, Form("The K0/K0bar particle doesn't have correct daughter, skipping!!"));
908 return bGenValues;
909 }
910 mcPartDaughterV0 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughterK0));
911 if (!mcPartDaughterV0) {
912 AliDebug(2,"The K0/K0bar daughter particle not found in MC array");
913 return bGenValues;
914 }
915 if (TMath::Abs(mcPartDaughterV0->GetPdgCode())!=310) {
916 AliDebug(2,"The K0/K0bar daughter particle is not a K0S");
917 return bGenValues;
918 }
919 } else if (TMath::Abs(mcPartDaughterK0->GetPdgCode())==3122) {
920 mcPartDaughterV0 = dynamic_cast<AliAODMCParticle*>(mcPartDaughterK0);
921 if (!mcPartDaughterV0) {
922 AliDebug(2,"The Lambda particle not found in MC array");
923 return bGenValues;
924 }
925 }
926
9e4f1968 927 if (!mcPartDaughterV0) {
928 AliDebug(2,"V0 particle not found in MC array");
929 return bGenValues;
930 }
a578b2da 931
932 Double_t cTLc = Ctau(fmcPartCandidate); // by default wrt Primary Vtx
933 Double_t pTbach = mcPartDaughterBachelor->Pt(); // get the bachelor pT
934
935 Double_t vtx1[3] = {0,0,0}; // primary vertex
936 Bool_t hasPrimVtx = fmcPartCandidate->XvYvZv(vtx1); // cm
937
938 // getting vertex from daughters
939 Double_t vtx1daughter0[3] = {0,0,0}; // secondary vertex from daughter 0
940 Bool_t hasSecVtx1 = mcPartDaughterBachelor->XvYvZv(vtx1daughter0); //cm
941 Double_t vtx1daughter1[3] = {0,0,0}; // secondary vertex from daughter 1
942 Bool_t hasSecVtx2 = mcPartDaughterV0->XvYvZv(vtx1daughter1); //cm
943 if (!hasPrimVtx || !hasSecVtx1 || !hasSecVtx2) {
944 AliDebug(2,"At least one of Prim.vtx, V0vtx, BachelorVtx doesn't exist!");
945 //return bGenValues;
946 }
947
948 if (TMath::Abs(vtx1daughter0[0]-vtx1daughter1[0])>1E-5 ||
949 TMath::Abs(vtx1daughter0[1]-vtx1daughter1[1])>1E-5 ||
950 TMath::Abs(vtx1daughter0[2]-vtx1daughter1[2])>1E-5) {
951 AliError("Daughters have different secondary vertex, skipping the track");
952 //return bGenValues;
953 }
954
955 // getting the momentum from the daughters
956 Double_t px1[2] = {mcPartDaughterBachelor->Px(), mcPartDaughterV0->Px()};
957 Double_t py1[2] = {mcPartDaughterBachelor->Py(), mcPartDaughterV0->Py()};
958 Double_t pz1[2] = {mcPartDaughterBachelor->Pz(), mcPartDaughterV0->Pz()};
959
960 Int_t nprongs = 2;
961 Short_t charge = mcPartDaughterBachelor->Charge();
962 Double_t d0[2] = {0.,0.};
963 AliAODRecoDecayHF* decayLc = new AliAODRecoDecayHF(vtx1,vtx1daughter0,nprongs,charge,px1,py1,pz1,d0);
964 Double_t cosPAwrtPrimVtxLc = decayLc->CosPointingAngle();
965 delete decayLc;
966
967 // getting vertex from daughters
968 Double_t vtx2daughter0[3] = {0,0,0}; // secondary vertex from daughter 0
969 Bool_t hasSecVtx3 = mcPartV0DaughterPos->XvYvZv(vtx2daughter0); //cm
970 Double_t vtx2daughter1[3] = {0,0,0}; // secondary vertex from daughter 1
971 Bool_t hasSecVtx4 = mcPartV0DaughterNeg->XvYvZv(vtx2daughter1); //cm
972 if (!hasSecVtx3 || !hasSecVtx4) {
973 AliDebug(2,"At least one of V0Posvtx, V0Negtx doesn't exist!");
974 //return bGenValues;
975 }
976
977 if (TMath::Abs(vtx2daughter0[0]-vtx2daughter1[0])>1E-5 ||
978 TMath::Abs(vtx2daughter0[1]-vtx2daughter1[1])>1E-5 ||
979 TMath::Abs(vtx2daughter0[2]-vtx2daughter1[2])>1E-5) {
980 AliError("Daughters have different secondary vertex, skipping the track");
981 //return bGenValues;
982 }
983
984 // getting the momentum from the daughters
985 Double_t px[2] = {mcPartV0DaughterPos->Px(), mcPartV0DaughterNeg->Px()};
986 Double_t py[2] = {mcPartV0DaughterPos->Py(), mcPartV0DaughterNeg->Py()};
987 Double_t pz[2] = {mcPartV0DaughterPos->Pz(), mcPartV0DaughterNeg->Pz()};
988
989 nprongs = 2;
990 charge = 0;
991 AliAODRecoDecayHF* decay = new AliAODRecoDecayHF(vtx1,vtx2daughter0,nprongs,charge,px,py,pz,d0);
992 Double_t cosPAwrtPrimVtxV0 = decay->CosPointingAngle();
993 Double_t cTV0 = 0.; //ct
994 if (fGenLcOption==kCountK0Sp) {
995 cTV0 = decay->Ct(310); // by default wrt Primary Vtx
996 } else if (fGenLcOption==kCountLambdapi) {
997 cTV0 = decay->Ct(3122); // by default wrt Primary Vtx
998 }
999
1000 Double_t invMass = 0.; //invMass
1001 if (fGenLcOption==kCountK0Sp) {
1002 invMass = decay->InvMass2Prongs(0,1,211,211);
1003 } else if (fGenLcOption==kCountLambdapi) {
1004 if (fmcPartCandidate->GetPdgCode() == 4122)
1005 invMass = decay->InvMass2Prongs(0,1,2212,211);
1006 else if (fmcPartCandidate->GetPdgCode() ==-4122)
1007 invMass = decay->InvMass2Prongs(0,1,211,2212);
1008 }
1009 delete decay;
1010
1011 vectorMC[0] = fmcPartCandidate->Pt();
1012 vectorMC[1] = fmcPartCandidate->Y() ;
1013 vectorMC[2] = fmcPartCandidate->Phi();
1014 vectorMC[3] = cosPAwrtPrimVtxV0;
1015 vectorMC[4] = 0; // dummy value x MC, onTheFlyStatus
1016 vectorMC[5] = fCentValue; // reconstructed centrality
1017 vectorMC[6] = 1; // dummy value x MC, fFake
1018 vectorMC[7] = fMultiplicity; // reconstructed multiplicity
1019
1020 if (fConfiguration==AliCFTaskVertexingHF::kSnail) {
1021 vectorMC[8] = pTbach;
1022 vectorMC[9] = mcPartV0DaughterPos->Pt();
1023 vectorMC[10] = mcPartV0DaughterNeg->Pt();
1024 vectorMC[11] = invMass;
1025 vectorMC[12] = 0; // dummy value x MC, V0 DCA
1026 vectorMC[13] = cTV0*1.E4; // in micron
1027 vectorMC[14] = cTLc*1.E4; // in micron
1028 vectorMC[15] = cosPAwrtPrimVtxLc;
1029 }
1030
1031 bGenValues = kTRUE;
1032 return bGenValues;
1033
1034}