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 //-----------------------------------------------------------------------
26 //-----------------------------------------------------------------------
27 // Base class for HF Unfolding (pt and eta)
28 // correlation matrix filled at Acceptance and PPR level
29 // Author: A.Grelli , Utrecht - agrelli@uu.nl
30 //-----------------------------------------------------------------------
32 #include <TParticle.h>
33 #include <TDatabasePDG.h>
38 #include "AliCFHeavyFlavourTaskMultiVarMultiStep.h"
40 #include "AliMCEvent.h"
41 #include "AliCFManager.h"
42 #include "AliCFContainer.h"
44 #include "AliAODEvent.h"
45 #include "AliAODRecoDecay.h"
46 #include "AliAODRecoDecayHF.h"
47 #include "AliAODRecoDecayHF2Prong.h"
48 #include "AliAODMCParticle.h"
49 #include "AliESDtrack.h"
51 #include "THnSparse.h"
53 //__________________________________________________________________________
54 AliCFHeavyFlavourTaskMultiVarMultiStep::AliCFHeavyFlavourTaskMultiVarMultiStep() :
58 fHistEventsProcessed(0x0),
64 fCountRecoITSClusters(0),
67 fFillFromGenerated(kFALSE),
75 //___________________________________________________________________________
76 AliCFHeavyFlavourTaskMultiVarMultiStep::AliCFHeavyFlavourTaskMultiVarMultiStep(const Char_t* name) :
77 AliAnalysisTaskSE(name),
80 fHistEventsProcessed(0x0),
86 fCountRecoITSClusters(0),
89 fFillFromGenerated(kFALSE),
94 // Constructor. Initialization of Inputs and Outputs
96 Info("AliCFHeavyFlavourTaskMultiVarMultiStep","Calling Constructor");
98 DefineInput(0) and DefineOutput(0)
99 are taken care of by AliAnalysisTaskSE constructor
101 DefineOutput(1,TH1I::Class());
102 DefineOutput(2,AliCFContainer::Class());
103 DefineOutput(3,THnSparseD::Class());
106 //___________________________________________________________________________
107 AliCFHeavyFlavourTaskMultiVarMultiStep& AliCFHeavyFlavourTaskMultiVarMultiStep::operator=(const AliCFHeavyFlavourTaskMultiVarMultiStep& c)
110 // Assignment operator
113 AliAnalysisTaskSE::operator=(c) ;
115 fCFManager = c.fCFManager;
116 fHistEventsProcessed = c.fHistEventsProcessed;
121 //___________________________________________________________________________
122 AliCFHeavyFlavourTaskMultiVarMultiStep::AliCFHeavyFlavourTaskMultiVarMultiStep(const AliCFHeavyFlavourTaskMultiVarMultiStep& c) :
123 AliAnalysisTaskSE(c),
125 fCFManager(c.fCFManager),
126 fHistEventsProcessed(c.fHistEventsProcessed),
127 fCorrelation(c.fCorrelation),
128 fCountMC(c.fCountMC),
129 fCountAcc(c.fCountAcc),
130 fCountReco(c.fCountReco),
131 fCountRecoAcc(c.fCountRecoAcc),
132 fCountRecoITSClusters(c.fCountRecoITSClusters),
133 fCountRecoPPR(c.fCountRecoPPR),
135 fFillFromGenerated(c.fFillFromGenerated),
136 fMinITSClusters(c.fMinITSClusters),
137 fAcceptanceUnf(c.fAcceptanceUnf)
144 //___________________________________________________________________________
145 AliCFHeavyFlavourTaskMultiVarMultiStep::~AliCFHeavyFlavourTaskMultiVarMultiStep() {
149 if (fCFManager) delete fCFManager ;
150 if (fHistEventsProcessed) delete fHistEventsProcessed ;
151 if (fCorrelation) delete fCorrelation ;
154 //_________________________________________________
155 void AliCFHeavyFlavourTaskMultiVarMultiStep::UserExec(Option_t *)
158 // Main loop function
161 if (fFillFromGenerated){
162 AliWarning("Flag to fill container with generated value ON ---> dca, d0pi, d0K, d0xd0, cosPointingAngle will be set as dummy!");
166 Error("UserExec","NO EVENT FOUND!");
171 if (fEvents%10000 ==0) AliInfo(Form("Event %d",fEvents));
172 AliAODEvent* aodEvent = dynamic_cast<AliAODEvent*>(fInputEvent);
173 fCFManager->SetEventInfo(aodEvent);
175 // MC-event selection
176 Double_t containerInput[11] ;
178 //loop on the MC event
180 TClonesArray* mcArray = dynamic_cast<TClonesArray*>(aodEvent->FindListObject(AliAODMCParticle::StdBranchName()));
181 if (!mcArray) AliError("Could not find Monte-Carlo in AOD");
184 Int_t icountReco = 0;
185 Int_t icountRecoAcc = 0;
186 Int_t icountRecoITSClusters = 0;
187 Int_t icountRecoPPR = 0;
191 for (Int_t iPart=0; iPart<mcArray->GetEntriesFast(); iPart++) {
192 AliAODMCParticle* mcPart = dynamic_cast<AliAODMCParticle*>(mcArray->At(iPart));
193 if (mcPart->GetPdgCode() == 4) cquarks++;
194 if (mcPart->GetPdgCode() == -4) cquarks++;
196 AliWarning("Particle not found in tree, skipping");
200 // check the MC-level cuts
202 if (!fCFManager->CheckParticleCuts(0, mcPart)) continue; // 0 stands for MC level
203 Int_t pdgGranma = CheckOrigin(mcPart, mcArray);
204 Int_t abspdgGranma = TMath::Abs(pdgGranma);
205 if ((abspdgGranma > 500 && abspdgGranma < 600) || (abspdgGranma > 5000 && abspdgGranma < 6000)) {
206 AliDebug(2,Form("Particle has a b-meson, or b-baryon mother (pdg code mother = %d )--> not coming from a c-quark, skipping...", pdgGranma));
207 continue; // skipping particles that don't come from c quark
210 // if (TMath::Abs(pdgGranma)!=4) {
212 // fill the container for Gen-level selection
213 Double_t vectorMC[7] = {9999.,9999.,9999.,9999.,9999.,9999.,9999.};
214 if (GetGeneratedValuesFromMCParticle(mcPart, mcArray, vectorMC)){
215 containerInput[0] = vectorMC[0];
216 containerInput[1] = vectorMC[1] ;
217 containerInput[2] = vectorMC[2] ;
218 containerInput[3] = vectorMC[3] ;
219 containerInput[4] = vectorMC[4] ;
220 containerInput[5] = vectorMC[5] ; // in micron
221 containerInput[6] = 0.; // dummy value, meaningless in MC, in micron
222 containerInput[7] = 0.; // dummy value, meaningless in MC, in micron
223 containerInput[8] = 0.; // dummy value, meaningless in MC, in micron
224 containerInput[9] = -100000.; // dummy value, meaningless in MC, in micron^2
225 containerInput[10] = 1.01; // dummy value, meaningless in MC
226 containerInput[11] = vectorMC[6]; // dummy value, meaningless in MC
227 fCFManager->GetParticleContainer()->Fill(containerInput,kStepGenerated);
230 // check the MC-Acceptance level cuts
231 // since standard CF functions are not applicable, using Kine Cuts on daughters
233 Int_t daughter0 = mcPart->GetDaughter(0);
234 Int_t daughter1 = mcPart->GetDaughter(1);
235 AliDebug(2, Form("daughter0 = %d and daughter1 = %d",daughter0,daughter1));
236 if (daughter0 == 0 || daughter1 == 0) {
237 AliDebug(2, "Error! the D0 MC doesn't have correct daughters!! But it should have, this check was already done...");
239 if (TMath::Abs(daughter1 - daughter0) != 1) {
240 AliDebug(2, "The D0 MC doesn't come from a 2-prong decay, but it should be, this check was already done...");
242 AliAODMCParticle* mcPartDaughter0 = dynamic_cast<AliAODMCParticle*>(mcArray->At(daughter0));
243 AliAODMCParticle* mcPartDaughter1 = dynamic_cast<AliAODMCParticle*>(mcArray->At(daughter1));
244 if (!mcPartDaughter0 || !mcPartDaughter1) {
245 AliWarning("At least one Daughter Particle not found in tree, but it should be, this check was already done...");
247 Double_t eta0 = mcPartDaughter0->Eta();
248 Double_t eta1 = mcPartDaughter1->Eta();
249 Double_t y0 = mcPartDaughter0->Y();
250 Double_t y1 = mcPartDaughter1->Y();
251 Double_t pt0 = mcPartDaughter0->Pt();
252 Double_t pt1 = mcPartDaughter1->Pt();
253 AliDebug(2, Form("Daughter 0: eta = %f, y = %f, pt = %f", eta0, y0, pt0));
254 AliDebug(2, Form("Daughter 1: eta = %f, y = %f, pt = %f", eta1, y1, pt1));
255 Bool_t daught0inAcceptance = (TMath::Abs(eta0) < 0.9 && pt0 > 0.1);
256 Bool_t daught1inAcceptance = (TMath::Abs(eta1) < 0.9 && pt1 > 0.1);
257 if (daught0inAcceptance && daught1inAcceptance) {
258 // checking whether the cuts implemented in the CF are equivalent - simply a cross-check
259 AliDebug(2, "Daughter particles in acceptance");
260 if (!fCFManager->CheckParticleCuts(1, mcPartDaughter0)) {
261 AliInfo("Inconsistency with CF cut for daughter 0!");
263 if (!fCFManager->CheckParticleCuts(1, mcPartDaughter1)) {
264 AliInfo("Inconsistency with CF cut for daughter 1!");
266 fCFManager->GetParticleContainer()->Fill(containerInput,kStepAcceptance);
271 AliDebug(3,"Problems in filling the container");
275 if (cquarks<2) AliDebug(2,Form("Event found with %d c-quarks", cquarks));
277 AliDebug(2, Form("Found %i MC particles that are D0!!",icountMC));
278 AliDebug(2, Form("Found %i MC particles that are D0 and satisfy Acc cuts!!",icountAcc));
280 // Now go to rec level
281 fCountMC += icountMC;
282 fCountAcc += icountAcc;
284 // AOD primary vertex
285 AliAODVertex *vtx1 = (AliAODVertex*)aodEvent->GetPrimaryVertex();
287 // load heavy flavour vertices
288 TClonesArray *arrayD0toKpi = (TClonesArray*)((aodEvent->GetList())->FindObject("D0toKpi"));
289 if (!arrayD0toKpi) AliError("Could not find array of HF vertices");
290 AliDebug(2, Form("Found %d vertices",arrayD0toKpi->GetEntriesFast()));
292 for (Int_t iD0toKpi = 0; iD0toKpi<arrayD0toKpi->GetEntriesFast(); iD0toKpi++) {
294 AliAODRecoDecayHF2Prong* d0tokpi = (AliAODRecoDecayHF2Prong*)arrayD0toKpi->At(iD0toKpi);
295 Bool_t unsetvtx=kFALSE;
296 if(!d0tokpi->GetOwnPrimaryVtx()) {
297 d0tokpi->SetOwnPrimaryVtx(vtx1); // needed to compute all variables
301 // find associated MC particle
302 Int_t mcLabel = d0tokpi->MatchToMC(421, mcArray) ;
305 AliDebug(2,"No MC particle found");
308 AliAODMCParticle* mcVtxHF = (AliAODMCParticle*)mcArray->At(mcLabel);
310 AliWarning("Could not find associated MC in AOD MC tree");
313 // check whether the daughters are K- and pi+
314 AliAODMCParticle* dg0MC=(AliAODMCParticle*)mcArray->At(mcVtxHF->GetDaughter(0));
315 AliAODMCParticle* dg1MC=(AliAODMCParticle*)mcArray->At(mcVtxHF->GetDaughter(1));
316 if(!(TMath::Abs(dg0MC->GetPdgCode())==321 && TMath::Abs(dg1MC->GetPdgCode())==211) &&
317 !(TMath::Abs(dg0MC->GetPdgCode())==211 && TMath::Abs(dg1MC->GetPdgCode())==321)) continue;
319 // check whether the daughters have kTPCrefit set
320 AliAODTrack *track0 = (AliAODTrack*)d0tokpi->GetDaughter(0);
321 AliAODTrack *track1 = (AliAODTrack*)d0tokpi->GetDaughter(1);
322 if((!(track0->GetStatus()&AliESDtrack::kTPCrefit)) || (!(track1->GetStatus()&AliESDtrack::kTPCrefit))) {
323 // skipping if at least one daughter does not have kTPCrefit
327 const Double_t d0tokpiCuts[9] = {0.3,999999.,1.1,0.,0.,999999.,999999.,999999.,0.};
329 if (!(d0tokpi->SelectD0(&d0tokpiCuts[0],okD0,okD0bar))){
330 // skipping candidate
334 // check if associated MC v0 passes the cuts
335 if (!fCFManager->CheckParticleCuts(0 ,mcVtxHF)) { // 0 stands for MC
336 AliDebug(2, "Skipping the particles due to cuts");
339 Int_t pdgGranma = CheckOrigin(mcVtxHF, mcArray);
340 Int_t abspdgGranma = TMath::Abs(pdgGranma);
341 if ((abspdgGranma > 500 && abspdgGranma < 600) || (abspdgGranma > 5000 && abspdgGranma < 6000)) {
342 AliDebug(2,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));
343 continue; // skipping particles that don't come from c quark
346 // fill the container...
347 Double_t pt = d0tokpi->Pt();
348 Double_t rapidity = d0tokpi->YD0();
350 Double_t cosThetaStar = 9999.;
353 Double_t dca = d0tokpi->GetDCA();
356 Double_t d0xd0 = d0tokpi->Prodd0d0();
357 Double_t cosPointingAngle = d0tokpi->CosPointingAngle();
358 Double_t phi = d0tokpi->Phi();
359 Int_t pdgCode = mcVtxHF->GetPdgCode();
361 cosThetaStar = d0tokpi->CosThetaStarD0();
362 pTpi = d0tokpi->PtProng(0);
363 pTK = d0tokpi->PtProng(1);
364 d0pi = d0tokpi->Getd0Prong(0);
365 d0K = d0tokpi->Getd0Prong(1);
368 cosThetaStar = d0tokpi->CosThetaStarD0bar();
369 pTpi = d0tokpi->PtProng(1);
370 pTK = d0tokpi->PtProng(0);
371 d0pi = d0tokpi->Getd0Prong(1);
372 d0K = d0tokpi->Getd0Prong(0);
375 Double_t cT = d0tokpi->CtD0();
377 if (!fFillFromGenerated){
378 // ...either with reconstructed values....
379 containerInput[0] = pt;
380 containerInput[1] = rapidity;
381 containerInput[2] = cosThetaStar;
382 containerInput[3] = pTpi;
383 containerInput[4] = pTK;
384 containerInput[5] = cT*1.E4; // in micron
385 containerInput[6] = dca*1.E4; // in micron
386 containerInput[7] = d0pi*1.E4; // in micron
387 containerInput[8] = d0K*1.E4; // in micron
388 containerInput[9] = d0xd0*1.E8; // in micron^2
389 containerInput[10] = cosPointingAngle; // in micron
390 containerInput[11] = phi;
393 // ... or with generated values
394 Double_t vectorMC[7] = {9999.,9999.,9999.,9999.,9999.,9999.,9999.};
395 if (GetGeneratedValuesFromMCParticle(mcVtxHF, mcArray, vectorMC)){
396 containerInput[0] = vectorMC[0];
397 containerInput[1] = vectorMC[1] ;
398 containerInput[2] = vectorMC[2] ;
399 containerInput[3] = vectorMC[3] ;
400 containerInput[4] = vectorMC[4] ;
401 containerInput[5] = vectorMC[5] ; // in micron
402 containerInput[6] = 0.; // dummy value, meaningless in MC, in micron
403 containerInput[7] = 0.; // dummy value, meaningless in MC, in micron
404 containerInput[8] = 0.; // dummy value, meaningless in MC, in micron
405 containerInput[9] = 100000.; // dummy value, meaningless in MC, in micron^2
406 containerInput[10] = 1.01; // dummy value, meaningless in MC
407 containerInput[11] = vectorMC[6];
410 AliDebug(3,"Problems in filling the container");
414 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]));
416 fCFManager->GetParticleContainer()->Fill(containerInput,kStepReconstructed) ;
419 Bool_t acceptanceProng0 = (TMath::Abs(d0tokpi->EtaProng(0))< 0.9 && d0tokpi->PtProng(0) > 0.1);
420 Bool_t acceptanceProng1 = (TMath::Abs(d0tokpi->EtaProng(1))< 0.9 && d0tokpi->PtProng(1) > 0.1);
421 if (acceptanceProng0 && acceptanceProng1) {
422 AliDebug(2,"D0 reco daughters in acceptance");
423 fCFManager->GetParticleContainer()->Fill(containerInput,kStepRecoAcceptance) ;
428 Double_t fill[4]; //fill response matrix
430 // dimensions 0&1 : pt,eta (Rec)
435 // dimensions 2&3 : pt,eta (MC)
437 fill[2] = mcVtxHF->Pt();
438 fill[3] = mcVtxHF->Y();
440 fCorrelation->Fill(fill);
444 // cut on the min n. of clusters in ITS
446 for(Int_t l=0;l<6;l++) if(TESTBIT(d0tokpi->GetITSClusterMap(),l)) ncls0++;
447 AliDebug(2, Form("n clusters = %d", ncls0));
448 if (ncls0 >= fMinITSClusters){
449 fCFManager->GetParticleContainer()->Fill(containerInput,kStepRecoITSClusters) ;
450 icountRecoITSClusters++;
451 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));
454 Double_t cuts[6] = {9999999., 1.1, 0., 9999999., 9999999., 0.};
463 else if (pt > 1 && pt <= 2){
471 else if (pt > 2 && pt <= 3){
479 else if (pt > 3 && pt <= 5){
495 if (dca*1E4 < cuts[0]
496 && TMath::Abs(cosThetaStar) < cuts[1]
499 && TMath::Abs(d0pi*1E4) < cuts[3]
500 && TMath::Abs(d0K*1E4) < cuts[3]
501 && d0xd0*1E8 < cuts[4]
502 && cosPointingAngle > cuts[5]
505 AliDebug(2,"Particle passed PPR cuts");
506 fCFManager->GetParticleContainer()->Fill(containerInput,kStepRecoPPR) ;
509 if(!fAcceptanceUnf){ // unfolding
511 Double_t fill[4]; //fill response matrix
513 // dimensions 0&1 : pt,eta (Rec)
518 // dimensions 2&3 : pt,eta (MC)
520 fill[2] = mcVtxHF->Pt();
521 fill[3] = mcVtxHF->Y();
523 fCorrelation->Fill(fill);
528 AliDebug(2,"Particle skipped due to PPR cuts");
529 if (dca*1E4 > cuts[0]){
530 AliDebug(2,"Problems with dca");
532 if ( TMath::Abs(cosThetaStar) > cuts[1]){
533 AliDebug(2,"Problems with cosThetaStar");
536 AliDebug(2,"Problems with pTpi");
539 AliDebug(2,"Problems with pTK");
541 if (TMath::Abs(d0pi*1E4) > cuts[3]){
542 AliDebug(2,"Problems with d0pi");
544 if (TMath::Abs(d0K*1E4) > cuts[3]){
545 AliDebug(2,"Problems with d0K");
547 if (d0xd0*1E8 > cuts[4]){
548 AliDebug(2,"Problems with d0xd0");
550 if (cosPointingAngle < cuts[5]){
551 AliDebug(2,"Problems with cosPointingAngle");
557 if(unsetvtx) d0tokpi->UnsetOwnPrimaryVtx();
558 } // end loop on D0->Kpi
560 AliDebug(2, Form("Found %i Reco particles that are D0!!",icountReco));
562 fCountReco+= icountReco;
563 fCountRecoAcc+= icountRecoAcc;
564 fCountRecoITSClusters+= icountRecoITSClusters;
565 fCountRecoPPR+= icountRecoPPR;
567 fHistEventsProcessed->Fill(0);
568 /* PostData(0) is taken care of by AliAnalysisTaskSE */
569 PostData(1,fHistEventsProcessed) ;
570 PostData(2,fCFManager->GetParticleContainer()) ;
571 PostData(3,fCorrelation) ;
575 //___________________________________________________________________________
576 void AliCFHeavyFlavourTaskMultiVarMultiStep::Terminate(Option_t*)
578 // The Terminate() function is the last function to be called during
579 // a query. It always runs on the client, it can be used to present
580 // the results graphically or save the results to file.
582 AliAnalysisTaskSE::Terminate();
584 AliInfo(Form("Found %i MC particles that are D0 in MC, in %d events",fCountMC,fEvents));
585 AliInfo(Form("Found %i MC particles that are D0 in MC and satisfy Acc cuts, in %d events",fCountAcc,fEvents));
586 AliInfo(Form("Found %i reco D0 that are decaying in K+pi, in %d events",fCountReco,fEvents));
587 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));
588 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));
589 AliInfo(Form("Among the above, found %i reco D0 that are decaying in K+pi and satisfy PPR cuts, in %d events",fCountRecoPPR,fEvents));
591 // draw some example plots....
593 AliCFContainer *cont= dynamic_cast<AliCFContainer*> (GetOutputData(2));
595 printf("CONTAINER NOT FOUND\n");
598 // projecting the containers to obtain histograms
599 // first argument = variable, second argument = step
602 TH1D* h00 = cont->ShowProjection(0,0) ; // pt
603 TH1D* h10 = cont->ShowProjection(1,0) ; // rapidity
604 TH1D* h20 = cont->ShowProjection(2,0) ; // cosThetaStar
605 TH1D* h30 = cont->ShowProjection(3,0) ; // pTpi
606 TH1D* h40 = cont->ShowProjection(4,0) ; // pTK
607 TH1D* h50 = cont->ShowProjection(5,0) ; // cT
608 TH1D* h60 = cont->ShowProjection(6,0) ; // dca
609 TH1D* h70 = cont->ShowProjection(7,0) ; // d0pi
610 TH1D* h80 = cont->ShowProjection(8,0) ; // d0K
611 TH1D* h90 = cont->ShowProjection(9,0) ; // d0xd0
612 TH1D* h100 = cont->ShowProjection(10,0) ; // cosPointingAngle
613 TH1D* h110 = cont->ShowProjection(11,0) ; // phi
615 // MC-Acceptance level
616 TH1D* h01 = cont->ShowProjection(0,1) ; // pt
617 TH1D* h11 = cont->ShowProjection(1,1) ; // rapidity
618 TH1D* h21 = cont->ShowProjection(2,1) ; // cosThetaStar
619 TH1D* h31 = cont->ShowProjection(3,1) ; // pTpi
620 TH1D* h41 = cont->ShowProjection(4,1) ; // pTK
621 TH1D* h51 = cont->ShowProjection(5,1) ; // cT
622 TH1D* h61 = cont->ShowProjection(6,1) ; // dca
623 TH1D* h71 = cont->ShowProjection(7,1) ; // d0pi
624 TH1D* h81 = cont->ShowProjection(8,1) ; // d0K
625 TH1D* h91 = cont->ShowProjection(9,1) ; // d0xd0
626 TH1D* h101 = cont->ShowProjection(10,1) ; // cosPointingAngle
627 TH1D* h111 = cont->ShowProjection(11,1) ; // phi
630 TH1D* h02 = cont->ShowProjection(0,2) ; // pt
631 TH1D* h12 = cont->ShowProjection(1,2) ; // rapidity
632 TH1D* h22 = cont->ShowProjection(2,2) ; // cosThetaStar
633 TH1D* h32 = cont->ShowProjection(3,2) ; // pTpi
634 TH1D* h42 = cont->ShowProjection(4,2) ; // pTK
635 TH1D* h52 = cont->ShowProjection(5,2) ; // cT
636 TH1D* h62 = cont->ShowProjection(6,2) ; // dca
637 TH1D* h72 = cont->ShowProjection(7,2) ; // d0pi
638 TH1D* h82 = cont->ShowProjection(8,2) ; // d0K
639 TH1D* h92 = cont->ShowProjection(9,2) ; // d0xd0
640 TH1D* h102 = cont->ShowProjection(10,2) ; // cosPointingAngle
641 TH1D* h112 = cont->ShowProjection(11,2) ; // phi
643 h00->SetTitle("pT_D0 (GeV/c)");
644 h10->SetTitle("rapidity");
645 h20->SetTitle("cosThetaStar");
646 h30->SetTitle("pT_pi (GeV/c)");
647 h40->SetTitle("pT_K (Gev/c)");
648 h50->SetTitle("cT (#mum)");
649 h60->SetTitle("dca (#mum)");
650 h70->SetTitle("d0_pi (#mum)");
651 h80->SetTitle("d0_K (#mum)");
652 h90->SetTitle("d0xd0 (#mum^2)");
653 h100->SetTitle("cosPointingAngle");
654 h100->SetTitle("phi (rad)");
656 h00->GetXaxis()->SetTitle("pT_D0 (GeV/c)");
657 h10->GetXaxis()->SetTitle("rapidity");
658 h20->GetXaxis()->SetTitle("cosThetaStar");
659 h30->GetXaxis()->SetTitle("pT_pi (GeV/c)");
660 h40->GetXaxis()->SetTitle("pT_K (Gev/c)");
661 h50->GetXaxis()->SetTitle("cT (#mum)");
662 h60->GetXaxis()->SetTitle("dca (#mum)");
663 h70->GetXaxis()->SetTitle("d0_pi (#mum)");
664 h80->GetXaxis()->SetTitle("d0_K (#mum)");
665 h90->GetXaxis()->SetTitle("d0xd0 (#mum^2)");
666 h100->GetXaxis()->SetTitle("cosPointingAngle");
667 h110->GetXaxis()->SetTitle("phi (rad)");
669 h01->SetTitle("pT_D0 (GeV/c)");
670 h11->SetTitle("rapidity");
671 h21->SetTitle("cosThetaStar");
672 h31->SetTitle("pT_pi (GeV/c)");
673 h41->SetTitle("pT_K (Gev/c)");
674 h51->SetTitle("cT (#mum)");
675 h61->SetTitle("dca (#mum)");
676 h71->SetTitle("d0_pi (#mum)");
677 h81->SetTitle("d0_K (#mum)");
678 h91->SetTitle("d0xd0 (#mum^2)");
679 h101->SetTitle("cosPointingAngle");
680 h111->GetXaxis()->SetTitle("phi (rad)");
682 h01->GetXaxis()->SetTitle("pT_D0 (GeV/c)");
683 h11->GetXaxis()->SetTitle("rapidity");
684 h21->GetXaxis()->SetTitle("cosThetaStar");
685 h31->GetXaxis()->SetTitle("pT_pi (GeV/c)");
686 h41->GetXaxis()->SetTitle("pT_K (Gev/c)");
687 h51->GetXaxis()->SetTitle("cT (#mum)");
688 h61->GetXaxis()->SetTitle("dca (#mum)");
689 h71->GetXaxis()->SetTitle("d0_pi (#mum)");
690 h81->GetXaxis()->SetTitle("d0_K (#mum)");
691 h91->GetXaxis()->SetTitle("d0xd0 (#mum^2)");
692 h101->GetXaxis()->SetTitle("cosPointingAngle");
693 h111->GetXaxis()->SetTitle("phi (rad)");
695 h02->SetTitle("pT_D0 (GeV/c)");
696 h12->SetTitle("rapidity");
697 h22->SetTitle("cosThetaStar");
698 h32->SetTitle("pT_pi (GeV/c)");
699 h42->SetTitle("pT_K (Gev/c)");
700 h52->SetTitle("cT (#mum)");
701 h62->SetTitle("dca (#mum)");
702 h72->SetTitle("d0_pi (#mum)");
703 h82->SetTitle("d0_K (#mum)");
704 h92->SetTitle("d0xd0 (#mum^2)");
705 h102->SetTitle("cosPointingAngle");
706 h112->GetXaxis()->SetTitle("phi (rad)");
708 h02->GetXaxis()->SetTitle("pT_D0 (GeV/c)");
709 h12->GetXaxis()->SetTitle("rapidity");
710 h22->GetXaxis()->SetTitle("cosThetaStar");
711 h32->GetXaxis()->SetTitle("pT_pi (GeV/c)");
712 h42->GetXaxis()->SetTitle("pT_K (Gev/c)");
713 h52->GetXaxis()->SetTitle("cT (#mum)");
714 h62->GetXaxis()->SetTitle("dca (#mum)");
715 h72->GetXaxis()->SetTitle("d0_pi (#mum)");
716 h82->GetXaxis()->SetTitle("d0_K (#mum)");
717 h92->GetXaxis()->SetTitle("d0xd0 (#mum^2)");
718 h102->GetXaxis()->SetTitle("cosPointingAngle");
719 h112->GetXaxis()->SetTitle("phi (rad)");
721 Double_t max0 = h00->GetMaximum();
722 Double_t max1 = h10->GetMaximum();
723 Double_t max2 = h20->GetMaximum();
724 Double_t max3 = h30->GetMaximum();
725 Double_t max4 = h40->GetMaximum();
726 Double_t max5 = h50->GetMaximum();
727 Double_t max6 = h60->GetMaximum();
728 Double_t max7 = h70->GetMaximum();
729 Double_t max8 = h80->GetMaximum();
730 Double_t max9 = h90->GetMaximum();
731 Double_t max10 = h100->GetMaximum();
732 Double_t max11 = h110->GetMaximum();
734 h00->GetYaxis()->SetRangeUser(0,max0*1.2);
735 h10->GetYaxis()->SetRangeUser(0,max1*1.2);
736 h20->GetYaxis()->SetRangeUser(0,max2*1.2);
737 h30->GetYaxis()->SetRangeUser(0,max3*1.2);
738 h40->GetYaxis()->SetRangeUser(0,max4*1.2);
739 h50->GetYaxis()->SetRangeUser(0,max5*1.2);
740 h60->GetYaxis()->SetRangeUser(0,max6*1.2);
741 h70->GetYaxis()->SetRangeUser(0,max7*1.2);
742 h80->GetYaxis()->SetRangeUser(0,max8*1.2);
743 h90->GetYaxis()->SetRangeUser(0,max9*1.2);
744 h100->GetYaxis()->SetRangeUser(0,max10*1.2);
745 h110->GetYaxis()->SetRangeUser(0,max11*1.2);
747 h01->GetYaxis()->SetRangeUser(0,max0*1.2);
748 h11->GetYaxis()->SetRangeUser(0,max1*1.2);
749 h21->GetYaxis()->SetRangeUser(0,max2*1.2);
750 h31->GetYaxis()->SetRangeUser(0,max3*1.2);
751 h41->GetYaxis()->SetRangeUser(0,max4*1.2);
752 h51->GetYaxis()->SetRangeUser(0,max5*1.2);
753 h61->GetYaxis()->SetRangeUser(0,max6*1.2);
754 h71->GetYaxis()->SetRangeUser(0,max7*1.2);
755 h81->GetYaxis()->SetRangeUser(0,max8*1.2);
756 h91->GetYaxis()->SetRangeUser(0,max9*1.2);
757 h101->GetYaxis()->SetRangeUser(0,max10*1.2);
758 h111->GetYaxis()->SetRangeUser(0,max11*1.2);
760 h00->SetMarkerStyle(20);
761 h10->SetMarkerStyle(24);
762 h20->SetMarkerStyle(21);
763 h30->SetMarkerStyle(25);
764 h40->SetMarkerStyle(27);
765 h50->SetMarkerStyle(28);
766 h60->SetMarkerStyle(20);
767 h70->SetMarkerStyle(24);
768 h80->SetMarkerStyle(21);
769 h90->SetMarkerStyle(25);
770 h100->SetMarkerStyle(27);
771 h110->SetMarkerStyle(28);
773 h00->SetMarkerColor(2);
774 h10->SetMarkerColor(2);
775 h20->SetMarkerColor(2);
776 h30->SetMarkerColor(2);
777 h40->SetMarkerColor(2);
778 h50->SetMarkerColor(2);
779 h60->SetMarkerColor(2);
780 h70->SetMarkerColor(2);
781 h80->SetMarkerColor(2);
782 h90->SetMarkerColor(2);
783 h100->SetMarkerColor(2);
784 h110->SetMarkerColor(2);
786 h01->SetMarkerStyle(20) ;
787 h11->SetMarkerStyle(24) ;
788 h21->SetMarkerStyle(21) ;
789 h31->SetMarkerStyle(25) ;
790 h41->SetMarkerStyle(27) ;
791 h51->SetMarkerStyle(28) ;
792 h61->SetMarkerStyle(20);
793 h71->SetMarkerStyle(24);
794 h81->SetMarkerStyle(21);
795 h91->SetMarkerStyle(25);
796 h101->SetMarkerStyle(27);
797 h111->SetMarkerStyle(28);
799 h01->SetMarkerColor(8);
800 h11->SetMarkerColor(8);
801 h21->SetMarkerColor(8);
802 h31->SetMarkerColor(8);
803 h41->SetMarkerColor(8);
804 h51->SetMarkerColor(8);
805 h61->SetMarkerColor(8);
806 h71->SetMarkerColor(8);
807 h81->SetMarkerColor(8);
808 h91->SetMarkerColor(8);
809 h101->SetMarkerColor(8);
810 h111->SetMarkerColor(8);
812 h02->SetMarkerStyle(20) ;
813 h12->SetMarkerStyle(24) ;
814 h22->SetMarkerStyle(21) ;
815 h32->SetMarkerStyle(25) ;
816 h42->SetMarkerStyle(27) ;
817 h52->SetMarkerStyle(28) ;
818 h62->SetMarkerStyle(20);
819 h72->SetMarkerStyle(24);
820 h82->SetMarkerStyle(21);
821 h92->SetMarkerStyle(25);
822 h102->SetMarkerStyle(27);
823 h112->SetMarkerStyle(28);
825 h02->SetMarkerColor(4);
826 h12->SetMarkerColor(4);
827 h22->SetMarkerColor(4);
828 h32->SetMarkerColor(4);
829 h42->SetMarkerColor(4);
830 h52->SetMarkerColor(4);
831 h62->SetMarkerColor(4);
832 h72->SetMarkerColor(4);
833 h82->SetMarkerColor(4);
834 h92->SetMarkerColor(4);
835 h102->SetMarkerColor(4);
836 h112->SetMarkerColor(4);
838 gStyle->SetCanvasColor(0);
839 gStyle->SetFrameFillColor(0);
840 gStyle->SetTitleFillColor(0);
841 gStyle->SetStatColor(0);
843 // drawing in 2 separate canvas for a matter of clearity
844 TCanvas * c1 =new TCanvas("c1","pT, rapidiy, cosThetaStar",1100,1600);
876 TCanvas * c2 =new TCanvas("c2","pTpi, pTK, cT",1100,1600);
907 TCanvas * c3 =new TCanvas("c3","dca, d0pi, d0K",1100,1600);
938 TCanvas * c4 =new TCanvas("c4","d0xd0, cosPointingAngle, phi",1100,1600);
969 THnSparseD* hcorr = dynamic_cast<THnSparseD*> (GetOutputData(3));
971 TH2D* corr1 =hcorr->Projection(0,2);
972 TH2D* corr2 = hcorr->Projection(1,3);
974 TCanvas * c7 =new TCanvas("c7","",800,400);
982 TFile* file_projection = new TFile("file_projection.root","RECREATE");
986 h00->Write("pT_D0_step0");
987 h10->Write("rapidity_step0");
988 h20->Write("cosThetaStar_step0");
989 h30->Write("pT_pi_step0");
990 h40->Write("pT_K_step0");
991 h50->Write("cT_step0");
992 h60->Write("dca_step0");
993 h70->Write("d0_pi_step0");
994 h80->Write("d0_K_step0");
995 h90->Write("d0xd0_step0");
996 h100->Write("cosPointingAngle_step0");
997 h110->Write("phi_step0");
999 h01->Write("pT_D0_step1");
1000 h11->Write("rapidity_step1");
1001 h21->Write("cosThetaStar_step1");
1002 h31->Write("pT_pi_step1");
1003 h41->Write("pT_K_step1");
1004 h51->Write("cT_step1");
1005 h61->Write("dca_step1");
1006 h71->Write("d0_pi_step1");
1007 h81->Write("d0_K_step1");
1008 h91->Write("d0xd0_step1");
1009 h101->Write("cosPointingAngle_step1");
1010 h111->Write("phi_step1");
1012 h02->Write("pT_D0_step2");
1013 h12->Write("rapidity_step2");
1014 h22->Write("cosThetaStar_step2");
1015 h32->Write("pT_pi_step2");
1016 h42->Write("pT_K_step2");
1017 h52->Write("cT_step2");
1018 h62->Write("dca_step2");
1019 h72->Write("d0_pi_step2");
1020 h80->Write("d0_K_step2");
1021 h92->Write("d0xd0_step2");
1022 h102->Write("cosPointingAngle_step2");
1023 h112->Write("phi_step2");
1025 file_projection->Close();
1030 c1->SaveAs("Plots/pT_rapidity_cosThetaStar.eps");
1031 c2->SaveAs("Plots/pTpi_pTK_cT.eps");
1032 c3->SaveAs("Plots/dca_d0pi_d0TK.eps");
1033 c4->SaveAs("Plots/d0xd0_cosPointingAngle.eps");
1035 c1->SaveAs("Plots/pT_rapidity_cosThetaStar.gif");
1036 c2->SaveAs("Plots/pTpi_pTK_cT.gif");
1037 c3->SaveAs("Plots/dca_d0pi_d0TK.gif");
1038 c4->SaveAs("Plots/d0xd0_cosPointingAngle.gif");
1042 //___________________________________________________________________________
1043 void AliCFHeavyFlavourTaskMultiVarMultiStep::UserCreateOutputObjects() {
1044 //HERE ONE CAN CREATE OUTPUT OBJECTS, IN PARTICULAR IF THE OBJECT PARAMETERS DON'T NEED
1045 //TO BE SET BEFORE THE EXECUTION OF THE TASK
1047 Info("UserCreateOutputObjects","CreateOutputObjects of task %s\n", GetName());
1051 fHistEventsProcessed = new TH1I("fHistEventsProcessed","",1,0,1) ;
1054 //___________________________________________________________________________
1055 Double_t AliCFHeavyFlavourTaskMultiVarMultiStep::CosThetaStar(AliAODMCParticle* mcPart, AliAODMCParticle* mcPartDaughter0, AliAODMCParticle* mcPartDaughter1) const {
1058 // to calculate cos(ThetaStar) for generated particle
1059 // using the K, since mcPartDaughter0 and mcPartDaughter1 always correspond to K and pi respectively
1060 // (see where the function is called)
1063 Int_t pdgvtx = mcPart->GetPdgCode();
1064 /* if (pdgvtx > 0) { // setting as the first daughter always the kaon, to be used to calculate cos(ThetaStar)
1065 Int_t pdgprong0 = TMath::Abs(mcPartDaughter0->GetPdgCode());
1066 Int_t pdgprong1 = TMath::Abs(mcPartDaughter1->GetPdgCode());
1067 AliInfo(Form("D0, with pdgprong0 = %d, pdgprong1 = %d",pdgprong0,pdgprong1));
1068 AliDebug(2,"This is a D0");
1069 AliAODMCParticle* mcPartdummy = mcPartDaughter0;
1070 mcPartDaughter0 = mcPartDaughter1;
1071 mcPartDaughter1 = mcPartdummy;
1077 Int_t pdgprong0 = TMath::Abs(mcPartDaughter0->GetPdgCode());
1078 Int_t pdgprong1 = TMath::Abs(mcPartDaughter1->GetPdgCode());
1079 if (pdgvtx > 0) { // setting as the first daughter always the kaon, to be used to calculate cos(ThetaStar)
1083 AliDebug(2,"D0bar");
1085 if (pdgprong0 == 211){
1086 AliDebug(2,Form("pdgprong0 = %d, pdgprong1 = %d, switching...",pdgprong0,pdgprong1));
1087 AliAODMCParticle* mcPartdummy = mcPartDaughter0;
1088 mcPartDaughter0 = mcPartDaughter1;
1089 mcPartDaughter1 = mcPartdummy;
1090 pdgprong0 = TMath::Abs(mcPartDaughter0->GetPdgCode());
1091 pdgprong1 = TMath::Abs(mcPartDaughter1->GetPdgCode());
1094 AliDebug(2,Form("After checking, pdgprong0 = %d, pdgprong1 = %d",pdgprong0,pdgprong1));
1095 Double_t massvtx = TDatabasePDG::Instance()->GetParticle(TMath::Abs(pdgvtx))->Mass();
1097 massp[0] = TDatabasePDG::Instance()->GetParticle(pdgprong0)->Mass();
1098 massp[1] = TDatabasePDG::Instance()->GetParticle(pdgprong1)->Mass();
1100 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);
1102 Double_t px = mcPartDaughter0->Px()+mcPartDaughter1->Px();
1103 Double_t py = mcPartDaughter0->Py()+mcPartDaughter1->Py();
1104 Double_t pz = mcPartDaughter0->Pz()+mcPartDaughter1->Pz();
1105 Double_t p = TMath::Sqrt(px*px+py*py+pz*pz);
1106 Double_t e = TMath::Sqrt(massvtx*massvtx+p*p);
1107 Double_t beta = p/e;
1108 Double_t gamma = e/massvtx;
1109 TVector3 mom(mcPartDaughter0->Px(),mcPartDaughter0->Py(),mcPartDaughter0->Pz());
1110 TVector3 momTot(mcPartDaughter0->Px()+mcPartDaughter1->Px(),mcPartDaughter0->Py()+mcPartDaughter1->Py(),mcPartDaughter0->Pz()+mcPartDaughter1->Pz());
1112 Double_t qlprong = mom.Dot(momTot)/momTot.Mag(); // analog to AliAODRecoDecay::QlProng(0)
1114 AliDebug(2,Form("pStar = %f, beta = %f, gamma = %f, qlprong = %f, massp[0] = %f", pStar, beta, gamma, qlprong, massp[0]));
1115 Double_t cts = (qlprong/gamma-beta*TMath::Sqrt(pStar*pStar+massp[0]*massp[0]))/pStar;
1116 AliDebug(2,Form("cts = %f", cts));
1119 //___________________________________________________________________________
1120 Double_t AliCFHeavyFlavourTaskMultiVarMultiStep::CT(AliAODMCParticle* mcPart, AliAODMCParticle* mcPartDaughter0, AliAODMCParticle* mcPartDaughter1) const {
1123 // to calculate cT for generated particle
1126 Double_t xmcPart[3] = {0,0,0};
1127 Double_t xdaughter0[3] = {0,0,0};
1128 Double_t xdaughter1[3] = {0,0,0};
1129 mcPart->XvYvZv(xmcPart); // cm
1130 mcPartDaughter0->XvYvZv(xdaughter0); // cm
1131 mcPartDaughter1->XvYvZv(xdaughter1); //cm
1132 Double_t prodVtxD0 = TMath::Sqrt(xmcPart[0]*xmcPart[0]+
1133 xmcPart[1]*xmcPart[1]+
1134 xmcPart[2]*xmcPart[2]);
1135 Double_t prodVtxDaughter0 = TMath::Sqrt(xdaughter0[0]*xdaughter0[0]+
1136 xdaughter0[1]*xdaughter0[1]+
1137 xdaughter0[2]*xdaughter0[2]);
1138 Double_t prodVtxDaughter1 = TMath::Sqrt(xdaughter1[0]*xdaughter1[0]+
1139 xdaughter1[1]*xdaughter1[1]+
1140 xdaughter1[2]*xdaughter1[2]);
1142 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));
1143 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));
1144 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));
1146 Double_t cT0 = TMath::Sqrt((xdaughter0[0]-xmcPart[0])*(xdaughter0[0]-xmcPart[0])+
1147 (xdaughter0[1]-xmcPart[1])*(xdaughter0[1]-xmcPart[1])+
1148 (xdaughter0[2]-xmcPart[2])*(xdaughter0[2]-xmcPart[2]));
1150 Double_t cT1 = TMath::Sqrt((xdaughter1[0]-xmcPart[0])*(xdaughter1[0]-xmcPart[0])+
1151 (xdaughter1[1]-xmcPart[1])*(xdaughter1[1]-xmcPart[1])+
1152 (xdaughter1[2]-xmcPart[2])*(xdaughter1[2]-xmcPart[2]));
1154 if ((cT0 - cT1)>1E-5) {
1155 AliWarning(Form("cT from daughter 0 (%f) different from cT from daughter 1 (%f)! Using cT from daughter 0, but PLEASE, CHECK....",cT0,cT1));
1158 // calculating cT from cT0
1160 Double_t mass = TDatabasePDG::Instance()->GetParticle(mcPart->GetPdgCode())->Mass(); // mcPart->GetPdgCode() should return +/- 421 for the D0/D0bar
1161 Double_t p = mcPart-> P();
1162 Double_t cT = cT0*mass/p;
1163 AliDebug(2, Form("cT from daughter 0 = %f (micron)", cT0*1E4));
1164 AliDebug(2, Form("cT from daughter 1 = %f (micron)", cT1*1E4));
1165 AliDebug(2, Form("cT (with mass = %f and p = %f) = %f (micron)", mass, p, cT*1E4));
1168 //________________________________________________________________________________
1169 Bool_t AliCFHeavyFlavourTaskMultiVarMultiStep::GetGeneratedValuesFromMCParticle(AliAODMCParticle* mcPart, TClonesArray* mcArray, Double_t* vectorMC) const {
1172 // collecting all the necessary info (pt, y, cosThetaStar, ptPi, ptKa, cT) from MC particle
1175 Bool_t isOk = kFALSE;
1177 // check whether the D0 decays in pi+K
1178 // to be added!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1179 // could use a cut in the CF, but not clear how to define a TDecayChannel
1180 // implemented for the time being as a cut on the number of daughters - see later when
1181 // getting the daughters
1183 // getting the daughters
1184 Int_t daughter0 = mcPart->GetDaughter(0);
1185 Int_t daughter1 = mcPart->GetDaughter(1);
1186 AliDebug(2, Form("daughter0 = %d and daughter1 = %d",daughter0,daughter1));
1187 if (daughter0 == 0 || daughter1 == 0) {
1188 AliDebug(2, "Error! the D0 MC doesn't have correct daughters!!");
1191 if (TMath::Abs(daughter1 - daughter0) != 1) {
1192 AliDebug(2, "The D0 MC doesn't come from a 2-prong decay, skipping!!");
1195 AliAODMCParticle* mcPartDaughter0 = dynamic_cast<AliAODMCParticle*>(mcArray->At(daughter0));
1196 AliAODMCParticle* mcPartDaughter1 = dynamic_cast<AliAODMCParticle*>(mcArray->At(daughter1));
1197 if (!mcPartDaughter0 || !mcPartDaughter1) {
1198 AliWarning("At least one Daughter Particle not found in tree, skipping");
1201 if (!(TMath::Abs(mcPartDaughter0->GetPdgCode())==321 &&
1202 TMath::Abs(mcPartDaughter1->GetPdgCode())==211) &&
1203 !(TMath::Abs(mcPartDaughter0->GetPdgCode())==211 &&
1204 TMath::Abs(mcPartDaughter1->GetPdgCode())==321)) {
1205 AliDebug(2, "The D0 MC doesn't come from a Kpi decay, skipping!!");
1209 Double_t vtx1[3] = {0,0,0}; // primary vertex
1210 Double_t vtx2daughter0[3] = {0,0,0}; // secondary vertex from daughter 0
1211 Double_t vtx2daughter1[3] = {0,0,0}; // secondary vertex from daughter 1
1212 mcPart->XvYvZv(vtx1); // cm
1213 // getting vertex from daughters
1214 mcPartDaughter0->XvYvZv(vtx2daughter0); // cm
1215 mcPartDaughter1->XvYvZv(vtx2daughter1); //cm
1216 if (vtx2daughter0[0] != vtx2daughter1[0] && vtx2daughter0[1] != vtx2daughter1[1] && vtx2daughter0[2] != vtx2daughter1[2]) {
1217 AliError("Daughters have different secondary vertex, skipping the track");
1222 // always instantiate the AliAODRecoDecay with the positive daughter first, the negative second
1223 AliAODMCParticle* positiveDaugh = mcPartDaughter0;
1224 AliAODMCParticle* negativeDaugh = mcPartDaughter1;
1225 if (mcPartDaughter0->GetPdgCode()<0 && mcPartDaughter1->GetPdgCode()>0){
1226 // inverting in case the positive daughter is the second one
1227 positiveDaugh = mcPartDaughter1;
1228 negativeDaugh = mcPartDaughter0;
1230 // getting the momentum from the daughters
1231 Double_t px[2] = {positiveDaugh->Px(), negativeDaugh->Px()};
1232 Double_t py[2] = {positiveDaugh->Py(), negativeDaugh->Py()};
1233 Double_t pz[2] = {positiveDaugh->Pz(), negativeDaugh->Pz()};
1235 Double_t d0[2] = {0.,0.};
1237 AliAODRecoDecayHF* decay = new AliAODRecoDecayHF(vtx1,vtx2daughter0,nprongs,charge,px,py,pz,d0);
1239 Double_t cosThetaStar = 0.;
1240 Double_t cosThetaStarD0 = 0.;
1241 Double_t cosThetaStarD0bar = 0.;
1242 cosThetaStarD0 = decay->CosThetaStar(1,421,211,321);
1243 cosThetaStarD0bar = decay->CosThetaStar(0,421,321,211);
1244 if (mcPart->GetPdgCode() == 421){ // D0
1245 AliDebug(3, Form("D0, with pdgprong0 = %d, pdgprong1 = %d",mcPartDaughter0->GetPdgCode(),mcPartDaughter1->GetPdgCode()));
1246 cosThetaStar = cosThetaStarD0;
1248 else if (mcPart->GetPdgCode() == -421){ // D0bar{
1249 AliDebug(3, Form("D0bar, with pdgprong0 = %d, pdgprong1 = %d",mcPartDaughter0->GetPdgCode(),mcPartDaughter1->GetPdgCode()));
1250 cosThetaStar = cosThetaStarD0bar;
1253 AliWarning("There are problems!! particle was expected to be either a D0 or a D0bar, check...");
1256 if (cosThetaStar < -1 || cosThetaStar > 1) {
1257 AliWarning("Invalid value for cosine Theta star, returning");
1261 // calculate cos(Theta*) according to the method implemented herein
1263 Double_t cts = 9999.;
1264 cts = CosThetaStar(mcPart, mcPartDaughter0, mcPartDaughter1);
1265 if (cts < -1 || cts > 1) {
1266 AliWarning("Invalid value for cosine Theta star from AliCFHeavyFlavourTaskMultiVarMultiStep method");
1268 if (TMath::Abs(cts - cosThetaStar)>0.001) {
1269 AliError(Form("cosThetaStar automatically calculated different from that manually calculated!!! cosThetaStar = %f, cosThetaStar = %f", cosThetaStar,cts));
1272 Double_t cT = decay->Ct(421);
1274 // calculate cT from the method implemented herein
1276 cT1 = CT(mcPart, mcPartDaughter0, mcPartDaughter1);
1278 if (TMath::Abs(cT1 - cT)>0.001) {
1279 AliError(Form("cT automatically calculated different from that manually calculated!!! cT = %f, cT1 = %f",cT,cT1));
1282 // get the pT of the daughters
1287 if (TMath::Abs(mcPartDaughter0->GetPdgCode()) == 211) {
1288 pTpi = mcPartDaughter0->Pt();
1289 pTK = mcPartDaughter1->Pt();
1292 pTpi = mcPartDaughter1->Pt();
1293 pTK = mcPartDaughter0->Pt();
1296 vectorMC[0] = mcPart->Pt();
1297 vectorMC[1] = mcPart->Y() ;
1298 vectorMC[2] = cosThetaStar ;
1299 vectorMC[3] = pTpi ;
1301 vectorMC[5] = cT*1.E4 ; // in micron
1302 vectorMC[6] = mcPart->Phi() ;
1306 //_________________________________________________________________________________________________
1307 Int_t AliCFHeavyFlavourTaskMultiVarMultiStep::CheckOrigin(AliAODMCParticle* mcPart, TClonesArray* mcArray)const{
1310 // checking whether the very mother of the D0 is a charm or a bottom quark
1313 Int_t pdgGranma = 0;
1315 mother = mcPart->GetMother();
1319 AliDebug(2,Form("mother at step %d = %d", istep, mother));
1320 AliAODMCParticle* mcGranma = dynamic_cast<AliAODMCParticle*>(mcArray->At(mother));
1321 pdgGranma = mcGranma->GetPdgCode();
1322 AliDebug(2,Form("Pdg mother at step %d = %d", istep, pdgGranma));
1323 Int_t abspdgGranma = TMath::Abs(pdgGranma);
1324 if ((abspdgGranma > 500 && abspdgGranma < 600) || (abspdgGranma > 5000 && abspdgGranma < 6000)) {
1327 mother = mcGranma->GetMother();