AliPhysics  e09d476 (e09d476)
AliCFVertexingHF2Prong.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-2009, 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 step
18 // Author : C. Zampolli, CERN
19 // D. Caffarri, Univ & INFN Padova caffarri@pd.infn.it
20 // Base class for HF Unfolding - agrelli@uu.nl
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 
31 #include "AliCFVertexingHF2Prong.h"
32 #include "AliCFContainer.h"
33 #include "AliCFTaskVertexingHF.h"
34 
36 ClassImp(AliCFVertexingHF2Prong);
38 
39 //_________________________________________
40  AliCFVertexingHF2Prong::AliCFVertexingHF2Prong(TClonesArray *mcArray, UShort_t originDselection):
41  AliCFVertexingHF(mcArray, originDselection)
42 {
43  //
44  // constructor
45  //
46 
47  SetNProngs(2);
50  for(Int_t iP=0; iP<fProngs; iP++){
51  fPtAccCut[iP]=0.1;
52  fEtaAccCut[iP]=0.9;
53  }
54 
55 }
56 
57 
58 //_____________________________________
60 {
61  //
62  // copy constructor
63  //
64 
65  if (this != &c) {
67  }
68  return *this;
69 }
70 
71 //__________________________________________
73 {
74  //
75  // setting the recontructed candidate
76  //
77 
78  Bool_t bSignAssoc = kFALSE;
79  fRecoCandidate = recoCand;
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()) AliDebug(3,"Reco Cand has a pointer to PrimVtx\n");
87 
88  Int_t pdgCand = 421;
89  Int_t pdgDgD0toKpi[2]={321,211};
90  Int_t nentries = fmcArray->GetEntriesFast();
91 
92  AliDebug(3,Form("nentries = %d\n", nentries));
93 
94  Int_t mcLabel = fRecoCandidate->MatchToMC(pdgCand,fmcArray,2,pdgDgD0toKpi);
95  if (mcLabel == -1) return bSignAssoc;
96 
98  fFake = 0; // fake candidate
99  if (fFakeSelection==1) return bSignAssoc;
100  }
102  fFake = 2; // non-fake candidate
103  if (fFakeSelection==2) return bSignAssoc;
104  }
105 
106  SetMCLabel(mcLabel);
107  fmcPartCandidate = dynamic_cast<AliAODMCParticle*>(fmcArray->At(fmcLabel));
108  if (!fmcPartCandidate){
109  AliDebug(3,"No part candidate");
110  return bSignAssoc;
111  }
112  bSignAssoc = kTRUE;
113  return bSignAssoc;
114 }
115 
116 //______________________________________________
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  Double_t vtx1[3] = {0,0,0}; // primary vertex
125  Double_t vtx2daughter0[3] = {0,0,0}; // secondary vertex from daughter 0
126  Double_t vtx2daughter1[3] = {0,0,0}; // secondary vertex from daughter 1
127  fmcPartCandidate->XvYvZv(vtx1); // cm
128 
129  Int_t daughter0 = fmcPartCandidate->GetDaughter(0);
130  Int_t daughter1 = fmcPartCandidate->GetDaughter(1);
131  AliAODMCParticle* mcPartDaughter0 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter0));
132  AliAODMCParticle* mcPartDaughter1 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter1));
133  if(!mcPartDaughter0 || !mcPartDaughter1) return bGenValues;
134 
135  // getting vertex from daughters
136  mcPartDaughter0->XvYvZv(vtx2daughter0); // cm
137  mcPartDaughter1->XvYvZv(vtx2daughter1); //cm
138  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) {
139  AliError("Daughters have different secondary vertex, skipping the track");
140  return bGenValues;
141  }
142 
143  Int_t nprongs = 2;
144  Short_t charge = 0;
145  // always instantiate the AliAODRecoDecay with the positive daughter first, the negative second
146  AliAODMCParticle* positiveDaugh = mcPartDaughter0;
147  AliAODMCParticle* negativeDaugh = mcPartDaughter1;
148  if (mcPartDaughter0->GetPdgCode()<0 && mcPartDaughter1->GetPdgCode()>0){
149  // inverting in case the positive daughter is the second one
150  positiveDaugh = mcPartDaughter1;
151  negativeDaugh = mcPartDaughter0;
152  }
153  // getting the momentum from the daughters
154  Double_t px[2] = {positiveDaugh->Px(), negativeDaugh->Px()};
155  Double_t py[2] = {positiveDaugh->Py(), negativeDaugh->Py()};
156  Double_t pz[2] = {positiveDaugh->Pz(), negativeDaugh->Pz()};
157 
158  Double_t d0[2] = {0.,0.};
159 
160  AliAODRecoDecayHF* decay = new AliAODRecoDecayHF(vtx1,vtx2daughter0,nprongs,charge,px,py,pz,d0);
161 
162  Double_t cosThetaStar = 0.;
163  Double_t cosThetaStarD0 = 0.;
164  Double_t cosThetaStarD0bar = 0.;
165  cosThetaStarD0 = decay->CosThetaStar(1,421,211,321);
166  cosThetaStarD0bar = decay->CosThetaStar(0,421,321,211);
167  if (fmcPartCandidate->GetPdgCode() == 421){ // D0
168  AliDebug(3, Form("D0, with pdgprong0 = %d, pdgprong1 = %d",mcPartDaughter0->GetPdgCode(),mcPartDaughter1->GetPdgCode()));
169  cosThetaStar = cosThetaStarD0;
170  }
171  else if (fmcPartCandidate->GetPdgCode() == -421){ // D0bar{
172  AliDebug(3, Form("D0bar, with pdgprong0 = %d, pdgprong1 = %d",mcPartDaughter0->GetPdgCode(),mcPartDaughter1->GetPdgCode()));
173  cosThetaStar = cosThetaStarD0bar;
174  }
175  else{
176  AliWarning("There are problems!! particle was expected to be either a D0 or a D0bar, check...");
177  delete decay;
178  return bGenValues;
179  }
180  if (cosThetaStar < -1 || cosThetaStar > 1) {
181  AliWarning("Invalid value for cosine Theta star, returning");
182  delete decay;
183  return bGenValues;
184  }
185 
186  //ct
187  Double_t cT = decay->Ct(421);
188  // get the pT of the daughters
189  Double_t pTpi = 0.;
190  Double_t pTK = 0.;
191 
192  if (TMath::Abs(mcPartDaughter0->GetPdgCode()) == 211) {
193  pTpi = mcPartDaughter0->Pt();
194  pTK = mcPartDaughter1->Pt();
195  }
196  else {
197  pTpi = mcPartDaughter1->Pt();
198  pTK = mcPartDaughter0->Pt();
199  }
200 
201  switch (fConfiguration){
203  vectorMC[0] = fmcPartCandidate->Pt();
204  vectorMC[1] = fmcPartCandidate->Y() ;
205  vectorMC[2] = cosThetaStar ;
206  vectorMC[3] = pTpi ;
207  vectorMC[4] = pTK ;
208  vectorMC[5] = cT*1.E4 ; // in micron
209  vectorMC[6] = 0.; // dummy value for dca, meaningless in MC
210  vectorMC[7] = -80000.; // dummy value for d0pixd0K, meaningless in MC, in micron^2
211  vectorMC[8] = 1.01; // dummy value for cosPointing, meaningless in MC
212  vectorMC[9] = fmcPartCandidate->Phi();
213  vectorMC[10] = fzMCVertex; // z of reconstructed of primary vertex
214  vectorMC[11] = fCentValue; //reconstructed centrality
215  vectorMC[12] = 1.; // fake: always filling with 1 at MC level
216  vectorMC[13] = 1.01; // dummy value for cosPointingXY multiplicity
217  vectorMC[14] = 0.; // dummy value for NormalizedDecayLengthXY multiplicity
218  vectorMC[15] = fMultiplicity; // reconstructed multiplicity
219  break;
221  vectorMC[0] = fmcPartCandidate->Pt();
222  vectorMC[1] = fmcPartCandidate->Y() ;
223  vectorMC[2] = cT*1.E4; // in micron
224  vectorMC[3] = fmcPartCandidate->Phi();
225  vectorMC[4] = fzMCVertex;
226  vectorMC[5] = fCentValue; // dummy value for dca, meaningless in MC
227  vectorMC[6] = 1. ; // fake: always filling with 1 at MC level
228  vectorMC[7] = fMultiplicity; // dummy value for d0pi, meaningless in MC, in micron
229  break;
231  vectorMC[0] = fmcPartCandidate->Pt();
232  vectorMC[1] = fmcPartCandidate->Y() ;
233  vectorMC[2] = fCentValue; // dummy value for dca, meaningless in MC
234  vectorMC[3] = fMultiplicity; // dummy value for dca, meaningless in MC
235  break;
236  }
237  delete decay;
238  bGenValues = kTRUE;
239  return bGenValues;
240 }
241 //____________________________________________
243 {
244  //
245  // Getting the reconstructed values from the candidate
246  //
247 
248  Bool_t bFillRecoValues=kFALSE;
249 
251 
252  if (d0toKpi->GetPrimaryVtx())AliDebug(3,"d0toKpi has primary vtx\n");
253  if (fRecoCandidate->GetPrimaryVtx())AliDebug(3,"fRecoCandidate has primary vtx\n");
254 
255  Double_t pt = d0toKpi->Pt();
256  Double_t rapidity = d0toKpi->YD0();
257  Double_t invMass=0.;
258  Double_t cosThetaStar = 9999.;
259  Double_t pTpi = 0.;
260  Double_t pTK = 0.;
261  Double_t dca = d0toKpi->GetDCA();
262  Double_t d0pi = 0.;
263  Double_t d0K = 0.;
264  Double_t d0xd0 = d0toKpi->Prodd0d0();
265  Double_t cosPointingAngle = d0toKpi->CosPointingAngle();
266  Double_t phi = d0toKpi->Phi();
267  Int_t pdgCode = fmcPartCandidate->GetPdgCode();
268  Double_t cosPointingAngleXY = d0toKpi->CosPointingAngleXY();
269  Double_t normDecayLengthXY = d0toKpi->NormalizedDecayLengthXY();
270 
271  if (pdgCode > 0){
272  cosThetaStar = d0toKpi->CosThetaStarD0();
273  pTpi = d0toKpi->PtProng(0);
274  pTK = d0toKpi->PtProng(1);
275  d0pi = d0toKpi->Getd0Prong(0);
276  d0K = d0toKpi->Getd0Prong(1);
277  invMass=d0toKpi->InvMassD0();
278  }
279  else {
280  cosThetaStar = d0toKpi->CosThetaStarD0bar();
281  pTpi = d0toKpi->PtProng(1);
282  pTK = d0toKpi->PtProng(0);
283  d0pi = d0toKpi->Getd0Prong(1);
284  d0K = d0toKpi->Getd0Prong(0);
285  invMass= d0toKpi->InvMassD0bar();
286  }
287 
288  Double_t cT = d0toKpi->CtD0();
289 
290  switch (fConfiguration){
292  vectorReco[0] = pt;
293  vectorReco[1] = rapidity;
294  vectorReco[2] = cosThetaStar;
295  vectorReco[3] = pTpi;
296  vectorReco[4] = pTK;
297  vectorReco[5] = cT*1.E4; // in micron
298  vectorReco[6] = dca*1.E4; // in micron
299  vectorReco[7] = d0xd0*1.E8; // in micron^2
300  vectorReco[8] = cosPointingAngle;
301  vectorReco[9] = phi;
302  vectorReco[10] = fzPrimVertex; // z of reconstructed of primary vertex
303  vectorReco[11] = fCentValue; //reconstructed centrality
304  vectorReco[12] = fFake; // whether the reconstructed candidate was a fake (fFake = 0) or not (fFake = 2)
305  vectorReco[13] = cosPointingAngleXY;
306  vectorReco[14] = normDecayLengthXY; // in cm
307  vectorReco[15] = fMultiplicity; // reconstructed multiplicity
308  break;
310  vectorReco[0] = pt;
311  vectorReco[1] = rapidity ;
312  vectorReco[2] = cT*1.E4; // in micron
313  vectorReco[3] = phi;
314  vectorReco[4] = fzPrimVertex;
315  vectorReco[5] = fCentValue;
316  vectorReco[6] = fFake ;
317  vectorReco[7] = fMultiplicity;
318  break;
320  vectorReco[0] = pt;
321  vectorReco[1] = rapidity ;
322  vectorReco[2] = fCentValue;
323  vectorReco[3] = fMultiplicity;
324  break;
325  }
326 
327  bFillRecoValues = kTRUE;
328 
329  return bFillRecoValues;
330 }
331 
332 //_____________________________________________________________
334 {
335  //
336  // checking the MC decay channel
337  //
338  Bool_t checkCD = kFALSE;
339  Int_t daughter0 = fmcPartCandidate->GetDaughter(0);
340  Int_t daughter1 = fmcPartCandidate->GetDaughter(1);
341  AliAODMCParticle* mcPartDaughter0 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter0));
342  AliAODMCParticle* mcPartDaughter1 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter1));
343 
344  if (!mcPartDaughter0 || !mcPartDaughter1) {
345  AliDebug (2,"Problems in the MC Daughters\n");
346  return checkCD;
347  }
348 
349  if (!(TMath::Abs(mcPartDaughter0->GetPdgCode())==321 &&
350  TMath::Abs(mcPartDaughter1->GetPdgCode())==211) &&
351  !(TMath::Abs(mcPartDaughter0->GetPdgCode())==211 &&
352  TMath::Abs(mcPartDaughter1->GetPdgCode())==321)) {
353  AliDebug(2, "The D0 MC doesn't come from a Kpi decay, skipping!!");
354  return checkCD;
355  }
356 
357  Double_t sumPxDau=mcPartDaughter0->Px()+mcPartDaughter1->Px();
358  Double_t sumPyDau=mcPartDaughter0->Py()+mcPartDaughter1->Py();
359  Double_t sumPzDau=mcPartDaughter0->Pz()+mcPartDaughter1->Pz();
360  Double_t pxMother=fmcPartCandidate->Px();
361  Double_t pyMother=fmcPartCandidate->Py();
362  Double_t pzMother=fmcPartCandidate->Pz();
363  if(TMath::Abs(pxMother-sumPxDau)/(TMath::Abs(pxMother)+1.e-13)>0.00001 ||
364  TMath::Abs(pyMother-sumPyDau)/(TMath::Abs(pyMother)+1.e-13)>0.00001 ||
365  TMath::Abs(pzMother-sumPzDau)/(TMath::Abs(pzMother)+1.e-13)>0.00001){
366  AliDebug(2, "Momentum conservation violated, skipping!!");
367  return checkCD;
368  }
369 
370  checkCD = kTRUE;
371  return checkCD;
372 
373 }
374 
Int_t charge
Double_t NormalizedDecayLengthXY() const
AliCFVertexingHF & operator=(const AliCFVertexingHF &c)
double Double_t
Definition: External.C:58
Bool_t GetRecoValuesFromCandidate(Double_t *) const
TClonesArray * fmcArray
Double_t Ct(UInt_t pdg) const
Class for HF corrections as a function of many variables and step.
AliAODMCParticle * fmcPartCandidate
Reconstructed HF candidate.
TCanvas * c
Definition: TestFitELoss.C:172
Double_t CosPointingAngleXY() const
Bool_t SetRecoCandidateParam(AliAODRecoDecayHF *recoCand)
void SetNProngs(Int_t nProngs)
Float_t * fPtAccCut
centrality value
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
fast configuration, only a subset of variables
Double_t CosThetaStarD0bar() const
angle of K
float Float_t
Definition: External.C:68
Bool_t GetGeneratedValuesFromMCParticle(Double_t *)
AliCFVertexingHF2Prong & operator=(const AliCFVertexingHF2Prong &other)
slow configuration, all variables
rapidity
Definition: HFPtSpectrum.C:47
short Short_t
Definition: External.C:23
AliAODRecoDecayHF * fRecoCandidate
mcArray candidate
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
Double_t CosPointingAngle() const
void SetMCLabel(Int_t mcLabel)
Double_t fzMCVertex
Reco z primary vertex.
Double_t fMultiplicity
flag to remove events not geenrated with PYTHIA
Class for HF corrections as a function of many variables and step.