AliPhysics  cda3415 (cda3415)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
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;
230  }
231  delete decay;
232  bGenValues = kTRUE;
233  return bGenValues;
234 }
235 //____________________________________________
237 {
238  //
239  // Getting the reconstructed values from the candidate
240  //
241 
242  Bool_t bFillRecoValues=kFALSE;
243 
245 
246  if (d0toKpi->GetPrimaryVtx())AliDebug(3,"d0toKpi has primary vtx\n");
247  if (fRecoCandidate->GetPrimaryVtx())AliDebug(3,"fRecoCandidate has primary vtx\n");
248 
249  Double_t pt = d0toKpi->Pt();
250  Double_t rapidity = d0toKpi->YD0();
251  Double_t invMass=0.;
252  Double_t cosThetaStar = 9999.;
253  Double_t pTpi = 0.;
254  Double_t pTK = 0.;
255  Double_t dca = d0toKpi->GetDCA();
256  Double_t d0pi = 0.;
257  Double_t d0K = 0.;
258  Double_t d0xd0 = d0toKpi->Prodd0d0();
259  Double_t cosPointingAngle = d0toKpi->CosPointingAngle();
260  Double_t phi = d0toKpi->Phi();
261  Int_t pdgCode = fmcPartCandidate->GetPdgCode();
262  Double_t cosPointingAngleXY = d0toKpi->CosPointingAngleXY();
263  Double_t normDecayLengthXY = d0toKpi->NormalizedDecayLengthXY();
264 
265  if (pdgCode > 0){
266  cosThetaStar = d0toKpi->CosThetaStarD0();
267  pTpi = d0toKpi->PtProng(0);
268  pTK = d0toKpi->PtProng(1);
269  d0pi = d0toKpi->Getd0Prong(0);
270  d0K = d0toKpi->Getd0Prong(1);
271  invMass=d0toKpi->InvMassD0();
272  }
273  else {
274  cosThetaStar = d0toKpi->CosThetaStarD0bar();
275  pTpi = d0toKpi->PtProng(1);
276  pTK = d0toKpi->PtProng(0);
277  d0pi = d0toKpi->Getd0Prong(1);
278  d0K = d0toKpi->Getd0Prong(0);
279  invMass= d0toKpi->InvMassD0bar();
280  }
281 
282  Double_t cT = d0toKpi->CtD0();
283 
284  switch (fConfiguration){
286  vectorReco[0] = pt;
287  vectorReco[1] = rapidity;
288  vectorReco[2] = cosThetaStar;
289  vectorReco[3] = pTpi;
290  vectorReco[4] = pTK;
291  vectorReco[5] = cT*1.E4; // in micron
292  vectorReco[6] = dca*1.E4; // in micron
293  vectorReco[7] = d0xd0*1.E8; // in micron^2
294  vectorReco[8] = cosPointingAngle;
295  vectorReco[9] = phi;
296  vectorReco[10] = fzPrimVertex; // z of reconstructed of primary vertex
297  vectorReco[11] = fCentValue; //reconstructed centrality
298  vectorReco[12] = fFake; // whether the reconstructed candidate was a fake (fFake = 0) or not (fFake = 2)
299  vectorReco[13] = cosPointingAngleXY;
300  vectorReco[14] = normDecayLengthXY; // in cm
301  vectorReco[15] = fMultiplicity; // reconstructed multiplicity
302  break;
304  vectorReco[0] = pt;
305  vectorReco[1] = rapidity ;
306  vectorReco[2] = cT*1.E4; // in micron
307  vectorReco[3] = phi;
308  vectorReco[4] = fzPrimVertex;
309  vectorReco[5] = fCentValue;
310  vectorReco[6] = fFake ;
311  vectorReco[7] = fMultiplicity;
312  break;
313  }
314 
315  bFillRecoValues = kTRUE;
316 
317  return bFillRecoValues;
318 }
319 
320 //_____________________________________________________________
322 {
323  //
324  // checking the MC decay channel
325  //
326  Bool_t checkCD = kFALSE;
327  Int_t daughter0 = fmcPartCandidate->GetDaughter(0);
328  Int_t daughter1 = fmcPartCandidate->GetDaughter(1);
329  AliAODMCParticle* mcPartDaughter0 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter0));
330  AliAODMCParticle* mcPartDaughter1 = dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter1));
331 
332  if (!mcPartDaughter0 || !mcPartDaughter1) {
333  AliDebug (2,"Problems in the MC Daughters\n");
334  return checkCD;
335  }
336 
337  if (!(TMath::Abs(mcPartDaughter0->GetPdgCode())==321 &&
338  TMath::Abs(mcPartDaughter1->GetPdgCode())==211) &&
339  !(TMath::Abs(mcPartDaughter0->GetPdgCode())==211 &&
340  TMath::Abs(mcPartDaughter1->GetPdgCode())==321)) {
341  AliDebug(2, "The D0 MC doesn't come from a Kpi decay, skipping!!");
342  return checkCD;
343  }
344 
345  Double_t sumPxDau=mcPartDaughter0->Px()+mcPartDaughter1->Px();
346  Double_t sumPyDau=mcPartDaughter0->Py()+mcPartDaughter1->Py();
347  Double_t sumPzDau=mcPartDaughter0->Pz()+mcPartDaughter1->Pz();
348  Double_t pxMother=fmcPartCandidate->Px();
349  Double_t pyMother=fmcPartCandidate->Py();
350  Double_t pzMother=fmcPartCandidate->Pz();
351  if(TMath::Abs(pxMother-sumPxDau)/(TMath::Abs(pxMother)+1.e-13)>0.00001 ||
352  TMath::Abs(pyMother-sumPyDau)/(TMath::Abs(pyMother)+1.e-13)>0.00001 ||
353  TMath::Abs(pzMother-sumPzDau)/(TMath::Abs(pzMother)+1.e-13)>0.00001){
354  AliDebug(2, "Momentum conservation violated, skipping!!");
355  return checkCD;
356  }
357 
358  checkCD = kTRUE;
359  return checkCD;
360 
361 }
362 
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
Double_t CosThetaStarD0bar() const
angle of K
float Float_t
Definition: External.C:68
Bool_t GetGeneratedValuesFromMCParticle(Double_t *)
AliCFVertexingHF2Prong & operator=(const AliCFVertexingHF2Prong &other)
rapidity
Definition: HFPtSpectrum.C:46
short Short_t
Definition: External.C:23
AliAODRecoDecayHF * fRecoCandidate
mcArray candidate
decay
Definition: HFPtSpectrum.C:41
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()
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)
slow configuration, all variables
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.