AliPhysics  9fe175b (9fe175b)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliCFVertexingHFCascade.cxx
Go to the documentation of this file.
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 
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"
32 #include "AliCFContainer.h"
33 #include "AliCFTaskVertexingHF.h"
34 #include "AliPIDResponse.h"
35 #include "AliPID.h"
36 
40 
41 //_________________________________________
44  fPDGcascade(0),
45  fPDGbachelor(0),
46  fPDGneutrDaugh(0),
47  fPDGneutrDaughForMC(0),
48  fPDGneutrDaughPositive(0),
49  fPDGneutrDaughNegative(0),
50  fPrimVtx(0x0),
51  fUseCutsForTMVA(kFALSE),
52  fCutOnMomConservation(0.00001)
53 {
54  // default constructor
55 
56  SetNProngs(3);
57  fPtAccCut = new Float_t[fProngs];
58  fEtaAccCut = new Float_t[fProngs];
59  // element 0 in the cut arrays corresponds to the soft pion!!!!!!!! Careful when setting the values...
60  fPtAccCut[0] = 0.;
61  fEtaAccCut[0] = 0.;
62  for(Int_t iP=1; iP<fProngs; iP++){
63  fPtAccCut[iP] = 0.1;
64  fEtaAccCut[iP] = 0.9;
65  }
66 
67 }
68 
69 //_________________________________________
70 AliCFVertexingHFCascade::AliCFVertexingHFCascade(TClonesArray *mcArray, UShort_t originDselection):
71 AliCFVertexingHF(mcArray, originDselection),
72  fPDGcascade(0),
73  fPDGbachelor(0),
74  fPDGneutrDaugh(0),
75  fPDGneutrDaughForMC(0),
76  fPDGneutrDaughPositive(0),
77  fPDGneutrDaughNegative(0),
78  fPrimVtx(0x0),
79  fUseCutsForTMVA(kFALSE),
80  fCutOnMomConservation(0.00001)
81 {
82  // standard constructor
83 
84  SetNProngs(3);
85  fPtAccCut = new Float_t[fProngs];
86  fEtaAccCut = new Float_t[fProngs];
87  // element 0 in the cut arrays corresponds to the soft pion!!!!!!!! Careful when setting the values...
88  fPtAccCut[0] = 0.;
89  fEtaAccCut[0] = 0.;
90  for(Int_t iP=1; iP<fProngs; iP++){
91  fPtAccCut[iP] = 0.1;
92  fEtaAccCut[iP] = 0.9;
93  }
94 
95 }
96 
97 
98 //_____________________________________
100 {
101  // operator =
102 
103  if (this != &c) {
104 
106 
107  }
108  return *this;
109 }
110 
111 //__________________________________________
113 {
114  // set the AliAODRecoDecay candidate
115 
116  Bool_t bSignAssoc = kFALSE;
117 
118  fRecoCandidate = recoCand;
119  AliAODRecoCascadeHF* cascade = (AliAODRecoCascadeHF*)recoCand;
120 
121  if (!fRecoCandidate) {
122  AliError("fRecoCandidate not found, problem in assignement\n");
123  return bSignAssoc;
124  }
125 
126  if ( fRecoCandidate->GetPrimaryVtx()) AliDebug(3,"fReco Candidate has a pointer to PrimVtx\n");
127 
128  //Int_t pdgCand = 413;
129 
130  Int_t pdgDgCascade[2] = {fPDGneutrDaugh, fPDGbachelor};
131  Int_t pdgDgNeutrDaugh[2] = {fPDGneutrDaughPositive, fPDGneutrDaughNegative};
132 
133  Int_t nentries = fmcArray->GetEntriesFast();
134 
135  AliDebug(3,Form("nentries = %d\n", nentries));
136 
137  Bool_t isV0 = kFALSE;
138  if (fPDGcascade == 4122) {
139  isV0 = kTRUE;
140  pdgDgCascade[0] = fPDGbachelor;
141  pdgDgCascade[1] = fPDGneutrDaugh;
142  }
143  AliDebug(3, Form("calling MatchToMC with: fPDGcascade = %d, fPDGneutrDaugh = %d, pdgDgCascade[0] = %d, pdgDgCascade[1] = %d, pdgDgNeutrDaugh[0] = %d, pdgDgNeutrDaugh[1] = %d, fmcArray = %p", fPDGcascade, fPDGneutrDaugh, pdgDgCascade[0], pdgDgCascade[1], pdgDgNeutrDaugh[0], pdgDgNeutrDaugh[1], fmcArray));
144  Int_t mcLabel = cascade->MatchToMC(fPDGcascade, fPDGneutrDaugh, pdgDgCascade, pdgDgNeutrDaugh, fmcArray, isV0);
145 
146  if (mcLabel == -1) return bSignAssoc;
147 
149  fFake = 0; // fake candidate
150  if (fFakeSelection == 1) return bSignAssoc;
151  }
153  fFake = 2; // non-fake candidate
154  if (fFakeSelection == 2) return bSignAssoc;
155  }
156 
157  SetMCLabel(mcLabel);
158  fmcPartCandidate = dynamic_cast<AliAODMCParticle*>(fmcArray->At(fmcLabel));
159 
160  if (!fmcPartCandidate){
161  AliDebug(3,"No part candidate");
162  return bSignAssoc;
163  }
164 
165  bSignAssoc = kTRUE;
166  return bSignAssoc;
167 }
168 
169 //______________________________________________
171 {
172  //
173  // collecting all the necessary info (pt, y, cosThetaStar, ptPi, ptKa, cT) from MC particle
174  //
175 
176  Bool_t bGenValues = kFALSE;
177 
178  Int_t daughter0cascade = fmcPartCandidate->GetDaughter(0);
179  Int_t daughter1cascade = fmcPartCandidate->GetDaughter(1);
180 
181  AliAODMCParticle* mcPartDaughter0 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter0cascade));
182  AliAODMCParticle* mcPartDaughter1 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter1cascade));
183  AliAODMCParticle* mcPartDaughterNeutrDaugh = NULL;
184  AliAODMCParticle* mcPartDaughterBachelor = NULL;
185 
186  // the Neutral Particle (e.g. D0 for D*, K0S for Lc...)
187  // for D* the D0 (the neutral) is the first daughter, while for Lc the V0 is the second, so we check the
188  // charge of the daughters to decide which is which
189  if (mcPartDaughter0->Charge()/3 == 0){
190  mcPartDaughterNeutrDaugh = mcPartDaughter0;
191  mcPartDaughterBachelor = mcPartDaughter1;
192  }
193  else {
194  mcPartDaughterNeutrDaugh = mcPartDaughter1;
195  mcPartDaughterBachelor = mcPartDaughter0;
196  }
197 
198  if (!mcPartDaughterNeutrDaugh || !mcPartDaughterBachelor) return kFALSE;
199 
200  Double_t vtx1[3] = {0,0,0}; // primary vertex
201  Double_t vtx2daughter0[3] = {0,0,0}; // secondary vertex from daughter 0
202  Double_t vtx2daughter1[3] = {0,0,0}; // secondary vertex from daughter 1
203  fmcPartCandidate->XvYvZv(vtx1); // cm
204 
205  //Daughters of the neutral particle of the cascade
206  Int_t daughter0 = mcPartDaughterNeutrDaugh->GetDaughter(0); // this is the positive
207  Int_t daughter1 = mcPartDaughterNeutrDaugh->GetDaughter(1); // this is the negative
208 
209  AliAODMCParticle* mcPartNeutrDaughter0 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter0));
210  AliAODMCParticle* mcPartNeutrDaughter1 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter1));
211 
212  if (!mcPartNeutrDaughter0 || !mcPartNeutrDaughter1) return kFALSE;
213 
214  // getting vertex from daughters
215  mcPartNeutrDaughter0->XvYvZv(vtx2daughter0); // cm
216  mcPartNeutrDaughter1->XvYvZv(vtx2daughter1); //cm
217  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) {
218  AliError("Daughters have different secondary vertex, skipping the track");
219  return bGenValues;
220  }
221 
222  Int_t nprongs = 2;
223  Short_t charge = 0;
224  // always instantiate the AliAODRecoDecay with the positive daughter first, the negative second
225  AliAODMCParticle* positiveDaugh = mcPartNeutrDaughter0;
226  AliAODMCParticle* negativeDaugh = mcPartNeutrDaughter1;
227  if (mcPartNeutrDaughter0->GetPdgCode() < 0 && mcPartNeutrDaughter1->GetPdgCode() > 0){
228  // inverting in case the positive daughter is the second one
229  positiveDaugh = mcPartNeutrDaughter1;
230  negativeDaugh = mcPartNeutrDaughter0;
231  }
232 
233  // getting the momentum from the daughters
234  Double_t px[2] = {positiveDaugh->Px(), negativeDaugh->Px()};
235  Double_t py[2] = {positiveDaugh->Py(), negativeDaugh->Py()};
236  Double_t pz[2] = {positiveDaugh->Pz(), negativeDaugh->Pz()};
237 
238  Double_t d0[2] = {0.,0.};
239 
240  AliAODRecoDecayHF* decay = new AliAODRecoDecayHF(vtx1, vtx2daughter0, nprongs, charge, px, py, pz, d0);
241 
242  Double_t cosThetaStar = 0.;
243  Double_t cosThetaStarNeutrDaugh = 0.;
244  Double_t cosThetaStarNeutrDaughBar = 0.;
245  cosThetaStarNeutrDaugh = decay->CosThetaStar(1, fPDGneutrDaugh, fPDGneutrDaughPositive, fPDGneutrDaughNegative);
246  cosThetaStarNeutrDaughBar = decay->CosThetaStar(0, fPDGneutrDaugh, fPDGneutrDaughNegative, fPDGneutrDaughPositive);
247  if (mcPartDaughterNeutrDaugh->GetPdgCode() == fPDGneutrDaughForMC){ // neutral particle
248  AliDebug(3, Form("Neutral Daughter, with pdgprong0 = %d, pdgprong1 = %d", mcPartDaughter0->GetPdgCode(), mcPartDaughter1->GetPdgCode()));
249  cosThetaStar = cosThetaStarNeutrDaugh;
250  }
251  else if (mcPartDaughterNeutrDaugh->GetPdgCode() == -fPDGneutrDaughForMC){ // neutral particle bar
252  AliDebug(3, Form("Neutral Daughter, with pdgprong0 = %d, pdgprong1 = %d",mcPartDaughter0->GetPdgCode(),mcPartDaughter1->GetPdgCode()));
253  cosThetaStar = cosThetaStarNeutrDaughBar;
254  }
255  else{
256  AliWarning(Form("There are problems!! particle was expected to be either with pdg = %d or its antiparticle with pdg = %d, while we have a %d, check...", fPDGneutrDaughForMC, -fPDGneutrDaughForMC, mcPartDaughterNeutrDaugh->GetPdgCode()));
257  delete decay;
258  return vectorMC;
259  }
260  if (cosThetaStar < -1 || cosThetaStar > 1) {
261  AliWarning(Form("Invalid value for cosine Theta star %f, returning", cosThetaStar));
262  delete decay;
263  return bGenValues;
264  }
265 
266  Double_t vectorNeutrDaugh[2] = {0.,0.};
267 
268  // evaluate the correct cascade
269  if (!EvaluateIfCorrectNeutrDaugh(mcPartDaughterNeutrDaugh, vectorNeutrDaugh)) {
270  AliDebug(2, "Error! the Neutral Daughter MC doesn't have correct daughters!!");
271  delete decay;
272  return bGenValues;
273  }
274 
275  //ct
276  Double_t cT = decay->Ct(fPDGneutrDaugh);
277  // // get the pT of the daughters
278  // Double_t pTNeutrDaugh= 0.;
279  // Double_t pTBachelor = 0.;
280 
281  // if (TMath::Abs(fmcPartCandidate->GetPdgCode()) == fPDGcascade) {
282  // pTNeutrDaugh = mcPartDaughterNeutrDaugh->Pt();
283  // pTBachelor = mcPartDaughterBachelor->Pt();
284  // }
285 
286  AliDebug(3, Form("The candidate has pt = %f, y = %f", fmcPartCandidate->Pt(), fmcPartCandidate->Y()));
287 
288  switch (fConfiguration){
290  vectorMC[0] = fmcPartCandidate->Pt();
291  vectorMC[1] = fmcPartCandidate->Y() ;
292  vectorMC[2] = cosThetaStar ;
293  vectorMC[3] = vectorNeutrDaugh[0];
294  vectorMC[4] = vectorNeutrDaugh[1];
295  vectorMC[5] = cT*1.E4 ; // in micron
296  vectorMC[6] = 0.; // dummy value, meaningless in MC
297  vectorMC[7] = -100000.; // dummy value, meaningless in MC, in micron^2
298  vectorMC[8] = 1.01; // dummy value, meaningless in MC
299  vectorMC[9] = fmcPartCandidate->Phi();
300  vectorMC[10] = fzMCVertex; // z of reconstructed of primary vertex
301  vectorMC[11] = fCentValue; // reconstructed centrality
302  vectorMC[12] = 1.; // always filling with 1 at MC level
303  vectorMC[13] = 1.01; // dummy value for cosPointingXY multiplicity
304  vectorMC[14] = 0.; // dummy value for NormalizedDecayLengthXY multiplicity
305  vectorMC[15] = fMultiplicity; // reconstructed multiplicity
306  break;
308  vectorMC[0] = fmcPartCandidate->Pt();
309  vectorMC[1] = fmcPartCandidate->Y() ;
310  vectorMC[2] = cT*1.E4; // in micron
311  vectorMC[3] = fmcPartCandidate->Phi();
312  vectorMC[4] = fzMCVertex;
313  vectorMC[5] = fCentValue; // dummy value for dca, meaningless in MC
314  vectorMC[6] = 1. ; // fake: always filling with 1 at MC level
315  vectorMC[7] = fMultiplicity; // dummy value for d0pi, meaningless in MC, in micron
316  break;
317  }
318 
319  delete decay;
320  bGenValues = kTRUE;
321  return bGenValues;
322 }
323 //____________________________________________
324 Bool_t AliCFVertexingHFCascade::GetRecoValuesFromCandidate(Double_t *vectorReco) const
325 {
326  // read the variables for the container
327 
328  Bool_t bFillRecoValues = kFALSE;
329 
330  //Get the cascade and the neutral particle from it
332  AliAODRecoDecay* neutrDaugh = NULL;
333  if (fPDGcascade == 413) neutrDaugh = cascade->Get2Prong();
334  else if (fPDGcascade == 4122) neutrDaugh = cascade->Getv0();
335  else {
336  return kFALSE;
337  }
338 
339  //if (cascade->GetPrimaryVtx())printf("cascade has primary vtx\n");
340  //if (fRecoCandidate->GetPrimaryVtx())printf("fRecoCandidateDstar has primary vtx\n");
341 
342  Double_t pt = cascade->Pt();
343  Double_t rapidity = cascade->Y(fPDGcascade);
344  // Double_t invMass = 0.;
345  Double_t cosThetaStar = 9999.;
346  Double_t pTneutrDaughPos = 0.;
347  Double_t pTneutrDaughNeg = 0.;
348  Double_t dca = neutrDaugh->GetDCA();
349  // Double_t d0neutrDaughPos = 0.;
350  // Double_t d0neutrDaughNeg = 0.;
351  Double_t d0xd0 = neutrDaugh->Prodd0d0();
352  Double_t cosPointingAngle = neutrDaugh->CosPointingAngle(fPrimVtx);
353  Double_t phi = cascade->Phi();
354  Double_t cosPointingAngleXY = neutrDaugh->CosPointingAngleXY(fPrimVtx);
355  Double_t normDecayLengthXY = neutrDaugh->NormalizedDecayLengthXY(fPrimVtx);
356 
357  Int_t pdgCode = fmcPartCandidate->GetPdgCode();
358 
359  // UInt_t pdgDaughCascade[2] = { static_cast<UInt_t>(fPDGbachelor), static_cast<UInt_t>(fPDGneutrDaugh) }; // bachelor is first daughter of cascade
360  // UInt_t pdgDaughBarCascade[2] = { static_cast<UInt_t>(fPDGneutrDaugh), static_cast<UInt_t>(fPDGbachelor) }; // bachelor is second daughter in case of a cascade-bar
361 
362  if (pdgCode > 0){
363  cosThetaStar = neutrDaugh->CosThetaStar(1, fPDGneutrDaugh, fPDGneutrDaughPositive, fPDGneutrDaughNegative);
364  pTneutrDaughPos = neutrDaugh->PtProng(0);
365  pTneutrDaughNeg = neutrDaugh->PtProng(1);
366  // d0neutrDaughPos = neutrDaugh->Getd0Prong(0);
367  // d0neutrDaughNeg = neutrDaugh->Getd0Prong(1);
368  // invMass = neutrDaugh->InvMass(2, pdgDaughCascade);
369  }
370  else {
371  cosThetaStar = neutrDaugh->CosThetaStar(0, fPDGneutrDaugh, fPDGneutrDaughPositive, fPDGneutrDaughNegative);
372  pTneutrDaughPos = neutrDaugh->PtProng(1);
373  pTneutrDaughNeg = neutrDaugh->PtProng(0);
374  // d0neutrDaughPos = neutrDaugh->Getd0Prong(1);
375  // d0neutrDaughNeg = neutrDaugh->Getd0Prong(0);
376  // invMass = neutrDaugh->InvMass(2, pdgDaughBarCascade);
377  }
378 
379  Double_t cT = neutrDaugh->Ct(fPDGneutrDaugh, fPrimVtx);
380 
381  switch (fConfiguration){
383  vectorReco[0] = pt;
384  vectorReco[1] = rapidity;
385  vectorReco[2] = cosThetaStar;
386  vectorReco[3] = pTneutrDaughPos;
387  vectorReco[4] = pTneutrDaughNeg;
388  vectorReco[5] = cT*1.E4; // in micron
389  vectorReco[6] = dca*1.E4; // in micron
390  vectorReco[7] = d0xd0*1.E8; // in micron^2
391  vectorReco[8] = cosPointingAngle; // in micron
392  vectorReco[9] = phi;
393  vectorReco[10] = fzPrimVertex; // z of reconstructed of primary vertex
394  vectorReco[11] = fCentValue;
395  vectorReco[12] = fFake; // whether the reconstructed candidate was a fake (fFake = 0) or not (fFake = 2)
396  vectorReco[13] = cosPointingAngleXY;
397  vectorReco[14] = normDecayLengthXY; // in cm
398  vectorReco[15] = fMultiplicity; // reconstructed multiplicity
399  break;
401  vectorReco[0] = pt;
402  vectorReco[1] = rapidity;
403  vectorReco[2] = cT*1.E4; // in micron
404  vectorReco[3] = phi;
405  vectorReco[4] = fzPrimVertex;
406  vectorReco[5] = fCentValue;
407  vectorReco[6] = fFake;
408  vectorReco[7] = fMultiplicity;
409  break;
410  }
411 
412  bFillRecoValues = kTRUE;
413 
414  return bFillRecoValues;
415 }
416 
417 
418 //_____________________________________________________________
420 {
421  // check the required decay channel
422 
423  Bool_t checkCD = kFALSE;
424 
425  Int_t daughter0 = fmcPartCandidate->GetDaughter(0);
426  Int_t daughter1 = fmcPartCandidate->GetDaughter(1);
427  AliAODMCParticle* mcPartDaughter0 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter0));
428  AliAODMCParticle* mcPartDaughter1 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter1));
429 
430  if (!mcPartDaughter0 || !mcPartDaughter1) {
431  AliDebug (2,"Problems in the MC Daughters\n");
432  return checkCD;
433  }
434 
435  if(TMath::Abs(fmcPartCandidate->GetPdgCode()) == 4122 && (daughter1 - daughter0 != 1)) {
436  AliDebug(2, Form("The MC particle doesn't have the correct daughters!!"));
437  return checkCD;
438  }
439 
440  if (!(TMath::Abs(mcPartDaughter0->GetPdgCode()) == fPDGneutrDaughForMC &&
441  TMath::Abs(mcPartDaughter1->GetPdgCode()) == fPDGbachelor) &&
442  !(TMath::Abs(mcPartDaughter0->GetPdgCode()) == fPDGbachelor &&
443  TMath::Abs(mcPartDaughter1->GetPdgCode()) == fPDGneutrDaughForMC)) {
444  AliDebug(2, Form("The cascade MC doesn't come from a the decay under study, skipping!! (Pdg codes of daughters = %d, %d)", mcPartDaughter0->GetPdgCode(), mcPartDaughter1->GetPdgCode()));
445  return checkCD;
446  }
447 
448  // the Neutral Particle (e.g. D0 for D*, K0S for Lc...)
449  AliAODMCParticle* mcPartDaughterNeutrDaugh = NULL;
450 
451  // for D* the D0 (the neutral) is the first daughter, while for Lc the V0 is the second, so we check the
452  // charge of teh daughters to decide which is which
453  AliDebug(3, Form("Charge0 = %d, Charge1 = %d", mcPartDaughter0->Charge()/3, mcPartDaughter1->Charge()/3));
454  if (mcPartDaughter0->Charge()/3 != 0){
455  mcPartDaughterNeutrDaugh = mcPartDaughter1;
456  }
457  else {
458  mcPartDaughterNeutrDaugh = mcPartDaughter0;
459  }
460 
461  Double_t vectorNeutrDaugh[2] ={0., 0.};
462 
463  // We are looking at a cascade ...evaluate the correct cascade
464  if (!EvaluateIfCorrectNeutrDaugh(mcPartDaughterNeutrDaugh, vectorNeutrDaugh)) {
465  AliDebug(2, "Error! the NeutrDaugh MC doesn't have correct daughters!!");
466  return checkCD;
467  }
468 
469  checkCD = kTRUE;
470  return checkCD;
471 
472 }
473 
474 //__________________________________________
475 Bool_t AliCFVertexingHFCascade::EvaluateIfCorrectNeutrDaugh(AliAODMCParticle* neutralDaugh, Double_t* vectorNeutrDaugh)const
476 {
477  //
478  // check wether D0 is decaing into kpi
479  //
480 
481  Bool_t isHadronic = kFALSE;
482  AliDebug(2, Form("neutralDaugh = %p, pdg = %d", neutralDaugh, neutralDaugh->GetPdgCode()));
483 
484  if (fPDGcascade == 4122) {
485  Int_t labelresonanceDaugh = neutralDaugh->GetDaughter(0);
486  AliAODMCParticle* resonanceDaugh = dynamic_cast<AliAODMCParticle*>(fmcArray->At(labelresonanceDaugh));
487  if (!resonanceDaugh){
488  return kFALSE;
489  }
490  else {
491  AliDebug(3, Form("The daughter of the resonant particle is a %d (we are looking for a %d)", resonanceDaugh->GetPdgCode(), fPDGneutrDaugh));
492  if (TMath::Abs(resonanceDaugh->GetPdgCode()) != fPDGneutrDaugh){
493  return kFALSE;
494  }
495  else {
496  neutralDaugh = resonanceDaugh;
497  }
498  }
499  }
500 
501  Int_t daughterNeutrDaugh0 = neutralDaugh->GetDaughter(0);
502  Int_t daughterNeutrDaugh1 = neutralDaugh->GetDaughter(1);
503 
504  AliDebug(2, Form("daughter0 = %d and daughter1 = %d", daughterNeutrDaugh0, daughterNeutrDaugh1));
505  if (daughterNeutrDaugh0 == 0 || daughterNeutrDaugh1 == 0) {
506  AliDebug(2, "Error! the D0 MC doesn't have correct daughters!!");
507  return isHadronic;
508  }
509 
510  Int_t numberOfExpectedDaughters = 2;
511  if (TMath::Abs(daughterNeutrDaugh1 - daughterNeutrDaugh0) != numberOfExpectedDaughters-1) { // should be everytime true - see PDGdatabooklet
512  AliDebug(2, "The D0 MC doesn't come from a 2-prong decay, skipping!!");
513  return isHadronic;
514  }
515 
516  AliAODMCParticle* mcPartDaughterNeutrDaugh0 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughterNeutrDaugh0));
517  AliAODMCParticle* mcPartDaughterNeutrDaugh1 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughterNeutrDaugh1));
518  if (!mcPartDaughterNeutrDaugh0 || !mcPartDaughterNeutrDaugh1) {
519  AliWarning("D0 MC analysis: At least one Daughter Particle not found in tree, skipping");
520  return isHadronic;
521  }
522 
523  AliDebug(3, Form("Daughter 0 has pdg = %d, daughter 1 has pdg = %d", mcPartDaughterNeutrDaugh0->GetPdgCode(), mcPartDaughterNeutrDaugh1->GetPdgCode()));
524  if (!(TMath::Abs(mcPartDaughterNeutrDaugh0->GetPdgCode()) == fPDGneutrDaughPositive &&
525  TMath::Abs(mcPartDaughterNeutrDaugh1->GetPdgCode()) == fPDGneutrDaughNegative) &&
526  !(TMath::Abs(mcPartDaughterNeutrDaugh0->GetPdgCode()) == fPDGneutrDaughNegative &&
527  TMath::Abs(mcPartDaughterNeutrDaugh1->GetPdgCode()) == fPDGneutrDaughPositive)) {
528  AliDebug(2, "The neutral particle (MC) doesn't come from the required decay, skipping!!");
529  return isHadronic;
530  }
531 
532  Double_t sumPxDau = mcPartDaughterNeutrDaugh0->Px()+mcPartDaughterNeutrDaugh1->Px();
533  Double_t sumPyDau = mcPartDaughterNeutrDaugh0->Py()+mcPartDaughterNeutrDaugh1->Py();
534  Double_t sumPzDau = mcPartDaughterNeutrDaugh0->Pz()+mcPartDaughterNeutrDaugh1->Pz();
535  Double_t pxMother = neutralDaugh->Px();
536  Double_t pyMother = neutralDaugh->Py();
537  Double_t pzMother = neutralDaugh->Pz();
538  AliDebug(3, Form("pxMother = %f, pyMother = %f, pzMother = %f", pxMother, pyMother, pzMother));
539  AliDebug(3, Form("sumPxDau = %f, sumPyDau = %f, sumPzDau = %f", sumPxDau, sumPyDau, sumPzDau));
540  if(TMath::Abs(pxMother-sumPxDau)/(TMath::Abs(pxMother)+1.e-13)>fCutOnMomConservation ||
541  TMath::Abs(pyMother-sumPyDau)/(TMath::Abs(pyMother)+1.e-13)>fCutOnMomConservation ||
542  TMath::Abs(pzMother-sumPzDau)/(TMath::Abs(pzMother)+1.e-13)>fCutOnMomConservation){
543  AliDebug(2, "Momentum conservation violated, skipping!!");
544  return isHadronic;
545  }
546 
547  Double_t pTNeutrDaughPositive = 0;
548  Double_t pTNeutrDaughNegative = 0;
549 
550  if (mcPartDaughterNeutrDaugh0->GetPdgCode() > 0 ) {
551  pTNeutrDaughPositive = mcPartDaughterNeutrDaugh0->Pt();
552  pTNeutrDaughNegative = mcPartDaughterNeutrDaugh1->Pt();
553  }
554  else {
555  pTNeutrDaughPositive = mcPartDaughterNeutrDaugh1->Pt();
556  pTNeutrDaughNegative = mcPartDaughterNeutrDaugh0->Pt();
557  }
558 
559  isHadronic = kTRUE;
560 
561  vectorNeutrDaugh[0] = pTNeutrDaughPositive;
562  vectorNeutrDaugh[1] = pTNeutrDaughNegative;
563 
564  return isHadronic;
565 
566 }
567 
568 //___________________________________________________________
569 
571 {
572  //
573  // setting the pt cut to be used in the Acceptance steps (MC+Reco)
574  //
575 
576  AliDebug(3, "The 3rd element of the pt cut array will correspond to the cut applied to the soft pion - please check that it is correct");
577  if (fProngs>0){
578  for (Int_t iP=0; iP<fProngs; iP++){
579  fPtAccCut[iP]=ptAccCut[iP];
580  }
581  }
582  return;
583 }
584 
585 
586 
587 //___________________________________________________________
588 
590 {
591  //
592  // setting the eta cut to be used in the Acceptance steps (MC+Reco)
593  //
594 
595  AliDebug(3, "The 3rd element of the eta cut array will correspond to the cut applied to the soft pion - please check that it is correct");
596  if (fProngs>0){
597  for (Int_t iP=0; iP<fProngs; iP++){
598  fEtaAccCut[iP] = etaAccCut[iP];
599  }
600  }
601  return;
602 }
603 //___________________________________________________________
604 
605 void AliCFVertexingHFCascade::SetAccCut(Float_t* ptAccCut, Float_t* etaAccCut)
606 {
607  //
608  // setting the pt and eta cut to be used in the Acceptance steps (MC+Reco)
609  //
610 
611  AliDebug(3, "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");
612  if (fProngs>0){
613  for (Int_t iP=0; iP<fProngs; iP++){
614  fPtAccCut[iP]=ptAccCut[iP];
615  fEtaAccCut[iP]=etaAccCut[iP];
616  }
617  }
618  return;
619 }
620 
621 //___________________________________________________________
622 
624 {
625  //
626  // setting the pt and eta cut to be used in the Acceptance steps (MC+Reco)
627  //
628 
629  Int_t bachelorPosition = 2;
630  if (fPDGcascade == 4122) bachelorPosition = 0;
631  AliAODMCParticle* mcPartDaughter = dynamic_cast<AliAODMCParticle*>(fmcArray->At(fLabelArray[bachelorPosition])); // should be the soft pion...
632  if(!mcPartDaughter) return;
633  Int_t mother = mcPartDaughter->GetMother();
634  AliAODMCParticle* mcMother = dynamic_cast<AliAODMCParticle*>(fmcArray->At(mother));
635  if(!mcMother) return;
636 
637  if (TMath::Abs(mcPartDaughter->GetPdgCode()) != fPDGbachelor || TMath::Abs(mcMother->GetPdgCode()) != fPDGcascade){
638  AliError(Form("Apparently the expected bachelor is not in the third position, causing an error (pdg expected = %d, actual = %d)!!", fPDGbachelor, mcPartDaughter->GetPdgCode()));
639  AliError("This should be fixed when checking the MC part family in the CF task...");
640  return;
641  }
642  if (fProngs>0){
643  for (Int_t iP=0; iP<fProngs; iP++){
644  fPtAccCut[iP]=0.1;
645  fEtaAccCut[iP]=0.9;
646  }
647 
648  if (fPDGcascade != 4122){
649  fPtAccCut[2]=0.06; // soft pion
650  fEtaAccCut[2]=0.9; // soft pion
651  }
652  }
653  return;
654 }
655 
656 //_____________________________________________________________
657 Double_t AliCFVertexingHFCascade::GetEtaProng(Int_t iProng) const
658 {
659  //
660  // getting eta of the prong - overload the mother class method
661  //
662 
663  if (fRecoCandidate){
664 
666 
667  Double_t etaProng =-9999;
668  AliAODRecoDecay* neutrDaugh=0;
669  Int_t ibachelor = 1;
670  if (fPDGcascade == 413) {
671  neutrDaugh = cascade->Get2Prong();
672  }
673  else if (fPDGcascade == 4122) {
674  neutrDaugh = cascade->Getv0();
675  ibachelor = 0;
676  }
677  if (iProng==0) etaProng = neutrDaugh->EtaProng(0);
678  if (iProng==1) etaProng = neutrDaugh->EtaProng(1);
679  if (iProng==2) etaProng = cascade->EtaProng(ibachelor);
680 
681  return etaProng;
682 
683  }
684  return 999999;
685 }
686 //_____________________________________________________________
687 Double_t AliCFVertexingHFCascade::GetPtProng(Int_t iProng) const
688 {
689  //
690  // getting pt of the prong
691  //
692 
693  if (fRecoCandidate){
694 
696  Double_t ptProng= -9999;
697  AliAODRecoDecay* neutrDaugh=0;
698  if (fPDGcascade == 413) neutrDaugh = cascade->Get2Prong();
699  else if (fPDGcascade == 4122) neutrDaugh = cascade->Getv0();
700  if (iProng == 0) ptProng = neutrDaugh->PtProng(0);
701  if (iProng == 1) ptProng = neutrDaugh->PtProng(1);
702  if (iProng == 2) ptProng = cascade->PtProng(1);
703 
704  // Double_t ptProng = fRecoCandidate->PtProng(iProng);
705  return ptProng;
706 
707  }
708  return 999999;
709 
710 }
711 //_____________________________________________________________
712 Bool_t AliCFVertexingHFCascade::CheckAdditionalCuts(AliPIDResponse* pidResponse) const {
713 
714  // function to check whether the candidate passes the additional cuts defined in the task to get the
715  // invariant mass spectra; these cuts are NOT pt-dependent
716 
717  if (fPDGcascade == 4122){
718  // the method is implemented only in this case so far
720  AliAODv0 * v0part = cascade->Getv0();
721  AliAODTrack *bachelor = (AliAODTrack*)cascade->GetBachelor();
722  Double_t bachelorEta = bachelor->Eta();
723  AliAODTrack *v0pos = (AliAODTrack*)v0part->GetDaughter(0);
724  AliAODTrack *v0neg = (AliAODTrack*)v0part->GetDaughter(1);
725  Double_t v0posEta = v0pos->Eta();
726  Double_t v0negEta = v0neg->Eta();
727 
728  Bool_t onFlyV0 = v0part->GetOnFlyStatus(); // on-the-flight V0s
729  Double_t nSigmaTPCpr=-999.;
730  Double_t nSigmaTOFpr=-999.;
731  nSigmaTPCpr = pidResponse->NumberOfSigmasTPC(bachelor,(AliPID::kProton));
732  nSigmaTOFpr = pidResponse->NumberOfSigmasTOF(bachelor,(AliPID::kProton));
733  Double_t ptArm = v0part->PtArmV0();
734  Double_t invmassK0s = v0part->MassK0Short();
735  Double_t mK0SPDG = TDatabasePDG::Instance()->GetParticle(310)->Mass();
736 
737  Bool_t cutsForTMVA = (TMath::Abs(bachelorEta) < 0.8 && TMath::Abs(v0posEta) < 0.8 && TMath::Abs(v0negEta) < 0.8) &&
738  ((nSigmaTOFpr < -800) || (TMath::Abs(nSigmaTOFpr) < 3)) &&
739  ((ptArm > 0.01 && ptArm < 0.07) || (ptArm > 0.105)) &&
740  ((TMath::Abs(invmassK0s - mK0SPDG)) < 0.01);
741 
742 
743  if (!fUseCutsForTMVA) cutsForTMVA = kTRUE;
744 
745  Bool_t cutsForInvMassTask = !(onFlyV0) &&
746  (cascade->CosV0PointingAngle()>0.99) &&
747  (TMath::Abs(nSigmaTPCpr) <= 3) &&
748  (v0part->Getd0Prong(0) < 20) &&
749  (v0part->Getd0Prong(1) < 20);
750 
751  if (cutsForTMVA && cutsForInvMassTask) {
752  // K0Smass cut
753  // eta cut
754  // TOF PID cut
755  // Arm cut
756  return kTRUE;
757  }
758  }
759 
760  return kFALSE;
761 
762 }
Int_t charge
AliCFVertexingHF & operator=(const AliCFVertexingHF &c)
Bool_t GetRecoValuesFromCandidate(Double_t *) const
Int_t fPDGneutrDaughPositive
pdg code of the V0
Double_t GetPtProng(Int_t iProng) const
TClonesArray * fmcArray
Class for HF corrections as a function of many variables and steps For D* and other cascades...
Double_t Ct(UInt_t pdg) const
Int_t MatchToMC(Int_t pdgabs, Int_t pdgabs2prong, Int_t *pdgDg, Int_t *pdgDg2prong, TClonesArray *mcArray, Bool_t isV0=kFALSE) const
AliAODv0 * Getv0() const
AliAODVertex * fPrimVtx
pdg code of the negative daughter of the V0
AliAODMCParticle * fmcPartCandidate
Reconstructed HF candidate.
Int_t fPDGbachelor
pdg code of the cascade
AliCFVertexingHFCascade & operator=(const AliCFVertexingHFCascade &other)
Double_t CosPointingAngleXY() const
void SetEtaAccCut(Float_t *etaAccCut)
void SetNProngs(Int_t nProngs)
void SetPtAccCut(Float_t *ptAccCut)
Float_t * fPtAccCut
centrality value
Double_t GetEtaProng(Int_t iProng) const
Float_t fFake
fakes selection: 0 –> all, 1 –> non-fake, 2 –> fake
Int_t fConfiguration
multiplicity of the event
Int_t fPDGneutrDaughForMC
pdg code of the V0
AliAODTrack * GetBachelor() const
Int_t fPDGneutrDaughNegative
pdg code of the positive daughter of the V0
rapidity
Definition: HFPtSpectrum.C:46
Bool_t GetGeneratedValuesFromMCParticle(Double_t *)
Double_t CosV0PointingAngle() const
Bool_t fUseCutsForTMVA
primaryVertex
Int_t * fLabelArray
n. of prongs
Int_t fPDGneutrDaugh
pdg code of the bachelor
AliAODRecoDecayHF * fRecoCandidate
mcArray candidate
Bool_t CheckAdditionalCuts(AliPIDResponse *pidResponse) const
decay
Definition: HFPtSpectrum.C:41
slow configuration, all variables
ClassImp(AliAnalysisTaskCRC) AliAnalysisTaskCRC
Int_t fmcLabel
flag to keep only the charm particles that comes from beauty decays
Double_t fzPrimVertex
get Number of variables for the container from the channel decay
Int_t NumberOfFakeDaughters() const
Int_t fProngs
results of the MatchToMC()
AliAODVertex * GetPrimaryVtx() const
void SetMCLabel(Int_t mcLabel)
AliAODRecoDecayHF2Prong * Get2Prong() const
Bool_t EvaluateIfCorrectNeutrDaugh(AliAODMCParticle *neutralDaugh, Double_t *VectorD0) const
Double_t fzMCVertex
Reco z primary vertex.
Double_t fMultiplicity
flag to remove events not geenrated with PYTHIA
Bool_t SetRecoCandidateParam(AliAODRecoDecayHF *recoCand)
Class for HF corrections as a function of many variables and step.