1 /**************************************************************************
2 * Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 //-----------------------------------------------------------------------
17 // Class for HF corrections as a function of many variables
18 // 6 Steps introduced: MC, MC Acc, Reco, Reco Acc, Reco Acc + ITS Cl,
19 // Reco Acc + ITS Cl + PPR cuts
20 // 11 variables used: pt, y, cosThetaStar, ptPi, ptK, ct,
21 // dca, d0Pi, d0K, d0Pixd0K, cosPointingAngle
23 //-----------------------------------------------------------------------
24 // Author : C. Zampolli, CERN
25 //-----------------------------------------------------------------------
28 #include <TParticle.h>
29 #include <TDatabasePDG.h>
34 #include "AliCFHeavyFlavourTaskMultiVarMultiStep.h"
36 #include "AliMCEvent.h"
37 #include "AliCFManager.h"
38 #include "AliCFContainer.h"
40 #include "AliAODEvent.h"
41 #include "AliAODRecoDecay.h"
42 #include "AliAODRecoDecayHF.h"
43 #include "AliAODRecoDecayHF2Prong.h"
44 #include "AliAODMCParticle.h"
46 //__________________________________________________________________________
47 AliCFHeavyFlavourTaskMultiVarMultiStep::AliCFHeavyFlavourTaskMultiVarMultiStep() :
51 fHistEventsProcessed(0x0),
56 fCountRecoITSClusters(0),
59 fFillFromGenerated(kFALSE),
66 //___________________________________________________________________________
67 AliCFHeavyFlavourTaskMultiVarMultiStep::AliCFHeavyFlavourTaskMultiVarMultiStep(const Char_t* name) :
68 AliAnalysisTaskSE(name),
71 fHistEventsProcessed(0x0),
76 fCountRecoITSClusters(0),
79 fFillFromGenerated(kFALSE),
83 // Constructor. Initialization of Inputs and Outputs
85 Info("AliCFHeavyFlavourTaskMultiVarMultiStep","Calling Constructor");
87 DefineInput(0) and DefineOutput(0)
88 are taken care of by AliAnalysisTaskSE constructor
90 DefineOutput(1,TH1I::Class());
91 DefineOutput(2,AliCFContainer::Class());
94 //___________________________________________________________________________
95 AliCFHeavyFlavourTaskMultiVarMultiStep& AliCFHeavyFlavourTaskMultiVarMultiStep::operator=(const AliCFHeavyFlavourTaskMultiVarMultiStep& c)
98 // Assignment operator
101 AliAnalysisTaskSE::operator=(c) ;
103 fCFManager = c.fCFManager;
104 fHistEventsProcessed = c.fHistEventsProcessed;
109 //___________________________________________________________________________
110 AliCFHeavyFlavourTaskMultiVarMultiStep::AliCFHeavyFlavourTaskMultiVarMultiStep(const AliCFHeavyFlavourTaskMultiVarMultiStep& c) :
111 AliAnalysisTaskSE(c),
113 fCFManager(c.fCFManager),
114 fHistEventsProcessed(c.fHistEventsProcessed),
115 fCountMC(c.fCountMC),
116 fCountAcc(c.fCountAcc),
117 fCountReco(c.fCountReco),
118 fCountRecoAcc(c.fCountRecoAcc),
119 fCountRecoITSClusters(c.fCountRecoITSClusters),
120 fCountRecoPPR(c.fCountRecoPPR),
122 fFillFromGenerated(c.fFillFromGenerated),
123 fMinITSClusters(c.fMinITSClusters)
130 //___________________________________________________________________________
131 AliCFHeavyFlavourTaskMultiVarMultiStep::~AliCFHeavyFlavourTaskMultiVarMultiStep() {
135 if (fCFManager) delete fCFManager ;
136 if (fHistEventsProcessed) delete fHistEventsProcessed ;
139 //_________________________________________________
140 void AliCFHeavyFlavourTaskMultiVarMultiStep::UserExec(Option_t *)
143 // Main loop function
146 if (fFillFromGenerated){
147 AliWarning("Flag to fill container with generated value ON ---> dca, d0pi, d0K, d0xd0, cosPointingAngle will be set as dummy!");
151 Error("UserExec","NO EVENT FOUND!");
156 if (fEvents%10000 ==0) AliInfo(Form("Event %d",fEvents));
157 AliAODEvent* aodEvent = dynamic_cast<AliAODEvent*>(fInputEvent);
158 fCFManager->SetEventInfo(aodEvent);
160 // MC-event selection
161 Double_t containerInput[11] ;
163 //loop on the MC event
165 TClonesArray* mcArray = dynamic_cast<TClonesArray*>(aodEvent->FindListObject(AliAODMCParticle::StdBranchName()));
166 if (!mcArray) AliError("Could not find Monte-Carlo in AOD");
169 Int_t icountReco = 0;
170 Int_t icountRecoAcc = 0;
171 Int_t icountRecoITSClusters = 0;
172 Int_t icountRecoPPR = 0;
176 for (Int_t iPart=0; iPart<mcArray->GetEntriesFast(); iPart++) {
177 AliAODMCParticle* mcPart = dynamic_cast<AliAODMCParticle*>(mcArray->At(iPart));
178 if (mcPart->GetPdgCode() == 4) cquarks++;
179 if (mcPart->GetPdgCode() == -4) cquarks++;
181 AliWarning("Particle not found in tree, skipping");
185 // check the MC-level cuts
187 if (!fCFManager->CheckParticleCuts(0, mcPart)) continue; // 0 stands for MC level
188 Int_t pdgGranma = CheckOrigin(mcPart, mcArray);
189 Int_t abspdgGranma = TMath::Abs(pdgGranma);
190 if ((abspdgGranma > 500 && abspdgGranma < 600) || (abspdgGranma > 5000 && abspdgGranma < 6000)) {
191 AliInfo(Form("Particle has a b-meson, or b-baryon mother (pdg code mother = %d )--> not coming from a c-quark, skipping...", pdgGranma));
192 continue; // skipping particles that don't come from c quark
195 // if (TMath::Abs(pdgGranma)!=4) {
197 // fill the container for Gen-level selection
198 Double_t vectorMC[7] = {9999.,9999.,9999.,9999.,9999.,9999.,9999.};
199 if (GetGeneratedValuesFromMCParticle(mcPart, mcArray, vectorMC)){
200 containerInput[0] = vectorMC[0];
201 containerInput[1] = vectorMC[1] ;
202 containerInput[2] = vectorMC[2] ;
203 containerInput[3] = vectorMC[3] ;
204 containerInput[4] = vectorMC[4] ;
205 containerInput[5] = vectorMC[5] ; // in micron
206 containerInput[6] = 0.; // dummy value, meaningless in MC, in micron
207 containerInput[7] = 0.; // dummy value, meaningless in MC, in micron
208 containerInput[8] = 0.; // dummy value, meaningless in MC, in micron
209 containerInput[9] = -100000.; // dummy value, meaningless in MC, in micron^2
210 containerInput[10] = 1.01; // dummy value, meaningless in MC
211 containerInput[11] = vectorMC[6]; // dummy value, meaningless in MC
212 fCFManager->GetParticleContainer()->Fill(containerInput,kStepGenerated);
215 // check the MC-Acceptance level cuts
216 // since standard CF functions are not applicable, using Kine Cuts on daughters
218 Int_t daughter0 = mcPart->GetDaughter(0);
219 Int_t daughter1 = mcPart->GetDaughter(1);
220 AliDebug(2, Form("daughter0 = %d and daughter1 = %d",daughter0,daughter1));
221 if (daughter0 == 0 || daughter1 == 0) {
222 AliDebug(2, "Error! the D0 MC doesn't have correct daughters!! But it should have, this check was already done...");
224 if (TMath::Abs(daughter1 - daughter0) != 1) {
225 AliDebug(2, "The D0 MC doesn't come from a 2-prong decay, but it should be, this check was already done...");
227 AliAODMCParticle* mcPartDaughter0 = dynamic_cast<AliAODMCParticle*>(mcArray->At(daughter0));
228 AliAODMCParticle* mcPartDaughter1 = dynamic_cast<AliAODMCParticle*>(mcArray->At(daughter1));
229 if (!mcPartDaughter0 || !mcPartDaughter1) {
230 AliWarning("At least one Daughter Particle not found in tree, but it should be, this check was already done...");
232 Double_t eta0 = mcPartDaughter0->Eta();
233 Double_t eta1 = mcPartDaughter1->Eta();
234 Double_t y0 = mcPartDaughter0->Y();
235 Double_t y1 = mcPartDaughter1->Y();
236 Double_t pt0 = mcPartDaughter0->Pt();
237 Double_t pt1 = mcPartDaughter1->Pt();
238 AliDebug(2, Form("Daughter 0: eta = %f, y = %f, pt = %f", eta0, y0, pt0));
239 AliDebug(2, Form("Daughter 1: eta = %f, y = %f, pt = %f", eta1, y1, pt1));
240 Bool_t daught0inAcceptance = (TMath::Abs(eta0) < 0.9 && pt0 > 0.1);
241 Bool_t daught1inAcceptance = (TMath::Abs(eta1) < 0.9 && pt1 > 0.1);
242 if (daught0inAcceptance && daught1inAcceptance) {
243 // checking whether the cuts implemented in the CF are equivalent - simply a cross-check
244 AliDebug(2, "Daughter particles in acceptance");
245 if (!fCFManager->CheckParticleCuts(1, mcPartDaughter0)) {
246 AliInfo("Inconsistency with CF cut for daughter 0!");
248 if (!fCFManager->CheckParticleCuts(1, mcPartDaughter1)) {
249 AliInfo("Inconsistency with CF cut for daughter 1!");
251 fCFManager->GetParticleContainer()->Fill(containerInput,kStepAcceptance);
256 AliDebug(3,"Problems in filling the container");
260 if (cquarks<2) AliInfo(Form("Event found with %d c-quarks", cquarks));
262 AliDebug(2, Form("Found %i MC particles that are D0!!",icountMC));
263 AliDebug(2, Form("Found %i MC particles that are D0 and satisfy Acc cuts!!",icountAcc));
265 // Now go to rec level
266 fCountMC += icountMC;
267 fCountAcc += icountAcc;
269 // AOD primary vertex
270 AliAODVertex *vtx1 = (AliAODVertex*)aodEvent->GetPrimaryVertex();
272 // load heavy flavour vertices
273 TClonesArray *arrayD0toKpi = (TClonesArray*)((aodEvent->GetList())->FindObject("D0toKpi"));
274 if (!arrayD0toKpi) AliError("Could not find array of HF vertices");
275 AliDebug(2, Form("Found %d vertices",arrayD0toKpi->GetEntriesFast()));
277 for (Int_t iD0toKpi = 0; iD0toKpi<arrayD0toKpi->GetEntriesFast(); iD0toKpi++) {
279 AliAODRecoDecayHF2Prong* d0tokpi = (AliAODRecoDecayHF2Prong*)arrayD0toKpi->At(iD0toKpi);
280 Bool_t unsetvtx=kFALSE;
281 if(!d0tokpi->GetOwnPrimaryVtx()) {
282 d0tokpi->SetOwnPrimaryVtx(vtx1); // needed to compute all variables
286 // find associated MC particle
287 Int_t mcLabel = d0tokpi->MatchToMC(421, mcArray) ;
290 AliDebug(2,"No MC particle found");
293 AliAODMCParticle* mcVtxHF = (AliAODMCParticle*)mcArray->At(mcLabel);
295 AliWarning("Could not find associated MC in AOD MC tree");
299 // check if associated MC v0 passes the cuts
300 if (!fCFManager->CheckParticleCuts(0 ,mcVtxHF)) { // 0 stands for MC
301 AliDebug(2, "Skipping the particles due to cuts");
304 Int_t pdgGranma = CheckOrigin(mcVtxHF, mcArray);
305 Int_t abspdgGranma = TMath::Abs(pdgGranma);
306 if ((abspdgGranma > 500 && abspdgGranma < 600) || (abspdgGranma > 5000 && abspdgGranma < 6000)) {
307 AliInfo(Form("At Reco level, from MC info: Particle has a b-meson, or b-baryon mother (pdg code mother = %d )--> not coming from a c-quark, skipping...", pdgGranma));
308 continue; // skipping particles that don't come from c quark
311 // fill the container...
312 Double_t pt = d0tokpi->Pt();
313 Double_t rapidity = d0tokpi->YD0();
315 Double_t cosThetaStar = 9999.;
318 Double_t dca = d0tokpi->GetDCA();
321 Double_t d0xd0 = d0tokpi->Prodd0d0();
322 Double_t cosPointingAngle = d0tokpi->CosPointingAngle();
323 Double_t phi = d0tokpi->Phi();
324 Int_t pdgCode = mcVtxHF->GetPdgCode();
326 cosThetaStar = d0tokpi->CosThetaStarD0();
327 pTpi = d0tokpi->PtProng(0);
328 pTK = d0tokpi->PtProng(1);
329 d0pi = d0tokpi->Getd0Prong(0);
330 d0K = d0tokpi->Getd0Prong(1);
333 cosThetaStar = d0tokpi->CosThetaStarD0bar();
334 pTpi = d0tokpi->PtProng(1);
335 pTK = d0tokpi->PtProng(0);
336 d0pi = d0tokpi->Getd0Prong(1);
337 d0K = d0tokpi->Getd0Prong(0);
340 Double_t cT = d0tokpi->CtD0();
342 if (!fFillFromGenerated){
343 // ...either with reconstructed values....
344 containerInput[0] = pt;
345 containerInput[1] = rapidity;
346 containerInput[2] = cosThetaStar;
347 containerInput[3] = pTpi;
348 containerInput[4] = pTK;
349 containerInput[5] = cT*1.E4; // in micron
350 containerInput[6] = dca*1.E4; // in micron
351 containerInput[7] = d0pi*1.E4; // in micron
352 containerInput[8] = d0K*1.E4; // in micron
353 containerInput[9] = d0xd0*1.E8; // in micron^2
354 containerInput[10] = cosPointingAngle; // in micron
355 containerInput[11] = phi;
358 // ... or with generated values
359 Double_t vectorMC[7] = {9999.,9999.,9999.,9999.,9999.,9999.,9999.};
360 if (GetGeneratedValuesFromMCParticle(mcVtxHF, mcArray, vectorMC)){
361 containerInput[0] = vectorMC[0];
362 containerInput[1] = vectorMC[1] ;
363 containerInput[2] = vectorMC[2] ;
364 containerInput[3] = vectorMC[3] ;
365 containerInput[4] = vectorMC[4] ;
366 containerInput[5] = vectorMC[5] ; // in micron
367 containerInput[6] = 0.; // dummy value, meaningless in MC, in micron
368 containerInput[7] = 0.; // dummy value, meaningless in MC, in micron
369 containerInput[8] = 0.; // dummy value, meaningless in MC, in micron
370 containerInput[9] = 100000.; // dummy value, meaningless in MC, in micron^2
371 containerInput[10] = 1.01; // dummy value, meaningless in MC
372 containerInput[11] = vectorMC[6];
375 AliDebug(3,"Problems in filling the container");
379 AliDebug(2, Form("Filling the container with pt = %f, rapidity = %f, cosThetaStar = %f, pTpi = %f, pTK = %f, cT = %f", containerInput[0], containerInput[1], containerInput[2], containerInput[3], containerInput[4], containerInput[5]));
381 fCFManager->GetParticleContainer()->Fill(containerInput,kStepReconstructed) ;
384 Bool_t acceptanceProng0 = (TMath::Abs(d0tokpi->EtaProng(0))< 0.9 && d0tokpi->PtProng(0) > 0.1);
385 Bool_t acceptanceProng1 = (TMath::Abs(d0tokpi->EtaProng(1))< 0.9 && d0tokpi->PtProng(1) > 0.1);
386 if (acceptanceProng0 && acceptanceProng1) {
387 AliDebug(2,"D0 reco daughters in acceptance");
388 fCFManager->GetParticleContainer()->Fill(containerInput,kStepRecoAcceptance) ;
391 // cut on the min n. of clusters in ITS
393 for(Int_t l=0;l<6;l++) if(TESTBIT(d0tokpi->GetITSClusterMap(),l)) ncls0++;
394 AliDebug(2, Form("n clusters = %d", ncls0));
395 if (ncls0 >= fMinITSClusters){
396 fCFManager->GetParticleContainer()->Fill(containerInput,kStepRecoITSClusters) ;
397 icountRecoITSClusters++;
398 AliDebug(2,Form("pT = %f, dca = %f, cosThetaStar = %f, pTpi = %f, pTK = %f, d0pi = %f, d0K = %f, d0xd0 = %f, cosPointingAngle = %f", pt, dca, cosThetaStar,pTpi, pTK, d0pi*1E4, d0K*1E4, d0xd0*1E8, cosPointingAngle));
401 Double_t cuts[6] = {9999999., 1.1, 0., 9999999., 9999999., 0.};
410 else if (pt > 1 && pt <= 2){
418 else if (pt > 2 && pt <= 3){
426 else if (pt > 3 && pt <= 5){
442 if (dca*1E4 < cuts[0]
443 && TMath::Abs(cosThetaStar) < cuts[1]
446 && TMath::Abs(d0pi*1E4) < cuts[3]
447 && TMath::Abs(d0K*1E4) < cuts[3]
448 && d0xd0*1E8 < cuts[4]
449 && cosPointingAngle > cuts[5]
452 AliDebug(2,"Particle passed PPR cuts");
453 fCFManager->GetParticleContainer()->Fill(containerInput,kStepRecoPPR) ;
457 AliDebug(2,"Particle skipped due to PPR cuts");
458 if (dca*1E4 > cuts[0]){
459 AliDebug(2,"Problems with dca");
461 if ( TMath::Abs(cosThetaStar) > cuts[1]){
462 AliDebug(2,"Problems with cosThetaStar");
465 AliDebug(2,"Problems with pTpi");
468 AliDebug(2,"Problems with pTK");
470 if (TMath::Abs(d0pi*1E4) > cuts[3]){
471 AliDebug(2,"Problems with d0pi");
473 if (TMath::Abs(d0K*1E4) > cuts[3]){
474 AliDebug(2,"Problems with d0K");
476 if (d0xd0*1E8 > cuts[4]){
477 AliDebug(2,"Problems with d0xd0");
479 if (cosPointingAngle < cuts[5]){
480 AliDebug(2,"Problems with cosPointingAngle");
486 if(unsetvtx) d0tokpi->UnsetOwnPrimaryVtx();
487 } // end loop on D0->Kpi
489 AliDebug(2, Form("Found %i Reco particles that are D0!!",icountReco));
491 fCountReco+= icountReco;
492 fCountRecoAcc+= icountRecoAcc;
493 fCountRecoITSClusters+= icountRecoITSClusters;
494 fCountRecoPPR+= icountRecoPPR;
496 fHistEventsProcessed->Fill(0);
497 /* PostData(0) is taken care of by AliAnalysisTaskSE */
498 PostData(1,fHistEventsProcessed) ;
499 PostData(2,fCFManager->GetParticleContainer()) ;
503 //___________________________________________________________________________
504 void AliCFHeavyFlavourTaskMultiVarMultiStep::Terminate(Option_t*)
506 // The Terminate() function is the last function to be called during
507 // a query. It always runs on the client, it can be used to present
508 // the results graphically or save the results to file.
510 AliAnalysisTaskSE::Terminate();
512 AliInfo(Form("Found %i MC particles that are D0 in MC, in %d events",fCountMC,fEvents));
513 AliInfo(Form("Found %i MC particles that are D0 in MC and satisfy Acc cuts, in %d events",fCountAcc,fEvents));
514 AliInfo(Form("Found %i reco D0 that are decaying in K+pi, in %d events",fCountReco,fEvents));
515 AliInfo(Form("Among the above, found %i reco D0 that are decaying in K+pi and are in the requested acceptance, in %d events",fCountRecoAcc,fEvents));
516 AliInfo(Form("Among the above, found %i reco D0 that are decaying in K+pi and have at least %d clusters in ITS, in %d events",fCountRecoITSClusters,fMinITSClusters,fEvents));
517 AliInfo(Form("Among the above, found %i reco D0 that are decaying in K+pi and satisfy PPR cuts, in %d events",fCountRecoPPR,fEvents));
519 // draw some example plots....
521 AliCFContainer *cont= dynamic_cast<AliCFContainer*> (GetOutputData(2));
523 printf("CONTAINER NOT FOUND\n");
526 // projecting the containers to obtain histograms
527 // first argument = variable, second argument = step
530 TH1D* h00 = cont->ShowProjection(0,0) ; // pt
531 TH1D* h10 = cont->ShowProjection(1,0) ; // rapidity
532 TH1D* h20 = cont->ShowProjection(2,0) ; // cosThetaStar
533 TH1D* h30 = cont->ShowProjection(3,0) ; // pTpi
534 TH1D* h40 = cont->ShowProjection(4,0) ; // pTK
535 TH1D* h50 = cont->ShowProjection(5,0) ; // cT
536 TH1D* h60 = cont->ShowProjection(6,0) ; // dca
537 TH1D* h70 = cont->ShowProjection(7,0) ; // d0pi
538 TH1D* h80 = cont->ShowProjection(8,0) ; // d0K
539 TH1D* h90 = cont->ShowProjection(9,0) ; // d0xd0
540 TH1D* h100 = cont->ShowProjection(10,0) ; // cosPointingAngle
541 TH1D* h110 = cont->ShowProjection(11,0) ; // phi
543 // MC-Acceptance level
544 TH1D* h01 = cont->ShowProjection(0,1) ; // pt
545 TH1D* h11 = cont->ShowProjection(1,1) ; // rapidity
546 TH1D* h21 = cont->ShowProjection(2,1) ; // cosThetaStar
547 TH1D* h31 = cont->ShowProjection(3,1) ; // pTpi
548 TH1D* h41 = cont->ShowProjection(4,1) ; // pTK
549 TH1D* h51 = cont->ShowProjection(5,1) ; // cT
550 TH1D* h61 = cont->ShowProjection(6,1) ; // dca
551 TH1D* h71 = cont->ShowProjection(7,1) ; // d0pi
552 TH1D* h81 = cont->ShowProjection(8,1) ; // d0K
553 TH1D* h91 = cont->ShowProjection(9,1) ; // d0xd0
554 TH1D* h101 = cont->ShowProjection(10,1) ; // cosPointingAngle
555 TH1D* h111 = cont->ShowProjection(11,1) ; // phi
558 TH1D* h02 = cont->ShowProjection(0,2) ; // pt
559 TH1D* h12 = cont->ShowProjection(1,2) ; // rapidity
560 TH1D* h22 = cont->ShowProjection(2,2) ; // cosThetaStar
561 TH1D* h32 = cont->ShowProjection(3,2) ; // pTpi
562 TH1D* h42 = cont->ShowProjection(4,2) ; // pTK
563 TH1D* h52 = cont->ShowProjection(5,2) ; // cT
564 TH1D* h62 = cont->ShowProjection(6,2) ; // dca
565 TH1D* h72 = cont->ShowProjection(7,2) ; // d0pi
566 TH1D* h82 = cont->ShowProjection(8,2) ; // d0K
567 TH1D* h92 = cont->ShowProjection(9,2) ; // d0xd0
568 TH1D* h102 = cont->ShowProjection(10,2) ; // cosPointingAngle
569 TH1D* h112 = cont->ShowProjection(11,2) ; // phi
571 h00->SetTitle("pT_D0 (GeV/c)");
572 h10->SetTitle("rapidity");
573 h20->SetTitle("cosThetaStar");
574 h30->SetTitle("pT_pi (GeV/c)");
575 h40->SetTitle("pT_K (Gev/c)");
576 h50->SetTitle("cT (#mum)");
577 h60->SetTitle("dca (#mum)");
578 h70->SetTitle("d0_pi (#mum)");
579 h80->SetTitle("d0_K (#mum)");
580 h90->SetTitle("d0xd0 (#mum^2)");
581 h100->SetTitle("cosPointingAngle");
582 h100->SetTitle("phi (rad)");
584 h00->GetXaxis()->SetTitle("pT_D0 (GeV/c)");
585 h10->GetXaxis()->SetTitle("rapidity");
586 h20->GetXaxis()->SetTitle("cosThetaStar");
587 h30->GetXaxis()->SetTitle("pT_pi (GeV/c)");
588 h40->GetXaxis()->SetTitle("pT_K (Gev/c)");
589 h50->GetXaxis()->SetTitle("cT (#mum)");
590 h60->GetXaxis()->SetTitle("dca (#mum)");
591 h70->GetXaxis()->SetTitle("d0_pi (#mum)");
592 h80->GetXaxis()->SetTitle("d0_K (#mum)");
593 h90->GetXaxis()->SetTitle("d0xd0 (#mum^2)");
594 h100->GetXaxis()->SetTitle("cosPointingAngle");
595 h110->GetXaxis()->SetTitle("phi (rad)");
597 h01->SetTitle("pT_D0 (GeV/c)");
598 h11->SetTitle("rapidity");
599 h21->SetTitle("cosThetaStar");
600 h31->SetTitle("pT_pi (GeV/c)");
601 h41->SetTitle("pT_K (Gev/c)");
602 h51->SetTitle("cT (#mum)");
603 h61->SetTitle("dca (#mum)");
604 h71->SetTitle("d0_pi (#mum)");
605 h81->SetTitle("d0_K (#mum)");
606 h91->SetTitle("d0xd0 (#mum^2)");
607 h101->SetTitle("cosPointingAngle");
608 h111->GetXaxis()->SetTitle("phi (rad)");
610 h01->GetXaxis()->SetTitle("pT_D0 (GeV/c)");
611 h11->GetXaxis()->SetTitle("rapidity");
612 h21->GetXaxis()->SetTitle("cosThetaStar");
613 h31->GetXaxis()->SetTitle("pT_pi (GeV/c)");
614 h41->GetXaxis()->SetTitle("pT_K (Gev/c)");
615 h51->GetXaxis()->SetTitle("cT (#mum)");
616 h61->GetXaxis()->SetTitle("dca (#mum)");
617 h71->GetXaxis()->SetTitle("d0_pi (#mum)");
618 h81->GetXaxis()->SetTitle("d0_K (#mum)");
619 h91->GetXaxis()->SetTitle("d0xd0 (#mum^2)");
620 h101->GetXaxis()->SetTitle("cosPointingAngle");
621 h111->GetXaxis()->SetTitle("phi (rad)");
623 h02->SetTitle("pT_D0 (GeV/c)");
624 h12->SetTitle("rapidity");
625 h22->SetTitle("cosThetaStar");
626 h32->SetTitle("pT_pi (GeV/c)");
627 h42->SetTitle("pT_K (Gev/c)");
628 h52->SetTitle("cT (#mum)");
629 h62->SetTitle("dca (#mum)");
630 h72->SetTitle("d0_pi (#mum)");
631 h82->SetTitle("d0_K (#mum)");
632 h92->SetTitle("d0xd0 (#mum^2)");
633 h102->SetTitle("cosPointingAngle");
634 h112->GetXaxis()->SetTitle("phi (rad)");
636 h02->GetXaxis()->SetTitle("pT_D0 (GeV/c)");
637 h12->GetXaxis()->SetTitle("rapidity");
638 h22->GetXaxis()->SetTitle("cosThetaStar");
639 h32->GetXaxis()->SetTitle("pT_pi (GeV/c)");
640 h42->GetXaxis()->SetTitle("pT_K (Gev/c)");
641 h52->GetXaxis()->SetTitle("cT (#mum)");
642 h62->GetXaxis()->SetTitle("dca (#mum)");
643 h72->GetXaxis()->SetTitle("d0_pi (#mum)");
644 h82->GetXaxis()->SetTitle("d0_K (#mum)");
645 h92->GetXaxis()->SetTitle("d0xd0 (#mum^2)");
646 h102->GetXaxis()->SetTitle("cosPointingAngle");
647 h112->GetXaxis()->SetTitle("phi (rad)");
649 Double_t max0 = h00->GetMaximum();
650 Double_t max1 = h10->GetMaximum();
651 Double_t max2 = h20->GetMaximum();
652 Double_t max3 = h30->GetMaximum();
653 Double_t max4 = h40->GetMaximum();
654 Double_t max5 = h50->GetMaximum();
655 Double_t max6 = h60->GetMaximum();
656 Double_t max7 = h70->GetMaximum();
657 Double_t max8 = h80->GetMaximum();
658 Double_t max9 = h90->GetMaximum();
659 Double_t max10 = h100->GetMaximum();
660 Double_t max11 = h110->GetMaximum();
662 h00->GetYaxis()->SetRangeUser(0,max0*1.2);
663 h10->GetYaxis()->SetRangeUser(0,max1*1.2);
664 h20->GetYaxis()->SetRangeUser(0,max2*1.2);
665 h30->GetYaxis()->SetRangeUser(0,max3*1.2);
666 h40->GetYaxis()->SetRangeUser(0,max4*1.2);
667 h50->GetYaxis()->SetRangeUser(0,max5*1.2);
668 h60->GetYaxis()->SetRangeUser(0,max6*1.2);
669 h70->GetYaxis()->SetRangeUser(0,max7*1.2);
670 h80->GetYaxis()->SetRangeUser(0,max8*1.2);
671 h90->GetYaxis()->SetRangeUser(0,max9*1.2);
672 h100->GetYaxis()->SetRangeUser(0,max10*1.2);
673 h110->GetYaxis()->SetRangeUser(0,max11*1.2);
675 h01->GetYaxis()->SetRangeUser(0,max0*1.2);
676 h11->GetYaxis()->SetRangeUser(0,max1*1.2);
677 h21->GetYaxis()->SetRangeUser(0,max2*1.2);
678 h31->GetYaxis()->SetRangeUser(0,max3*1.2);
679 h41->GetYaxis()->SetRangeUser(0,max4*1.2);
680 h51->GetYaxis()->SetRangeUser(0,max5*1.2);
681 h61->GetYaxis()->SetRangeUser(0,max6*1.2);
682 h71->GetYaxis()->SetRangeUser(0,max7*1.2);
683 h81->GetYaxis()->SetRangeUser(0,max8*1.2);
684 h91->GetYaxis()->SetRangeUser(0,max9*1.2);
685 h101->GetYaxis()->SetRangeUser(0,max10*1.2);
686 h111->GetYaxis()->SetRangeUser(0,max11*1.2);
688 h00->SetMarkerStyle(20);
689 h10->SetMarkerStyle(24);
690 h20->SetMarkerStyle(21);
691 h30->SetMarkerStyle(25);
692 h40->SetMarkerStyle(27);
693 h50->SetMarkerStyle(28);
694 h60->SetMarkerStyle(20);
695 h70->SetMarkerStyle(24);
696 h80->SetMarkerStyle(21);
697 h90->SetMarkerStyle(25);
698 h100->SetMarkerStyle(27);
699 h110->SetMarkerStyle(28);
701 h00->SetMarkerColor(2);
702 h10->SetMarkerColor(2);
703 h20->SetMarkerColor(2);
704 h30->SetMarkerColor(2);
705 h40->SetMarkerColor(2);
706 h50->SetMarkerColor(2);
707 h60->SetMarkerColor(2);
708 h70->SetMarkerColor(2);
709 h80->SetMarkerColor(2);
710 h90->SetMarkerColor(2);
711 h100->SetMarkerColor(2);
712 h110->SetMarkerColor(2);
714 h01->SetMarkerStyle(20) ;
715 h11->SetMarkerStyle(24) ;
716 h21->SetMarkerStyle(21) ;
717 h31->SetMarkerStyle(25) ;
718 h41->SetMarkerStyle(27) ;
719 h51->SetMarkerStyle(28) ;
720 h61->SetMarkerStyle(20);
721 h71->SetMarkerStyle(24);
722 h81->SetMarkerStyle(21);
723 h91->SetMarkerStyle(25);
724 h101->SetMarkerStyle(27);
725 h111->SetMarkerStyle(28);
727 h01->SetMarkerColor(8);
728 h11->SetMarkerColor(8);
729 h21->SetMarkerColor(8);
730 h31->SetMarkerColor(8);
731 h41->SetMarkerColor(8);
732 h51->SetMarkerColor(8);
733 h61->SetMarkerColor(8);
734 h71->SetMarkerColor(8);
735 h81->SetMarkerColor(8);
736 h91->SetMarkerColor(8);
737 h101->SetMarkerColor(8);
738 h111->SetMarkerColor(8);
740 h02->SetMarkerStyle(20) ;
741 h12->SetMarkerStyle(24) ;
742 h22->SetMarkerStyle(21) ;
743 h32->SetMarkerStyle(25) ;
744 h42->SetMarkerStyle(27) ;
745 h52->SetMarkerStyle(28) ;
746 h62->SetMarkerStyle(20);
747 h72->SetMarkerStyle(24);
748 h82->SetMarkerStyle(21);
749 h92->SetMarkerStyle(25);
750 h102->SetMarkerStyle(27);
751 h112->SetMarkerStyle(28);
753 h02->SetMarkerColor(4);
754 h12->SetMarkerColor(4);
755 h22->SetMarkerColor(4);
756 h32->SetMarkerColor(4);
757 h42->SetMarkerColor(4);
758 h52->SetMarkerColor(4);
759 h62->SetMarkerColor(4);
760 h72->SetMarkerColor(4);
761 h82->SetMarkerColor(4);
762 h92->SetMarkerColor(4);
763 h102->SetMarkerColor(4);
764 h112->SetMarkerColor(4);
766 gStyle->SetCanvasColor(0);
767 gStyle->SetFrameFillColor(0);
768 gStyle->SetTitleFillColor(0);
769 gStyle->SetStatColor(0);
771 // drawing in 2 separate canvas for a matter of clearity
772 TCanvas * c1 =new TCanvas("c1","pT, rapidiy, cosThetaStar",1100,1600);
804 TCanvas * c2 =new TCanvas("c2","pTpi, pTK, cT",1100,1600);
835 TCanvas * c3 =new TCanvas("c3","dca, d0pi, d0K",1100,1600);
866 TCanvas * c4 =new TCanvas("c4","d0xd0, cosPointingAngle, phi",1100,1600);
897 TFile* file_projection = new TFile("file_projection.root","RECREATE");
898 h00->Write("pT_D0_step0");
899 h10->Write("rapidity_step0");
900 h20->Write("cosThetaStar_step0");
901 h30->Write("pT_pi_step0");
902 h40->Write("pT_K_step0");
903 h50->Write("cT_step0");
904 h60->Write("dca_step0");
905 h70->Write("d0_pi_step0");
906 h80->Write("d0_K_step0");
907 h90->Write("d0xd0_step0");
908 h100->Write("cosPointingAngle_step0");
909 h110->Write("phi_step0");
911 h01->Write("pT_D0_step1");
912 h11->Write("rapidity_step1");
913 h21->Write("cosThetaStar_step1");
914 h31->Write("pT_pi_step1");
915 h41->Write("pT_K_step1");
916 h51->Write("cT_step1");
917 h61->Write("dca_step1");
918 h71->Write("d0_pi_step1");
919 h81->Write("d0_K_step1");
920 h91->Write("d0xd0_step1");
921 h101->Write("cosPointingAngle_step1");
922 h111->Write("phi_step1");
924 h02->Write("pT_D0_step2");
925 h12->Write("rapidity_step2");
926 h22->Write("cosThetaStar_step2");
927 h32->Write("pT_pi_step2");
928 h42->Write("pT_K_step2");
929 h52->Write("cT_step2");
930 h62->Write("dca_step2");
931 h72->Write("d0_pi_step2");
932 h80->Write("d0_K_step2");
933 h92->Write("d0xd0_step2");
934 h102->Write("cosPointingAngle_step2");
935 h112->Write("phi_step2");
937 file_projection->Close();
940 c1->SaveAs("Plots/pT_rapidity_cosThetaStar.eps");
941 c2->SaveAs("Plots/pTpi_pTK_cT.eps");
942 c3->SaveAs("Plots/dca_d0pi_d0TK.eps");
943 c4->SaveAs("Plots/d0xd0_cosPointingAngle.eps");
945 c1->SaveAs("Plots/pT_rapidity_cosThetaStar.gif");
946 c2->SaveAs("Plots/pTpi_pTK_cT.gif");
947 c3->SaveAs("Plots/dca_d0pi_d0TK.gif");
948 c4->SaveAs("Plots/d0xd0_cosPointingAngle.gif");
952 //___________________________________________________________________________
953 void AliCFHeavyFlavourTaskMultiVarMultiStep::UserCreateOutputObjects() {
954 //HERE ONE CAN CREATE OUTPUT OBJECTS, IN PARTICULAR IF THE OBJECT PARAMETERS DON'T NEED
955 //TO BE SET BEFORE THE EXECUTION OF THE TASK
957 Info("UserCreateOutputObjects","CreateOutputObjects of task %s\n", GetName());
961 fHistEventsProcessed = new TH1I("fHistEventsProcessed","",1,0,1) ;
964 //___________________________________________________________________________
965 Double_t AliCFHeavyFlavourTaskMultiVarMultiStep::CosThetaStar(AliAODMCParticle* mcPart, AliAODMCParticle* mcPartDaughter0, AliAODMCParticle* mcPartDaughter1) const {
968 // to calculate cos(ThetaStar) for generated particle
969 // using the K, since mcPartDaughter0 and mcPartDaughter1 always correspond to K and pi respectively
970 // (see where the function is called)
973 Int_t pdgvtx = mcPart->GetPdgCode();
974 /* if (pdgvtx > 0) { // setting as the first daughter always the kaon, to be used to calculate cos(ThetaStar)
975 Int_t pdgprong0 = TMath::Abs(mcPartDaughter0->GetPdgCode());
976 Int_t pdgprong1 = TMath::Abs(mcPartDaughter1->GetPdgCode());
977 AliInfo(Form("D0, with pdgprong0 = %d, pdgprong1 = %d",pdgprong0,pdgprong1));
978 AliDebug(2,"This is a D0");
979 AliAODMCParticle* mcPartdummy = mcPartDaughter0;
980 mcPartDaughter0 = mcPartDaughter1;
981 mcPartDaughter1 = mcPartdummy;
987 Int_t pdgprong0 = TMath::Abs(mcPartDaughter0->GetPdgCode());
988 Int_t pdgprong1 = TMath::Abs(mcPartDaughter1->GetPdgCode());
989 if (pdgvtx > 0) { // setting as the first daughter always the kaon, to be used to calculate cos(ThetaStar)
995 if (pdgprong0 == 211){
996 AliDebug(2,Form("pdgprong0 = %d, pdgprong1 = %d, switching...",pdgprong0,pdgprong1));
997 AliAODMCParticle* mcPartdummy = mcPartDaughter0;
998 mcPartDaughter0 = mcPartDaughter1;
999 mcPartDaughter1 = mcPartdummy;
1000 pdgprong0 = TMath::Abs(mcPartDaughter0->GetPdgCode());
1001 pdgprong1 = TMath::Abs(mcPartDaughter1->GetPdgCode());
1004 AliDebug(2,Form("After checking, pdgprong0 = %d, pdgprong1 = %d",pdgprong0,pdgprong1));
1005 Double_t massvtx = TDatabasePDG::Instance()->GetParticle(TMath::Abs(pdgvtx))->Mass();
1007 massp[0] = TDatabasePDG::Instance()->GetParticle(pdgprong0)->Mass();
1008 massp[1] = TDatabasePDG::Instance()->GetParticle(pdgprong1)->Mass();
1010 Double_t pStar = TMath::Sqrt(TMath::Power(massvtx*massvtx-massp[0]*massp[0]-massp[1]*massp[1],2.)-4.*massp[0]*massp[0]*massp[1]*massp[1])/(2.*massvtx);
1012 Double_t px = mcPartDaughter0->Px()+mcPartDaughter1->Px();
1013 Double_t py = mcPartDaughter0->Py()+mcPartDaughter1->Py();
1014 Double_t pz = mcPartDaughter0->Pz()+mcPartDaughter1->Pz();
1015 Double_t p = TMath::Sqrt(px*px+py*py+pz*pz);
1016 Double_t e = TMath::Sqrt(massvtx*massvtx+p*p);
1017 Double_t beta = p/e;
1018 Double_t gamma = e/massvtx;
1019 TVector3 mom(mcPartDaughter0->Px(),mcPartDaughter0->Py(),mcPartDaughter0->Pz());
1020 TVector3 momTot(mcPartDaughter0->Px()+mcPartDaughter1->Px(),mcPartDaughter0->Py()+mcPartDaughter1->Py(),mcPartDaughter0->Pz()+mcPartDaughter1->Pz());
1022 Double_t qlprong = mom.Dot(momTot)/momTot.Mag(); // analog to AliAODRecoDecay::QlProng(0)
1024 AliDebug(2,Form("pStar = %f, beta = %f, gamma = %f, qlprong = %f, massp[0] = %f", pStar, beta, gamma, qlprong, massp[0]));
1025 Double_t cts = (qlprong/gamma-beta*TMath::Sqrt(pStar*pStar+massp[0]*massp[0]))/pStar;
1026 AliDebug(2,Form("cts = %f", cts));
1029 //___________________________________________________________________________
1030 Double_t AliCFHeavyFlavourTaskMultiVarMultiStep::CT(AliAODMCParticle* mcPart, AliAODMCParticle* mcPartDaughter0, AliAODMCParticle* mcPartDaughter1) const {
1033 // to calculate cT for generated particle
1036 Double_t xmcPart[3] = {0,0,0};
1037 Double_t xdaughter0[3] = {0,0,0};
1038 Double_t xdaughter1[3] = {0,0,0};
1039 mcPart->XvYvZv(xmcPart); // cm
1040 mcPartDaughter0->XvYvZv(xdaughter0); // cm
1041 mcPartDaughter1->XvYvZv(xdaughter1); //cm
1042 Double_t prodVtxD0 = TMath::Sqrt(xmcPart[0]*xmcPart[0]+
1043 xmcPart[1]*xmcPart[1]+
1044 xmcPart[2]*xmcPart[2]);
1045 Double_t prodVtxDaughter0 = TMath::Sqrt(xdaughter0[0]*xdaughter0[0]+
1046 xdaughter0[1]*xdaughter0[1]+
1047 xdaughter0[2]*xdaughter0[2]);
1048 Double_t prodVtxDaughter1 = TMath::Sqrt(xdaughter1[0]*xdaughter1[0]+
1049 xdaughter1[1]*xdaughter1[1]+
1050 xdaughter1[2]*xdaughter1[2]);
1052 AliDebug(2, Form("D0: x = %f, y = %f, z = %f, production vertex distance = %f (cm), %f (micron)", xmcPart[0], xmcPart[1], xmcPart[2], prodVtxD0, prodVtxD0*1.E4));
1053 AliDebug(2, Form("Daughter0: x = %f, y = %f, z = %f, production vertex distance = %f (cm) %f (micron)", xdaughter0[0], xdaughter0[1], xdaughter0[2], prodVtxDaughter0, prodVtxDaughter0*1E4));
1054 AliDebug(2, Form("Daughter1: x = %f, y = %f, z = %f, production vertex distance = %f (cm) %f (micron)", xdaughter1[0], xdaughter1[1], xdaughter1[2], prodVtxDaughter1, prodVtxDaughter1*1.E4));
1056 Double_t cT0 = TMath::Sqrt((xdaughter0[0]-xmcPart[0])*(xdaughter0[0]-xmcPart[0])+
1057 (xdaughter0[1]-xmcPart[1])*(xdaughter0[1]-xmcPart[1])+
1058 (xdaughter0[2]-xmcPart[2])*(xdaughter0[2]-xmcPart[2]));
1060 Double_t cT1 = TMath::Sqrt((xdaughter1[0]-xmcPart[0])*(xdaughter1[0]-xmcPart[0])+
1061 (xdaughter1[1]-xmcPart[1])*(xdaughter1[1]-xmcPart[1])+
1062 (xdaughter1[2]-xmcPart[2])*(xdaughter1[2]-xmcPart[2]));
1064 if ((cT0 - cT1)>1E-5) {
1065 AliWarning(Form("cT from daughter 0 (%f) different from cT from daughter 1 (%f)! Using cT from daughter 0, but PLEASE, CHECK....",cT0,cT1));
1068 // calculating cT from cT0
1070 Double_t mass = TDatabasePDG::Instance()->GetParticle(mcPart->GetPdgCode())->Mass(); // mcPart->GetPdgCode() should return +/- 421 for the D0/D0bar
1071 Double_t p = mcPart-> P();
1072 Double_t cT = cT0*mass/p;
1073 AliDebug(2, Form("cT from daughter 0 = %f (micron)", cT0*1E4));
1074 AliDebug(2, Form("cT from daughter 1 = %f (micron)", cT1*1E4));
1075 AliDebug(2, Form("cT (with mass = %f and p = %f) = %f (micron)", mass, p, cT*1E4));
1078 //________________________________________________________________________________
1079 Bool_t AliCFHeavyFlavourTaskMultiVarMultiStep::GetGeneratedValuesFromMCParticle(AliAODMCParticle* mcPart, TClonesArray* mcArray, Double_t* vectorMC) const {
1082 // collecting all the necessary info (pt, y, cosThetaStar, ptPi, ptKa, cT) from MC particle
1085 Bool_t isOk = kFALSE;
1087 // check whether the D0 decays in pi+K
1088 // to be added!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1089 // could use a cut in the CF, but not clear how to define a TDecayChannel
1090 // implemented for the time being as a cut on the number of daughters - see later when
1091 // getting the daughters
1093 // getting the daughters
1094 Int_t daughter0 = mcPart->GetDaughter(0);
1095 Int_t daughter1 = mcPart->GetDaughter(1);
1096 AliDebug(2, Form("daughter0 = %d and daughter1 = %d",daughter0,daughter1));
1097 if (daughter0 == 0 || daughter1 == 0) {
1098 AliDebug(2, "Error! the D0 MC doesn't have correct daughters!!");
1101 if (TMath::Abs(daughter1 - daughter0) != 1) {
1102 AliDebug(2, "The D0 MC doesn't come from a 2-prong decay, skipping!!");
1105 AliAODMCParticle* mcPartDaughter0 = dynamic_cast<AliAODMCParticle*>(mcArray->At(daughter0));
1106 AliAODMCParticle* mcPartDaughter1 = dynamic_cast<AliAODMCParticle*>(mcArray->At(daughter1));
1107 if (!mcPartDaughter0 || !mcPartDaughter1) {
1108 AliWarning("At least one Daughter Particle not found in tree, skipping");
1111 if (!(TMath::Abs(mcPartDaughter0->GetPdgCode())==321 &&
1112 TMath::Abs(mcPartDaughter1->GetPdgCode())==211) &&
1113 !(TMath::Abs(mcPartDaughter0->GetPdgCode())==211 &&
1114 TMath::Abs(mcPartDaughter1->GetPdgCode())==321)) {
1115 AliDebug(2, "The D0 MC doesn't come from a Kpi decay, skipping!!");
1119 Double_t vtx1[3] = {0,0,0}; // primary vertex
1120 Double_t vtx2daughter0[3] = {0,0,0}; // secondary vertex from daughter 0
1121 Double_t vtx2daughter1[3] = {0,0,0}; // secondary vertex from daughter 1
1122 mcPart->XvYvZv(vtx1); // cm
1123 // getting vertex from daughters
1124 mcPartDaughter0->XvYvZv(vtx2daughter0); // cm
1125 mcPartDaughter1->XvYvZv(vtx2daughter1); //cm
1126 if (vtx2daughter0[0] != vtx2daughter1[0] && vtx2daughter0[1] != vtx2daughter1[1] && vtx2daughter0[2] != vtx2daughter1[2]) {
1127 AliError("Daughters have different secondary vertex, skipping the track");
1132 // always instantiate the AliAODRecoDecay with the positive daughter first, the negative second
1133 AliAODMCParticle* positiveDaugh = mcPartDaughter0;
1134 AliAODMCParticle* negativeDaugh = mcPartDaughter1;
1135 if (mcPartDaughter0->GetPdgCode()<0 && mcPartDaughter1->GetPdgCode()>0){
1136 // inverting in case the positive daughter is the second one
1137 positiveDaugh = mcPartDaughter1;
1138 negativeDaugh = mcPartDaughter0;
1140 // getting the momentum from the daughters
1141 Double_t px[2] = {positiveDaugh->Px(), negativeDaugh->Px()};
1142 Double_t py[2] = {positiveDaugh->Py(), negativeDaugh->Py()};
1143 Double_t pz[2] = {positiveDaugh->Pz(), negativeDaugh->Pz()};
1145 Double_t d0[2] = {0.,0.};
1147 AliAODRecoDecayHF* decay = new AliAODRecoDecayHF(vtx1,vtx2daughter0,nprongs,charge,px,py,pz,d0);
1149 Double_t cosThetaStar = 0.;
1150 Double_t cosThetaStarD0 = 0.;
1151 Double_t cosThetaStarD0bar = 0.;
1152 cosThetaStarD0 = decay->CosThetaStar(1,421,211,321);
1153 cosThetaStarD0bar = decay->CosThetaStar(0,421,321,211);
1154 if (mcPart->GetPdgCode() == 421){ // D0
1155 AliDebug(3, Form("D0, with pdgprong0 = %d, pdgprong1 = %d",mcPartDaughter0->GetPdgCode(),mcPartDaughter1->GetPdgCode()));
1156 cosThetaStar = cosThetaStarD0;
1158 else if (mcPart->GetPdgCode() == -421){ // D0bar{
1159 AliDebug(3, Form("D0bar, with pdgprong0 = %d, pdgprong1 = %d",mcPartDaughter0->GetPdgCode(),mcPartDaughter1->GetPdgCode()));
1160 cosThetaStar = cosThetaStarD0bar;
1163 AliWarning("There are problems!! particle was expected to be either a D0 or a D0bar, check...");
1166 if (cosThetaStar < -1 || cosThetaStar > 1) {
1167 AliWarning("Invalid value for cosine Theta star, returning");
1171 // calculate cos(Theta*) according to the method implemented herein
1173 Double_t cts = 9999.;
1174 cts = CosThetaStar(mcPart, mcPartDaughter0, mcPartDaughter1);
1175 if (cts < -1 || cts > 1) {
1176 AliWarning("Invalid value for cosine Theta star from AliCFHeavyFlavourTaskMultiVarMultiStep method");
1178 if (TMath::Abs(cts - cosThetaStar)>0.001) {
1179 AliError(Form("cosThetaStar automatically calculated different from that manually calculated!!! cosThetaStar = %f, cosThetaStar = %f", cosThetaStar,cts));
1182 Double_t cT = decay->Ct(421);
1184 // calculate cT from the method implemented herein
1186 cT1 = CT(mcPart, mcPartDaughter0, mcPartDaughter1);
1188 if (TMath::Abs(cT1 - cT)>0.001) {
1189 AliError(Form("cT automatically calculated different from that manually calculated!!! cT = %f, cT1 = %f",cT,cT1));
1192 // get the pT of the daughters
1197 if (TMath::Abs(mcPartDaughter0->GetPdgCode()) == 211) {
1198 pTpi = mcPartDaughter0->Pt();
1199 pTK = mcPartDaughter1->Pt();
1202 pTpi = mcPartDaughter1->Pt();
1203 pTK = mcPartDaughter0->Pt();
1206 vectorMC[0] = mcPart->Pt();
1207 vectorMC[1] = mcPart->Y() ;
1208 vectorMC[2] = cosThetaStar ;
1209 vectorMC[3] = pTpi ;
1211 vectorMC[5] = cT*1.E4 ; // in micron
1212 vectorMC[6] = mcPart->Phi() ;
1216 //_________________________________________________________________________________________________
1217 Int_t AliCFHeavyFlavourTaskMultiVarMultiStep::CheckOrigin(AliAODMCParticle* mcPart, TClonesArray* mcArray)const{
1220 // checking whether the very mother of the D0 is a charm or a bottom quark
1223 Int_t pdgGranma = 0;
1225 mother = mcPart->GetMother();
1229 AliDebug(2,Form("mother at step %d = %d", istep, mother));
1230 AliAODMCParticle* mcGranma = dynamic_cast<AliAODMCParticle*>(mcArray->At(mother));
1231 pdgGranma = mcGranma->GetPdgCode();
1232 AliDebug(2,Form("Pdg mother at step %d = %d", istep, pdgGranma));
1233 Int_t abspdgGranma = TMath::Abs(pdgGranma);
1234 if ((abspdgGranma > 500 && abspdgGranma < 600) || (abspdgGranma > 5000 && abspdgGranma < 6000)) {
1237 mother = mcGranma->GetMother();