AliPhysics  32e057f (32e057f)
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 
38 ClassImp(AliCFVertexingHFCascade);
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),
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;
318  vectorMC[0] = fmcPartCandidate->Pt();
319  vectorMC[1] = fmcPartCandidate->Y() ;
320  vectorMC[2] = fCentValue; // dummy value for dca, meaningless in MC
321  vectorMC[3] = fMultiplicity; // dummy value for d0pi, meaningless in MC, in micron
322  break;
323  }
324 
325  delete decay;
326  bGenValues = kTRUE;
327  return bGenValues;
328 }
329 //____________________________________________
331 {
332  // read the variables for the container
333 
334  Bool_t bFillRecoValues = kFALSE;
335 
336  //Get the cascade and the neutral particle from it
338  AliAODRecoDecay* neutrDaugh = NULL;
339  if (fPDGcascade == 413) neutrDaugh = cascade->Get2Prong();
340  else if (fPDGcascade == 4122) neutrDaugh = cascade->Getv0();
341  else {
342  return kFALSE;
343  }
344 
345  //if (cascade->GetPrimaryVtx())printf("cascade has primary vtx\n");
346  //if (fRecoCandidate->GetPrimaryVtx())printf("fRecoCandidateDstar has primary vtx\n");
347 
348  Double_t pt = cascade->Pt();
349  Double_t rapidity = cascade->Y(fPDGcascade);
350  // Double_t invMass = 0.;
351  Double_t cosThetaStar = 9999.;
352  Double_t pTneutrDaughPos = 0.;
353  Double_t pTneutrDaughNeg = 0.;
354  Double_t dca = neutrDaugh->GetDCA();
355  // Double_t d0neutrDaughPos = 0.;
356  // Double_t d0neutrDaughNeg = 0.;
357  Double_t d0xd0 = neutrDaugh->Prodd0d0();
358  Double_t cosPointingAngle = neutrDaugh->CosPointingAngle(fPrimVtx);
359  Double_t phi = cascade->Phi();
360  Double_t cosPointingAngleXY = neutrDaugh->CosPointingAngleXY(fPrimVtx);
361  Double_t normDecayLengthXY = neutrDaugh->NormalizedDecayLengthXY(fPrimVtx);
362 
363  Int_t pdgCode = fmcPartCandidate->GetPdgCode();
364 
365  // UInt_t pdgDaughCascade[2] = { static_cast<UInt_t>(fPDGbachelor), static_cast<UInt_t>(fPDGneutrDaugh) }; // bachelor is first daughter of cascade
366  // UInt_t pdgDaughBarCascade[2] = { static_cast<UInt_t>(fPDGneutrDaugh), static_cast<UInt_t>(fPDGbachelor) }; // bachelor is second daughter in case of a cascade-bar
367 
368  if (pdgCode > 0){
369  cosThetaStar = neutrDaugh->CosThetaStar(1, fPDGneutrDaugh, fPDGneutrDaughPositive, fPDGneutrDaughNegative);
370  pTneutrDaughPos = neutrDaugh->PtProng(0);
371  pTneutrDaughNeg = neutrDaugh->PtProng(1);
372  // d0neutrDaughPos = neutrDaugh->Getd0Prong(0);
373  // d0neutrDaughNeg = neutrDaugh->Getd0Prong(1);
374  // invMass = neutrDaugh->InvMass(2, pdgDaughCascade);
375  }
376  else {
377  cosThetaStar = neutrDaugh->CosThetaStar(0, fPDGneutrDaugh, fPDGneutrDaughPositive, fPDGneutrDaughNegative);
378  pTneutrDaughPos = neutrDaugh->PtProng(1);
379  pTneutrDaughNeg = neutrDaugh->PtProng(0);
380  // d0neutrDaughPos = neutrDaugh->Getd0Prong(1);
381  // d0neutrDaughNeg = neutrDaugh->Getd0Prong(0);
382  // invMass = neutrDaugh->InvMass(2, pdgDaughBarCascade);
383  }
384 
385  Double_t cT = neutrDaugh->Ct(fPDGneutrDaugh, fPrimVtx);
386 
387  switch (fConfiguration){
389  vectorReco[0] = pt;
390  vectorReco[1] = rapidity;
391  vectorReco[2] = cosThetaStar;
392  vectorReco[3] = pTneutrDaughPos;
393  vectorReco[4] = pTneutrDaughNeg;
394  vectorReco[5] = cT*1.E4; // in micron
395  vectorReco[6] = dca*1.E4; // in micron
396  vectorReco[7] = d0xd0*1.E8; // in micron^2
397  vectorReco[8] = cosPointingAngle; // in micron
398  vectorReco[9] = phi;
399  vectorReco[10] = fzPrimVertex; // z of reconstructed of primary vertex
400  vectorReco[11] = fCentValue;
401  vectorReco[12] = fFake; // whether the reconstructed candidate was a fake (fFake = 0) or not (fFake = 2)
402  vectorReco[13] = cosPointingAngleXY;
403  vectorReco[14] = normDecayLengthXY; // in cm
404  vectorReco[15] = fMultiplicity; // reconstructed multiplicity
405  break;
407  vectorReco[0] = pt;
408  vectorReco[1] = rapidity;
409  vectorReco[2] = cT*1.E4; // in micron
410  vectorReco[3] = phi;
411  vectorReco[4] = fzPrimVertex;
412  vectorReco[5] = fCentValue;
413  vectorReco[6] = fFake;
414  vectorReco[7] = fMultiplicity;
415  break;
417  vectorReco[0] = pt;
418  vectorReco[1] = rapidity;
419  vectorReco[2] = fCentValue;
420  vectorReco[3] = fMultiplicity;
421  break;
422  }
423 
424  bFillRecoValues = kTRUE;
425 
426  return bFillRecoValues;
427 }
428 
429 
430 //_____________________________________________________________
432 {
433  // check the required decay channel
434 
435  Bool_t checkCD = kFALSE;
436 
437  Int_t daughter0 = fmcPartCandidate->GetDaughter(0);
438  Int_t daughter1 = fmcPartCandidate->GetDaughter(1);
439  AliAODMCParticle* mcPartDaughter0 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter0));
440  AliAODMCParticle* mcPartDaughter1 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter1));
441 
442  if (!mcPartDaughter0 || !mcPartDaughter1) {
443  AliDebug (2,"Problems in the MC Daughters\n");
444  return checkCD;
445  }
446 
447  if(TMath::Abs(fmcPartCandidate->GetPdgCode()) == 4122 && (daughter1 - daughter0 != 1)) {
448  AliDebug(2, Form("The MC particle doesn't have the correct daughters!!"));
449  return checkCD;
450  }
451 
452  if (!(TMath::Abs(mcPartDaughter0->GetPdgCode()) == fPDGneutrDaughForMC &&
453  TMath::Abs(mcPartDaughter1->GetPdgCode()) == fPDGbachelor) &&
454  !(TMath::Abs(mcPartDaughter0->GetPdgCode()) == fPDGbachelor &&
455  TMath::Abs(mcPartDaughter1->GetPdgCode()) == fPDGneutrDaughForMC)) {
456  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()));
457  return checkCD;
458  }
459 
460  // the Neutral Particle (e.g. D0 for D*, K0S for Lc...)
461  AliAODMCParticle* mcPartDaughterNeutrDaugh = NULL;
462 
463  // for D* the D0 (the neutral) is the first daughter, while for Lc the V0 is the second, so we check the
464  // charge of teh daughters to decide which is which
465  AliDebug(3, Form("Charge0 = %d, Charge1 = %d", mcPartDaughter0->Charge()/3, mcPartDaughter1->Charge()/3));
466  if (mcPartDaughter0->Charge()/3 != 0){
467  mcPartDaughterNeutrDaugh = mcPartDaughter1;
468  }
469  else {
470  mcPartDaughterNeutrDaugh = mcPartDaughter0;
471  }
472 
473  Double_t vectorNeutrDaugh[2] ={0., 0.};
474 
475  // We are looking at a cascade ...evaluate the correct cascade
476  if (!EvaluateIfCorrectNeutrDaugh(mcPartDaughterNeutrDaugh, vectorNeutrDaugh)) {
477  AliDebug(2, "Error! the NeutrDaugh MC doesn't have correct daughters!!");
478  return checkCD;
479  }
480 
481  checkCD = kTRUE;
482  return checkCD;
483 
484 }
485 
486 //__________________________________________
487 Bool_t AliCFVertexingHFCascade::EvaluateIfCorrectNeutrDaugh(AliAODMCParticle* neutralDaugh, Double_t* vectorNeutrDaugh)const
488 {
489  //
490  // check wether D0 is decaing into kpi
491  //
492 
493  Bool_t isHadronic = kFALSE;
494  AliDebug(2, Form("neutralDaugh = %p, pdg = %d", neutralDaugh, neutralDaugh->GetPdgCode()));
495 
496  if (fPDGcascade == 4122) {
497  Int_t labelresonanceDaugh = neutralDaugh->GetDaughter(0);
498  AliAODMCParticle* resonanceDaugh = dynamic_cast<AliAODMCParticle*>(fmcArray->At(labelresonanceDaugh));
499  if (!resonanceDaugh){
500  return kFALSE;
501  }
502  else {
503  AliDebug(3, Form("The daughter of the resonant particle is a %d (we are looking for a %d)", resonanceDaugh->GetPdgCode(), fPDGneutrDaugh));
504  if (TMath::Abs(resonanceDaugh->GetPdgCode()) != fPDGneutrDaugh){
505  return kFALSE;
506  }
507  else {
508  neutralDaugh = resonanceDaugh;
509  }
510  }
511  }
512 
513  Int_t daughterNeutrDaugh0 = neutralDaugh->GetDaughter(0);
514  Int_t daughterNeutrDaugh1 = neutralDaugh->GetDaughter(1);
515 
516  AliDebug(2, Form("daughter0 = %d and daughter1 = %d", daughterNeutrDaugh0, daughterNeutrDaugh1));
517  if (daughterNeutrDaugh0 == 0 || daughterNeutrDaugh1 == 0) {
518  AliDebug(2, "Error! the D0 MC doesn't have correct daughters!!");
519  return isHadronic;
520  }
521 
522  Int_t numberOfExpectedDaughters = 2;
523  if (TMath::Abs(daughterNeutrDaugh1 - daughterNeutrDaugh0) != numberOfExpectedDaughters-1) { // should be everytime true - see PDGdatabooklet
524  AliDebug(2, "The D0 MC doesn't come from a 2-prong decay, skipping!!");
525  return isHadronic;
526  }
527 
528  AliAODMCParticle* mcPartDaughterNeutrDaugh0 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughterNeutrDaugh0));
529  AliAODMCParticle* mcPartDaughterNeutrDaugh1 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughterNeutrDaugh1));
530  if (!mcPartDaughterNeutrDaugh0 || !mcPartDaughterNeutrDaugh1) {
531  AliWarning("D0 MC analysis: At least one Daughter Particle not found in tree, skipping");
532  return isHadronic;
533  }
534 
535  AliDebug(3, Form("Daughter 0 has pdg = %d, daughter 1 has pdg = %d", mcPartDaughterNeutrDaugh0->GetPdgCode(), mcPartDaughterNeutrDaugh1->GetPdgCode()));
536  if (!(TMath::Abs(mcPartDaughterNeutrDaugh0->GetPdgCode()) == fPDGneutrDaughPositive &&
537  TMath::Abs(mcPartDaughterNeutrDaugh1->GetPdgCode()) == fPDGneutrDaughNegative) &&
538  !(TMath::Abs(mcPartDaughterNeutrDaugh0->GetPdgCode()) == fPDGneutrDaughNegative &&
539  TMath::Abs(mcPartDaughterNeutrDaugh1->GetPdgCode()) == fPDGneutrDaughPositive)) {
540  AliDebug(2, "The neutral particle (MC) doesn't come from the required decay, skipping!!");
541  return isHadronic;
542  }
543 
544  Double_t sumPxDau = mcPartDaughterNeutrDaugh0->Px()+mcPartDaughterNeutrDaugh1->Px();
545  Double_t sumPyDau = mcPartDaughterNeutrDaugh0->Py()+mcPartDaughterNeutrDaugh1->Py();
546  Double_t sumPzDau = mcPartDaughterNeutrDaugh0->Pz()+mcPartDaughterNeutrDaugh1->Pz();
547  Double_t pxMother = neutralDaugh->Px();
548  Double_t pyMother = neutralDaugh->Py();
549  Double_t pzMother = neutralDaugh->Pz();
550  AliDebug(3, Form("pxMother = %f, pyMother = %f, pzMother = %f", pxMother, pyMother, pzMother));
551  AliDebug(3, Form("sumPxDau = %f, sumPyDau = %f, sumPzDau = %f", sumPxDau, sumPyDau, sumPzDau));
552  if(TMath::Abs(pxMother-sumPxDau)/(TMath::Abs(pxMother)+1.e-13)>fCutOnMomConservation ||
553  TMath::Abs(pyMother-sumPyDau)/(TMath::Abs(pyMother)+1.e-13)>fCutOnMomConservation ||
554  TMath::Abs(pzMother-sumPzDau)/(TMath::Abs(pzMother)+1.e-13)>fCutOnMomConservation){
555  AliDebug(2, "Momentum conservation violated, skipping!!");
556  return isHadronic;
557  }
558 
559  Double_t pTNeutrDaughPositive = 0;
560  Double_t pTNeutrDaughNegative = 0;
561 
562  if (mcPartDaughterNeutrDaugh0->GetPdgCode() > 0 ) {
563  pTNeutrDaughPositive = mcPartDaughterNeutrDaugh0->Pt();
564  pTNeutrDaughNegative = mcPartDaughterNeutrDaugh1->Pt();
565  }
566  else {
567  pTNeutrDaughPositive = mcPartDaughterNeutrDaugh1->Pt();
568  pTNeutrDaughNegative = mcPartDaughterNeutrDaugh0->Pt();
569  }
570 
571  isHadronic = kTRUE;
572 
573  vectorNeutrDaugh[0] = pTNeutrDaughPositive;
574  vectorNeutrDaugh[1] = pTNeutrDaughNegative;
575 
576  return isHadronic;
577 
578 }
579 
580 //___________________________________________________________
581 
583 {
584  //
585  // setting the pt cut to be used in the Acceptance steps (MC+Reco)
586  //
587 
588  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");
589  if (fProngs>0){
590  for (Int_t iP=0; iP<fProngs; iP++){
591  fPtAccCut[iP]=ptAccCut[iP];
592  }
593  }
594  return;
595 }
596 
597 
598 
599 //___________________________________________________________
600 
602 {
603  //
604  // setting the eta cut to be used in the Acceptance steps (MC+Reco)
605  //
606 
607  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");
608  if (fProngs>0){
609  for (Int_t iP=0; iP<fProngs; iP++){
610  fEtaAccCut[iP] = etaAccCut[iP];
611  }
612  }
613  return;
614 }
615 //___________________________________________________________
616 
618 {
619  //
620  // setting the pt and eta cut to be used in the Acceptance steps (MC+Reco)
621  //
622 
623  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");
624  if (fProngs>0){
625  for (Int_t iP=0; iP<fProngs; iP++){
626  fPtAccCut[iP]=ptAccCut[iP];
627  fEtaAccCut[iP]=etaAccCut[iP];
628  }
629  }
630  return;
631 }
632 
633 //___________________________________________________________
634 
636 {
637  //
638  // setting the pt and eta cut to be used in the Acceptance steps (MC+Reco)
639  //
640 
641  Int_t bachelorPosition = 2;
642  if (fPDGcascade == 4122) bachelorPosition = 0;
643  AliAODMCParticle* mcPartDaughter = dynamic_cast<AliAODMCParticle*>(fmcArray->At(fLabelArray[bachelorPosition])); // should be the soft pion...
644  if(!mcPartDaughter) return;
645  Int_t mother = mcPartDaughter->GetMother();
646  AliAODMCParticle* mcMother = dynamic_cast<AliAODMCParticle*>(fmcArray->At(mother));
647  if(!mcMother) return;
648 
649  if (TMath::Abs(mcPartDaughter->GetPdgCode()) != fPDGbachelor || TMath::Abs(mcMother->GetPdgCode()) != fPDGcascade){
650  AliError(Form("Apparently the expected bachelor is not in the third position, causing an error (pdg expected = %d, actual = %d)!!", fPDGbachelor, mcPartDaughter->GetPdgCode()));
651  AliError("This should be fixed when checking the MC part family in the CF task...");
652  return;
653  }
654  if (fProngs>0){
655  for (Int_t iP=0; iP<fProngs; iP++){
656  fPtAccCut[iP]=0.1;
657  fEtaAccCut[iP]=0.9;
658  }
659 
660  if (fPDGcascade != 4122){
661  fPtAccCut[2]=0.06; // soft pion
662  fEtaAccCut[2]=0.9; // soft pion
663  }
664  }
665  return;
666 }
667 
668 //_____________________________________________________________
670 {
671  //
672  // getting eta of the prong - overload the mother class method
673  //
674 
675  if (fRecoCandidate){
676 
678 
679  Double_t etaProng =-9999;
680  AliAODRecoDecay* neutrDaugh=0;
681  Int_t ibachelor = 1;
682  if (fPDGcascade == 413) {
683  neutrDaugh = cascade->Get2Prong();
684  }
685  else if (fPDGcascade == 4122) {
686  neutrDaugh = cascade->Getv0();
687  ibachelor = 0;
688  }
689  if (iProng==0) etaProng = neutrDaugh->EtaProng(0);
690  if (iProng==1) etaProng = neutrDaugh->EtaProng(1);
691  if (iProng==2) etaProng = cascade->EtaProng(ibachelor);
692 
693  return etaProng;
694 
695  }
696  return 999999;
697 }
698 //_____________________________________________________________
700 {
701  //
702  // getting pt of the prong
703  //
704 
705  if (fRecoCandidate){
706 
708  Double_t ptProng= -9999;
709  AliAODRecoDecay* neutrDaugh=0;
710  if (fPDGcascade == 413) neutrDaugh = cascade->Get2Prong();
711  else if (fPDGcascade == 4122) neutrDaugh = cascade->Getv0();
712  if (iProng == 0) ptProng = neutrDaugh->PtProng(0);
713  if (iProng == 1) ptProng = neutrDaugh->PtProng(1);
714  if (iProng == 2) ptProng = cascade->PtProng(1);
715 
716  // Double_t ptProng = fRecoCandidate->PtProng(iProng);
717  return ptProng;
718 
719  }
720  return 999999;
721 
722 }
723 //_____________________________________________________________
724 Bool_t AliCFVertexingHFCascade::CheckAdditionalCuts(AliPIDResponse* pidResponse) const {
725 
726  // function to check whether the candidate passes the additional cuts defined in the task to get the
727  // invariant mass spectra; these cuts are NOT pt-dependent
728 
729  if (fPDGcascade == 4122){
730  // the method is implemented only in this case so far
732  AliAODv0 * v0part = cascade->Getv0();
733  AliAODTrack *bachelor = (AliAODTrack*)cascade->GetBachelor();
734  Double_t bachelorEta = bachelor->Eta();
735  AliAODTrack *v0pos = (AliAODTrack*)v0part->GetDaughter(0);
736  AliAODTrack *v0neg = (AliAODTrack*)v0part->GetDaughter(1);
737  Double_t v0posEta = v0pos->Eta();
738  Double_t v0negEta = v0neg->Eta();
739 
740  Bool_t onFlyV0 = v0part->GetOnFlyStatus(); // on-the-flight V0s
741  Double_t nSigmaTPCpr=-999.;
742  Double_t nSigmaTOFpr=-999.;
743  nSigmaTPCpr = pidResponse->NumberOfSigmasTPC(bachelor,(AliPID::kProton));
744  nSigmaTOFpr = pidResponse->NumberOfSigmasTOF(bachelor,(AliPID::kProton));
745  Double_t ptArm = v0part->PtArmV0();
746  Double_t invmassK0s = v0part->MassK0Short();
747  Double_t mK0SPDG = TDatabasePDG::Instance()->GetParticle(310)->Mass();
748 
749  Bool_t cutsForTMVA = (TMath::Abs(bachelorEta) < 0.8 && TMath::Abs(v0posEta) < 0.8 && TMath::Abs(v0negEta) < 0.8) &&
750  ((nSigmaTOFpr < -800) || (TMath::Abs(nSigmaTOFpr) < 3)) &&
751  ((ptArm > 0.01 && ptArm < 0.07) || (ptArm > 0.105)) &&
752  ((TMath::Abs(invmassK0s - mK0SPDG)) < 0.01);
753 
754 
755  if (!fUseCutsForTMVA) cutsForTMVA = kTRUE;
756 
757  Bool_t cutsForInvMassTask = !(onFlyV0) &&
758  (cascade->CosV0PointingAngle()>0.99) &&
759  (TMath::Abs(nSigmaTPCpr) <= 3) &&
760  (v0part->Getd0Prong(0) < 20) &&
761  (v0part->Getd0Prong(1) < 20);
762 
763  if (cutsForTMVA && cutsForInvMassTask) {
764  // K0Smass cut
765  // eta cut
766  // TOF PID cut
767  // Arm cut
768  return kTRUE;
769  }
770  }
771 
772  return kFALSE;
773 
774 }
Int_t charge
AliCFVertexingHF & operator=(const AliCFVertexingHF &c)
Bool_t GetRecoValuesFromCandidate(Double_t *) const
double Double_t
Definition: External.C:58
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)
TCanvas * c
Definition: TestFitELoss.C:172
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 Int_t
Definition: External.C:63
Int_t fPDGneutrDaughForMC
pdg code of the V0
fast configuration, only a subset of variables
float Float_t
Definition: External.C:68
AliAODTrack * GetBachelor() const
slow configuration, all variables
Int_t fPDGneutrDaughNegative
pdg code of the positive daughter of the V0
rapidity
Definition: HFPtSpectrum.C:47
Bool_t GetGeneratedValuesFromMCParticle(Double_t *)
Double_t CosV0PointingAngle() const
short Short_t
Definition: External.C:23
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
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()
unsigned short UShort_t
Definition: External.C:28
AliAODVertex * GetPrimaryVtx() const
bool Bool_t
Definition: External.C:53
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.