]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG3/vertexingHF/AliCFVertexingHFCascade.cxx
Coding conventions (O. Borysov)
[u/mrichter/AliRoot.git] / PWG3 / vertexingHF / AliCFVertexingHFCascade.cxx
CommitLineData
a9f238cf 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//-----------------------------------------------------------------------
17// Class for HF corrections as a function of many variables and steps
18// For D* and other cascades
19//
20// Author : A.Grelli a.grelli@uu.nl UTECHT
21//-----------------------------------------------------------------------
22
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
34ClassImp(AliCFVertexingHFCascade)
35
36
37//_________________________________________
38 AliCFVertexingHFCascade::AliCFVertexingHFCascade(TClonesArray *mcArray, UShort_t originDselection):
39 AliCFVertexingHF(mcArray, originDselection)
40{
41 // standard constructor
42
43 SetNProngs(3);
2bf2e62b 44 fPtAccCut=new Float_t[fProngs];
45 fEtaAccCut=new Float_t[fProngs];
46 // element 0 in the cut arrays corresponds to the soft pion!!!!!!!! Careful when setting the values...
47 fPtAccCut[0]=0.;
48 fEtaAccCut[0]=0.;
49 for(Int_t iP=1; iP<fProngs; iP++){
50 fPtAccCut[iP]=0.1;
51 fEtaAccCut[iP]=0.9;
52 }
53
a9f238cf 54}
55
56
57//_____________________________________
58AliCFVertexingHFCascade& AliCFVertexingHFCascade::operator=(const AliCFVertexingHFCascade& c)
59{
60 // operator =
61
62 if (this != &c) {
63
64 AliCFVertexingHF::operator=(c);
65
66 }
67 return *this;
68}
69
70//__________________________________________
71Bool_t AliCFVertexingHFCascade::SetRecoCandidateParam(AliAODRecoDecayHF *recoCand)
72{
73 // set the AliAODRecoDecay candidate
74
75 Bool_t bSignAssoc = kFALSE;
76
77 fRecoCandidate = recoCand;
78 AliAODRecoCascadeHF* dstarD0pi = (AliAODRecoCascadeHF*)recoCand;
79
80 if (!fRecoCandidate) {
81 AliError("fRecoCandidate not found, problem in assignement\n");
82 return bSignAssoc;
83 }
84
85 if ( fRecoCandidate->GetPrimaryVtx()) AliDebug(3,"fReco Candidate has a pointer to PrimVtx\n");
86 //if (recoCand->GetPrimaryVtx()) printf("Reco Cand has a pointer to PrimVtx\n");
87
88 //Int_t pdgCand = 413;
89
90 Int_t pdgDgDStartoD0pi[2]={421,211};
91 Int_t pdgDgD0toKpi[2]={321,211};
92
93 Int_t nentries = fmcArray->GetEntriesFast();
94
95 AliDebug(3,Form("nentries = %d\n", nentries));
96
97 Int_t mcLabel = dstarD0pi->MatchToMC(413,421,pdgDgDStartoD0pi,pdgDgD0toKpi,fmcArray);
98
fbec9fa9 99 if (mcLabel == -1) return bSignAssoc;
100
101 if ((fRecoCandidate->NumberOfFakeDaughters()>0)&&(fFakeSelection==1)) return bSignAssoc;
102 if ((fRecoCandidate->NumberOfFakeDaughters()==0)&&(fFakeSelection==2)) return bSignAssoc;
103
a9f238cf 104 SetMCLabel(mcLabel);
105 fmcPartCandidate = dynamic_cast<AliAODMCParticle*>(fmcArray->At(fmcLabel));
106
107 if (!fmcPartCandidate){
108 AliDebug(3,"No part candidate");
109 return bSignAssoc;
110 }
111
112 bSignAssoc = kTRUE;
113 return bSignAssoc;
114}
115
116//______________________________________________
117Bool_t AliCFVertexingHFCascade::GetGeneratedValuesFromMCParticle(Double_t* vectorMC)
118{
119 //
120 // collecting all the necessary info (pt, y, cosThetaStar, ptPi, ptKa, cT) from MC particle
121 //
122
123 Bool_t bGenValues = kFALSE;
124
125
126 Int_t daughter0ds = fmcPartCandidate->GetDaughter(0);
127 Int_t daughter1ds = fmcPartCandidate->GetDaughter(1);
128
129 //the D0
130 AliAODMCParticle* mcPartDaughterD0 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter0ds));
131 AliAODMCParticle* mcPartDaughterPis = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter1ds));
132
133 Double_t vtx1[3] = {0,0,0}; // primary vertex
134 Double_t vtx2daughter0[3] = {0,0,0}; // secondary vertex from daughter 0
135 Double_t vtx2daughter1[3] = {0,0,0}; // secondary vertex from daughter 1
136 fmcPartCandidate->XvYvZv(vtx1); // cm
137
138 //D0 daughters
139 Int_t daughter0 = mcPartDaughterD0->GetDaughter(0);
140 Int_t daughter1 = mcPartDaughterD0->GetDaughter(1);
141
142 AliAODMCParticle* mcPartDaughter0 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter0)); //D0
143 AliAODMCParticle* mcPartDaughter1 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter1)); //pis
144
145 // getting vertex from daughters
146 mcPartDaughter0->XvYvZv(vtx2daughter0); // cm
147 mcPartDaughter1->XvYvZv(vtx2daughter1); //cm
148 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) {
149 AliError("Daughters have different secondary vertex, skipping the track");
150 return bGenValues;
151 }
152
153 Int_t nprongs = 2;
154 Short_t charge = 0;
155 // always instantiate the AliAODRecoDecay with the positive daughter first, the negative second
156 AliAODMCParticle* positiveDaugh = mcPartDaughter0;
157 AliAODMCParticle* negativeDaugh = mcPartDaughter1;
158 if (mcPartDaughter0->GetPdgCode()<0 && mcPartDaughter1->GetPdgCode()>0){
159 // inverting in case the positive daughter is the second one
160 positiveDaugh = mcPartDaughter1;
161 negativeDaugh = mcPartDaughter0;
162 }
163 // getting the momentum from the daughters
164 Double_t px[2] = {positiveDaugh->Px(), negativeDaugh->Px()};
165 Double_t py[2] = {positiveDaugh->Py(), negativeDaugh->Py()};
166 Double_t pz[2] = {positiveDaugh->Pz(), negativeDaugh->Pz()};
167
168 Double_t d0[2] = {0.,0.};
169
170 AliAODRecoDecayHF* decay = new AliAODRecoDecayHF(vtx1,vtx2daughter0,nprongs,charge,px,py,pz,d0);
171
172 Double_t cosThetaStar = 0.;
173 Double_t cosThetaStarD0 = 0.;
174 Double_t cosThetaStarD0bar = 0.;
175 cosThetaStarD0 = decay->CosThetaStar(1,421,211,321);
176 cosThetaStarD0bar = decay->CosThetaStar(0,421,321,211);
177 if (mcPartDaughterD0->GetPdgCode() == 421){ // D0
178 AliDebug(3, Form("D0, with pdgprong0 = %d, pdgprong1 = %d",mcPartDaughter0->GetPdgCode(),mcPartDaughter1->GetPdgCode()));
179 cosThetaStar = cosThetaStarD0;
180 }
181 else if (mcPartDaughterD0->GetPdgCode() == -421){ // D0bar{
182 AliDebug(3, Form("D0bar, with pdgprong0 = %d, pdgprong1 = %d",mcPartDaughter0->GetPdgCode(),mcPartDaughter1->GetPdgCode()));
183 cosThetaStar = cosThetaStarD0bar;
184 }
185 else{
186 AliWarning("There are problems!! particle was expected to be either a D0 or a D0bar, check...");
187 return vectorMC;
188 }
189 if (cosThetaStar < -1 || cosThetaStar > 1) {
190 AliWarning("Invalid value for cosine Theta star, returning");
191 return bGenValues;
192 }
193
194 Double_t vectorD0[2] ={0.,0.};
195
196 // evaluate the correct cascade
197 if (!EvaluateIfD0toKpi(mcPartDaughterD0,vectorD0)) {
198 AliDebug(2, "Error! the D0 MC doesn't have correct daughters!!");
199 return bGenValues;
200 }
201
202 //ct
203 Double_t cT = decay->Ct(421);
204 // get the pT of the daughters
205 Double_t pTD0 = 0.;
206 Double_t pTpi = 0.;
207
208 if (TMath::Abs(fmcPartCandidate->GetPdgCode()) == 413) {
209 pTD0 = mcPartDaughterD0->Pt();
210 pTpi = mcPartDaughterPis->Pt();
211 }
212
213
214 vectorMC[0] = fmcPartCandidate->Pt();
215 vectorMC[1] = fmcPartCandidate->Y() ;
216 vectorMC[2] = cosThetaStar ;
217 vectorMC[3] = vectorD0[0];
218 vectorMC[4] = vectorD0[1];
219 vectorMC[5] = cT*1.E4 ; // in micron
220 vectorMC[6] = 0.; // dummy value, meaningless in MC
221 vectorMC[7] = 0.; // dummy value, meaningless in MC, in micron
222 vectorMC[8] = 0.; // dummy value, meaningless in MC, in micron
223 vectorMC[9] = -100000.; // dummy value, meaningless in MC, in micron^2
224 vectorMC[10] = 1.01; // dummy value, meaningless in MC
225 vectorMC[11] = fmcPartCandidate->Phi();
226 vectorMC[12] = fzMCVertex; // z of reconstructed of primary vertex
b7af2639 227 vectorMC[13] = fCentValue; // reconstructed centrality
a9f238cf 228
229 delete decay;
230 bGenValues = kTRUE;
231 return bGenValues;
232}
233//____________________________________________
234Bool_t AliCFVertexingHFCascade::GetRecoValuesFromCandidate(Double_t *vectorReco) const
235{
236 // read the variables for the container
237
238 Bool_t bFillRecoValues=kFALSE;
239
240 //Get the D* and the D0 from D*
241 AliAODRecoCascadeHF* dstarD0pi = (AliAODRecoCascadeHF*)fRecoCandidate;
242 AliAODRecoDecayHF2Prong* d0toKpi = (AliAODRecoDecayHF2Prong*)dstarD0pi->Get2Prong();
243
244
245 if (dstarD0pi->GetPrimaryVtx())printf("dstarD0pi has primary vtx\n");
246 if (fRecoCandidate->GetPrimaryVtx())printf("fRecoCandidateDstar has primary vtx\n");
247
248 Double_t pt = dstarD0pi->Pt();
249 Double_t rapidity = dstarD0pi->YDstar();
250 Double_t invMass=0.;
251 Double_t cosThetaStar = 9999.;
252 Double_t pTpi = 0.;
253 Double_t pTK = 0.;
254 Double_t dca = d0toKpi->GetDCA();
255 Double_t d0pi = 0.;
256 Double_t d0K = 0.;
257 Double_t d0xd0 = d0toKpi->Prodd0d0();
258 Double_t cosPointingAngle = d0toKpi->CosPointingAngle();
259 Double_t phi = dstarD0pi->Phi();
260
261 Int_t pdgCode = fmcPartCandidate->GetPdgCode();
262
263 if (pdgCode > 0){
264 cosThetaStar = d0toKpi->CosThetaStarD0();
265 pTpi = d0toKpi->PtProng(0);
266 pTK = d0toKpi->PtProng(1);
267 d0pi = d0toKpi->Getd0Prong(0);
268 d0K = d0toKpi->Getd0Prong(1);
269 invMass=d0toKpi->InvMassD0();
270 }
271 else {
272 cosThetaStar = d0toKpi->CosThetaStarD0bar();
273 pTpi = d0toKpi->PtProng(1);
274 pTK = d0toKpi->PtProng(0);
275 d0pi = d0toKpi->Getd0Prong(1);
276 d0K = d0toKpi->Getd0Prong(0);
277 invMass= d0toKpi->InvMassD0bar();
278 }
279
280 Double_t cT = d0toKpi->CtD0();
281
282 vectorReco[0] = pt;
283 vectorReco[1] = rapidity;
284 vectorReco[2] = cosThetaStar;
285 vectorReco[3] = pTpi;
286 vectorReco[4] = pTK;
287 vectorReco[5] = cT*1.E4; // in micron
288 vectorReco[6] = dca*1.E4; // in micron
289 vectorReco[7] = d0pi*1.E4; // in micron
290 vectorReco[8] = d0K*1.E4; // in micron
291 vectorReco[9] = d0xd0*1.E8; // in micron^2
292 vectorReco[10] = cosPointingAngle; // in micron
293 vectorReco[11] = phi;
294 vectorReco[12] = fzPrimVertex; // z of reconstructed of primary vertex
b7af2639 295 vectorReco[13] = fCentValue;
a9f238cf 296
297 bFillRecoValues = kTRUE;
298
299 return bFillRecoValues;
300}
301
302
303//_____________________________________________________________
304Bool_t AliCFVertexingHFCascade::CheckMCChannelDecay() const
305{
306 // check the required decay channel
307
308 Bool_t checkCD = kFALSE;
309
310
311 Int_t daughter0 = fmcPartCandidate->GetDaughter(0);
312 Int_t daughter1 = fmcPartCandidate->GetDaughter(1);
313 AliAODMCParticle* mcPartDaughter0 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter0));
314 AliAODMCParticle* mcPartDaughter1 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter1));
315
316 if (!mcPartDaughter0 || !mcPartDaughter1) {
317 AliDebug (2,"Problems in the MC Daughters\n");
318 return checkCD;
319 }
320
321 if (!(TMath::Abs(mcPartDaughter0->GetPdgCode())==421 &&
322 TMath::Abs(mcPartDaughter1->GetPdgCode())==211) &&
323 !(TMath::Abs(mcPartDaughter0->GetPdgCode())==211 &&
324 TMath::Abs(mcPartDaughter1->GetPdgCode())==421)) {
325 AliDebug(2, "The D0 MC doesn't come from a Kpi decay, skipping!!");
326 return checkCD;
327 }
328
329 Double_t vectorD0[2] ={0.,0.};
330
331 // D* is a cascade ...evaluate the correct cascade
332 if (!EvaluateIfD0toKpi(mcPartDaughter0,vectorD0)) {
333 AliDebug(2, "Error! the D0 MC doesn't have correct daughters!!");
334 return checkCD;
335 }
336
337 checkCD = kTRUE;
338 return checkCD;
339
340}
341
342//__________________________________________
343Bool_t AliCFVertexingHFCascade::EvaluateIfD0toKpi(AliAODMCParticle* neutralDaugh, Double_t* vectorD0)const
344{
345 //
346 // chack wether D0 is decaing into kpi
347 //
348
349 Bool_t isHadronic = kFALSE;
350
351 Int_t daughterD00 = neutralDaugh->GetDaughter(0);
352 Int_t daughterD01 = neutralDaugh->GetDaughter(1);
353
354 AliDebug(2, Form("daughter0 = %d and daughter1 = %d",daughterD00,daughterD01));
355 if (daughterD00 == 0 || daughterD01 == 0) {
356 AliDebug(2, "Error! the D0 MC doesn't have correct daughters!!");
357 return isHadronic;
358 }
359
360 if (TMath::Abs(daughterD01 - daughterD00) != 1) { // should be everytime true - see PDGdatabooklet
361 AliDebug(2, "The D0 MC doesn't come from a 2-prong decay, skipping!!");
362 return isHadronic;
363 }
364
365 AliAODMCParticle* mcPartDaughterD00 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughterD00));
366 AliAODMCParticle* mcPartDaughterD01 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughterD01));
367 if (!mcPartDaughterD00 || !mcPartDaughterD01) {
368 AliWarning("D0 MC analysis: At least one Daughter Particle not found in tree, skipping");
369 return isHadronic;
370 }
371
372 if (!(TMath::Abs(mcPartDaughterD00->GetPdgCode())==321 &&
373 TMath::Abs(mcPartDaughterD01->GetPdgCode())==211) &&
374 !(TMath::Abs(mcPartDaughterD00->GetPdgCode())==211 &&
375 TMath::Abs(mcPartDaughterD01->GetPdgCode())==321)) {
376 AliDebug(2, "The D0 MC doesn't come from a Kpi decay, skipping!!");
377 return isHadronic;
378 }
379
380 Double_t pTD0pi = 0;
381 Double_t pTD0K = 0;
382
383
384 if (TMath::Abs(mcPartDaughterD00->GetPdgCode()) == 211) {
385 pTD0pi = mcPartDaughterD00->Pt();
386 pTD0K = mcPartDaughterD01->Pt();
387 }
388 else {
389 pTD0pi = mcPartDaughterD01->Pt();
390 pTD0K = mcPartDaughterD00->Pt();
391 }
392
393 isHadronic = kTRUE;
394
395 vectorD0[0] = pTD0pi;
396 vectorD0[1] = pTD0K;
397
398 return isHadronic;
399
400}
401
2bf2e62b 402//___________________________________________________________
403
404void AliCFVertexingHFCascade::SetPtAccCut(Float_t* ptAccCut)
405{
406 //
407 // setting the pt cut to be used in the Acceptance steps (MC+Reco)
408 //
409
410 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");
411 if (fProngs>0){
412 for (Int_t iP=0; iP<fProngs; iP++){
413 fPtAccCut[iP]=ptAccCut[iP];
414 }
415 }
416 return;
417}
418
419
420
421//___________________________________________________________
422
423void AliCFVertexingHFCascade::SetEtaAccCut(Float_t* etaAccCut)
424{
425 //
426 // setting the eta cut to be used in the Acceptance steps (MC+Reco)
427 //
428
429 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");
430 if (fProngs>0){
431 for (Int_t iP=0; iP<fProngs; iP++){
432 fEtaAccCut[iP]=etaAccCut[iP];
433 }
434 }
435 return;
436}
437//___________________________________________________________
438
439void AliCFVertexingHFCascade::SetAccCut(Float_t* ptAccCut, Float_t* etaAccCut)
440{
441 //
442 // setting the pt and eta cut to be used in the Acceptance steps (MC+Reco)
443 //
444
445 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");
446 if (fProngs>0){
447 for (Int_t iP=0; iP<fProngs; iP++){
448 fPtAccCut[iP]=ptAccCut[iP];
449 fEtaAccCut[iP]=etaAccCut[iP];
450 }
451 }
452 return;
453}
454
455//___________________________________________________________
456
457void AliCFVertexingHFCascade::SetAccCut()
458{
459 //
460 // setting the pt and eta cut to be used in the Acceptance steps (MC+Reco)
461 //
367e9aa3 462
463 AliAODMCParticle* mcPartDaughter = dynamic_cast<AliAODMCParticle*>(fmcArray->At(fLabelArray[2])); // should be the soft pion...
464 if(!mcPartDaughter) return;
465 Int_t mother = mcPartDaughter->GetMother();
466 AliAODMCParticle* mcMother = dynamic_cast<AliAODMCParticle*>(fmcArray->At(mother));
467 if(!mcMother) return;
468
469 if (TMath::Abs(mcPartDaughter->GetPdgCode())!= 211 || TMath::Abs(mcMother->GetPdgCode())!=413){
470 AliFatal("Apparently the soft pion is not in the third position, causing a crash!!");
471 }
472 if (fProngs>0){
473 for (Int_t iP=0; iP<fProngs-1; iP++){
474 fPtAccCut[iP]=0.1;
475 fEtaAccCut[iP]=0.9;
476 }
477 fPtAccCut[2]=0.06; // soft pion
478 fEtaAccCut[2]=0.9; // soft pion
479 }
480 return;
2bf2e62b 481}
a9f238cf 482
367e9aa3 483//_____________________________________________________________
484Double_t AliCFVertexingHFCascade::GetEtaProng(Int_t iProng) const
485{
486 //
487 // getting eta of the prong - overload the mother class method
488 //
a9f238cf 489
367e9aa3 490 if (fRecoCandidate){
491
492 AliAODRecoCascadeHF* dstarD0pi = (AliAODRecoCascadeHF*)fRecoCandidate;
493
494 Double_t etaProng =-9999;
495 if(iProng==0) etaProng =dstarD0pi->Get2Prong()->EtaProng(0);
496 if(iProng==1) etaProng =dstarD0pi->Get2Prong()->EtaProng(1);
497 if(iProng==2) etaProng =dstarD0pi->EtaProng(1);
498
499 return etaProng;
500
501 }
502 return 999999;
503}
504//_____________________________________________________________
505Double_t AliCFVertexingHFCascade::GetPtProng(Int_t iProng) const
506{
507 //
508 // getting pt of the prong
509 //
510
511 if (fRecoCandidate){
512
513 AliAODRecoCascadeHF* dstarD0pi = (AliAODRecoCascadeHF*)fRecoCandidate;
514 Double_t ptProng= -9999;
515 if(iProng==0) ptProng =dstarD0pi->Get2Prong()->PtProng(0);
516 if(iProng==1) ptProng =dstarD0pi->Get2Prong()->PtProng(1);
517 if(iProng==2) ptProng =dstarD0pi->PtProng(1);
518
519 // Double_t ptProng = fRecoCandidate->PtProng(iProng);
520 return ptProng;
521
522 }
523 return 999999;
524
525}