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
93 //________________________________________________________________________
94 AliAnalysisTaskSESignificance::AliAnalysisTaskSESignificance(const char *name, TList* listMDV,AliRDHFCuts *rdCuts,Int_t decaychannel,Int_t selectionlevel):
95 AliAnalysisTaskSE(name),
106 fDecChannel(decaychannel),
110 fSelectionlevel(selectionlevel),
113 fPartOrAndAntiPart(0),
119 if (fDecChannel!=2) SetMassLimits(0.15,fPDGmother); //check range
123 SetMassLimits(min, max);
125 fNPtBins=fRDCuts->GetNPtBins();
127 fNVars=fRDCuts->GetNVarsForOpt();
128 if(fNVars>kMaxCutVar) AliFatal(Form("Too large number of cut variables, maximum is %d",kMaxCutVar));
130 if(fDebug>1)fRDCuts->PrintAll();
131 // Output slot #1 writes into a TList container
132 DefineOutput(1,TList::Class()); //My private output
133 DefineOutput(2,TList::Class());
134 DefineOutput(3,AliRDHFCuts::Class()); //class of the cuts
138 //________________________________________________________________________
139 AliAnalysisTaskSESignificance::~AliAnalysisTaskSESignificance()
162 //_________________________________________________________________
163 void AliAnalysisTaskSESignificance::SetPDGCodes(){
164 // sets channel dependent quantities
171 fPDGdaughters[0]=211;//pi
172 fPDGdaughters[1]=321;//K
173 fPDGdaughters[2]=211;//pi
174 fPDGdaughters[3]=0; //empty
175 fBranchName="Charm3Prong";
181 fPDGdaughters[0]=211;//pi
182 fPDGdaughters[1]=321;//K
183 fPDGdaughters[2]=0; //empty
184 fPDGdaughters[3]=0; //empty
185 fBranchName="D0toKpi";
191 fPDGdaughters[1]=211;//pi
192 fPDGdaughters[0]=321;//K
193 fPDGdaughters[2]=211;//pi (soft?)
194 fPDGdaughters[3]=0; //empty
201 fPDGdaughters[0]=321;//K
202 fPDGdaughters[1]=321;//K
203 fPDGdaughters[2]=211;//pi
204 fPDGdaughters[3]=0; //empty
205 fBranchName="Charm3Prong";
211 fPDGdaughters[0]=321;
212 fPDGdaughters[1]=211;
213 fPDGdaughters[2]=211;
214 fPDGdaughters[3]=211;
215 fBranchName="Charm4Prong";
221 fPDGdaughters[0]=2212;//p
222 fPDGdaughters[1]=321;//K
223 fPDGdaughters[2]=211;//pi
224 fPDGdaughters[3]=0; //empty
225 fBranchName="Charm3Prong";
230 //_________________________________________________________________
231 Bool_t AliAnalysisTaskSESignificance::CheckConsistency(){
233 Bool_t result = kTRUE;
235 const Int_t nvars=fRDCuts->GetNVars();//ForOpt();
236 //Float_t *vars = new Float_t[nvars];
237 Bool_t *varsforopt = fRDCuts->GetVarsForOpt();
238 Bool_t *uppervars = fRDCuts->GetIsUpperCut();
239 TString *names = fRDCuts->GetVarNames();
241 for(Int_t i=0;i<fNPtBins;i++){
242 TString mdvname=Form("multiDimVectorPtBin%d",i);
245 for(Int_t ivar=0;ivar<nvars;ivar++){
246 if(varsforopt[ivar]){
247 Float_t min = ((AliMultiDimVector*)fCutList->FindObject(mdvname.Data()))->GetMinLimit(ic);
248 Float_t max = ((AliMultiDimVector*)fCutList->FindObject(mdvname.Data()))->GetMaxLimit(ic);
250 AliFatal(Form("tight and loose cut for optimization variable number %d are the same in ptbin %d\n",ic,i));
253 Bool_t lowermdv = ((AliMultiDimVector*)fCutList->FindObject(mdvname.Data()))->GetGreaterThan(ic);
254 if(uppervars[ivar]&&lowermdv){
255 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));
258 if(!uppervars[ivar]&&!lowermdv){
259 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));
268 //_________________________________________________________________
269 void AliAnalysisTaskSESignificance::SetBFeedDown(FeedDownEnum flagB){
270 if(fReadMC)fBFeedDown=flagB;
272 AliInfo("B feed down not allowed without MC info\n");
276 //_________________________________________________________________
277 void AliAnalysisTaskSESignificance::SetMassLimits(Float_t range, Int_t pdg){
279 Int_t abspdg=TMath::Abs(pdg);
280 mass=TDatabasePDG::Instance()->GetParticle(abspdg)->Mass();
281 fUpmasslimit = mass+range;
282 fLowmasslimit = mass-range;
284 //_________________________________________________________________
285 void AliAnalysisTaskSESignificance::SetMassLimits(Float_t lowlimit, Float_t uplimit){
288 fUpmasslimit = uplimit;
289 fLowmasslimit = lowlimit;
295 //________________________________________________________________________
296 void AliAnalysisTaskSESignificance::LocalInit()
300 if(fDebug > 1) printf("AnalysisTaskSESignificance::Init() \n");
305 AliRDHFCutsDplustoKpipi* copycut=new AliRDHFCutsDplustoKpipi(*(static_cast<AliRDHFCutsDplustoKpipi*>(fRDCuts)));
312 AliRDHFCutsD0toKpi* copycut=new AliRDHFCutsD0toKpi(*(static_cast<AliRDHFCutsD0toKpi*>(fRDCuts)));
319 AliRDHFCutsDStartoKpipi* copycut=new AliRDHFCutsDStartoKpipi(*(static_cast<AliRDHFCutsDStartoKpipi*>(fRDCuts)));
326 AliRDHFCutsDstoKKpi* copycut=new AliRDHFCutsDstoKKpi(*(static_cast<AliRDHFCutsDstoKKpi*>(fRDCuts)));
333 AliRDHFCutsD0toKpipipi* copycut=new AliRDHFCutsD0toKpipipi(*(static_cast<AliRDHFCutsD0toKpipipi*>(fRDCuts)));
340 AliRDHFCutsLctopKpi* copycut=new AliRDHFCutsLctopKpi(*(static_cast<AliRDHFCutsLctopKpi*>(fRDCuts)));
350 TList *mdvList = new TList();
358 //________________________________________________________________________
359 void AliAnalysisTaskSESignificance::UserCreateOutputObjects()
361 // Create the output container
363 if(fDebug > 1) printf("AnalysisTaskSESignificance::UserCreateOutputObjects() \n");
365 // Several histograms are more conveniently managed in a TList
366 fOutput = new TList();
368 fOutput->SetName("OutputHistos");
370 //same number of steps in each multiDimVectorPtBin%d !
371 Int_t nHist=((AliMultiDimVector*)fCutList->FindObject("multiDimVectorPtBin0"))->GetNTotCells();
372 cout<<"ncells = "<<nHist<<" n ptbins = "<<fNPtBins<<endl;
373 nHist=nHist*fNPtBins;
374 cout<<"Total = "<<nHist<<endl;
375 for(Int_t i=0;i<nHist;i++){
383 hisname.Form("hMass_%d",i);
384 signame.Form("hSig_%d",i);
385 bkgname.Form("hBkg_%d",i);
386 rflname.Form("hRfl_%d",i);
388 title.Form("Invariant mass;M[GeV/c^{2}];Entries");
390 fMassHist[i]=new TH1F(hisname.Data(),title.Data(),fNBins,fLowmasslimit,fUpmasslimit);
391 fMassHist[i]->Sumw2();
392 fOutput->Add(fMassHist[i]);
395 fSigHist[i]=new TH1F(signame.Data(),title.Data(),fNBins,fLowmasslimit,fUpmasslimit);
396 fSigHist[i]->Sumw2();
397 fOutput->Add(fSigHist[i]);
399 fBkgHist[i]=new TH1F(bkgname.Data(),title.Data(),fNBins,fLowmasslimit,fUpmasslimit);
400 fBkgHist[i]->Sumw2();
401 fOutput->Add(fBkgHist[i]);
403 if(fDecChannel != AliAnalysisTaskSESignificance::kDplustoKpipi){
404 fRflHist[i]=new TH1F(rflname.Data(),title.Data(),fNBins,fLowmasslimit,fUpmasslimit);
405 fRflHist[i]->Sumw2();
406 fOutput->Add(fRflHist[i]);
411 fHistNEvents=new TH1F("fHistNEvents","Number of AODs scanned",8,-0.5,7.5);
412 fHistNEvents->GetXaxis()->SetBinLabel(1,"nEventsAnal");
413 fHistNEvents->GetXaxis()->SetBinLabel(2,"nEvSelected (vtx)");
414 fHistNEvents->GetXaxis()->SetBinLabel(3,"nCandidatesSelected");
415 fHistNEvents->GetXaxis()->SetBinLabel(4,"nTotEntries Mass hists");
416 fHistNEvents->GetXaxis()->SetBinLabel(5,"Pile-up Rej");
417 fHistNEvents->GetXaxis()->SetBinLabel(6,"N. of 0SMH");
419 fHistNEvents->GetXaxis()->SetBinLabel(7,"MC Cand from c");
420 fHistNEvents->GetXaxis()->SetBinLabel(8,"MC Cand from b");
422 fHistNEvents->GetXaxis()->SetBinLabel(7,"N candidates");
424 fHistNEvents->GetXaxis()->SetNdivisions(1,kFALSE);
425 fOutput->Add(fHistNEvents);
432 //________________________________________________________________________
433 void AliAnalysisTaskSESignificance::UserExec(Option_t */*option*/)
435 // Execute analysis for current event:
436 // heavy flavor candidates association to MC truth
438 AliAODEvent *aod = dynamic_cast<AliAODEvent*> (InputEvent());
439 if(fDebug>2) printf("Analysing decay %d\n",fDecChannel);
440 // Post the data already here
442 TClonesArray *arrayProng =0;
444 if(!aod && AODEvent() && IsStandardAOD()) {
445 // In case there is an AOD handler writing a standard AOD, use the AOD
446 // event in memory rather than the input (ESD) event.
447 aod = dynamic_cast<AliAODEvent*> (AODEvent());
448 // in this case the braches in the deltaAOD (AliAOD.VertexingHF.root)
449 // have to taken from the AOD event hold by the AliAODExtension
450 AliAODHandler* aodHandler = (AliAODHandler*)
451 ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
452 if(aodHandler->GetExtensions()) {
454 AliAODExtension *ext = (AliAODExtension*)aodHandler->GetExtensions()->FindObject("AliAOD.VertexingHF.root");
455 AliAODEvent *aodFromExt = ext->GetAOD();
456 arrayProng=(TClonesArray*)aodFromExt->GetList()->FindObject(fBranchName.Data());
460 arrayProng=(TClonesArray*)aod->GetList()->FindObject(fBranchName.Data());
462 if(!aod || !arrayProng) {
463 AliError("AliAnalysisTaskSESignificance::UserExec:Branch not found!\n");
467 // fix for temporary bug in ESDfilter
468 // the AODs with null vertex pointer didn't pass the PhysSel
469 if(!aod->GetPrimaryVertex() || TMath::Abs(aod->GetMagneticField())<0.001) return;
470 TClonesArray *arrayMC=0;
471 AliAODMCHeader *mcHeader=0;
476 arrayMC = (TClonesArray*)aod->GetList()->FindObject(AliAODMCParticle::StdBranchName());
478 AliError("AliAnalysisTaskSESignificance::UserExec:MC particles branch not found!\n");
483 mcHeader = (AliAODMCHeader*)aod->GetList()->FindObject(AliAODMCHeader::StdBranchName());
485 AliError("AliAnalysisTaskSESignificance::UserExec:MC header branch not found!\n");
490 fHistNEvents->Fill(0); // count event
492 AliAODRecoDecayHF *d=0;
496 Int_t nHistpermv=((AliMultiDimVector*)fCutList->FindObject("multiDimVectorPtBin0"))->GetNTotCells();
497 Int_t nProng = arrayProng->GetEntriesFast();
498 if(fDebug>1) printf("Number of D2H: %d\n",nProng);
500 // trigger class for PbPb C0SMH-B-NOPF-ALLNOTRD, C0SMH-B-NOPF-ALL
501 TString trigclass=aod->GetFiredTriggerClasses();
502 if(trigclass.Contains("C0SMH-B-NOPF-ALLNOTRD") || trigclass.Contains("C0SMH-B-NOPF-ALL")) fHistNEvents->Fill(5);
504 if(fRDCuts->IsEventSelected(aod)) {
505 fHistNEvents->Fill(1);
507 if(fRDCuts->GetWhyRejection()==1) // rejected for pileup
508 fHistNEvents->Fill(4);
512 for (Int_t iProng = 0; iProng < nProng; iProng++) {
513 fHistNEvents->Fill(6);
514 d=(AliAODRecoDecayHF*)arrayProng->UncheckedAt(iProng);
516 AliAODRecoCascadeHF* DStarToD0pi = NULL;
517 AliAODRecoDecayHF2Prong* D0Particle = NULL;
518 fPDGDStarToD0pi[0] = 421; fPDGDStarToD0pi[1] = 211;
519 fPDGD0ToKpi[0] = 321; fPDGD0ToKpi[1] = 211;
521 Bool_t isSelBit=kTRUE;
524 isSelBit=d->HasSelectionBit(AliRDHFCuts::kDplusCuts);
527 isSelBit=d->HasSelectionBit(AliRDHFCuts::kD0toKpiCuts);
530 isSelBit=d->HasSelectionBit(AliRDHFCuts::kDstarCuts);
533 isSelBit=d->HasSelectionBit(AliRDHFCuts::kDsCuts);
535 if(fDecChannel==5) isSelBit=d->HasSelectionBit(AliRDHFCuts::kLcCuts);
541 if(!isSelBit) continue;
543 if (fDecChannel==2) {
544 DStarToD0pi = (AliAODRecoCascadeHF*)arrayProng->At(iProng);
545 if (!DStarToD0pi->GetSecondaryVtx()) continue;
546 D0Particle = (AliAODRecoDecayHF2Prong*)DStarToD0pi->Get2Prong();
547 if (!D0Particle) continue;
550 Bool_t isFidAcc = fRDCuts->IsInFiducialAcceptance(d->Pt(),d->Y(fPDGmother));
551 Int_t isSelected=fRDCuts->IsSelected(d,fSelectionlevel,aod);
553 if(fReadMC && fBFeedDown!=kBoth && isSelected){
554 Int_t labD = d->MatchToMC(fPDGmother,arrayMC,fNProngs,fPDGdaughters);
556 AliAODMCParticle *partD = (AliAODMCParticle*)arrayMC->At(labD);
557 Int_t pdgGranma = CheckOrigin(partD, arrayMC);
558 Int_t abspdgGranma = TMath::Abs(pdgGranma);
559 if ((abspdgGranma > 500 && abspdgGranma < 600) || (abspdgGranma > 5000 && abspdgGranma < 6000)) {
561 AliDebug(2,Form("Particle has a b-meson, or b-baryon mother (pdg code mother = %d )--> not coming from a c-quark, skipping...", pdgGranma));
562 fHistNEvents->Fill(7);
563 if(fBFeedDown==kCharmOnly) isSelected=kFALSE; //from beauty
567 fHistNEvents->Fill(6);
568 if(fBFeedDown==kBeautyOnly)isSelected=kFALSE;
573 if(isSelected&&isFidAcc) {
574 fHistNEvents->Fill(2); // count selected with loosest cuts
575 if(fDebug>1) printf("+++++++Is Selected\n");
578 if(fDecChannel==3) SetPDGdaughterDstoKKpi();
579 fRDCuts->GetCutVarsForOpt(d,fVars,fNVars,fPDGdaughters,aod);
580 Int_t ptbin=fRDCuts->PtBin(d->Pt());
581 if(ptbin==-1) continue;
582 TString mdvname=Form("multiDimVectorPtBin%d",ptbin);
583 AliMultiDimVector* muvec=(AliMultiDimVector*)fCutList->FindObject(mdvname.Data());
585 ULong64_t *addresses = muvec->GetGlobalAddressesAboveCuts(fVars,(Float_t)d->Pt(),nVals);
586 if(fDebug>1)printf("nvals = %d\n",nVals);
587 for(Int_t ivals=0;ivals<nVals;ivals++){
588 if(addresses[ivals]>=muvec->GetNTotCells()){
589 if (fDebug>1) printf("Overflow!!\n");
594 fHistNEvents->Fill(3);
596 //fill the histograms with the appropriate method
597 switch (fDecChannel){
599 FillDplus(d,arrayMC,(Int_t)(ptbin*nHistpermv+addresses[ivals]),isSelected);
602 FillD02p(d,arrayMC,(Int_t)(ptbin*nHistpermv+addresses[ivals]),isSelected);
605 FillDstar(DStarToD0pi,arrayMC,(Int_t)(ptbin*nHistpermv+addresses[ivals]),isSelected);
609 FillDs(d,arrayMC,(Int_t)(ptbin*nHistpermv+addresses[ivals]),isSelected,1);
613 FillD04p(d,arrayMC,(Int_t)(ptbin*nHistpermv+addresses[ivals]),isSelected);
616 FillLambdac(d,arrayMC,(Int_t)(ptbin*nHistpermv+addresses[ivals]),isSelected);
624 if (fDecChannel==3 && isSelected&2){
625 SetPDGdaughterDstopiKK();
627 fRDCuts->GetCutVarsForOpt(d,fVars,fNVars,fPDGdaughters,aod);
629 addresses = muvec->GetGlobalAddressesAboveCuts(fVars,(Float_t)d->Pt(),nVals);
630 if(fDebug>1)printf("nvals = %d\n",nVals);
631 for(Int_t ivals=0;ivals<nVals;ivals++){
632 if(addresses[ivals]>=muvec->GetNTotCells()){
633 if (fDebug>1) printf("Overflow!!\n");
637 FillDs(d,arrayMC,(Int_t)(ptbin*nHistpermv+addresses[ivals]),isSelected,0);
653 //***************************************************************************
655 // Methods used in the UserExec
658 //********************************************************************************************
660 //Methods to fill the istograms with MC information, one for each candidate
661 //NB: the implementation for each candidate is responsibility of the corresponding developer
663 void AliAnalysisTaskSESignificance::FillDplus(AliAODRecoDecayHF* d,TClonesArray *arrayMC,Int_t index,Int_t isSel){
666 AliError("Candidate not selected\n");
670 if(fPartOrAndAntiPart*d->GetCharge()<0)return;
671 Int_t pdgdaughters[3] = {211,321,211};
672 Double_t mass=d->InvMass(3,(UInt_t*)pdgdaughters);
674 fMassHist[index]->Fill(mass);
679 lab = d->MatchToMC(411,arrayMC,3,pdgdaughters);
681 fSigHist[index]->Fill(mass);
683 fBkgHist[index]->Fill(mass);
689 void AliAnalysisTaskSESignificance::FillD02p(AliAODRecoDecayHF* d,TClonesArray *arrayMC,Int_t index,Int_t isSel){
694 Int_t pdgdaughtersD0[2]={211,321};//pi,K
695 Int_t pdgdaughtersD0bar[2]={321,211};//K,pi
697 masses[0]=d->InvMass(fNProngs,(UInt_t*)pdgdaughtersD0); //D0
698 masses[1]=d->InvMass(fNProngs,(UInt_t*)pdgdaughtersD0bar); //D0bar
700 if((isSel==1 || isSel==3) && fPartOrAndAntiPart>=0) fMassHist[index]->Fill(masses[0]);
701 if(isSel>=2 && fPartOrAndAntiPart<=0) fMassHist[index]->Fill(masses[1]);
711 Int_t pdgdaughters[2];
712 pdgdaughters[0]=211;//pi
713 pdgdaughters[1]=321;//K
715 matchtoMC = d->MatchToMC(fPDGmother,arrayMC,fNProngs,pdgdaughters);
717 Int_t prongPdgPlus=421,prongPdgMinus=(-1)*421;
718 if((isSel==1 || isSel==3) && fPartOrAndAntiPart>=0){ //D0
720 AliAODMCParticle *dMC = (AliAODMCParticle*)arrayMC->At(matchtoMC);
721 Int_t pdgMC = dMC->GetPdgCode();
723 if(pdgMC==prongPdgPlus) fSigHist[index]->Fill(masses[0]);
724 else fRflHist[index]->Fill(masses[0]);
726 } else fBkgHist[index]->Fill(masses[0]);
729 if(isSel>=2 && fPartOrAndAntiPart<=0){ //D0bar
731 AliAODMCParticle *dMC = (AliAODMCParticle*)arrayMC->At(matchtoMC);
732 Int_t pdgMC = dMC->GetPdgCode();
734 if(pdgMC==prongPdgMinus) fSigHist[index]->Fill(masses[1]);
735 else fRflHist[index]->Fill(masses[1]);
736 } else fBkgHist[index]->Fill(masses[1]);
741 void AliAnalysisTaskSESignificance::FillDstar(AliAODRecoCascadeHF* dstarD0pi,TClonesArray *arrayMC,Int_t index,Int_t isSel){
744 AliInfo("Dstar selected\n");
746 Double_t mass = dstarD0pi->DeltaInvMass();
748 if((isSel==1 || isSel==3) && fPartOrAndAntiPart>=0) fMassHist[index]->Fill(mass);
749 if(isSel>=2 && fPartOrAndAntiPart<=0) fMassHist[index]->Fill(mass);
752 Int_t matchtoMC = -1;
753 matchtoMC = dstarD0pi->MatchToMC(413,421,fPDGDStarToD0pi, fPDGD0ToKpi, arrayMC);
755 Int_t prongPdgDStarPlus=413,prongPdgDStarMinus=(-1)*413;
757 if ((isSel==1 || isSel==3) && fPartOrAndAntiPart>=0) {
760 AliAODMCParticle *dMC = (AliAODMCParticle*)arrayMC->At(matchtoMC);
761 Int_t pdgMC = dMC->GetPdgCode();
763 if (pdgMC==prongPdgDStarPlus) fSigHist[index]->Fill(mass);
765 dstarD0pi->SetCharge(-1*dstarD0pi->GetCharge());
766 mass = dstarD0pi->DeltaInvMass();
767 fRflHist[index]->Fill(mass);
768 dstarD0pi->SetCharge(-1*dstarD0pi->GetCharge());
771 else fBkgHist[index]->Fill(mass);
774 if (isSel>=2 && fPartOrAndAntiPart<=0) {
777 AliAODMCParticle *dMC = (AliAODMCParticle*)arrayMC->At(matchtoMC);
778 Int_t pdgMC = dMC->GetPdgCode();
780 if (pdgMC==prongPdgDStarMinus) fSigHist[index]->Fill(mass);
782 dstarD0pi->SetCharge(-1*dstarD0pi->GetCharge());
783 mass = dstarD0pi->DeltaInvMass();
784 fRflHist[index]->Fill(mass);
785 dstarD0pi->SetCharge(-1*dstarD0pi->GetCharge());
788 else fBkgHist[index]->Fill(mass);
795 void AliAnalysisTaskSESignificance::FillDs(AliAODRecoDecayHF* d,TClonesArray *arrayMC,Int_t index,Int_t isSel,Int_t optDecay){
800 Int_t pdgDsKKpi[3]={321,321,211};//K,K,pi
801 Int_t pdgDspiKK[3]={211,321,321};//pi,K,K
803 masses[0]=d->InvMass(fNProngs,(UInt_t*)pdgDsKKpi); //Ds
804 masses[1]=d->InvMass(fNProngs,(UInt_t*)pdgDspiKK); //Dsbar
808 labDs = d->MatchToMC(431,arrayMC,3,pdgDsKKpi);
811 Int_t isKKpi=isSel&1;
812 Int_t ispiKK=isSel&2;
813 Int_t isPhiKKpi=isSel&4;
814 Int_t isPhipiKK=isSel&8;
815 Int_t isK0starKKpi=isSel&16;
816 Int_t isK0starpiKK=isSel&32;
819 if(fDsChannel==kPhi && (isPhiKKpi==0 && isPhipiKK==0)) return;
820 if(fDsChannel==kK0star && (isK0starKKpi==0 && isK0starpiKK==0)) return;
823 if(isKKpi && fPartOrAndAntiPart*d->GetCharge()>=0) {
824 if(fDsChannel==kPhi && isPhiKKpi==0) return;
825 if(fDsChannel==kK0star && isK0starKKpi==0) return;
827 fMassHist[index]->Fill(masses[0]);
831 Int_t labDau0=((AliAODTrack*)d->GetDaughter(0))->GetLabel();
832 AliAODMCParticle* p=(AliAODMCParticle*)arrayMC->UncheckedAt(labDau0);
833 Int_t pdgCode0=TMath::Abs(p->GetPdgCode());
835 fSigHist[index]->Fill(masses[0]); //signal
837 fRflHist[index]->Fill(masses[0]); //Reflected signal
840 fBkgHist[index]->Fill(masses[0]); // Background
847 if(ispiKK && fPartOrAndAntiPart*d->GetCharge()>=0){
848 if(fDsChannel==kPhi && isPhipiKK==0) return;
849 if(fDsChannel==kK0star && isK0starpiKK==0) return;
851 fMassHist[index]->Fill(masses[1]);
855 Int_t labDau0=((AliAODTrack*)d->GetDaughter(0))->GetLabel();
856 AliAODMCParticle* p=(AliAODMCParticle*)arrayMC->UncheckedAt(labDau0);
857 Int_t pdgCode0=TMath::Abs(p->GetPdgCode());
859 fSigHist[index]->Fill(masses[1]);
861 fRflHist[index]->Fill(masses[1]);
864 fBkgHist[index]->Fill(masses[1]);
871 void AliAnalysisTaskSESignificance::FillD04p(AliAODRecoDecayHF* /*d*/,TClonesArray */*arrayMC*/,Int_t /*index*/,Int_t /*matchtoMC*/){
872 //D0->Kpipipi channel
873 AliInfo("D0 in 4 prongs channel not implemented\n");
877 void AliAnalysisTaskSESignificance::FillLambdac(AliAODRecoDecayHF* d,TClonesArray* arrayMC,Int_t index,Int_t isSel){
881 Int_t pdgdaughtersLc[3]={2212,321,211}; //p,K,pi
882 masses[0]=d->InvMass(fNProngs,(UInt_t*)pdgdaughtersLc);
883 Int_t pdgdaughtersLc2[3]={211,321,2212}; //pi,K,p
884 masses[1]=d->InvMass(fNProngs,(UInt_t*)pdgdaughtersLc2);
887 if(fPartOrAndAntiPart==0 || fPartOrAndAntiPart==d->GetCharge()) {
889 // isSel=1 : p K pi ; isSel=2 : pi K p ;
890 if(isSel==1 || isSel==3) fMassHist[index]->Fill(masses[0]);
891 if(isSel>=2) fMassHist[index]->Fill(masses[1]);
893 // Check the MC truth
900 Int_t matchtoMC = -1;
902 Int_t pPDG = 2212; // p
903 Int_t kPDG = 321; // K
904 Int_t piPDG = 211; // pi
905 Int_t absPdgMom = 4122;
906 matchtoMC = d->MatchToMC(absPdgMom,arrayMC,fNProngs,pdgdaughtersLc);
910 AliAODMCParticle *dMC = (AliAODMCParticle*)arrayMC->At(matchtoMC);
911 Int_t pdgMC = dMC->GetPdgCode();
912 if (TMath::Abs(pdgMC)!=absPdgMom) AliInfo("What's up, isn't it a lambdac ?!");
913 Int_t labDau0 = ((AliAODTrack*)d->GetDaughter(0))->GetLabel();
914 AliAODMCParticle* p0 = (AliAODMCParticle*)arrayMC->UncheckedAt(labDau0);
915 Int_t pdgCode0 = TMath::Abs(p0->GetPdgCode());
916 Int_t labDau1 = ((AliAODTrack*)d->GetDaughter(1))->GetLabel();
917 AliAODMCParticle* p1 = (AliAODMCParticle*)arrayMC->UncheckedAt(labDau1);
918 Int_t pdgCode1 = TMath::Abs(p1->GetPdgCode());
919 Int_t labDau2 = ((AliAODTrack*)d->GetDaughter(2))->GetLabel();
920 AliAODMCParticle* p2 = (AliAODMCParticle*)arrayMC->UncheckedAt(labDau2);
921 Int_t pdgCode2 = TMath::Abs(p2->GetPdgCode());
923 // Fill in the histograms in case of p K pi decays
925 if(pdgCode0==pPDG && pdgCode1==kPDG && pdgCode2==piPDG){
926 fSigHist[index]->Fill(masses[0]);
928 fRflHist[index]->Fill(masses[0]);
931 // Fill in the histograms in case of pi K p decays
933 if(pdgCode0==piPDG && pdgCode1==kPDG && pdgCode2==pPDG){
934 fSigHist[index]->Fill(masses[1]);
936 fRflHist[index]->Fill(masses[1]);
940 if(ispKpi==1) fBkgHist[index]->Fill(masses[0]);
941 if(ispiKp==2) fBkgHist[index]->Fill(masses[1]);
950 //________________________________________________________________________
951 void AliAnalysisTaskSESignificance::Terminate(Option_t */*option*/)
953 // Terminate analysis
955 if(fDebug > 1) printf("AnalysisTaskSESignificance: Terminate() \n");
958 fOutput = dynamic_cast<TList*> (GetOutputData(1));
960 printf("ERROR: fOutput not available\n");
964 fCutList = dynamic_cast<TList*> (GetOutputData(2));
966 printf("ERROR: fCutList not available\n");
970 AliMultiDimVector* mdvtmp=(AliMultiDimVector*)fCutList->FindObject("multiDimVectorPtBin0");
972 cout<<"multidimvec not found in TList"<<endl;
976 Int_t nHist=mdvtmp->GetNTotCells();
977 TCanvas *c1=new TCanvas("c1","Invariant mass distribution - loose cuts",500,500);
979 for(Int_t i=0;i<nHist;i++){
986 hisname.Form("hMass_%d",i);
987 signame.Form("hSig_%d",i);
988 bkgname.Form("hBkg_%d",i);
989 rflname.Form("hRfl_%d",i);
991 fMassHist[i]=dynamic_cast<TH1F*>(fOutput->FindObject(hisname.Data()));
993 if (!drawn && fMassHist[i]->GetEntries() > 0){
995 fMassHist[i]->Draw();
1000 fSigHist[i]=dynamic_cast<TH1F*>(fOutput->FindObject(signame.Data()));
1001 fBkgHist[i]=dynamic_cast<TH1F*>(fOutput->FindObject(bkgname.Data()));
1002 if(fDecChannel != AliAnalysisTaskSESignificance::kDplustoKpipi) fRflHist[i]=dynamic_cast<TH1F*>(fOutput->FindObject(rflname.Data()));
1012 //_________________________________________________________________________________________________
1013 Int_t AliAnalysisTaskSESignificance::CheckOrigin(const AliAODMCParticle* mcPart, const TClonesArray* mcArray)const{
1016 // checking whether the very mother of the D0 is a charm or a bottom quark
1019 Int_t pdgGranma = 0;
1021 mother = mcPart->GetMother();
1025 AliDebug(2,Form("mother at step %d = %d", istep, mother));
1026 AliAODMCParticle* mcGranma = dynamic_cast<AliAODMCParticle*>(mcArray->At(mother));
1027 if(!mcGranma) break;
1028 pdgGranma = mcGranma->GetPdgCode();
1029 AliDebug(2,Form("Pdg mother at step %d = %d", istep, pdgGranma));
1030 Int_t abspdgGranma = TMath::Abs(pdgGranma);
1031 if ((abspdgGranma > 500 && abspdgGranma < 600) || (abspdgGranma > 5000 && abspdgGranma < 6000)) {
1034 mother = mcGranma->GetMother();
1038 //_________________________________________________________________________________________________