AliPhysics  vAN-20150924 (e816f45)
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros
AliHFsubtractBFDcuts.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 
25 #include "AliHFsubtractBFDcuts.h"
26 
27 #include <vector>
28 
29 #include "TNamed.h"
30 #include "THnSparse.h"
31 #include "TH1F.h"
32 #include "TH3F.h"
33 #include "TClonesArray.h"
34 #include "TString.h"
35 #include "TObjString.h"
36 #include "TMath.h"
37 
39 #include "AliAODMCParticle.h"
40 #include "AliAODEvent.h"
41 #include "AliAODVertex.h"
42 #include "AliESDVertex.h"
43 #include "AliVTrack.h"
44 #include "AliAODTrack.h"
45 #include "AliVertexerTracks.h"
46 #include "AliExternalTrackParam.h"
47 #include "AliNeutralTrackParam.h"
48 
52 
54  : TNamed()
55  , fIsMC(kTRUE)
56  , fCheckAcceptance(kTRUE)
57  , fResolveResonances(kTRUE)
58  , fTHnGenStep(0x0)
59  , fTHnData(0x0)
60  , fTHnMC(0x0)
61  , fMCarray(0x0)
62  , fAODtracks(0x0)
63  , fLabCand(-1)
64  , fPtCand(0.)
65  , fNprongs((UInt_t)-1)
66  , fNprongsInAcc((UInt_t)-1)
67  , fMotherPt(-1.)
68  , fGenerateDecayList(kFALSE) // DON'T ACTIVATE, DOESN'T MERGE
69  , fDecayProngs()
70  , fDecayStrList(0x0)
71  , fQAhists(0x0)
72 {
74 }
75 
76 AliHFsubtractBFDcuts::AliHFsubtractBFDcuts(const char* name, const char* title)
77  : TNamed(name,title)
78  , fIsMC(kTRUE)
79  , fCheckAcceptance(kTRUE)
80  , fResolveResonances(kTRUE)
81  , fTHnGenStep(0x0)
82  , fTHnData(0x0)
83  , fTHnMC(0x0)
84  , fMCarray(0x0)
85  , fAODtracks(0x0)
86  , fLabCand(-1)
87  , fPtCand(0.)
88  , fNprongs((UInt_t)-1)
89  , fNprongsInAcc((UInt_t)-1)
90  , fMotherPt(-1.)
91  , fGenerateDecayList(kFALSE) // DON'T ACTIVATE, DOESN'T MERGE
92  , fDecayProngs()
93  , fDecayStrList(0x0)
94  , fQAhists(0x0)
95 {
97  fDecayStrList = new TList();
98  fDecayStrList->SetOwner();
99  fQAhists = new TList();
100  fQAhists->SetOwner();
101 }
102 
104  : TNamed(c.GetName(),c.GetTitle())
105  , fIsMC(c.fIsMC)
106  , fCheckAcceptance(c.fCheckAcceptance)
107  , fResolveResonances(c.fResolveResonances)
108  , fTHnGenStep(c.fTHnGenStep)
109  , fTHnData(c.fTHnData)
110  , fTHnMC(c.fTHnMC)
111  , fMCarray(c.fMCarray)
112  , fAODtracks(c.fAODtracks)
113  , fLabCand(c.fLabCand)
114  , fPtCand(c.fPtCand)
115  , fNprongs(c.fNprongs)
116  , fNprongsInAcc(c.fNprongsInAcc)
117  , fMotherPt(c.fMotherPt)
118  , fGenerateDecayList(c.fGenerateDecayList)
119  , fDecayProngs(c.fDecayProngs)
120  , fDecayStrList(c.fDecayStrList) // FIXME: TList copy contructor not implemented
121  , fQAhists(c.fQAhists)
122 {
124 }
125 
127 {
129  return c;
130 }
131 
133  AliDebug(3, "TODO: implement me!");
134 }
135 
137  // mass, pt, normLXY, cosPointXY, normL, cosPoint, LXY, L
138  Int_t dimAxes[8]={500 ,24 ,30 ,100 ,30 ,100 ,100 ,100 };
139  Double_t min[8]={ 1.7, 0., 0., 0.99, 0., 0.99, 0. , 0. };
140  Double_t max[8]={ 2.2,24.,30., 1. ,30., 1. , 1.0, 1.0};
141  fTHnData=new THnSparseF("fCutsDataFD","fCutsDataFD",8,dimAxes,min,max);
142  fTHnData->GetAxis(0)->SetName("mass");
143  fTHnData->GetAxis(0)->SetTitle("Mass (K,#pi) (GeV/#it{c^{2}})");
144  fTHnData->GetAxis(1)->SetName("pt");
145  fTHnData->GetAxis(1)->SetTitle("#it{p}_{T} (GeV/#it{c})");
146  fTHnData->GetAxis(2)->SetName("NormDecLengthXY");
147  fTHnData->GetAxis(2)->SetTitle("Normalized XY decay length");
148  fTHnData->GetAxis(3)->SetName("CosPointXY");
149  fTHnData->GetAxis(3)->SetTitle("Cos#theta_{point}^{XY}");
150  fTHnData->GetAxis(4)->SetName("NormDecLength");
151  fTHnData->GetAxis(4)->SetTitle("Normalized decay length");
152  fTHnData->GetAxis(5)->SetName("CosPoint");
153  fTHnData->GetAxis(5)->SetTitle("Cos#theta_{point}");
154  fTHnData->GetAxis(6)->SetName("DecLengthXY");
155  fTHnData->GetAxis(6)->SetTitle("XY decay length");
156  fTHnData->GetAxis(7)->SetName("DecLength");
157  fTHnData->GetAxis(7)->SetTitle("Decay length");
158 
159  // pt, normLXY, cosPointXY, #prongs, mother pt, normL, cosPoint, LXY, L
160  Int_t dimAxesMC[9]={24 ,30 ,100 ,20 ,24 ,30 ,100 ,100 ,100 };
161  Double_t minMC[9]={ 0., 0., 0.96, 0., 0., 0., 0.99, 0. , 0. };
162  Double_t maxMC[9]={24.,30., 1. ,20.,24.,30., 1. , 1.0, 1.0};
163  fTHnMC=new THnSparseF("fCutsMCFD","fCutsMCFD",9,dimAxesMC,minMC,maxMC);
164  fTHnMC->GetAxis(0)->SetName("pt");
165  fTHnMC->GetAxis(0)->SetTitle("#it{p}_{T} (GeV/#it{c})");
166  fTHnMC->GetAxis(1)->SetName("NormDecLengthXY");
167  fTHnMC->GetAxis(1)->SetTitle("Normalized XY decay length");
168  fTHnMC->GetAxis(2)->SetName("CosPointXY");
169  fTHnMC->GetAxis(2)->SetTitle("Cos#theta_{point}^{XY}");
170  fTHnMC->GetAxis(3)->SetName("nProngs");
171  fTHnMC->GetAxis(3)->SetTitle("Number of Decay Prongs");
172  fTHnMC->GetAxis(4)->SetName("Mother_pt");
173  fTHnMC->GetAxis(4)->SetTitle("Mother #it{p}_{T} (GeV/#it{c})");
174  fTHnMC->GetAxis(5)->SetName("NormDecLength");
175  fTHnMC->GetAxis(5)->SetTitle("Normalized decay length");
176  fTHnMC->GetAxis(6)->SetName("CosPoint");
177  fTHnMC->GetAxis(6)->SetTitle("Cos#theta_{point}");
178  fTHnMC->GetAxis(7)->SetName("DecLengthXY");
179  fTHnMC->GetAxis(7)->SetTitle("XY decay length");
180  fTHnMC->GetAxis(8)->SetName("DecLength");
181  fTHnMC->GetAxis(8)->SetTitle("Decay length");
182 
183  Int_t dimAxesGen[3]={24 ,20 ,24 };
184  Double_t minGen[3]={ 0., 0., 0.};
185  Double_t maxGen[3]={24.,20.,24.};
186  fTHnGenStep=new THnSparseF("fPtMCGenStep","fPtMCGenStep",3,dimAxesGen,minGen,maxGen);
187  fTHnGenStep->GetAxis(0)->SetName("pt");
188  fTHnGenStep->GetAxis(0)->SetTitle("#it{p}_{T} (GeV/#it{c})");
189  fTHnGenStep->GetAxis(1)->SetName("nProngs");
190  fTHnGenStep->GetAxis(1)->SetTitle("Number of Decay Prongs");
191  fTHnGenStep->GetAxis(2)->SetName("Mother_pt");
192  fTHnGenStep->GetAxis(2)->SetTitle("Mother #it{p}_{T} (GeV/#it{c})");
193 
194  fQAhists->Add(new TH1F("hRapidityDist" , "All Particles;y;Counts (a.u.)" ,800,-4., 4. )); // 0
195  fQAhists->Add(new TH1F("hRapidityDistStable" , "All Stable Particles;y;Counts (a.u.)" ,800,-4., 4. )); // 1
196  fQAhists->Add(new TH2F("hDecayLengthB" , ";D meson #it{p}_T;Decay Length B Meson (cm);counts (a.u.)" , 24, 0.,24.,200,0.,2.0 )); // 2
197  fQAhists->Add(new TH2F("hDecayLengthBxy" , ";D meson #it{p}_T;Decay Length B Meson in XY direction (cm);counts (a.u.)" , 24, 0.,24.,200,0.,2.0 )); // 3
198  fQAhists->Add(new TH3F("hDCABhypothesis" , "All Particles;D meson #it{p}_T;Distance of Closest Approach (cm);Impact parameter of D0 x track (cm^{2})" , 24, 0.,24.,100,0.,1.0,100,0.,0.001)); // 4
199  fQAhists->Add(new TH3F("hDCABprongs" , "Only Real B Decay Prongs;D meson #it{p}_T;Distance of Closest Approach (cm);Impact parameter of D0 x track (cm^{2})" , 24, 0.,24.,100,0.,1.0,100,0.,0.001)); // 5
200  fQAhists->Add(new TH3F("hVtxDistBprongs" , "Only Real B Decay Prongs;D meson #it{p}_T;Distance to Primary Vertex (cm);Error Distance to Primary Vertex (cm)" , 24, 0.,24.,100,0.,1.0,100,0.,1.0 )); // 6
201  fQAhists->Add(new TH3F("hVtxDistXYBprongs" , "Only Real B Decay Prongs;D meson #it{p}_T;Distance to Primary Vertex in XY (cm);Error Distance to Primary Vertex in XY (cm)", 24, 0.,24.,100,0.,1.0,100,0.,1.0 )); // 7
202  fQAhists->Add(new TH3F("hVtxDistBhypothesis" , "All Particles;D meson #it{p}_T;Distance to Primary Vertex (cm);Error Distance to Primary Vertex (cm)" , 24, 0.,24.,100,0.,1.0,100,0.,1.0 )); // 8
203  fQAhists->Add(new TH3F("hVtxDistXYBhypthesis" , "All Particles;D meson #it{p}_T;Distance to Primary Vertex in XY (cm);Error Distance to Primary Vertex in XY (cm)" , 24, 0.,24.,100,0.,1.0,100,0.,1.0 )); // 9
204  fQAhists->Add(new TH2F("hNormVtxDistBprongs" , "Only Real B Decay Prongs;D meson #it{p}_T;Distance to Primary Vertex (cm);counts (a.u.)" , 24, 0.,24.,100,0.,1.0 )); // 10
205  fQAhists->Add(new TH2F("hNormVtxDistXYBprongs" , "Only Real B Decay Prongs;D meson #it{p}_T;Distance to Primary Vertex in XY (cm);counts (a.u.)" , 24, 0.,24.,100,0.,1.0 )); // 11
206  fQAhists->Add(new TH2F("hNormVtxDistBhypothesis" , "All Particles;D meson #it{p}_T;Distance to Primary Vertex (cm);counts (a.u.)" , 24, 0.,24.,100,0.,1.0 )); // 12
207  fQAhists->Add(new TH2F("hNormVtxDistXYBhypthesis", "All Particles;D meson #it{p}_T;Distance to Primary Vertex in XY (cm);counts (a.u.)" , 24, 0.,24.,100,0.,1.0 )); // 13
208  fQAhists->ls();
209 
210  return;
211 }
212 
213 void AliHFsubtractBFDcuts::FillGenStep(AliAODMCParticle* dzeropart,Double_t pt/*=-1.*/,Double_t weight/*=1.*/,TClonesArray* mcArray/*=0x0*/){
214  fMCarray=mcArray;
215  if (pt<0) {
216  pt=dzeropart->Pt();
217  }
218  if (fIsMC && fMCarray) {
219  fNprongs=0;
220  fNprongsInAcc=0;
221  fDecayChain=kFALSE; // TODO: use this value
222  fMotherPt=pt;
223  fLabCand=dzeropart->GetLabel();
224  fPtCand=dzeropart->Pt();
225  if (!AnalyseDecay(fGenerateDecayList, kTRUE)) {
226  AliDebug(3, "Error during the decay type determination!");
227  }
228  Double_t entry[] = {pt,(Double_t)fNprongsInAcc,fMotherPt};
229  fTHnGenStep->Fill(entry,weight);
230  // y distribution of all particles
231  for (Int_t i=0; i<fMCarray->GetEntriesFast(); ++i) {
232  Double_t y=((AliAODMCParticle*)fMCarray->UncheckedAt(i))->Y();
233  ((TH1F*)fQAhists->At(0))->Fill(y); // all particles
234  if (IsStable(i)) ((TH1F*)fQAhists->At(1))->Fill(y); // all stable particles
235  }
236  }
237  else {
238  Double_t entry[] = {pt,0.,-1.};
239  fTHnGenStep->Fill(entry,weight);
240  }
241  fMCarray=0x0;
242  return;
243 }
244 
245 void AliHFsubtractBFDcuts::FillSparses(AliAODRecoDecayHF2Prong* dzerocand,Int_t isSelected,Double_t pt,Double_t massD0,Double_t massD0bar,Double_t weight,TClonesArray* mcArray,AliAODEvent* aodEvent){
246  fMCarray=mcArray;
247  if (aodEvent) {
248  fAODtracks=aodEvent->GetTracks();
249  fBkG =aodEvent->GetMagneticField();
250  fPriVtx =aodEvent->GetPrimaryVertex();
251  }
252  if(isSelected<=0||isSelected>3){
253  Printf("isSelected = %d", isSelected);
254  return;
255  }
256  if(massD0<0){
257  dzerocand->InvMassD0(massD0,massD0bar);
258  Printf("mass D0 =%f, massD0bar = %f ", massD0, massD0bar);
259  }
260  if(pt<0){
261  pt=dzerocand->Pt();
262  }
263  Double_t normalDecayLengXY=dzerocand->NormalizedDecayLengthXY();
264  Double_t cptangXY=dzerocand->CosPointingAngleXY();
265  Double_t normalDecayLeng=dzerocand->NormalizedDecayLength();
266  Double_t cptang=dzerocand->CosPointingAngle();
267  Double_t decayLengXY=dzerocand->DecayLengthXY();
268  Double_t decayLeng=dzerocand->DecayLength();
269  // mass, pt, normLXY, cosPointXY, normL, cosPoint, LXY, L
270  Double_t pointData[8]={massD0,pt,normalDecayLengXY,cptangXY,normalDecayLeng,cptang,decayLengXY,decayLeng};
271 
272  if(isSelected==1||isSelected==3){
273  fTHnData->Fill(pointData,weight);
274  }
275  if(isSelected==2||isSelected==3){
276  pointData[0]=massD0bar;
277  fTHnData->Fill(pointData,weight);
278  }
279 
280  if(fIsMC && fMCarray) {
281  fNprongs=0;
282  fNprongsInAcc=0;
283  fDecayChain=kFALSE; // TODO: use this value
284  fMotherPt=pt;
285  fD0Cand=dzerocand;
286  if (fD0Cand) fD0CandParam=new AliNeutralTrackParam(fD0Cand);
287  if (!GetCandidateLabel() || !AnalyseDecay(kFALSE, kFALSE)) {
288  AliDebug(3, "Error during the decay type determination!");
289  }
290  // pt, normLXY, cosPointXY, #prongs, mother pt, normL, cosPoint, LXY, L
291  Double_t pointMC[9]={pt,normalDecayLengXY,cptangXY,(Double_t)fNprongsInAcc,fMotherPt,normalDecayLeng,cptang,decayLengXY,decayLeng};
292  fTHnMC->Fill(pointMC, weight);
293  }
294  fMCarray=0x0;
295  fAODtracks=0x0;
296  fBkG=0.;
297  fD0Cand=0x0;
298  return;
299 }
300 
302  if (fD0Cand) {
303  Int_t labDau0=((AliAODTrack*)fD0Cand->GetDaughter(0))->GetLabel();
304  if (labDau0<0) labDau0*=-1;
305  AliAODMCParticle* firstDau=(AliAODMCParticle*)fMCarray->UncheckedAt(labDau0);
306  fLabCand = firstDau->GetMother();
307  return kTRUE;
308  }
309  else {
310  AliDebug(3, "Could not obtain the label of the candidate");
311  return kFALSE;
312  }
313  return kFALSE;
314 }
315 
316 Bool_t AliHFsubtractBFDcuts::AnalyseDecay(Bool_t generateString, Bool_t mcOnly) {
317  AliAODMCParticle* cand=(AliAODMCParticle*)fMCarray->UncheckedAt(fLabCand);
318  fLabMother = cand->GetMother();
319  AliAODMCParticle* mother = (AliAODMCParticle*)fMCarray->UncheckedAt(fLabMother);
320  Int_t pdgMother = mother->GetPdgCode();
321  if (pdgMother<0) pdgMother*=-1; // treat particles and anti-particles the same way
322  if (pdgMother==4 || pdgMother==2212 || pdgMother==2112) { // prompt production
323  fNprongs=1;
324  fNprongsInAcc=1;
325  return kTRUE;
326  }
327  if ((pdgMother%1000)/100==4 || (pdgMother%10000)/1000==4) {
328  // chained decay of charmed hadrons, using recursion to resolve it
329  fDecayChain=kTRUE;
331  return AnalyseDecay(generateString, mcOnly);
332  }
333  if ((pdgMother%1000)/100!=5 && (pdgMother%10000)/1000!=5) {
334  AliDebug(3, "Found strange decay, expected the mother to be a beauty hadron!");
335  fNprongs=0;
336  fNprongsInAcc=0;
337  return kFALSE;
338  }
339  CountProngs(fLabMother, fLabCand, generateString, mcOnly); // count the prongs
340 
341  if (generateString) {
342  // Store the decay
343  std::sort(fDecayProngs.begin(), fDecayProngs.end());
344  TString decayStr = "";
345  for (ULong64_t i=0; i<fDecayProngs.size(); ++i) {
346  decayStr = (i==0) ? Form("%d", fDecayProngs[i]) : Form("%s_%d", decayStr.Data(), fDecayProngs[i]);
347  }
348  //decayStr = Form("%s__%d_%d_%d", decayStr.Data(), fNprongs, fNprongsInAcc, fDecayProngs.size());
349  TObjString* str = new TObjString(decayStr);
350  if (!fDecayStrList->FindObject(str)) fDecayStrList->Add(str); // only allow unique entries
351  fDecayProngs.clear();
352  }
353 
354  if (mcOnly) {
355  Double_t decayLengthB; // Decay length B meson
356  Double_t decayLengthBxy; // Decay length B meson (xy-plane)
357  Double_t originB[3] = {0.,0.,0.};
358  if(!mother->XvYvZv(originB)) AliDebug(3, "Couldn't determine MC origin of the beauty hadron");
359  Double_t originD[3] = {0.,0.,0.};
360  if(!cand->XvYvZv(originD)) AliDebug(3, "Couldn't determine MC origin of the charmed hadron");
361  decayLengthBxy = TMath::Sqrt((originB[0]-originD[0])*(originB[0]-originD[0])+
362  (originB[1]-originD[1])*(originB[1]-originD[1]));
363  decayLengthB = TMath::Sqrt(decayLengthBxy*decayLengthBxy+(originB[2]-originD[2])*(originB[2]-originD[2]));
364  ((TH2F*)fQAhists->At(2))->Fill(fPtCand,decayLengthB);
365  ((TH2F*)fQAhists->At(3))->Fill(fPtCand,decayLengthBxy);
366  }
367  else {
368  for (Int_t iAODtrack=0; iAODtrack<fAODtracks->GetEntriesFast(); ++iAODtrack) {
369  CheckBhypothesis(iAODtrack, kFALSE);
370  }
371  }
372 
373  fMotherPt=mother->Pt();
374  return kTRUE;
375 }
376 
377 void AliHFsubtractBFDcuts::CountProngs(Int_t labCurrMother, Int_t labCurrExcl,
378  Bool_t generateString, Bool_t mcOnly) {
379  for (Int_t iMCParticle=0; iMCParticle<fMCarray->GetEntriesFast(); ++iMCParticle) {
380  if (iMCParticle!=labCurrExcl) {
381  if (((AliAODMCParticle*)fMCarray->UncheckedAt(iMCParticle))->GetMother()==labCurrMother) {
382  if (!fResolveResonances || IsStable(iMCParticle)) {
383  if (generateString) fDecayProngs.push_back(((AliAODMCParticle*)fMCarray->UncheckedAt(iMCParticle))->GetPdgCode());
384  ++fNprongs;
385  if (!mcOnly) {
386  for (Int_t iAODtrack=0; iAODtrack<fAODtracks->GetEntriesFast(); ++iAODtrack) {
387  AliAODTrack* aodTrack=(AliAODTrack*)fAODtracks->UncheckedAt(iAODtrack);
388  if (aodTrack->GetLabel()==iMCParticle) CheckBhypothesis(iAODtrack, kTRUE);
389  }
390  }
391  if (!fCheckAcceptance || IsInAcceptance(iMCParticle)) {
392  ++fNprongsInAcc;
393  }
394  }
395  else CountProngs(iMCParticle, -1, generateString, mcOnly);
396  }
397  }
398  else {
399  ++fNprongs; // candidate is only counted as a single prong
400  ++fNprongsInAcc;
401  if (generateString) fDecayProngs.push_back(((AliAODMCParticle*)fMCarray->UncheckedAt(iMCParticle))->GetPdgCode());
402  }
403  }
404 }
405 
406 Bool_t AliHFsubtractBFDcuts::IsStable(Int_t labProng) const {
407  const Int_t stablePartPdgs[] = { 11, 13, 211, 321, 2212, 12, 14, 22, 111, 130 };
408  const Int_t nStablePartPdgs = sizeof(stablePartPdgs)/sizeof(Int_t);
409  AliAODMCParticle* prong = (AliAODMCParticle*)fMCarray->UncheckedAt(labProng);
410  Int_t pdgProng = prong->GetPdgCode();
411  if (pdgProng<0) pdgProng*=-1; // treat particles and anti-particles the same way
412  for (Int_t iPdg=0; iPdg<nStablePartPdgs; ++iPdg) {
413  if (stablePartPdgs[iPdg] == pdgProng) return kTRUE;
414  }
415  return kFALSE;
416 }
417 
418 Bool_t AliHFsubtractBFDcuts::IsInAcceptance(Int_t labProng) const {
419  AliDebug(1, "AliHFsubtractBFDcuts::IsInAcceptance(...) hasn't been implemented yet, prong");
420  Double_t eta = ((AliAODMCParticle*)fMCarray->UncheckedAt(labProng))->Eta();
421  Double_t pt = ((AliAODMCParticle*)fMCarray->UncheckedAt(labProng))->Pt();
422  Short_t charge = ((AliAODMCParticle*)fMCarray->UncheckedAt(labProng))->Charge();
423  if ((pt>0.15) && (eta>-0.9) && (eta<0.9) && (charge!=0)) return kTRUE;
424  return kFALSE;
425 }
426 
427 Bool_t AliHFsubtractBFDcuts::CheckBhypothesis(Int_t iAODtrack, Bool_t Bprong) {
428  AliExternalTrackParam* t = new AliExternalTrackParam();
429  t->CopyFromVTrack((AliVTrack*)fAODtracks->UncheckedAt(iAODtrack));
430 
431  TObjArray* tracks = new TObjArray(2);
432  tracks->AddAt(t, 0);
433  tracks->AddAt(fD0CandParam,1);
434 
435  AliAODVertex* bVtx = RecBvtx(tracks);
436  if(!bVtx) {
437  AliDebug(3, "Couldn't reconstruct B meson vertex!");
438  delete t; t=0x0;
439  return kFALSE;
440  }
441 
442  Double_t vtxDist = (fPriVtx) ? bVtx->DistanceToVertex(fPriVtx) : -1.0 ;
443  Double_t vtxDistXY = (fPriVtx) ? bVtx->DistanceXYToVertex(fPriVtx) : -2.e10;
444  Double_t vtxDistErr = (fPriVtx) ? bVtx->ErrorDistanceToVertex(fPriVtx) : -1.0 ;
445  Double_t vtxDistErrXY = (fPriVtx) ? bVtx->ErrorDistanceXYToVertex(fPriVtx) : -2.e10;
446 
447  const Double_t maxD = 1.;
448 
449  // Propagate candidates to secondary vertex
450  Double_t dz[2],cov[3];
451  t->PropagateToDCA(bVtx,fBkG,maxD,dz,cov);
452  fD0CandParam->PropagateToDCA(bVtx,fBkG,maxD,dz,cov);
453 
454  // Impact parameters
455  t->PropagateToDCA(fPriVtx,fBkG,maxD,dz,cov);
456  Double_t d0Track=dz[0];
457  Double_t d0TrackErr=TMath::Sqrt(cov[0]);
458  fD0CandParam->PropagateToDCA(fPriVtx,fBkG,maxD,dz,cov);
459  Double_t d0D0Cand=dz[0];
460  Double_t d0D0CandErr=TMath::Sqrt(cov[0]);
461 
462  // distance of closest approach of the D0 and the track
463  Double_t xDCAtrack, xDCAD0;
464  Double_t dcaB=t->GetDCA(fD0CandParam,fBkG,xDCAtrack,xDCAD0);
465  if (!Bprong) {
466  ((TH3F*)fQAhists->At(4))->Fill(fPtCand,dcaB,d0D0Cand*d0Track);
467  ((TH3F*)fQAhists->At(6))->Fill(fPtCand,vtxDist,vtxDistErr);
468  ((TH3F*)fQAhists->At(7))->Fill(fPtCand,vtxDistXY,vtxDistErrXY);
469  ((TH2F*)fQAhists->At(10))->Fill(fPtCand,vtxDist/vtxDistErr);
470  ((TH2F*)fQAhists->At(11))->Fill(fPtCand,vtxDistXY/vtxDistErrXY);
471  }
472  else {
473  ((TH3F*)fQAhists->At(5))->Fill(fPtCand,dcaB,d0D0Cand*d0Track);
474  ((TH3F*)fQAhists->At(8))->Fill(fPtCand,vtxDist,vtxDistErr);
475  ((TH3F*)fQAhists->At(9))->Fill(fPtCand,vtxDistXY,vtxDistErrXY);
476  ((TH2F*)fQAhists->At(12))->Fill(fPtCand,vtxDist/vtxDistErr);
477  ((TH2F*)fQAhists->At(13))->Fill(fPtCand,vtxDistXY/vtxDistErrXY);
478  }
479 
480  delete tracks; tracks=0x0;
481  delete bVtx ; bVtx =0x0;
482  delete t ; t =0x0;
483  return kTRUE;
484 }
485 
486 AliAODVertex* AliHFsubtractBFDcuts::RecBvtx(TObjArray* tracks) const {
487  AliESDVertex* vtxESD=0x0;
488  AliVertexerTracks* vertexer = new AliVertexerTracks(fBkG);
489  vertexer->SetVtxStart((AliESDVertex*)fPriVtx);
490  vtxESD = (AliESDVertex*)vertexer->VertexForSelectedESDTracks(tracks);
491  delete vertexer; vertexer=0x0;
492  if(!vtxESD || vtxESD->GetNContributors()!=tracks->GetEntriesFast()) {
493  AliDebug(3, "Couldn't reconstruct B Meson vertex");
494  delete vtxESD; vtxESD=0x0;
495  return 0x0;
496  }
497  Double_t rVtxSq=vtxESD->GetX()*vtxESD->GetX()+vtxESD->GetY()*vtxESD->GetY();
498  if(rVtxSq>8.){
499  // vertex outside beam pipe, reject candidate to avoid propagation through material
500  delete vtxESD; vtxESD=0x0;
501  return 0x0;
502  }
503  // convert to AliAODVertex
504  Double_t pos[3],cov[6],chi2perNDF;
505  vtxESD->GetXYZ(pos);
506  vtxESD->GetCovMatrix(cov);
507  chi2perNDF=vtxESD->GetChi2toNDF();
508  delete vtxESD; vtxESD=0x0;
509  return new AliAODVertex(pos,cov,chi2perNDF,0x0,-1,AliAODVertex::kUndef,0);
510 }
Int_t charge
Double_t NormalizedDecayLengthXY() const
Double_t NormalizedDecayLength() const
ClassImp(AliAnalysisTaskTriggerRates) AliAnalysisTaskTriggerRates
Bool_t AnalyseDecay(Bool_t generateString, Bool_t mcOnly)
Bool_t fIsMC
Method to check Whether the current D0 candidate and the track originate from a B decay...
const char * title
Definition: MakeQAPdf.C:26
THnSparseF * fTHnMC
! THnSparse for cut variables (MC at PID level, w/o mass axis)y
AliAODVertex * RecBvtx(TObjArray *tracks) const
Is that prong within the fiducial acceptance.
THnSparseF * fTHnGenStep
flag resolve resonances in during the prong determination
Double_t fPtCand
Label of the candidate D0 (charmed hadron in case of a chained decay)
Class for storing and handling D0 meson candidates properties // for estimating the feed-down fractio...
std::vector< Int_t > fDecayProngs
Generate the list containig strings with all PDG codes of the decay prongs.
Double_t CosPointingAngleXY() const
void FillSparses(AliAODRecoDecayHF2Prong *dzeroPart, Int_t isSelected, Double_t pt=-1, Double_t massD0=-1, Double_t massD0bar=-1, Double_t weight=1., TClonesArray *mcArray=0x0, AliAODEvent *aodEvent=0x0)
AliAODRecoDecayHF2Prong * fD0Cand
Magnetic field (z-direction) in units of kG.
AliNeutralTrackParam * fD0CandParam
Pointer to the D0 candidate from reconstruction.
Int_t fLabMother
pT of the candidate (from MC track, not following decay chain)
Bool_t fCheckAcceptance
flag for MC/Data
TClonesArray * fAODtracks
! TClonesArray holding the AliAODTracks of the event to be processed
AliAODVertex * fPriVtx
! Primary AOD vertex
void FillGenStep(AliAODMCParticle *dzeroMC, Double_t pt=-1, Double_t weight=1., TClonesArray *mcArray=0x0)
TList * fQAhists
! List with QA histograms
TList * fDecayStrList
PDG codes of the daughters separated.
TClonesArray * fMCarray
Event specific variables.
UInt_t fNprongsInAcc
Number of prongs, counting the first charmed hadron as one particle (simulation cuts can lead to loss...
UInt_t fNprongs
Label of the mother of the candidate D0 (or charmed hadron)
Bool_t IsStable(Int_t labProng) const
counting the prongs of labCurrMother, labCurrExcl is assumed to be a stable particle ...
void CountProngs(Int_t labCurrMother, Int_t labCurrExcl, Bool_t generateString, Bool_t mConly)
check in which decay process a particle was created
Double_t fMotherPt
Chained decay of charmed hadrons.
Double_t DecayLengthXY() const
Bool_t fResolveResonances
flag for checking whether the decay prongs are within acceptance
Bool_t fDecayChain
Number of prongs, counting only the particles within acceptance.
Bool_t IsInAcceptance(Int_t labProng) const
Is that prong a stable particle?
AliHFsubtractBFDcuts operator=(const AliHFsubtractBFDcuts &c)
Int_t fLabCand
Pointer to an AliNeutralTrackParam of the D0 candidata for DCA calculation.
Double_t CosPointingAngle() const
Double_t DecayLength() const
THnSparseF * fTHnData
! THnSparse for cut variables (data, with inv mass axis), first axis is always mass ...
Bool_t CheckBhypothesis(Int_t iAODtrack, Bool_t Bprong)
Reconstruct a secondary vertex with the supplied tracks.