1 /**************************************************************************
2 * Copyright(c) 1998-2008, 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 **************************************************************************/
18 /////////////////////////////////////////////////////////////
20 // AliAnalysisTaskSESignificane to calculate effects on
21 // significance of D mesons cut
22 // Authors: G. Ortona, ortona@to.infn.it
23 // F. Prino, prino@to.infn.it
24 // Renu Bala, bala@to.infn.it
25 // Chiara Bianchin, cbianchi@pd.infn.it
26 /////////////////////////////////////////////////////////////
28 #include <Riostream.h>
29 #include <TClonesArray.h>
35 #include <TDatabasePDG.h>
38 #include "AliAnalysisManager.h"
39 #include "AliAODHandler.h"
40 #include "AliAODEvent.h"
41 #include "AliAODVertex.h"
42 #include "AliAODTrack.h"
43 #include "AliAODMCHeader.h"
44 #include "AliAODMCParticle.h"
45 #include "AliAODRecoDecayHF3Prong.h"
46 #include "AliAODRecoDecayHF.h"
47 #include "AliAODRecoDecayHF2Prong.h"
48 #include "AliAODRecoDecayHF4Prong.h"
49 #include "AliAODRecoCascadeHF.h"
51 #include "AliAnalysisTaskSE.h"
52 #include "AliRDHFCutsDplustoKpipi.h"
53 #include "AliRDHFCutsD0toKpipipi.h"
54 #include "AliRDHFCutsDstoKKpi.h"
55 #include "AliRDHFCutsDStartoKpipi.h"
56 #include "AliRDHFCutsD0toKpi.h"
57 #include "AliRDHFCutsLctopKpi.h"
58 #include "AliMultiDimVector.h"
60 #include "AliAnalysisTaskSESignificance.h"
62 ClassImp(AliAnalysisTaskSESignificance)
65 //________________________________________________________________________
66 AliAnalysisTaskSESignificance::AliAnalysisTaskSESignificance():
85 fPartOrAndAntiPart(0),
88 // Default constructor
92 for(Int_t i=0;i<4;i++) fPDGdaughters[i]=0;
93 for(Int_t i=0;i<2;i++) {fPDGD0ToKpi[i]=0;fPDGDStarToD0pi[i]=0;}
94 for(Int_t i=0;i<kMaxCutVar;i++) fVars[i]=0.;
95 for(Int_t i=0;i<kMaxNHist;i++) {
104 //________________________________________________________________________
105 AliAnalysisTaskSESignificance::AliAnalysisTaskSESignificance(const char *name, TList* listMDV,AliRDHFCuts *rdCuts,Int_t decaychannel,Int_t selectionlevel):
106 AliAnalysisTaskSE(name),
117 fDecChannel(decaychannel),
121 fSelectionlevel(selectionlevel),
124 fPartOrAndAntiPart(0),
130 if (fDecChannel!=2) SetMassLimits(0.15,fPDGmother); //check range
134 SetMassLimits(min, max);
136 fNPtBins=fRDCuts->GetNPtBins();
138 fNVars=fRDCuts->GetNVarsForOpt();
139 if(fNVars>kMaxCutVar) AliFatal(Form("Too large number of cut variables, maximum is %d",kMaxCutVar));
141 if(fDebug>1)fRDCuts->PrintAll();
142 // Output slot #1 writes into a TList container
143 DefineOutput(1,TList::Class()); //My private output
144 DefineOutput(2,TList::Class());
145 DefineOutput(3,AliRDHFCuts::Class()); //class of the cuts
149 //________________________________________________________________________
150 AliAnalysisTaskSESignificance::~AliAnalysisTaskSESignificance()
173 //_________________________________________________________________
174 void AliAnalysisTaskSESignificance::SetPDGCodes(){
175 // sets channel dependent quantities
182 fPDGdaughters[0]=211;//pi
183 fPDGdaughters[1]=321;//K
184 fPDGdaughters[2]=211;//pi
185 fPDGdaughters[3]=0; //empty
186 fBranchName="Charm3Prong";
192 fPDGdaughters[0]=211;//pi
193 fPDGdaughters[1]=321;//K
194 fPDGdaughters[2]=0; //empty
195 fPDGdaughters[3]=0; //empty
196 fBranchName="D0toKpi";
202 fPDGdaughters[1]=211;//pi
203 fPDGdaughters[0]=321;//K
204 fPDGdaughters[2]=211;//pi (soft?)
205 fPDGdaughters[3]=0; //empty
212 fPDGdaughters[0]=321;//K
213 fPDGdaughters[1]=321;//K
214 fPDGdaughters[2]=211;//pi
215 fPDGdaughters[3]=0; //empty
216 fBranchName="Charm3Prong";
222 fPDGdaughters[0]=321;
223 fPDGdaughters[1]=211;
224 fPDGdaughters[2]=211;
225 fPDGdaughters[3]=211;
226 fBranchName="Charm4Prong";
232 fPDGdaughters[0]=2212;//p
233 fPDGdaughters[1]=321;//K
234 fPDGdaughters[2]=211;//pi
235 fPDGdaughters[3]=0; //empty
236 fBranchName="Charm3Prong";
241 //_________________________________________________________________
242 Bool_t AliAnalysisTaskSESignificance::CheckConsistency(){
244 Bool_t result = kTRUE;
246 const Int_t nvars=fRDCuts->GetNVars();//ForOpt();
247 //Float_t *vars = new Float_t[nvars];
248 Bool_t *varsforopt = fRDCuts->GetVarsForOpt();
249 Bool_t *uppervars = fRDCuts->GetIsUpperCut();
250 TString *names = fRDCuts->GetVarNames();
252 for(Int_t i=0;i<fNPtBins;i++){
253 TString mdvname=Form("multiDimVectorPtBin%d",i);
256 for(Int_t ivar=0;ivar<nvars;ivar++){
257 if(varsforopt[ivar]){
258 Float_t min = ((AliMultiDimVector*)fCutList->FindObject(mdvname.Data()))->GetMinLimit(ic);
259 Float_t max = ((AliMultiDimVector*)fCutList->FindObject(mdvname.Data()))->GetMaxLimit(ic);
261 AliFatal(Form("tight and loose cut for optimization variable number %d are the same in ptbin %d\n",ic,i));
264 Bool_t lowermdv = ((AliMultiDimVector*)fCutList->FindObject(mdvname.Data()))->GetGreaterThan(ic);
265 if(uppervars[ivar]&&lowermdv){
266 AliFatal(Form("%s is declared as uppercut, but as been given tighter cut larger then loose cut in ptbin %d \n ---please check your cuts \n ",names[ivar].Data(),i));
269 if(!uppervars[ivar]&&!lowermdv){
270 AliFatal(Form("%s is declared as lower cut, but as been given tighter cut smaller then loose cut in ptbin %d \n ---please check your cuts \n",names[ivar].Data(),i));
279 //_________________________________________________________________
280 void AliAnalysisTaskSESignificance::SetBFeedDown(FeedDownEnum flagB){
281 if(fReadMC)fBFeedDown=flagB;
283 AliInfo("B feed down not allowed without MC info\n");
287 //_________________________________________________________________
288 void AliAnalysisTaskSESignificance::SetMassLimits(Float_t range, Int_t pdg){
290 Int_t abspdg=TMath::Abs(pdg);
291 mass=TDatabasePDG::Instance()->GetParticle(abspdg)->Mass();
292 fUpmasslimit = mass+range;
293 fLowmasslimit = mass-range;
295 //_________________________________________________________________
296 void AliAnalysisTaskSESignificance::SetMassLimits(Float_t lowlimit, Float_t uplimit){
299 fUpmasslimit = uplimit;
300 fLowmasslimit = lowlimit;
306 //________________________________________________________________________
307 void AliAnalysisTaskSESignificance::LocalInit()
311 if(fDebug > 1) printf("AnalysisTaskSESignificance::Init() \n");
316 AliRDHFCutsDplustoKpipi* copycut=new AliRDHFCutsDplustoKpipi(*(static_cast<AliRDHFCutsDplustoKpipi*>(fRDCuts)));
323 AliRDHFCutsD0toKpi* copycut=new AliRDHFCutsD0toKpi(*(static_cast<AliRDHFCutsD0toKpi*>(fRDCuts)));
330 AliRDHFCutsDStartoKpipi* copycut=new AliRDHFCutsDStartoKpipi(*(static_cast<AliRDHFCutsDStartoKpipi*>(fRDCuts)));
337 AliRDHFCutsDstoKKpi* copycut=new AliRDHFCutsDstoKKpi(*(static_cast<AliRDHFCutsDstoKKpi*>(fRDCuts)));
344 AliRDHFCutsD0toKpipipi* copycut=new AliRDHFCutsD0toKpipipi(*(static_cast<AliRDHFCutsD0toKpipipi*>(fRDCuts)));
351 AliRDHFCutsLctopKpi* copycut=new AliRDHFCutsLctopKpi(*(static_cast<AliRDHFCutsLctopKpi*>(fRDCuts)));
361 TList *mdvList = new TList();
369 //________________________________________________________________________
370 void AliAnalysisTaskSESignificance::UserCreateOutputObjects()
372 // Create the output container
374 if(fDebug > 1) printf("AnalysisTaskSESignificance::UserCreateOutputObjects() \n");
376 // Several histograms are more conveniently managed in a TList
377 fOutput = new TList();
379 fOutput->SetName("OutputHistos");
381 //same number of steps in each multiDimVectorPtBin%d !
382 Int_t nHist=((AliMultiDimVector*)fCutList->FindObject("multiDimVectorPtBin0"))->GetNTotCells();
383 cout<<"ncells = "<<nHist<<" n ptbins = "<<fNPtBins<<endl;
384 nHist=nHist*fNPtBins;
385 cout<<"Total = "<<nHist<<endl;
386 for(Int_t i=0;i<nHist;i++){
394 hisname.Form("hMass_%d",i);
395 signame.Form("hSig_%d",i);
396 bkgname.Form("hBkg_%d",i);
397 rflname.Form("hRfl_%d",i);
399 title.Form("Invariant mass;M[GeV/c^{2}];Entries");
401 fMassHist[i]=new TH1F(hisname.Data(),title.Data(),fNBins,fLowmasslimit,fUpmasslimit);
402 fMassHist[i]->Sumw2();
403 fOutput->Add(fMassHist[i]);
406 fSigHist[i]=new TH1F(signame.Data(),title.Data(),fNBins,fLowmasslimit,fUpmasslimit);
407 fSigHist[i]->Sumw2();
408 fOutput->Add(fSigHist[i]);
410 fBkgHist[i]=new TH1F(bkgname.Data(),title.Data(),fNBins,fLowmasslimit,fUpmasslimit);
411 fBkgHist[i]->Sumw2();
412 fOutput->Add(fBkgHist[i]);
414 if(fDecChannel != AliAnalysisTaskSESignificance::kDplustoKpipi){
415 fRflHist[i]=new TH1F(rflname.Data(),title.Data(),fNBins,fLowmasslimit,fUpmasslimit);
416 fRflHist[i]->Sumw2();
417 fOutput->Add(fRflHist[i]);
422 fHistNEvents=new TH1F("fHistNEvents","Number of AODs scanned",8,-0.5,7.5);
423 fHistNEvents->GetXaxis()->SetBinLabel(1,"nEventsAnal");
424 fHistNEvents->GetXaxis()->SetBinLabel(2,"nEvSelected (vtx)");
425 fHistNEvents->GetXaxis()->SetBinLabel(3,"nCandidatesSelected");
426 fHistNEvents->GetXaxis()->SetBinLabel(4,"nTotEntries Mass hists");
427 fHistNEvents->GetXaxis()->SetBinLabel(5,"Pile-up Rej");
428 fHistNEvents->GetXaxis()->SetBinLabel(6,"N. of 0SMH");
430 fHistNEvents->GetXaxis()->SetBinLabel(7,"MC Cand from c");
431 fHistNEvents->GetXaxis()->SetBinLabel(8,"MC Cand from b");
433 fHistNEvents->GetXaxis()->SetBinLabel(7,"N candidates");
435 fHistNEvents->GetXaxis()->SetNdivisions(1,kFALSE);
436 fOutput->Add(fHistNEvents);
443 //________________________________________________________________________
444 void AliAnalysisTaskSESignificance::UserExec(Option_t */*option*/)
446 // Execute analysis for current event:
447 // heavy flavor candidates association to MC truth
449 AliAODEvent *aod = dynamic_cast<AliAODEvent*> (InputEvent());
450 if(fDebug>2) printf("Analysing decay %d\n",fDecChannel);
451 // Post the data already here
453 TClonesArray *arrayProng =0;
455 if(!aod && AODEvent() && IsStandardAOD()) {
456 // In case there is an AOD handler writing a standard AOD, use the AOD
457 // event in memory rather than the input (ESD) event.
458 aod = dynamic_cast<AliAODEvent*> (AODEvent());
459 // in this case the braches in the deltaAOD (AliAOD.VertexingHF.root)
460 // have to taken from the AOD event hold by the AliAODExtension
461 AliAODHandler* aodHandler = (AliAODHandler*)
462 ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
463 if(aodHandler->GetExtensions()) {
465 AliAODExtension *ext = (AliAODExtension*)aodHandler->GetExtensions()->FindObject("AliAOD.VertexingHF.root");
466 AliAODEvent *aodFromExt = ext->GetAOD();
467 arrayProng=(TClonesArray*)aodFromExt->GetList()->FindObject(fBranchName.Data());
471 arrayProng=(TClonesArray*)aod->GetList()->FindObject(fBranchName.Data());
473 if(!aod || !arrayProng) {
474 AliError("AliAnalysisTaskSESignificance::UserExec:Branch not found!\n");
478 // fix for temporary bug in ESDfilter
479 // the AODs with null vertex pointer didn't pass the PhysSel
480 if(!aod->GetPrimaryVertex() || TMath::Abs(aod->GetMagneticField())<0.001) return;
481 TClonesArray *arrayMC=0;
482 AliAODMCHeader *mcHeader=0;
487 arrayMC = (TClonesArray*)aod->GetList()->FindObject(AliAODMCParticle::StdBranchName());
489 AliError("AliAnalysisTaskSESignificance::UserExec:MC particles branch not found!\n");
494 mcHeader = (AliAODMCHeader*)aod->GetList()->FindObject(AliAODMCHeader::StdBranchName());
496 AliError("AliAnalysisTaskSESignificance::UserExec:MC header branch not found!\n");
501 fHistNEvents->Fill(0); // count event
503 AliAODRecoDecayHF *d=0;
507 Int_t nHistpermv=((AliMultiDimVector*)fCutList->FindObject("multiDimVectorPtBin0"))->GetNTotCells();
508 Int_t nProng = arrayProng->GetEntriesFast();
509 if(fDebug>1) printf("Number of D2H: %d\n",nProng);
511 // trigger class for PbPb C0SMH-B-NOPF-ALLNOTRD, C0SMH-B-NOPF-ALL
512 TString trigclass=aod->GetFiredTriggerClasses();
513 if(trigclass.Contains("C0SMH-B-NOPF-ALLNOTRD") || trigclass.Contains("C0SMH-B-NOPF-ALL")) fHistNEvents->Fill(5);
515 if(fRDCuts->IsEventSelected(aod)) {
516 fHistNEvents->Fill(1);
518 if(fRDCuts->GetWhyRejection()==1) // rejected for pileup
519 fHistNEvents->Fill(4);
523 for (Int_t iProng = 0; iProng < nProng; iProng++) {
524 fHistNEvents->Fill(6);
525 d=(AliAODRecoDecayHF*)arrayProng->UncheckedAt(iProng);
527 AliAODRecoCascadeHF* DStarToD0pi = NULL;
528 AliAODRecoDecayHF2Prong* D0Particle = NULL;
529 fPDGDStarToD0pi[0] = 421; fPDGDStarToD0pi[1] = 211;
530 fPDGD0ToKpi[0] = 321; fPDGD0ToKpi[1] = 211;
532 Bool_t isSelBit=kTRUE;
535 isSelBit=d->HasSelectionBit(AliRDHFCuts::kDplusCuts);
538 isSelBit=d->HasSelectionBit(AliRDHFCuts::kD0toKpiCuts);
541 isSelBit=d->HasSelectionBit(AliRDHFCuts::kDstarCuts);
544 isSelBit=d->HasSelectionBit(AliRDHFCuts::kDsCuts);
546 if(fDecChannel==5) isSelBit=d->HasSelectionBit(AliRDHFCuts::kLcCuts);
552 if(!isSelBit) continue;
554 if (fDecChannel==2) {
555 DStarToD0pi = (AliAODRecoCascadeHF*)arrayProng->At(iProng);
556 if (!DStarToD0pi->GetSecondaryVtx()) continue;
557 D0Particle = (AliAODRecoDecayHF2Prong*)DStarToD0pi->Get2Prong();
558 if (!D0Particle) continue;
561 Bool_t isFidAcc = fRDCuts->IsInFiducialAcceptance(d->Pt(),d->Y(fPDGmother));
562 Int_t isSelected=fRDCuts->IsSelected(d,fSelectionlevel,aod);
564 if(fReadMC && fBFeedDown!=kBoth && isSelected){
565 Int_t labD = d->MatchToMC(fPDGmother,arrayMC,fNProngs,fPDGdaughters);
567 AliAODMCParticle *partD = (AliAODMCParticle*)arrayMC->At(labD);
568 Int_t pdgGranma = CheckOrigin(partD, arrayMC);
569 Int_t abspdgGranma = TMath::Abs(pdgGranma);
570 if ((abspdgGranma > 500 && abspdgGranma < 600) || (abspdgGranma > 5000 && abspdgGranma < 6000)) {
572 AliDebug(2,Form("Particle has a b-meson, or b-baryon mother (pdg code mother = %d )--> not coming from a c-quark, skipping...", pdgGranma));
573 fHistNEvents->Fill(7);
574 if(fBFeedDown==kCharmOnly) isSelected=kFALSE; //from beauty
578 fHistNEvents->Fill(6);
579 if(fBFeedDown==kBeautyOnly)isSelected=kFALSE;
584 if(isSelected&&isFidAcc) {
585 fHistNEvents->Fill(2); // count selected with loosest cuts
586 if(fDebug>1) printf("+++++++Is Selected\n");
589 if(fDecChannel==3) SetPDGdaughterDstoKKpi();
590 fRDCuts->GetCutVarsForOpt(d,fVars,fNVars,fPDGdaughters,aod);
591 Int_t ptbin=fRDCuts->PtBin(d->Pt());
592 if(ptbin==-1) continue;
593 TString mdvname=Form("multiDimVectorPtBin%d",ptbin);
594 AliMultiDimVector* muvec=(AliMultiDimVector*)fCutList->FindObject(mdvname.Data());
596 ULong64_t *addresses = muvec->GetGlobalAddressesAboveCuts(fVars,(Float_t)d->Pt(),nVals);
597 if(fDebug>1)printf("nvals = %d\n",nVals);
598 for(Int_t ivals=0;ivals<nVals;ivals++){
599 if(addresses[ivals]>=muvec->GetNTotCells()){
600 if (fDebug>1) printf("Overflow!!\n");
605 fHistNEvents->Fill(3);
607 //fill the histograms with the appropriate method
608 switch (fDecChannel){
610 FillDplus(d,arrayMC,(Int_t)(ptbin*nHistpermv+addresses[ivals]),isSelected);
613 FillD02p(d,arrayMC,(Int_t)(ptbin*nHistpermv+addresses[ivals]),isSelected);
616 FillDstar(DStarToD0pi,arrayMC,(Int_t)(ptbin*nHistpermv+addresses[ivals]),isSelected);
620 FillDs(d,arrayMC,(Int_t)(ptbin*nHistpermv+addresses[ivals]),isSelected,1);
624 FillD04p(d,arrayMC,(Int_t)(ptbin*nHistpermv+addresses[ivals]),isSelected);
627 FillLambdac(d,arrayMC,(Int_t)(ptbin*nHistpermv+addresses[ivals]),isSelected);
635 if (fDecChannel==3 && isSelected&2){
636 SetPDGdaughterDstopiKK();
638 fRDCuts->GetCutVarsForOpt(d,fVars,fNVars,fPDGdaughters,aod);
640 addresses = muvec->GetGlobalAddressesAboveCuts(fVars,(Float_t)d->Pt(),nVals);
641 if(fDebug>1)printf("nvals = %d\n",nVals);
642 for(Int_t ivals=0;ivals<nVals;ivals++){
643 if(addresses[ivals]>=muvec->GetNTotCells()){
644 if (fDebug>1) printf("Overflow!!\n");
648 FillDs(d,arrayMC,(Int_t)(ptbin*nHistpermv+addresses[ivals]),isSelected,0);
664 //***************************************************************************
666 // Methods used in the UserExec
669 //********************************************************************************************
671 //Methods to fill the istograms with MC information, one for each candidate
672 //NB: the implementation for each candidate is responsibility of the corresponding developer
674 void AliAnalysisTaskSESignificance::FillDplus(AliAODRecoDecayHF* d,TClonesArray *arrayMC,Int_t index,Int_t isSel){
677 AliError("Candidate not selected\n");
681 if(fPartOrAndAntiPart*d->GetCharge()<0)return;
682 Int_t pdgdaughters[3] = {211,321,211};
683 Double_t mass=d->InvMass(3,(UInt_t*)pdgdaughters);
685 fMassHist[index]->Fill(mass);
690 lab = d->MatchToMC(411,arrayMC,3,pdgdaughters);
692 fSigHist[index]->Fill(mass);
694 fBkgHist[index]->Fill(mass);
700 void AliAnalysisTaskSESignificance::FillD02p(AliAODRecoDecayHF* d,TClonesArray *arrayMC,Int_t index,Int_t isSel){
705 Int_t pdgdaughtersD0[2]={211,321};//pi,K
706 Int_t pdgdaughtersD0bar[2]={321,211};//K,pi
708 masses[0]=d->InvMass(fNProngs,(UInt_t*)pdgdaughtersD0); //D0
709 masses[1]=d->InvMass(fNProngs,(UInt_t*)pdgdaughtersD0bar); //D0bar
711 if((isSel==1 || isSel==3) && fPartOrAndAntiPart>=0) fMassHist[index]->Fill(masses[0]);
712 if(isSel>=2 && fPartOrAndAntiPart<=0) fMassHist[index]->Fill(masses[1]);
722 Int_t pdgdaughters[2];
723 pdgdaughters[0]=211;//pi
724 pdgdaughters[1]=321;//K
726 matchtoMC = d->MatchToMC(fPDGmother,arrayMC,fNProngs,pdgdaughters);
728 Int_t prongPdgPlus=421,prongPdgMinus=(-1)*421;
729 if((isSel==1 || isSel==3) && fPartOrAndAntiPart>=0){ //D0
731 AliAODMCParticle *dMC = (AliAODMCParticle*)arrayMC->At(matchtoMC);
732 Int_t pdgMC = dMC->GetPdgCode();
734 if(pdgMC==prongPdgPlus) fSigHist[index]->Fill(masses[0]);
735 else fRflHist[index]->Fill(masses[0]);
737 } else fBkgHist[index]->Fill(masses[0]);
740 if(isSel>=2 && fPartOrAndAntiPart<=0){ //D0bar
742 AliAODMCParticle *dMC = (AliAODMCParticle*)arrayMC->At(matchtoMC);
743 Int_t pdgMC = dMC->GetPdgCode();
745 if(pdgMC==prongPdgMinus) fSigHist[index]->Fill(masses[1]);
746 else fRflHist[index]->Fill(masses[1]);
747 } else fBkgHist[index]->Fill(masses[1]);
752 void AliAnalysisTaskSESignificance::FillDstar(AliAODRecoCascadeHF* dstarD0pi,TClonesArray *arrayMC,Int_t index,Int_t isSel){
755 AliInfo("Dstar selected\n");
757 Double_t mass = dstarD0pi->DeltaInvMass();
759 if((isSel==1 || isSel==3) && fPartOrAndAntiPart>=0) fMassHist[index]->Fill(mass);
760 if(isSel>=2 && fPartOrAndAntiPart<=0) fMassHist[index]->Fill(mass);
763 Int_t matchtoMC = -1;
764 matchtoMC = dstarD0pi->MatchToMC(413,421,fPDGDStarToD0pi, fPDGD0ToKpi, arrayMC);
766 Int_t prongPdgDStarPlus=413,prongPdgDStarMinus=(-1)*413;
768 if ((isSel==1 || isSel==3) && fPartOrAndAntiPart>=0) {
771 AliAODMCParticle *dMC = (AliAODMCParticle*)arrayMC->At(matchtoMC);
772 Int_t pdgMC = dMC->GetPdgCode();
774 if (pdgMC==prongPdgDStarPlus) fSigHist[index]->Fill(mass);
776 dstarD0pi->SetCharge(-1*dstarD0pi->GetCharge());
777 mass = dstarD0pi->DeltaInvMass();
778 fRflHist[index]->Fill(mass);
779 dstarD0pi->SetCharge(-1*dstarD0pi->GetCharge());
782 else fBkgHist[index]->Fill(mass);
785 if (isSel>=2 && fPartOrAndAntiPart<=0) {
788 AliAODMCParticle *dMC = (AliAODMCParticle*)arrayMC->At(matchtoMC);
789 Int_t pdgMC = dMC->GetPdgCode();
791 if (pdgMC==prongPdgDStarMinus) fSigHist[index]->Fill(mass);
793 dstarD0pi->SetCharge(-1*dstarD0pi->GetCharge());
794 mass = dstarD0pi->DeltaInvMass();
795 fRflHist[index]->Fill(mass);
796 dstarD0pi->SetCharge(-1*dstarD0pi->GetCharge());
799 else fBkgHist[index]->Fill(mass);
806 void AliAnalysisTaskSESignificance::FillDs(AliAODRecoDecayHF* d,TClonesArray *arrayMC,Int_t index,Int_t isSel,Int_t optDecay){
811 Int_t pdgDsKKpi[3]={321,321,211};//K,K,pi
812 Int_t pdgDspiKK[3]={211,321,321};//pi,K,K
814 masses[0]=d->InvMass(fNProngs,(UInt_t*)pdgDsKKpi); //Ds
815 masses[1]=d->InvMass(fNProngs,(UInt_t*)pdgDspiKK); //Dsbar
819 labDs = d->MatchToMC(431,arrayMC,3,pdgDsKKpi);
822 Int_t isKKpi=isSel&1;
823 Int_t ispiKK=isSel&2;
824 Int_t isPhiKKpi=isSel&4;
825 Int_t isPhipiKK=isSel&8;
826 Int_t isK0starKKpi=isSel&16;
827 Int_t isK0starpiKK=isSel&32;
830 if(fDsChannel==kPhi && (isPhiKKpi==0 && isPhipiKK==0)) return;
831 if(fDsChannel==kK0star && (isK0starKKpi==0 && isK0starpiKK==0)) return;
834 if(isKKpi && fPartOrAndAntiPart*d->GetCharge()>=0) {
835 if(fDsChannel==kPhi && isPhiKKpi==0) return;
836 if(fDsChannel==kK0star && isK0starKKpi==0) return;
838 fMassHist[index]->Fill(masses[0]);
842 Int_t labDau0=((AliAODTrack*)d->GetDaughter(0))->GetLabel();
843 AliAODMCParticle* p=(AliAODMCParticle*)arrayMC->UncheckedAt(labDau0);
844 Int_t pdgCode0=TMath::Abs(p->GetPdgCode());
846 fSigHist[index]->Fill(masses[0]); //signal
848 fRflHist[index]->Fill(masses[0]); //Reflected signal
851 fBkgHist[index]->Fill(masses[0]); // Background
858 if(ispiKK && fPartOrAndAntiPart*d->GetCharge()>=0){
859 if(fDsChannel==kPhi && isPhipiKK==0) return;
860 if(fDsChannel==kK0star && isK0starpiKK==0) return;
862 fMassHist[index]->Fill(masses[1]);
866 Int_t labDau0=((AliAODTrack*)d->GetDaughter(0))->GetLabel();
867 AliAODMCParticle* p=(AliAODMCParticle*)arrayMC->UncheckedAt(labDau0);
868 Int_t pdgCode0=TMath::Abs(p->GetPdgCode());
870 fSigHist[index]->Fill(masses[1]);
872 fRflHist[index]->Fill(masses[1]);
875 fBkgHist[index]->Fill(masses[1]);
882 void AliAnalysisTaskSESignificance::FillD04p(AliAODRecoDecayHF* /*d*/,TClonesArray */*arrayMC*/,Int_t /*index*/,Int_t /*matchtoMC*/){
883 //D0->Kpipipi channel
884 AliInfo("D0 in 4 prongs channel not implemented\n");
888 void AliAnalysisTaskSESignificance::FillLambdac(AliAODRecoDecayHF* d,TClonesArray* arrayMC,Int_t index,Int_t isSel){
892 Int_t pdgdaughtersLc[3]={2212,321,211}; //p,K,pi
893 masses[0]=d->InvMass(fNProngs,(UInt_t*)pdgdaughtersLc);
894 Int_t pdgdaughtersLc2[3]={211,321,2212}; //pi,K,p
895 masses[1]=d->InvMass(fNProngs,(UInt_t*)pdgdaughtersLc2);
898 if(fPartOrAndAntiPart==0 || fPartOrAndAntiPart==d->GetCharge()) {
900 // isSel=1 : p K pi ; isSel=2 : pi K p ;
901 if(isSel==1 || isSel==3) fMassHist[index]->Fill(masses[0]);
902 if(isSel>=2) fMassHist[index]->Fill(masses[1]);
904 // Check the MC truth
911 Int_t matchtoMC = -1;
913 Int_t pPDG = 2212; // p
914 Int_t kPDG = 321; // K
915 Int_t piPDG = 211; // pi
916 Int_t absPdgMom = 4122;
917 matchtoMC = d->MatchToMC(absPdgMom,arrayMC,fNProngs,pdgdaughtersLc);
921 AliAODMCParticle *dMC = (AliAODMCParticle*)arrayMC->At(matchtoMC);
922 Int_t pdgMC = dMC->GetPdgCode();
923 if (TMath::Abs(pdgMC)!=absPdgMom) AliInfo("What's up, isn't it a lambdac ?!");
924 Int_t labDau0 = ((AliAODTrack*)d->GetDaughter(0))->GetLabel();
925 AliAODMCParticle* p0 = (AliAODMCParticle*)arrayMC->UncheckedAt(labDau0);
926 Int_t pdgCode0 = TMath::Abs(p0->GetPdgCode());
927 Int_t labDau1 = ((AliAODTrack*)d->GetDaughter(1))->GetLabel();
928 AliAODMCParticle* p1 = (AliAODMCParticle*)arrayMC->UncheckedAt(labDau1);
929 Int_t pdgCode1 = TMath::Abs(p1->GetPdgCode());
930 Int_t labDau2 = ((AliAODTrack*)d->GetDaughter(2))->GetLabel();
931 AliAODMCParticle* p2 = (AliAODMCParticle*)arrayMC->UncheckedAt(labDau2);
932 Int_t pdgCode2 = TMath::Abs(p2->GetPdgCode());
934 // Fill in the histograms in case of p K pi decays
936 if(pdgCode0==pPDG && pdgCode1==kPDG && pdgCode2==piPDG){
937 fSigHist[index]->Fill(masses[0]);
939 fRflHist[index]->Fill(masses[0]);
942 // Fill in the histograms in case of pi K p decays
944 if(pdgCode0==piPDG && pdgCode1==kPDG && pdgCode2==pPDG){
945 fSigHist[index]->Fill(masses[1]);
947 fRflHist[index]->Fill(masses[1]);
951 if(ispKpi==1) fBkgHist[index]->Fill(masses[0]);
952 if(ispiKp==2) fBkgHist[index]->Fill(masses[1]);
961 //________________________________________________________________________
962 void AliAnalysisTaskSESignificance::Terminate(Option_t */*option*/)
964 // Terminate analysis
966 if(fDebug > 1) printf("AnalysisTaskSESignificance: Terminate() \n");
969 fOutput = dynamic_cast<TList*> (GetOutputData(1));
971 printf("ERROR: fOutput not available\n");
975 fCutList = dynamic_cast<TList*> (GetOutputData(2));
977 printf("ERROR: fCutList not available\n");
981 AliMultiDimVector* mdvtmp=(AliMultiDimVector*)fCutList->FindObject("multiDimVectorPtBin0");
983 cout<<"multidimvec not found in TList"<<endl;
987 Int_t nHist=mdvtmp->GetNTotCells();
988 TCanvas *c1=new TCanvas("c1","Invariant mass distribution - loose cuts",500,500);
990 for(Int_t i=0;i<nHist;i++){
997 hisname.Form("hMass_%d",i);
998 signame.Form("hSig_%d",i);
999 bkgname.Form("hBkg_%d",i);
1000 rflname.Form("hRfl_%d",i);
1002 fMassHist[i]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
1004 if (!drawn && fMassHist[i]->GetEntries() > 0){
1006 fMassHist[i]->Draw();
1011 fSigHist[i]=dynamic_cast<TH1F*>(fOutput->FindObject(signame.Data()));
1012 fBkgHist[i]=dynamic_cast<TH1F*>(fOutput->FindObject(bkgname.Data()));
1013 if(fDecChannel != AliAnalysisTaskSESignificance::kDplustoKpipi) fRflHist[i]=dynamic_cast<TH1F*>(fOutput->FindObject(rflname.Data()));
1023 //_________________________________________________________________________________________________
1024 Int_t AliAnalysisTaskSESignificance::CheckOrigin(const AliAODMCParticle* mcPart, const TClonesArray* mcArray)const{
1027 // checking whether the very mother of the D0 is a charm or a bottom quark
1030 Int_t pdgGranma = 0;
1032 mother = mcPart->GetMother();
1036 AliDebug(2,Form("mother at step %d = %d", istep, mother));
1037 AliAODMCParticle* mcGranma = dynamic_cast<AliAODMCParticle*>(mcArray->At(mother));
1038 if(!mcGranma) break;
1039 pdgGranma = mcGranma->GetPdgCode();
1040 AliDebug(2,Form("Pdg mother at step %d = %d", istep, pdgGranma));
1041 Int_t abspdgGranma = TMath::Abs(pdgGranma);
1042 if ((abspdgGranma > 500 && abspdgGranma < 600) || (abspdgGranma > 5000 && abspdgGranma < 6000)) {
1045 mother = mcGranma->GetMother();
1049 //_________________________________________________________________________________________________