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