]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG3/vertexingHF/AliCFVertexingHF3Prong.cxx
Coding conventions (O. Borysov)
[u/mrichter/AliRoot.git] / PWG3 / vertexingHF / AliCFVertexingHF3Prong.cxx
CommitLineData
043062fe 1/**************************************************************************
2 * Copyright(c) 2007-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
7b45817b 16/* $Id$ */
043062fe 17
18///////////////////////////////////////////////////////////////////
19// //
20// Class to compute variables for correction framework //
21// for 3-body decays of D mesons (D+, Ds, Lc) //
22// in bins of cut variables //
23// Origin: Francesco Prino (prino@to.infn.it) //
24// Renu Bala (bala@to.infn.it) //
25// //
26///////////////////////////////////////////////////////////////////
27
28#include "AliAODMCParticle.h"
29#include "AliAODEvent.h"
30#include "TClonesArray.h"
31#include "AliCFVertexingHF.h"
32#include "AliESDtrack.h"
33#include "TDatabasePDG.h"
34
35#include "AliCFVertexingHF3Prong.h"
36#include "AliCFContainer.h"
37
38ClassImp(AliCFVertexingHF3Prong)
39
40
41//_________________________________________
42AliCFVertexingHF3Prong::AliCFVertexingHF3Prong(Int_t decay):
43AliCFVertexingHF(),
44 fDecay(decay)
45 {
46 //
47 SetNProngs(3);
2bf2e62b 48
49 fPtAccCut=new Float_t[fProngs];
50 fEtaAccCut=new Float_t[fProngs];
51 for(Int_t iP=0; iP<fProngs; iP++){
52 fPtAccCut[iP]=0.1;
53 fEtaAccCut[iP]=0.9;
54 }
55
043062fe 56}
57//_________________________________________
58AliCFVertexingHF3Prong::AliCFVertexingHF3Prong(TClonesArray *mcArray, UShort_t originDselection, Int_t decay):
59 AliCFVertexingHF(mcArray, originDselection),
60 fDecay(decay)
61
62{
63 //
64 SetNProngs(3);
2bf2e62b 65 fPtAccCut=new Float_t[fProngs];
66 fEtaAccCut=new Float_t[fProngs];
67 for(Int_t iP=0; iP<fProngs; iP++){
68 fPtAccCut[iP]=0.1;
69 fEtaAccCut[iP]=0.9;
70 }
043062fe 71}
72
73
74//_____________________________________
75AliCFVertexingHF3Prong& AliCFVertexingHF3Prong::operator=(const AliCFVertexingHF3Prong& c){
76 //
77 if (this != &c) {
78
79 AliCFVertexingHF::operator=(c);
80
81 }
82 return *this;
83}
84
85//__________________________________________
86Bool_t AliCFVertexingHF3Prong::SetRecoCandidateParam(AliAODRecoDecayHF *recoCand){
87 // Checks if candidate is signal and D meson is present in MC array
88
89 Bool_t bSignAssoc = kFALSE;
90 fRecoCandidate = recoCand;
91
92 if (!fRecoCandidate) {
93 AliError("fRecoCandidate not found, problem in assignement\n");
94 return bSignAssoc;
95 }
96
97 Int_t pdgCand = -1;
98 Int_t pdgDaughter[3]={-1,-1,-1};
99 if(fDecay==kDplustoKpipi){
100 pdgCand=411;
101 pdgDaughter[0]=321;
102 pdgDaughter[1]=211;
103 pdgDaughter[2]=211;
104 }else if(fDecay==kDstoKKpi){
105 pdgCand=431;
106 pdgDaughter[0]=321;
107 pdgDaughter[1]=321;
108 pdgDaughter[2]=211;
109 }else if(fDecay==kLctopKpi){
110 AliError("LambdaC not yet implemented");
111 return bSignAssoc;
112 }else{
113 AliError("WRONG DECAY SETTING");
114 return bSignAssoc;
115 }
116
117 Int_t mcLabel = fRecoCandidate->MatchToMC(pdgCand,fmcArray,3,pdgDaughter);
118 if (mcLabel == -1) return bSignAssoc;
fbec9fa9 119
120 if ((fRecoCandidate->NumberOfFakeDaughters()>0)&&(fFakeSelection==1)) return bSignAssoc;
121 if ((fRecoCandidate->NumberOfFakeDaughters()==0)&&(fFakeSelection==2)) return bSignAssoc;
122
043062fe 123 SetMCLabel(mcLabel);
124 fmcPartCandidate = dynamic_cast<AliAODMCParticle*>(fmcArray->At(fmcLabel));
125
126 if (!fmcPartCandidate){
127 AliDebug(3,"No part candidate");
128 return bSignAssoc;
129 }
130
131 bSignAssoc = kTRUE;
132 return bSignAssoc;
133}
134
135//______________________________________________
136Bool_t AliCFVertexingHF3Prong::GetGeneratedValuesFromMCParticle(Double_t* vectorMC) {
137 //
138 // collecting all the necessary info from MC particle and fill vectorMC: 12 variables
139 // pt_D
140 // y_D
141 // phi_D
142 // ctau
143 // cos point
144 // pt_1
145 // pt_2
146 // pt_3
147 // d0_1
148 // d0_2
149 // d0_3
150 // zPrimVert
b7af2639 151 // centrality
043062fe 152
153 Bool_t bGenValues = kFALSE;
154
155 Int_t pdgCand = -1;
156 if(fDecay==kDplustoKpipi){
157 pdgCand=411;
158 }else if(fDecay==kDstoKKpi){
159 pdgCand=431;
160 }else if(fDecay==kLctopKpi){
161 AliError("LambdaC not yet implemented");
162 return bGenValues;
163 }else{
164 AliError("WRONG DECAY SETTING");
165 return bGenValues;
166 }
167
168 Double_t vertD[3] = {0,0,0}; // D origin
169 fmcPartCandidate->XvYvZv(vertD); // cm
170
171 Int_t nprongs = 3;
172 Int_t daughter[3];
173 Short_t charge = fmcPartCandidate->Charge();
174
175 // order the daughters as LS,OS,LS, e.g. D+ -> pi+ K- pi+
176 // the 2 LS are ordered so that in pos. 0 there is the one with lower label value
177 Int_t index=0;
178 Int_t nDauLS=0;
179 Int_t nDauOS=0;
180
181
182 Int_t nDau=fmcPartCandidate->GetNDaughters();
183 Int_t labelFirstDau = fmcPartCandidate->GetDaughter(0);
184 if(nDau==3){
185 for(Int_t iDau=0; iDau<3; iDau++){
186 Int_t ind = labelFirstDau+iDau;
187 AliAODMCParticle* part = dynamic_cast<AliAODMCParticle*>(fmcArray->At(ind));
968b84b9 188 if(!part){
189 AliError("Daughter particle not found in MC array");
190 return bGenValues;
191 }
043062fe 192 Short_t signDau=part->Charge();
193 if(signDau==charge){
194 nDauLS++;
195 daughter[index] = ind;
196 index=2;
197 }else{
198 daughter[1] = ind;
199 nDauOS++;
200 }
201 }
202 }else if(nDau==2){
203 for(Int_t iDau=0; iDau<2; iDau++){
204 Int_t ind = labelFirstDau+iDau;
205 AliAODMCParticle* part = dynamic_cast<AliAODMCParticle*>(fmcArray->At(ind));
968b84b9 206 if(!part){
207 AliError("Daughter particle not found in MC array");
208 return bGenValues;
209 }
043062fe 210 Int_t pdgCode=TMath::Abs(part->GetPdgCode());
211 if(pdgCode==211 || pdgCode==321 || pdgCode==2212){
212 Short_t signDau=part->Charge();
213 if(signDau==charge){
214 nDauLS++;
215 daughter[index] = ind;
216 index=2;
217 }else{
218 daughter[1] = ind;
219 nDauOS++;
220 }
221 }else{
222 Int_t nDauRes=part->GetNDaughters();
223 if(nDauRes!=2){
224 AliError("Wrong resonant decay");
225 return bGenValues;
226 }
227 Int_t labelFirstDauRes = part->GetDaughter(0);
228 for(Int_t iDauRes=0; iDauRes<2; iDauRes++){
229 Int_t indDR = labelFirstDauRes+iDauRes;
230 AliAODMCParticle* partDR = dynamic_cast<AliAODMCParticle*>(fmcArray->At(indDR));
968b84b9 231 if(!partDR){
232 AliError("Daughter particle not found in MC array");
233 return bGenValues;
234 }
043062fe 235 Short_t signDau=partDR->Charge();
236 if(signDau==charge){
237 nDauLS++;
238 daughter[index] = ind;
239 index=2;
240 }else{
241 daughter[1] = ind;
242 nDauOS++;
243 }
244 }
245 }
246 }
247 }else{
248 AliError(Form("Wrong number of daughters %d",nDau));
249 return bGenValues;
250 }
251
252 if(nDauLS!=2 || nDauOS!=1){
253 AliError(Form("Wrong decay channel: LS and OS daughters not OK: %d %d",nDauLS,nDauOS));
254 return bGenValues;
255 }
256 if(daughter[0]>daughter[2]){
257 Int_t tmp=daughter[0];
258 daughter[0]=daughter[2];
259 daughter[2]=tmp;
260 }
261
262 // getting the momentum from the daughters and decay vertex
263 Double_t px[3],py[3],pz[3],pt[3];
264 Double_t vertDec[3] = {0,0,0}; // decay vertex
265 for(Int_t iDau=0; iDau<3; iDau++){
266 AliAODMCParticle* part=dynamic_cast<AliAODMCParticle*>(fmcArray->At(daughter[iDau]));
968b84b9 267 if(!part){
268 AliError("Daughter particle not found in MC array");
269 return bGenValues;
270 }
043062fe 271 px[iDau]=part->Px();
272 py[iDau]=part->Py();
273 pz[iDau]=part->Pz();
274 pt[iDau]=part->Pt();
275 if(iDau==0) part->XvYvZv(vertDec);
276 }
277
278 Double_t d0[3] = {0.,0.,0.}; // dummy values!!!!
279
280 AliAODRecoDecayHF* decay = new AliAODRecoDecayHF(vertD,vertDec,nprongs,charge,px,py,pz,d0);
281 Double_t cT = decay->Ct(pdgCand);
282
283 vectorMC[0] = fmcPartCandidate->Pt();
284 vectorMC[1] = fmcPartCandidate->Y() ;
285 vectorMC[2] = fmcPartCandidate->Phi();
286 vectorMC[3] = cT*1.E4 ; // in micron
287 vectorMC[4] = 1.01; // cos pointing angle, dummy value, meaningless in MC
288 vectorMC[5] = pt[0];
289 vectorMC[6] = pt[1];
290 vectorMC[7] = pt[2];
291 vectorMC[8] = 0.; // imppar0, dummy value, meaningless in MC
292 vectorMC[9] = 0.; // imppar1, dummy value, meaningless in MC, in micron
293 vectorMC[10] = 0.; // imppar2, dummy value, meaningless in MC, in micron
294 vectorMC[11] = fzMCVertex; // z of reconstructed of primary vertex
b7af2639 295 vectorMC[12] = fCentValue; // reconstructed centrality value
296
043062fe 297
298 bGenValues = kTRUE;
299 return bGenValues;
300}
301
302
303//____________________________________________
304Bool_t AliCFVertexingHF3Prong::GetRecoValuesFromCandidate(Double_t *vectorReco) const
305{
306 // Fill vector (see above) with reconstructed quantities
307 Bool_t bFillRecoValues=kFALSE;
308
309 Int_t pdgCand = -1;
310 if(fDecay==kDplustoKpipi){
311 pdgCand=411;
312 }else if(fDecay==kDstoKKpi){
313 pdgCand=431;
314 }else if(fDecay==kLctopKpi){
315 AliError("LambdaC not yet implemented");
316 return bFillRecoValues;
317 }else{
318 AliError("WRONG DECAY SETTING");
319 return bFillRecoValues;
320 }
321
322 AliAODRecoDecayHF3Prong *decay3 = (AliAODRecoDecayHF3Prong*)fRecoCandidate;
323 Short_t charge=decay3->Charge();
324 Double_t rapidity=decay3->Y(pdgCand);
325 Double_t cT=decay3->Ct(pdgCand);
326 Double_t pt = decay3->Pt();
327 Double_t cosPointingAngle = decay3->CosPointingAngle();
328 Double_t phi = decay3->Phi();
329
330 Int_t daughtSorted[3];
331 Int_t tmpIndex=0;
332 Int_t nDauLS=0;
333 Int_t nDauOS=0;
334 for(Int_t iDau=0; iDau<3; iDau++){
335 AliAODTrack *trk = (AliAODTrack*)decay3->GetDaughter(iDau);
b7af2639 336 Int_t label = TMath::Abs(trk->GetLabel());
043062fe 337 Short_t chargedau=trk->Charge();
338 if(chargedau==charge){
339 daughtSorted[tmpIndex]=label;
340 tmpIndex=2;
341 nDauLS++;
342 }else{
343 daughtSorted[1]=label;
344 nDauOS++;
345 }
346 }
347
348 if(nDauLS!=2 || nDauOS!=1){
349 AliError("Wrong decay channel: number of OS and LS tracks not OK");
350 return bFillRecoValues;
351 }
352
353 if(daughtSorted[0]>daughtSorted[2]){
354 Int_t tmp=daughtSorted[0];
355 daughtSorted[0]=daughtSorted[2];
356 daughtSorted[2]=tmp;
357 }
358
359
360 vectorReco[0] = pt;
361 vectorReco[1] = rapidity;
362 vectorReco[2] = phi;
363 vectorReco[3] = cT*1.E4; // in micron
364 vectorReco[4] = cosPointingAngle; // in micron
365 vectorReco[5] = decay3->PtProng(daughtSorted[0]);
366 vectorReco[6] = decay3->PtProng(daughtSorted[1]);
367 vectorReco[7] = decay3->PtProng(daughtSorted[2]);
368 vectorReco[8] = decay3->Getd0Prong(daughtSorted[0]);
369 vectorReco[9] = decay3->Getd0Prong(daughtSorted[1]);
370 vectorReco[10] = decay3->Getd0Prong(daughtSorted[2]);
371 vectorReco[11] = fzPrimVertex; // z of reconstructed of primary vertex
b7af2639 372 vectorReco[12] = fCentValue; //reconstructed centrality value
373
374
043062fe 375 bFillRecoValues = kTRUE;
376 return bFillRecoValues;
377}
378
379
380//_____________________________________________________________
381Bool_t AliCFVertexingHF3Prong::CheckMCChannelDecay() const
382{
383 // Check the pdg codes of the daughters
384 Bool_t checkCD = kFALSE;
385
386 Int_t pdgCand = -1;
387 Int_t pdgDaughter[3]={-1,-1,-1};
388 if(fDecay==kDplustoKpipi){
389 pdgCand=411;
390 pdgDaughter[0]=321;
391 pdgDaughter[1]=211;
392 pdgDaughter[2]=211;
393 }else if(fDecay==kDstoKKpi){
394 pdgCand=431;
395 pdgDaughter[0]=321;
396 pdgDaughter[1]=321;
397 pdgDaughter[2]=211;
398 }else if(fDecay==kLctopKpi){
399 AliError("LambdaC not yet implemented");
400 return checkCD;
401 }else{
402 AliError("WRONG DECAY SETTING");
403 return checkCD;
404 }
405
406
407 Int_t daughter[3];
408
409 Int_t nDau=fmcPartCandidate->GetNDaughters();
410 Int_t labelFirstDau = fmcPartCandidate->GetDaughter(0);
411 if(nDau==3){
412 for(Int_t iDau=0; iDau<3; iDau++){
413 Int_t ind = labelFirstDau+iDau;
414 AliAODMCParticle* part = dynamic_cast<AliAODMCParticle*>(fmcArray->At(ind));
968b84b9 415 if(!part){
416 AliError("Daughter particle not found in MC array");
417 return checkCD;
418 }
043062fe 419 daughter[iDau]=TMath::Abs(part->GetPdgCode());
420 }
421 }else if(nDau==2){
422 Int_t nDauFound=0;
423 for(Int_t iDau=0; iDau<2; iDau++){
424 Int_t ind = labelFirstDau+iDau;
425 AliAODMCParticle* part = dynamic_cast<AliAODMCParticle*>(fmcArray->At(ind));
968b84b9 426 if(!part){
427 AliError("Daughter particle not found in MC array");
428 return checkCD;
429 }
043062fe 430 Int_t pdgCode=TMath::Abs(part->GetPdgCode());
431 if(pdgCode==211 || pdgCode==321 || pdgCode==2212){
432 if(nDauFound>=3) return checkCD;
433 daughter[nDauFound]=pdgCode;
434 nDauFound++;
435 }else{
436 Int_t nDauRes=part->GetNDaughters();
437 if(nDauRes!=2) return checkCD;
438 Int_t labelFirstDauRes = part->GetDaughter(0);
439 for(Int_t iDauRes=0; iDauRes<2; iDauRes++){
440 Int_t indDR = labelFirstDauRes+iDauRes;
441 AliAODMCParticle* partDR = dynamic_cast<AliAODMCParticle*>(fmcArray->At(indDR));
968b84b9 442 if(!partDR){
443 AliError("Daughter particle not found in MC array");
444 return checkCD;
445 }
043062fe 446 Int_t pdgCodeDR=TMath::Abs(partDR->GetPdgCode());
447 if(nDauFound>=3) return checkCD;
448 daughter[nDauFound]=pdgCodeDR;
449 nDauFound++;
450 }
451 }
452 }
453 }else{
454 return checkCD;
455 }
456 for(Int_t iDau1=0; iDau1<3; iDau1++){
457 for(Int_t iDau2=iDau1; iDau2<3; iDau2++){
458 if(daughter[iDau1]<daughter[iDau2]){
459 Int_t tmp=daughter[iDau1];
460 daughter[iDau1]=daughter[iDau2];
461 daughter[iDau2]=tmp;
462 }
463 }
464 }
465 for(Int_t iDau=0; iDau<3; iDau++){
466 if(daughter[iDau]!=pdgDaughter[iDau]){
467 AliDebug(2, "Wrong decay channel from MC, skipping!!");
468 return checkCD;
469 }
470 }
471
472 checkCD = kTRUE;
473 return checkCD;
474
475}