]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGHF/vertexingHF/AliCFVertexingHFLctoV0bachelor.cxx
Coverity
[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
30#include "AliAODRecoDecayHF2Prong.h"
31#include "AliAODMCParticle.h"
32#include "AliAODEvent.h"
33#include "TClonesArray.h"
34#include "AliCFVertexingHF.h"
35#include "AliESDtrack.h"
36#include "TDatabasePDG.h"
37#include "AliAODRecoCascadeHF.h"
38#include "AliAODv0.h"
39#include "AliCFVertexingHFLctoV0bachelor.h"
40#include "AliCFContainer.h"
41#include "AliCFTaskVertexingHF.h"
42
43#include <Riostream.h>
44
45using std::cout;
46using std::endl;
47
48ClassImp(AliCFVertexingHFLctoV0bachelor)
49
50//_________________________________________
51AliCFVertexingHFLctoV0bachelor::AliCFVertexingHFLctoV0bachelor():
52fGenLcOption(0)
53{
54 // standard constructor
55}
56
57//_____________________________________
58AliCFVertexingHFLctoV0bachelor::AliCFVertexingHFLctoV0bachelor(TClonesArray *mcArray, UShort_t originDselection, Int_t lcDecay):
59AliCFVertexingHF(mcArray, originDselection),
60 fGenLcOption(lcDecay)
61{
62 // standard constructor
63
64 SetNProngs(3);
65 fPtAccCut=new Float_t[fProngs];
66 fEtaAccCut=new Float_t[fProngs];
67 for(Int_t iP=0; iP<fProngs; iP++){
68 fPtAccCut[iP]=0.1;
69 fEtaAccCut[iP]=0.9;
70 }
71
72}
73
74
75//_____________________________________
76AliCFVertexingHFLctoV0bachelor& AliCFVertexingHFLctoV0bachelor::operator=(const AliCFVertexingHFLctoV0bachelor& c)
77{
78 // operator =
79
80 if (this != &c) {
81 AliCFVertexingHF::operator=(c);
82 }
83
84 return *this;
85
86}
87
88//__________________________________________
89Bool_t AliCFVertexingHFLctoV0bachelor::SetRecoCandidateParam(AliAODRecoDecayHF *recoCand)
90{
91 // set the AliAODRecoDecay candidate
92
93 Bool_t bSignAssoc = kFALSE;
94
95 fRecoCandidate = recoCand;
96 if (!fRecoCandidate) {
97 AliError("fRecoCandidate not found, problem in assignement\n");
98 return bSignAssoc;
99 }
100
101 if (fRecoCandidate->GetPrimaryVtx()) AliDebug(3,"fReco Candidate has a pointer to PrimVtx\n");
102
103 AliAODRecoCascadeHF* lcV0bachelor = (AliAODRecoCascadeHF*)fRecoCandidate;
104
105 if ( !(lcV0bachelor->Getv0()) ) return bSignAssoc;
106
107 Int_t nentries = fmcArray->GetEntriesFast();
108 AliDebug(3,Form("nentries = %d\n", nentries));
109
110 Int_t pdgCand = 4122;
111 Int_t mcLabel = -1;
112 Int_t mcLabelK0S = -1;
113 Int_t mcLabelLambda = -1;
114
115 // Lc->K0S+p and cc
116 Int_t pdgDgLctoV0bachelor[2]={310,2212};
117 Int_t pdgDgV0toDaughters[2]={211,211};
118 mcLabelK0S = lcV0bachelor->MatchToMC(pdgCand,pdgDgLctoV0bachelor[0],pdgDgLctoV0bachelor,pdgDgV0toDaughters,fmcArray,kTRUE);
119 // Lc->Lambda+pi and cc
120 pdgDgLctoV0bachelor[0]=3122, pdgDgLctoV0bachelor[1]=211;
121 pdgDgV0toDaughters[0]=2212, pdgDgV0toDaughters[1]=211;
122 mcLabelLambda = lcV0bachelor->MatchToMC(pdgCand,pdgDgLctoV0bachelor[0],pdgDgLctoV0bachelor,pdgDgV0toDaughters,fmcArray,kTRUE);
123
124 if (mcLabelK0S!=-1 && mcLabelLambda!=-1)
125 AliInfo("Strange: current Lc->V0+bachelor candidate has two MC different labels!");
126
127 if (fGenLcOption==kCountAllLctoV0) {
128 if (mcLabelK0S!=-1) mcLabel=mcLabelK0S;
129 if (mcLabelLambda!=-1) mcLabel=mcLabelLambda;
130 }
131 else if (fGenLcOption==kCountK0Sp) {
132 if (mcLabelK0S!=-1) mcLabel=mcLabelK0S;
133 if (mcLabelLambda!=-1) {
134 mcLabel=-1;
135 fFake = 0; // fake candidate
136 if (fFakeSelection==1) return bSignAssoc;
137 }
138 }
139 else if (fGenLcOption==kCountLambdapi) {
140 if (mcLabelLambda!=-1) mcLabel=mcLabelLambda;
141 if (mcLabelK0S!=-1) {
142 mcLabel=-1;
143 fFake = 0; // fake candidate
144 if (fFakeSelection==1) return bSignAssoc;
145 }
146 }
147
148 if (mcLabel==-1) return bSignAssoc;
149
150 if (fRecoCandidate->NumberOfFakeDaughters()>0){
151 fFake = 0; // fake candidate
152 if (fFakeSelection==1) return bSignAssoc;
153 }
154 if (fRecoCandidate->NumberOfFakeDaughters()==0){
155 fFake = 2; // non-fake candidate
156 if (fFakeSelection==2) return bSignAssoc;
157 }
158
159 SetMCLabel(mcLabel);
160 fmcPartCandidate = dynamic_cast<AliAODMCParticle*>(fmcArray->At(fmcLabel));
161
162 if (!fmcPartCandidate){
163 AliDebug(3,"No part candidate");
164 return bSignAssoc;
165 }
166
167 bSignAssoc = kTRUE;
168 return bSignAssoc;
169}
170
171//______________________________________________
172Bool_t AliCFVertexingHFLctoV0bachelor::GetGeneratedValuesFromMCParticle(Double_t* vectorMC)
173{
174 //
175 // collecting all the necessary info (pt, y, invMassV0, cosPAwrtPVxV0, onTheFlyStatusV0) from MC particle
176 // (additional infos: pTbachelor, pTV0pos, pTV0neg, phi, dcaV0, cTV0, cT, cosPA)
177 //
178
179 Bool_t bGenValues = kFALSE;
180
181 if (fmcPartCandidate->GetNDaughters()!=2) return bGenValues;
182
183 Int_t daughter0lc = fmcPartCandidate->GetDaughter(0);
184 Int_t daughter1lc = fmcPartCandidate->GetDaughter(1);
185
186 //the V0
187 AliAODMCParticle* mcPartDaughterV0=0;
188 if (fGenLcOption==kCountLambdapi) {
189 mcPartDaughterV0 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter0lc)); // strange baryon (0)
ea6f40e6 190 if(mcPartDaughterV0){
191 AliInfo(Form(" Case Lc->Lambda+pi: (V0) daughter0_Lc=%d (%d)",daughter0lc,mcPartDaughterV0->GetPdgCode()));
192 }
5cd139bc 193 }
194 else if (fGenLcOption==kCountK0Sp) {
195 AliAODMCParticle* mcPartDaughterK0 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter1lc)); // strange meson (1)
196 if (!mcPartDaughterK0) return bGenValues;
197 if (TMath::Abs(mcPartDaughterK0->GetPdgCode())!=311) return bGenValues;
198 Int_t daughterK0 = mcPartDaughterK0->GetDaughter(0);
199 mcPartDaughterV0 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughterK0));
ea6f40e6 200 if (!mcPartDaughterV0) return bGenValues;
5cd139bc 201 if (TMath::Abs(mcPartDaughterV0->GetPdgCode())!=310) return bGenValues;
202 AliInfo(Form(" Case Lc->K0S+p: (V0) daughter1_Lc=%d (%d to %d)",daughter1lc,mcPartDaughterK0->GetPdgCode(),
203 mcPartDaughterV0->GetPdgCode()));
204 }
205
206 //the bachelor
207 AliAODMCParticle* mcPartDaughterBachelor=0;
208 if (fGenLcOption==kCountLambdapi) {
209 mcPartDaughterBachelor = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter1lc)); // meson (1)
ea6f40e6 210 if(mcPartDaughterBachelor){
211 AliInfo(Form(" Case Lc->Lambda+pi: (bachelor) daughter1_Lc=%d (%d)",daughter1lc,mcPartDaughterBachelor->GetPdgCode()));
212 }
5cd139bc 213 }
214 if (fGenLcOption==kCountK0Sp) {
215 mcPartDaughterBachelor = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter0lc)); // baryon (0)
ea6f40e6 216 if(mcPartDaughterBachelor){
217 AliInfo(Form(" Case Lc->K0S+p: (bachelor) daughter0_Lc=%d (%d)",daughter0lc,mcPartDaughterBachelor->GetPdgCode()));
218 }
5cd139bc 219 }
220
221 if (!mcPartDaughterV0 || !mcPartDaughterBachelor) return bGenValues;
222
223 if (fGenLcOption==kCountLambdapi) {
224 if ( !(mcPartDaughterV0->GetPdgCode()==3122 &&
225 mcPartDaughterBachelor->GetPdgCode()==211) )
226 AliInfo("It isn't a Lc->Lambda+pion candidate");
227 }
228 if (fGenLcOption==kCountK0Sp) {
229 if ( !(mcPartDaughterV0->GetPdgCode()==310 &&
230 mcPartDaughterBachelor->GetPdgCode()==2212) )
231 AliInfo("It isn't a Lc->K0S+proton candidate");
232 }
233
234 Double_t vtx1[3] = {0,0,0}; // primary vertex
235 fmcPartCandidate->XvYvZv(vtx1); // cm
236
237 // getting vertex from daughters
238 Double_t vtx1daughter0[3] = {0,0,0}; // secondary vertex from daughter 0
239 Double_t vtx1daughter1[3] = {0,0,0}; // secondary vertex from daughter 1
240 mcPartDaughterBachelor->XvYvZv(vtx1daughter0); //cm
241 mcPartDaughterV0->XvYvZv(vtx1daughter1); //cm
242 if (TMath::Abs(vtx1daughter0[0]-vtx1daughter1[0])>1E-5 ||
243 TMath::Abs(vtx1daughter0[1]-vtx1daughter1[1])>1E-5 ||
244 TMath::Abs(vtx1daughter0[2]-vtx1daughter1[2])>1E-5) {
245 AliError("Daughters have different secondary vertex, skipping the track");
246 return bGenValues;
247 }
248
249 // getting the momentum from the daughters
250 Double_t px1[2] = {mcPartDaughterBachelor->Px(), mcPartDaughterV0->Px()};
251 Double_t py1[2] = {mcPartDaughterBachelor->Py(), mcPartDaughterV0->Py()};
252 Double_t pz1[2] = {mcPartDaughterBachelor->Pz(), mcPartDaughterV0->Pz()};
253
254 Int_t nprongs = 2;
255 Short_t charge = mcPartDaughterBachelor->Charge();
256 Double_t d0[2] = {0.,0.};
257 AliAODRecoDecayHF* decayLc = new AliAODRecoDecayHF(vtx1,vtx1daughter0,nprongs,charge,px1,py1,pz1,d0);
258 Double_t cosPAwrtPrimVtxLc = decayLc->CosPointingAngle();
259
260 //V0 daughters
261 Int_t daughter0 = mcPartDaughterV0->GetDaughter(0);
262 Int_t daughter1 = mcPartDaughterV0->GetDaughter(1);
263 AliAODMCParticle* mcPartDaughter0 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter0)); //V0daughter0
264 AliAODMCParticle* mcPartDaughter1 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter1)); //V0daughter1
265
266 if (!mcPartDaughter0 || !mcPartDaughter1) return kFALSE;
267
268 // getting vertex from daughters
269 Double_t vtx2daughter0[3] = {0,0,0}; // secondary vertex from daughter 0
270 Double_t vtx2daughter1[3] = {0,0,0}; // secondary vertex from daughter 1
271 mcPartDaughter0->XvYvZv(vtx2daughter0); //cm
272 mcPartDaughter1->XvYvZv(vtx2daughter1); //cm
273 if (TMath::Abs(vtx2daughter0[0]-vtx2daughter1[0])>1E-5 ||
274 TMath::Abs(vtx2daughter0[1]-vtx2daughter1[1])>1E-5 ||
275 TMath::Abs(vtx2daughter0[2]-vtx2daughter1[2])>1E-5) {
276 AliError("Daughters have different secondary vertex, skipping the track");
277 return bGenValues;
278 }
279
280 // always instantiate the AliAODRecoDecay with the positive daughter first, the negative second
281 AliAODMCParticle* positiveDaugh = mcPartDaughter0;
282 AliAODMCParticle* negativeDaugh = mcPartDaughter1;
283 if (mcPartDaughter0->GetPdgCode()<0 && mcPartDaughter1->GetPdgCode()>0){
284 // inverting in case the positive daughter is the second one
285 positiveDaugh = mcPartDaughter1;
286 negativeDaugh = mcPartDaughter0;
287 }
288 // getting the momentum from the daughters
289 Double_t px[2] = {positiveDaugh->Px(), negativeDaugh->Px()};
290 Double_t py[2] = {positiveDaugh->Py(), negativeDaugh->Py()};
291 Double_t pz[2] = {positiveDaugh->Pz(), negativeDaugh->Pz()};
292
293 nprongs = 2;
294 charge = 0;
295 AliAODRecoDecayHF* decay = new AliAODRecoDecayHF(vtx1,vtx2daughter0,nprongs,charge,px,py,pz,d0);
296 Double_t cosPAwrtPrimVtxV0 = decay->CosPointingAngle();
297
298 //ct
299 Double_t cTV0 = 0.;
300 if (fGenLcOption==kCountK0Sp) {
301 cTV0 = decay->Ct(310); // by default wrt Primary Vtx
302 } else if (fGenLcOption==kCountLambdapi) {
303 cTV0 = decay->Ct(3122); // by default wrt Primary Vtx
304 }
305
306 Double_t cTLc = Ctau(fmcPartCandidate); // by default wrt Primary Vtx
307
308 // get the bachelor pT
309 Double_t pTbach = 0.;
310
311 if (TMath::Abs(fmcPartCandidate->GetPdgCode()) == 4122)
312 pTbach = mcPartDaughterBachelor->Pt();
313
314 Double_t invMass = 0.;
315 if (fGenLcOption==kCountK0Sp) {
316 invMass = decay->InvMass2Prongs(0,1,211,211);
317 } else if (fGenLcOption==kCountLambdapi) {
318 if (fmcPartCandidate->GetPdgCode() == 4122)
319 invMass = decay->InvMass2Prongs(0,1,2212,211);
320 else if (fmcPartCandidate->GetPdgCode() ==-4122)
321 invMass = decay->InvMass2Prongs(0,1,211,2212);
322 }
323
324 switch (fConfiguration){
325 case AliCFTaskVertexingHF::kSnail:
326 vectorMC[0] = fmcPartCandidate->Pt();
327 vectorMC[1] = fmcPartCandidate->Y() ;
328 vectorMC[2] = fmcPartCandidate->Phi();
329 vectorMC[3] = cosPAwrtPrimVtxV0;
330 vectorMC[4] = 0; // dummy value x MC, onTheFlyStatus
331 vectorMC[5] = fCentValue; // reconstructed centrality
332 vectorMC[6] = 1; // dummy value x MC, fFake
333 vectorMC[7] = fMultiplicity; // reconstructed multiplicity
334
335 vectorMC[8] = pTbach;
336 vectorMC[9] = positiveDaugh->Pt();
337 vectorMC[10] = negativeDaugh->Pt();
338 vectorMC[11] = invMass;
339 vectorMC[12] = 0; // dummy value x MC, V0 DCA
340 vectorMC[13] = cTV0*1.E4; // in micron
341 vectorMC[14] = cTLc*1.E4; // in micron
342 vectorMC[15] = cosPAwrtPrimVtxLc;
343 break;
344 case AliCFTaskVertexingHF::kCheetah:
345 vectorMC[0] = fmcPartCandidate->Pt();
346 vectorMC[1] = fmcPartCandidate->Y() ;
347 vectorMC[2] = fmcPartCandidate->Phi();
348 vectorMC[3] = cosPAwrtPrimVtxV0;
349 vectorMC[4] = 0; // dummy value x MC, onTheFlyStatus
350 vectorMC[5] = fCentValue; // reconstructed centrality
351 vectorMC[6] = 1; // dummy value x MC, fFake
352 vectorMC[7] = fMultiplicity; // reconstructed multiplicity
353 break;
354 }
355
356 delete decay;
357 delete decayLc;
358
359 bGenValues = kTRUE;
360 return bGenValues;
361
362}
363//____________________________________________
364Bool_t AliCFVertexingHFLctoV0bachelor::GetRecoValuesFromCandidate(Double_t *vectorReco) const
365{
366 // read the variables for the container
367
368 Bool_t bFillRecoValues = kFALSE;
369
370 //Get the Lc and the V0 from Lc
371 AliAODRecoCascadeHF* lcV0bachelor = (AliAODRecoCascadeHF*)fRecoCandidate;
372
373 if ( !(lcV0bachelor->Getv0()) ) return bFillRecoValues;
374
375 AliAODVertex *vtx0 = (AliAODVertex*)lcV0bachelor->GetPrimaryVtx();
376 if (vtx0) AliDebug(1,"lcV0bachelor has primary vtx");
377
378 AliAODTrack* bachelor = (AliAODTrack*)lcV0bachelor->GetBachelor();
379 AliAODv0* v0toDaughters = (AliAODv0*)lcV0bachelor->Getv0();
380 Bool_t onTheFlyStatus = v0toDaughters->GetOnFlyStatus();
381 AliAODTrack* v0positiveTrack = (AliAODTrack*)lcV0bachelor->Getv0PositiveTrack();
382 AliAODTrack* v0negativeTrack = (AliAODTrack*)lcV0bachelor->Getv0NegativeTrack();
383
384 Double_t pt = lcV0bachelor->Pt();
385 Double_t rapidity = lcV0bachelor->Y(4122);
386 Double_t invMassV0 = 0.;
387 Double_t primVtxPos[3]; vtx0->GetXYZ(primVtxPos);
388 Double_t cosPAwrtPrimVtxV0 = v0toDaughters->CosPointingAngle(primVtxPos);
389 Double_t cTV0 = 0.;
390
391 Double_t pTbachelor = bachelor->Pt();
392 Double_t pTV0pos = v0positiveTrack->Pt();
393 Double_t pTV0neg = v0negativeTrack->Pt();
394 Double_t phi = lcV0bachelor->Phi();
395 Double_t dcaV0 = v0toDaughters->GetDCA();
396 Double_t cTLc = lcV0bachelor->Ct(4122); // wrt PrimVtx
397 //Double_t dcaLc = lcV0bachelor->GetDCA();
398 Double_t cosPointingAngleLc = lcV0bachelor->CosPointingAngle();
399
400 if (fGenLcOption==kCountK0Sp) {
401 cTV0 = v0toDaughters->Ct(310,primVtxPos);
402 } else if (fGenLcOption==kCountLambdapi) {
403 cTV0 = v0toDaughters->Ct(3122,primVtxPos);
404 }
405
406 Short_t bachelorCharge = bachelor->Charge();
407 if (fGenLcOption==kCountLambdapi) {
408 if (bachelorCharge==1) {
409 invMassV0 = v0toDaughters->MassLambda();
410 } else if (bachelorCharge==-1) {
411 invMassV0 = v0toDaughters->MassAntiLambda();
412 }
413
414 } else if (fGenLcOption==kCountK0Sp) {
415 invMassV0 = v0toDaughters->MassK0Short();
416 }
417
418 switch (fConfiguration){
419 case AliCFTaskVertexingHF::kSnail:
420 vectorReco[0] = pt;
421 vectorReco[1] = rapidity;
422 vectorReco[2] = phi;
423 vectorReco[3] = cosPAwrtPrimVtxV0;
424 vectorReco[4] = onTheFlyStatus;
425 vectorReco[5] = fCentValue;
426 vectorReco[6] = fFake; // whether the reconstructed candidate was a fake (fFake = 0) or not (fFake = 2)
427 vectorReco[7] = fMultiplicity;
428
429 vectorReco[8] = pTbachelor;
430 vectorReco[9] = pTV0pos;
431 vectorReco[10] = pTV0neg;
432 vectorReco[11] = invMassV0;
433 vectorReco[12] = dcaV0;
434 vectorReco[13] = cTV0*1.E4; // in micron
435 vectorReco[14] = cTLc*1.E4; // in micron
436 vectorReco[15] = cosPointingAngleLc;
437
438 break;
439 case AliCFTaskVertexingHF::kCheetah:
440 vectorReco[0] = pt;
441 vectorReco[1] = rapidity;
442 vectorReco[2] = phi;
443 vectorReco[3] = cosPAwrtPrimVtxV0;
444 vectorReco[4] = onTheFlyStatus;
445 vectorReco[5] = fCentValue;
446 vectorReco[6] = fFake; // whether the reconstructed candidate was a fake (fFake = 0) or not (fFake = 2)
447 vectorReco[7] = fMultiplicity;
448 break;
449 }
450
451 bFillRecoValues = kTRUE;
452
453 return bFillRecoValues;
454}
455
456//_____________________________________________________________
457Bool_t AliCFVertexingHFLctoV0bachelor::CheckMCChannelDecay() const
458{
459 // check the required decay channel
460
461 Bool_t checkCD = kFALSE;
462
463 if (fmcPartCandidate->GetNDaughters()!=2) return checkCD;
464
465 Int_t daughter0 = fmcPartCandidate->GetDaughter(0);
466 Int_t daughter1 = fmcPartCandidate->GetDaughter(1);
467 AliAODMCParticle* mcPartDaughter0 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter0));
468 AliAODMCParticle* mcPartDaughter1 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter1));
469
470 if (!mcPartDaughter0 || !mcPartDaughter1) {
471 AliDebug (2,"Problems in the MC Daughters\n");
472 return checkCD;
473 }
474
475 // Lc -> Lambda + pion AND cc
476 if (fGenLcOption==kCountLambdapi) {
477
478 if (!(TMath::Abs(mcPartDaughter0->GetPdgCode())==3122 &&
479 TMath::Abs(mcPartDaughter1->GetPdgCode())==211) &&
480 !(TMath::Abs(mcPartDaughter0->GetPdgCode())==211 &&
481 TMath::Abs(mcPartDaughter1->GetPdgCode())==3122)) {
482 AliDebug(2, "The Lc MC doesn't decay in Lambda+pion (or cc), skipping!!");
483 return checkCD;
484 } else if (TMath::Abs(mcPartDaughter0->GetPdgCode())==3122) {
485 if (mcPartDaughter0->GetNDaughters()!=2) return checkCD;
486 Int_t daughter0D0 = mcPartDaughter0->GetDaughter(0);
487 AliAODMCParticle* mcPartDaughter0D0 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter0D0));
ea6f40e6 488 if(!mcPartDaughter0D0){
489 AliError("Daughter particle not found in MC array");
490 return checkCD;
491 }
5cd139bc 492 Int_t daughter0D1 = mcPartDaughter0->GetDaughter(1);
493 AliAODMCParticle* mcPartDaughter0D1 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter0D1));
ea6f40e6 494 if(!mcPartDaughter0D1){
495 AliError("Daughter particle not found in MC array");
496 return checkCD;
497 }
5cd139bc 498 if (!(TMath::Abs(mcPartDaughter0D0->GetPdgCode())==211 &&
499 TMath::Abs(mcPartDaughter0D1->GetPdgCode())==2212) &&
500 !(TMath::Abs(mcPartDaughter0D0->GetPdgCode())==2212 &&
501 TMath::Abs(mcPartDaughter0D1->GetPdgCode())==211)) {
502 AliDebug(2, "The Lambda MC doesn't decay in pi+proton (or cc), skipping!!");
503 return checkCD;
504 }
505 } else if (TMath::Abs(mcPartDaughter1->GetPdgCode())==3122) {
506 if (mcPartDaughter1->GetNDaughters()!=2) return checkCD;
507 Int_t daughter1D0 = mcPartDaughter1->GetDaughter(0);
508 AliAODMCParticle* mcPartDaughter1D0 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter1D0));
ea6f40e6 509 if(!mcPartDaughter1D0){
510 AliError("Daughter particle not found in MC array");
511 return checkCD;
512 }
5cd139bc 513 Int_t daughter1D1 = mcPartDaughter1->GetDaughter(1);
514 AliAODMCParticle* mcPartDaughter1D1 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter1D1));
ea6f40e6 515 if(!mcPartDaughter1D1){
516 AliError("Daughter particle not found in MC array");
517 return checkCD;
518 }
5cd139bc 519 if (!(TMath::Abs(mcPartDaughter1D0->GetPdgCode())==211 &&
520 TMath::Abs(mcPartDaughter1D1->GetPdgCode())==2212) &&
521 !(TMath::Abs(mcPartDaughter1D0->GetPdgCode())==2212 &&
522 TMath::Abs(mcPartDaughter1D1->GetPdgCode())==211)) {
523 AliDebug(2, "The Lambda MC doesn't decay in pi+proton (or cc), skipping!!");
524 return checkCD;
525 }
526 }
527
528 } else if (fGenLcOption==kCountK0Sp) {
529 // Lc -> K0bar + proton AND cc
530
531 if (!(TMath::Abs(mcPartDaughter0->GetPdgCode())==311 &&
532 TMath::Abs(mcPartDaughter1->GetPdgCode())==2212) &&
533 !(TMath::Abs(mcPartDaughter0->GetPdgCode())==2212 &&
534 TMath::Abs(mcPartDaughter1->GetPdgCode())==311)) {
535 AliDebug(2, "The Lc MC doesn't decay in K0+proton (or cc), skipping!!");
536 return checkCD;
537 }
538
539 if (TMath::Abs(mcPartDaughter0->GetPdgCode())==311) {
540 Int_t daughter = mcPartDaughter0->GetDaughter(0);
541 AliAODMCParticle* mcPartDaughter = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter));
ea6f40e6 542 if(!mcPartDaughter){
543 AliError("Daughter particle not found in MC array");
544 return checkCD;
545 }
546
5cd139bc 547 if (!(TMath::Abs(mcPartDaughter->GetPdgCode())==310)) {
548 AliDebug(2, "The K0 (or K0bar) MC doesn't go in K0S, skipping!!");
549 return checkCD;
550 }
551 if (mcPartDaughter->GetNDaughters()!=2) return checkCD;
552 Int_t daughterD0 = mcPartDaughter->GetDaughter(0);
553 AliAODMCParticle* mcPartDaughterD0 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughterD0));
ea6f40e6 554 if(!mcPartDaughterD0){
555 AliError("Daughter particle not found in MC array");
556 return checkCD;
557 }
5cd139bc 558 Int_t daughterD1 = mcPartDaughter->GetDaughter(1);
559 AliAODMCParticle* mcPartDaughterD1 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughterD1));
ea6f40e6 560 if(!mcPartDaughterD1){
561 AliError("Daughter particle not found in MC array");
562 return checkCD;
563 }
5cd139bc 564 if (!(TMath::Abs(mcPartDaughterD0->GetPdgCode())==211 &&
565 TMath::Abs(mcPartDaughterD1->GetPdgCode())==211)) {
566 AliDebug(2, "The K0S MC doesn't decay in pi+pi, skipping!!");
567 return checkCD;
568 }
569
570 }
571
572 if (TMath::Abs(mcPartDaughter1->GetPdgCode())==311) {
573 Int_t daughter = mcPartDaughter1->GetDaughter(0);
574 AliAODMCParticle* mcPartDaughter = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter));
575 if (!(TMath::Abs(mcPartDaughter->GetPdgCode())==310)) {
576 AliDebug(2, "The K0 (or K0bar) MC doesn't go in K0S, skipping!!");
577 return checkCD;
578 }
579 if (mcPartDaughter->GetNDaughters()!=2) return checkCD;
580 Int_t daughterD0 = mcPartDaughter->GetDaughter(0);
581 AliAODMCParticle* mcPartDaughterD0 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughterD0));
582 Int_t daughterD1 = mcPartDaughter->GetDaughter(1);
583 AliAODMCParticle* mcPartDaughterD1 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughterD1));
584 if (! ( TMath::Abs(mcPartDaughterD0->GetPdgCode())==211 &&
585 TMath::Abs(mcPartDaughterD1->GetPdgCode())==211 ) ) {
586 AliDebug(2, "The K0S MC doesn't decay in pi+pi, skipping!!");
587 return checkCD;
588 }
589
590 }
591
592 }
593
594 checkCD = kTRUE;
595 return checkCD;
596
597}
598
599//___________________________________________________________
600
601void AliCFVertexingHFLctoV0bachelor::SetPtAccCut(Float_t* ptAccCut)
602{
603 //
604 // setting the pt cut to be used in the Acceptance steps (MC+Reco)
605 //
606
607 AliInfo("The 1st element of the pt cut array will correspond to the cut applied to the bachelor - please check that it is correct");
608 if (fProngs>0){
609 for (Int_t iP=0; iP<fProngs; iP++){
610 fPtAccCut[iP]=ptAccCut[iP];
611 }
612 }
613 return;
614}
615
616//___________________________________________________________
617
618void AliCFVertexingHFLctoV0bachelor::SetEtaAccCut(Float_t* etaAccCut)
619{
620 //
621 // setting the eta cut to be used in the Acceptance steps (MC+Reco)
622 //
623
624 AliInfo("The 1st element of the pt cut array will correspond to the cut applied to the bachelor - please check that it is correct");
625 if (fProngs>0){
626 for (Int_t iP=0; iP<fProngs; iP++){
627 fEtaAccCut[iP]=etaAccCut[iP];
628 }
629 }
630 return;
631}
632
633//___________________________________________________________
634
635void AliCFVertexingHFLctoV0bachelor::SetAccCut(Float_t* ptAccCut, Float_t* etaAccCut)
636{
637 //
638 // setting the pt and eta cut to be used in the Acceptance steps (MC+Reco)
639 //
640
641 AliInfo("The 1st element of the pt cut array will correspond to the cut applied to the bachelor - please check that it is correct");
642 if (fProngs>0){
643 for (Int_t iP=0; iP<fProngs; iP++){
644 fPtAccCut[iP]=ptAccCut[iP];
645 fEtaAccCut[iP]=etaAccCut[iP];
646 }
647 }
648 return;
649}
650
651//___________________________________________________________
652
653void AliCFVertexingHFLctoV0bachelor::SetAccCut()
654{
655 //
656 // setting the pt and eta cut to be used in the Acceptance steps (MC+Reco)
657 //
658
659 AliAODMCParticle* mcPartDaughter = dynamic_cast<AliAODMCParticle*>(fmcArray->At(fLabelArray[0])); // bachelor
660 if (!mcPartDaughter) return;
661 Int_t mother = mcPartDaughter->GetMother();
662 AliAODMCParticle* mcMother = dynamic_cast<AliAODMCParticle*>(fmcArray->At(mother));
663 if (!mcMother) return;
664 /*
665 if (fGenLcOption==kCountK0Sp) {
666 if ( !(TMath::Abs(mcPartDaughter->GetPdgCode())== 2212) )
667 AliFatal(Form("Apparently the proton bachelor is not in the first position (%d <- %d), causing a crash!!",
668 mcPartDaughter->GetPdgCode(),mcMother->GetPdgCode()));
669 }
670 else if (fGenLcOption==kCountLambdapi) {
671 if ( !(TMath::Abs(mcPartDaughter->GetPdgCode())== 211) )
672 AliFatal(Form("Apparently the pion bachelor is not in the first position (%d <- %d), causing a crash!!",
673 mcPartDaughter->GetPdgCode(),mcMother->GetPdgCode()));
674 }
675 */
676 if (fProngs>0) {
677 fPtAccCut[0]=0.3; // bachelor
678 fEtaAccCut[0]=0.9; // bachelor
679 for (Int_t iP=1; iP<fProngs; iP++){
680 fPtAccCut[iP]=0.1;
681 fEtaAccCut[iP]=0.9;
682 }
683 }
684
685 return;
686
687}
688
689//_____________________________________________________________
690Double_t AliCFVertexingHFLctoV0bachelor::GetEtaProng(Int_t iProng) const
691{
692 //
693 // getting eta of the prong - overload the mother class method
694 //
695
696 if (fRecoCandidate) {
697
698 AliAODRecoCascadeHF* lcV0bachelor = (AliAODRecoCascadeHF*)fRecoCandidate;
699
700 Double_t etaProng =-9999;
701 if (iProng==0) etaProng = lcV0bachelor->GetBachelor()->Eta();
702 else if (iProng==1) etaProng = lcV0bachelor->Getv0PositiveTrack()->Eta();
703 else if (iProng==2) etaProng = lcV0bachelor->Getv0NegativeTrack()->Eta();
704
705 return etaProng;
706
707 }
708 return 999999;
709}
710
711//_____________________________________________________________
712
713Double_t AliCFVertexingHFLctoV0bachelor::GetPtProng(Int_t iProng) const
714{
715 //
716 // getting pt of the prong
717 //
718
719 Double_t ptProng=-9999.;
720
721 if (!fRecoCandidate) return ptProng;
722
723 AliAODRecoCascadeHF* lcV0bachelor = (AliAODRecoCascadeHF*)fRecoCandidate;
724
725 if (iProng==0) ptProng = lcV0bachelor->GetBachelor()->Pt();
726 else if (iProng==1) ptProng = lcV0bachelor->Getv0PositiveTrack()->Pt();
727 else if (iProng==2) ptProng = lcV0bachelor->Getv0NegativeTrack()->Pt();
728
729 return ptProng;
730
731}
732
733//_____________________________________________________________
734
735Double_t AliCFVertexingHFLctoV0bachelor::Ctau(AliAODMCParticle *mcPartCandidate)
736{
737
738 Double_t cTau = 999999.;
739
740 Double_t vtx1[3] = {0,0,0}; // primary vertex
741 Bool_t hasProdVertex = mcPartCandidate->XvYvZv(vtx1); // cm
742
743 AliAODMCParticle *mcPartDaughter0 = (AliAODMCParticle*)fmcArray->At(mcPartCandidate->GetDaughter(0));
744 AliAODMCParticle *mcPartDaughter1 = (AliAODMCParticle*)fmcArray->At(mcPartCandidate->GetDaughter(1));
745 if (!mcPartDaughter0 && !mcPartDaughter1) return cTau;
746 Double_t vtx1daughter[3] = {0,0,0}; // secondary vertex
747 if (mcPartDaughter0)
748 hasProdVertex = hasProdVertex || mcPartDaughter0->XvYvZv(vtx1daughter); //cm
749 if (mcPartDaughter1)
750 hasProdVertex = hasProdVertex || mcPartDaughter1->XvYvZv(vtx1daughter); //cm
751
752 if (!hasProdVertex) return cTau;
753
754 Double_t decayLength = 0.;
755 for (Int_t ii=0; ii<3; ii++) decayLength += (vtx1daughter[ii]-vtx1[ii])*(vtx1daughter[ii]-vtx1[ii]);
756 decayLength = TMath::Sqrt(decayLength);
757
758 cTau = decayLength * mcPartCandidate->M()/mcPartCandidate->P();
759 AliDebug(2,Form(" cTau(4122)=%f",cTau));
760 return cTau;
761
762}