1 /**************************************************************************
2 * Copyright(c) 1998-2011, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 //-----------------------------------------------------------------------
17 // Class for HF corrections as a function of many variables and steps
18 // For D* and other cascades
20 // Author : A.Grelli a.grelli@uu.nl UTECHT
21 //-----------------------------------------------------------------------
23 #include "AliAODRecoDecayHF2Prong.h"
24 #include "AliAODMCParticle.h"
25 #include "AliAODEvent.h"
26 #include "TClonesArray.h"
27 #include "AliCFVertexingHF.h"
28 #include "AliESDtrack.h"
29 #include "TDatabasePDG.h"
30 #include "AliAODRecoCascadeHF.h"
31 #include "AliCFVertexingHFCascade.h"
32 #include "AliCFContainer.h"
33 #include "AliCFTaskVertexingHF.h"
35 ClassImp(AliCFVertexingHFCascade)
38 //_________________________________________
39 AliCFVertexingHFCascade::AliCFVertexingHFCascade(TClonesArray *mcArray, UShort_t originDselection):
40 AliCFVertexingHF(mcArray, originDselection)
42 // standard constructor
45 fPtAccCut=new Float_t[fProngs];
46 fEtaAccCut=new Float_t[fProngs];
47 // element 0 in the cut arrays corresponds to the soft pion!!!!!!!! Careful when setting the values...
50 for(Int_t iP=1; iP<fProngs; iP++){
58 //_____________________________________
59 AliCFVertexingHFCascade& AliCFVertexingHFCascade::operator=(const AliCFVertexingHFCascade& c)
65 AliCFVertexingHF::operator=(c);
71 //__________________________________________
72 Bool_t AliCFVertexingHFCascade::SetRecoCandidateParam(AliAODRecoDecayHF *recoCand)
74 // set the AliAODRecoDecay candidate
76 Bool_t bSignAssoc = kFALSE;
78 fRecoCandidate = recoCand;
79 AliAODRecoCascadeHF* dstarD0pi = (AliAODRecoCascadeHF*)recoCand;
81 if (!fRecoCandidate) {
82 AliError("fRecoCandidate not found, problem in assignement\n");
86 if ( fRecoCandidate->GetPrimaryVtx()) AliDebug(3,"fReco Candidate has a pointer to PrimVtx\n");
87 //if (recoCand->GetPrimaryVtx()) printf("Reco Cand has a pointer to PrimVtx\n");
89 //Int_t pdgCand = 413;
91 Int_t pdgDgDStartoD0pi[2]={421,211};
92 Int_t pdgDgD0toKpi[2]={321,211};
94 Int_t nentries = fmcArray->GetEntriesFast();
96 AliDebug(3,Form("nentries = %d\n", nentries));
98 Int_t mcLabel = dstarD0pi->MatchToMC(413,421,pdgDgDStartoD0pi,pdgDgD0toKpi,fmcArray);
100 if (mcLabel == -1) return bSignAssoc;
102 if (fRecoCandidate->NumberOfFakeDaughters()>0){
103 fFake = 0; // fake candidate
104 if (fFakeSelection==1) return bSignAssoc;
106 if (fRecoCandidate->NumberOfFakeDaughters()==0){
107 fFake = 2; // non-fake candidate
108 if (fFakeSelection==2) return bSignAssoc;
112 fmcPartCandidate = dynamic_cast<AliAODMCParticle*>(fmcArray->At(fmcLabel));
114 if (!fmcPartCandidate){
115 AliDebug(3,"No part candidate");
123 //______________________________________________
124 Bool_t AliCFVertexingHFCascade::GetGeneratedValuesFromMCParticle(Double_t* vectorMC)
127 // collecting all the necessary info (pt, y, cosThetaStar, ptPi, ptKa, cT) from MC particle
130 Bool_t bGenValues = kFALSE;
133 Int_t daughter0ds = fmcPartCandidate->GetDaughter(0);
134 Int_t daughter1ds = fmcPartCandidate->GetDaughter(1);
137 AliAODMCParticle* mcPartDaughterD0 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter0ds));
138 AliAODMCParticle* mcPartDaughterPis = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter1ds));
140 if(!mcPartDaughterD0 || !mcPartDaughterPis) return kFALSE;
142 Double_t vtx1[3] = {0,0,0}; // primary vertex
143 Double_t vtx2daughter0[3] = {0,0,0}; // secondary vertex from daughter 0
144 Double_t vtx2daughter1[3] = {0,0,0}; // secondary vertex from daughter 1
145 fmcPartCandidate->XvYvZv(vtx1); // cm
148 Int_t daughter0 = mcPartDaughterD0->GetDaughter(0);
149 Int_t daughter1 = mcPartDaughterD0->GetDaughter(1);
151 AliAODMCParticle* mcPartDaughter0 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter0)); //D0
152 AliAODMCParticle* mcPartDaughter1 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter1)); //pis
154 if(!mcPartDaughter0 || !mcPartDaughter1) return kFALSE;
156 // getting vertex from daughters
157 mcPartDaughter0->XvYvZv(vtx2daughter0); // cm
158 mcPartDaughter1->XvYvZv(vtx2daughter1); //cm
159 if (TMath::Abs(vtx2daughter0[0] - vtx2daughter1[0])>1E-5 || TMath::Abs(vtx2daughter0[1]- vtx2daughter1[1])>1E-5 || TMath::Abs(vtx2daughter0[2] - vtx2daughter1[2])>1E-5) {
160 AliError("Daughters have different secondary vertex, skipping the track");
166 // always instantiate the AliAODRecoDecay with the positive daughter first, the negative second
167 AliAODMCParticle* positiveDaugh = mcPartDaughter0;
168 AliAODMCParticle* negativeDaugh = mcPartDaughter1;
169 if (mcPartDaughter0->GetPdgCode()<0 && mcPartDaughter1->GetPdgCode()>0){
170 // inverting in case the positive daughter is the second one
171 positiveDaugh = mcPartDaughter1;
172 negativeDaugh = mcPartDaughter0;
174 // getting the momentum from the daughters
175 Double_t px[2] = {positiveDaugh->Px(), negativeDaugh->Px()};
176 Double_t py[2] = {positiveDaugh->Py(), negativeDaugh->Py()};
177 Double_t pz[2] = {positiveDaugh->Pz(), negativeDaugh->Pz()};
179 Double_t d0[2] = {0.,0.};
181 AliAODRecoDecayHF* decay = new AliAODRecoDecayHF(vtx1,vtx2daughter0,nprongs,charge,px,py,pz,d0);
183 Double_t cosThetaStar = 0.;
184 Double_t cosThetaStarD0 = 0.;
185 Double_t cosThetaStarD0bar = 0.;
186 cosThetaStarD0 = decay->CosThetaStar(1,421,211,321);
187 cosThetaStarD0bar = decay->CosThetaStar(0,421,321,211);
188 if (mcPartDaughterD0->GetPdgCode() == 421){ // D0
189 AliDebug(3, Form("D0, with pdgprong0 = %d, pdgprong1 = %d",mcPartDaughter0->GetPdgCode(),mcPartDaughter1->GetPdgCode()));
190 cosThetaStar = cosThetaStarD0;
192 else if (mcPartDaughterD0->GetPdgCode() == -421){ // D0bar{
193 AliDebug(3, Form("D0bar, with pdgprong0 = %d, pdgprong1 = %d",mcPartDaughter0->GetPdgCode(),mcPartDaughter1->GetPdgCode()));
194 cosThetaStar = cosThetaStarD0bar;
197 AliWarning("There are problems!! particle was expected to be either a D0 or a D0bar, check...");
200 if (cosThetaStar < -1 || cosThetaStar > 1) {
201 AliWarning("Invalid value for cosine Theta star, returning");
205 Double_t vectorD0[2] ={0.,0.};
207 // evaluate the correct cascade
208 if (!EvaluateIfD0toKpi(mcPartDaughterD0,vectorD0)) {
209 AliDebug(2, "Error! the D0 MC doesn't have correct daughters!!");
214 Double_t cT = decay->Ct(421);
215 // get the pT of the daughters
219 if (TMath::Abs(fmcPartCandidate->GetPdgCode()) == 413) {
220 pTD0 = mcPartDaughterD0->Pt();
221 pTpi = mcPartDaughterPis->Pt();
225 switch (fConfiguration){
226 case AliCFTaskVertexingHF::kSnail:
227 vectorMC[0] = fmcPartCandidate->Pt();
228 vectorMC[1] = fmcPartCandidate->Y() ;
229 vectorMC[2] = cosThetaStar ;
230 vectorMC[3] = vectorD0[0];
231 vectorMC[4] = vectorD0[1];
232 vectorMC[5] = cT*1.E4 ; // in micron
233 vectorMC[6] = 0.; // dummy value, meaningless in MC
234 vectorMC[7] = -100000.; // dummy value, meaningless in MC, in micron^2
235 vectorMC[8] = 1.01; // dummy value, meaningless in MC
236 vectorMC[9] = fmcPartCandidate->Phi();
237 vectorMC[10] = fzMCVertex; // z of reconstructed of primary vertex
238 vectorMC[11] = fCentValue; // reconstructed centrality
239 vectorMC[12] = 1.; // always filling with 1 at MC level
240 vectorMC[13] = 1.01; // dummy value for cosPointingXY multiplicity
241 vectorMC[14] = 0.; // dummy value for NormalizedDecayLengthXY multiplicity
242 vectorMC[15] = fMultiplicity; // reconstructed multiplicity
244 case AliCFTaskVertexingHF::kCheetah:
245 vectorMC[0] = fmcPartCandidate->Pt();
246 vectorMC[1] = fmcPartCandidate->Y() ;
247 vectorMC[2] = cT*1.E4; // in micron
248 vectorMC[3] = fmcPartCandidate->Phi();
249 vectorMC[4] = fzMCVertex;
250 vectorMC[5] = fCentValue; // dummy value for dca, meaningless in MC
251 vectorMC[6] = 1. ; // fake: always filling with 1 at MC level
252 vectorMC[7] = fMultiplicity; // dummy value for d0pi, meaningless in MC, in micron
260 //____________________________________________
261 Bool_t AliCFVertexingHFCascade::GetRecoValuesFromCandidate(Double_t *vectorReco) const
263 // read the variables for the container
265 Bool_t bFillRecoValues=kFALSE;
267 //Get the D* and the D0 from D*
268 AliAODRecoCascadeHF* dstarD0pi = (AliAODRecoCascadeHF*)fRecoCandidate;
269 AliAODRecoDecayHF2Prong* d0toKpi = (AliAODRecoDecayHF2Prong*)dstarD0pi->Get2Prong();
272 if (dstarD0pi->GetPrimaryVtx())printf("dstarD0pi has primary vtx\n");
273 if (fRecoCandidate->GetPrimaryVtx())printf("fRecoCandidateDstar has primary vtx\n");
275 Double_t pt = dstarD0pi->Pt();
276 Double_t rapidity = dstarD0pi->YDstar();
278 Double_t cosThetaStar = 9999.;
281 Double_t dca = d0toKpi->GetDCA();
284 Double_t d0xd0 = d0toKpi->Prodd0d0();
285 Double_t cosPointingAngle = d0toKpi->CosPointingAngle();
286 Double_t phi = dstarD0pi->Phi();
287 Double_t cosPointingAngleXY = d0toKpi->CosPointingAngleXY();
288 Double_t normDecayLengthXY = d0toKpi->NormalizedDecayLengthXY();
290 Int_t pdgCode = fmcPartCandidate->GetPdgCode();
293 cosThetaStar = d0toKpi->CosThetaStarD0();
294 pTpi = d0toKpi->PtProng(0);
295 pTK = d0toKpi->PtProng(1);
296 d0pi = d0toKpi->Getd0Prong(0);
297 d0K = d0toKpi->Getd0Prong(1);
298 invMass=d0toKpi->InvMassD0();
301 cosThetaStar = d0toKpi->CosThetaStarD0bar();
302 pTpi = d0toKpi->PtProng(1);
303 pTK = d0toKpi->PtProng(0);
304 d0pi = d0toKpi->Getd0Prong(1);
305 d0K = d0toKpi->Getd0Prong(0);
306 invMass= d0toKpi->InvMassD0bar();
309 Double_t cT = d0toKpi->CtD0();
311 switch (fConfiguration){
312 case AliCFTaskVertexingHF::kSnail:
314 vectorReco[1] = rapidity;
315 vectorReco[2] = cosThetaStar;
316 vectorReco[3] = pTpi;
318 vectorReco[5] = cT*1.E4; // in micron
319 vectorReco[6] = dca*1.E4; // in micron
320 vectorReco[7] = d0xd0*1.E8; // in micron^2
321 vectorReco[8] = cosPointingAngle; // in micron
323 vectorReco[10] = fzPrimVertex; // z of reconstructed of primary vertex
324 vectorReco[11] = fCentValue;
325 vectorReco[12] = fFake; // whether the reconstructed candidate was a fake (fFake = 0) or not (fFake = 2)
326 vectorReco[13] = cosPointingAngleXY;
327 vectorReco[14] = normDecayLengthXY; // in cm
328 vectorReco[15] = fMultiplicity; // reconstructed multiplicity
330 case AliCFTaskVertexingHF::kCheetah:
332 vectorReco[1] = rapidity ;
333 vectorReco[2] = cT*1.E4; // in micron
335 vectorReco[4] = fzPrimVertex;
336 vectorReco[5] = fCentValue;
337 vectorReco[6] = fFake ;
338 vectorReco[7] = fMultiplicity;
342 bFillRecoValues = kTRUE;
344 return bFillRecoValues;
348 //_____________________________________________________________
349 Bool_t AliCFVertexingHFCascade::CheckMCChannelDecay() const
351 // check the required decay channel
353 Bool_t checkCD = kFALSE;
356 Int_t daughter0 = fmcPartCandidate->GetDaughter(0);
357 Int_t daughter1 = fmcPartCandidate->GetDaughter(1);
358 AliAODMCParticle* mcPartDaughter0 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter0));
359 AliAODMCParticle* mcPartDaughter1 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter1));
361 if (!mcPartDaughter0 || !mcPartDaughter1) {
362 AliDebug (2,"Problems in the MC Daughters\n");
366 if (!(TMath::Abs(mcPartDaughter0->GetPdgCode())==421 &&
367 TMath::Abs(mcPartDaughter1->GetPdgCode())==211) &&
368 !(TMath::Abs(mcPartDaughter0->GetPdgCode())==211 &&
369 TMath::Abs(mcPartDaughter1->GetPdgCode())==421)) {
370 AliDebug(2, "The D0 MC doesn't come from a Kpi decay, skipping!!");
374 Double_t vectorD0[2] ={0.,0.};
376 // D* is a cascade ...evaluate the correct cascade
377 if (!EvaluateIfD0toKpi(mcPartDaughter0,vectorD0)) {
378 AliDebug(2, "Error! the D0 MC doesn't have correct daughters!!");
387 //__________________________________________
388 Bool_t AliCFVertexingHFCascade::EvaluateIfD0toKpi(AliAODMCParticle* neutralDaugh, Double_t* vectorD0)const
391 // chack wether D0 is decaing into kpi
394 Bool_t isHadronic = kFALSE;
396 Int_t daughterD00 = neutralDaugh->GetDaughter(0);
397 Int_t daughterD01 = neutralDaugh->GetDaughter(1);
399 AliDebug(2, Form("daughter0 = %d and daughter1 = %d",daughterD00,daughterD01));
400 if (daughterD00 == 0 || daughterD01 == 0) {
401 AliDebug(2, "Error! the D0 MC doesn't have correct daughters!!");
405 if (TMath::Abs(daughterD01 - daughterD00) != 1) { // should be everytime true - see PDGdatabooklet
406 AliDebug(2, "The D0 MC doesn't come from a 2-prong decay, skipping!!");
410 AliAODMCParticle* mcPartDaughterD00 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughterD00));
411 AliAODMCParticle* mcPartDaughterD01 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughterD01));
412 if (!mcPartDaughterD00 || !mcPartDaughterD01) {
413 AliWarning("D0 MC analysis: At least one Daughter Particle not found in tree, skipping");
417 if (!(TMath::Abs(mcPartDaughterD00->GetPdgCode())==321 &&
418 TMath::Abs(mcPartDaughterD01->GetPdgCode())==211) &&
419 !(TMath::Abs(mcPartDaughterD00->GetPdgCode())==211 &&
420 TMath::Abs(mcPartDaughterD01->GetPdgCode())==321)) {
421 AliDebug(2, "The D0 MC doesn't come from a Kpi decay, skipping!!");
429 if (TMath::Abs(mcPartDaughterD00->GetPdgCode()) == 211) {
430 pTD0pi = mcPartDaughterD00->Pt();
431 pTD0K = mcPartDaughterD01->Pt();
434 pTD0pi = mcPartDaughterD01->Pt();
435 pTD0K = mcPartDaughterD00->Pt();
440 vectorD0[0] = pTD0pi;
447 //___________________________________________________________
449 void AliCFVertexingHFCascade::SetPtAccCut(Float_t* ptAccCut)
452 // setting the pt cut to be used in the Acceptance steps (MC+Reco)
455 AliInfo("The 3rd element of the pt cut array will correspond to the cut applied to the soft pion - please check that it is correct");
457 for (Int_t iP=0; iP<fProngs; iP++){
458 fPtAccCut[iP]=ptAccCut[iP];
466 //___________________________________________________________
468 void AliCFVertexingHFCascade::SetEtaAccCut(Float_t* etaAccCut)
471 // setting the eta cut to be used in the Acceptance steps (MC+Reco)
474 AliInfo("The 3rd element of the eta cut array will correspond to the cut applied to the soft pion - please check that it is correct");
476 for (Int_t iP=0; iP<fProngs; iP++){
477 fEtaAccCut[iP]=etaAccCut[iP];
482 //___________________________________________________________
484 void AliCFVertexingHFCascade::SetAccCut(Float_t* ptAccCut, Float_t* etaAccCut)
487 // setting the pt and eta cut to be used in the Acceptance steps (MC+Reco)
490 AliInfo("The 3rd element of the pt and cut array will correspond to the cut applied to the soft pion - please check that they are correct");
492 for (Int_t iP=0; iP<fProngs; iP++){
493 fPtAccCut[iP]=ptAccCut[iP];
494 fEtaAccCut[iP]=etaAccCut[iP];
500 //___________________________________________________________
502 void AliCFVertexingHFCascade::SetAccCut()
505 // setting the pt and eta cut to be used in the Acceptance steps (MC+Reco)
508 AliAODMCParticle* mcPartDaughter = dynamic_cast<AliAODMCParticle*>(fmcArray->At(fLabelArray[2])); // should be the soft pion...
509 if(!mcPartDaughter) return;
510 Int_t mother = mcPartDaughter->GetMother();
511 AliAODMCParticle* mcMother = dynamic_cast<AliAODMCParticle*>(fmcArray->At(mother));
512 if(!mcMother) return;
514 if (TMath::Abs(mcPartDaughter->GetPdgCode())!= 211 || TMath::Abs(mcMother->GetPdgCode())!=413){
515 AliFatal("Apparently the soft pion is not in the third position, causing a crash!!");
518 for (Int_t iP=0; iP<fProngs-1; iP++){
522 fPtAccCut[2]=0.06; // soft pion
523 fEtaAccCut[2]=0.9; // soft pion
528 //_____________________________________________________________
529 Double_t AliCFVertexingHFCascade::GetEtaProng(Int_t iProng) const
532 // getting eta of the prong - overload the mother class method
537 AliAODRecoCascadeHF* dstarD0pi = (AliAODRecoCascadeHF*)fRecoCandidate;
539 Double_t etaProng =-9999;
540 if(iProng==0) etaProng =dstarD0pi->Get2Prong()->EtaProng(0);
541 if(iProng==1) etaProng =dstarD0pi->Get2Prong()->EtaProng(1);
542 if(iProng==2) etaProng =dstarD0pi->EtaProng(1);
549 //_____________________________________________________________
550 Double_t AliCFVertexingHFCascade::GetPtProng(Int_t iProng) const
553 // getting pt of the prong
558 AliAODRecoCascadeHF* dstarD0pi = (AliAODRecoCascadeHF*)fRecoCandidate;
559 Double_t ptProng= -9999;
560 if(iProng==0) ptProng =dstarD0pi->Get2Prong()->PtProng(0);
561 if(iProng==1) ptProng =dstarD0pi->Get2Prong()->PtProng(1);
562 if(iProng==2) ptProng =dstarD0pi->PtProng(1);
564 // Double_t ptProng = fRecoCandidate->PtProng(iProng);