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"
51 #include "AliAnalysisTaskSE.h"
90 fPartOrAndAntiPart(0),
123 fDecChannel(decaychannel),
127 fSelectionlevel(selectionlevel),
130 fPartOrAndAntiPart(0),
149 DefineOutput(1,TList::Class());
150 DefineOutput(2,TList::Class());
151 DefineOutput(3,AliRDHFCuts::Class());
259 TString mdvname=Form(
"multiDimVectorPtBin%d",i);
262 for(
Int_t ivar=0;ivar<nvars;ivar++){
263 if(varsforopt[ivar]){
267 AliFatal(Form(
"tight and loose cut for optimization variable number %d are the same in ptbin %d\n",ic,i));
271 if(uppervars[ivar]&&lowermdv){
272 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));
275 if(!uppervars[ivar]&&!lowermdv){
276 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));
289 AliInfo(
"B feed down not allowed without MC info\n");
296 Int_t abspdg=TMath::Abs(pdg);
297 mass=TDatabasePDG::Instance()->GetParticle(abspdg)->Mass();
317 if(fDebug > 1) printf(
"AnalysisTaskSESignificance::Init() \n");
380 if(fDebug > 1) printf(
"AnalysisTaskSESignificance::UserCreateOutputObjects() \n");
385 fOutput->SetName(
"OutputHistos");
389 cout<<
"ncells = "<<nHist<<
" n ptbins = "<<
fNPtBins<<endl;
391 cout<<
"Total = "<<nHist<<endl;
392 for(
Int_t i=0;i<nHist;i++){
400 hisname.Form(
"hMass_%d",i);
401 signame.Form(
"hSig_%d",i);
402 bkgname.Form(
"hBkg_%d",i);
403 rflname.Form(
"hRfl_%d",i);
405 title.Form(
"Invariant mass;M[GeV/c^{2}];Entries");
428 fHistNEvents=
new TH1F(
"fHistNEvents",
"Number of AODs scanned",8,-0.5,7.5);
430 fHistNEvents->GetXaxis()->SetBinLabel(2,
"nEvSelected (vtx)");
431 fHistNEvents->GetXaxis()->SetBinLabel(3,
"nCandidatesSelected");
432 fHistNEvents->GetXaxis()->SetBinLabel(4,
"nTotEntries Mass hists");
436 fHistNEvents->GetXaxis()->SetBinLabel(7,
"MC Cand from c");
437 fHistNEvents->GetXaxis()->SetBinLabel(8,
"MC Cand from b");
439 fHistNEvents->GetXaxis()->SetBinLabel(7,
"N candidates");
460 if (matchingAODdeltaAODlevel<0 || (matchingAODdeltaAODlevel==0 &&
fAODProtection==1)) {
465 if(fDebug>2) printf(
"Analysing decay %d\n",
fDecChannel);
468 TClonesArray *arrayProng =0;
470 if(!aod && AODEvent() && IsStandardAOD()) {
476 AliAODHandler* aodHandler = (AliAODHandler*)
477 ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
478 if(aodHandler->GetExtensions()) {
480 AliAODExtension *ext = (AliAODExtension*)aodHandler->GetExtensions()->FindObject(
"AliAOD.VertexingHF.root");
482 arrayProng=(TClonesArray*)aodFromExt->GetList()->FindObject(
fBranchName.Data());
486 arrayProng=(TClonesArray*)aod->GetList()->FindObject(
fBranchName.Data());
488 if(!aod || !arrayProng) {
489 AliError(
"AliAnalysisTaskSESignificance::UserExec:Branch not found!\n");
495 if(!aod->GetPrimaryVertex() || TMath::Abs(aod->GetMagneticField())<0.001)
return;
496 TClonesArray *arrayMC=0;
497 AliAODMCHeader *mcHeader=0;
502 arrayMC = (TClonesArray*)aod->GetList()->FindObject(AliAODMCParticle::StdBranchName());
504 AliError(
"AliAnalysisTaskSESignificance::UserExec:MC particles branch not found!\n");
509 mcHeader = (AliAODMCHeader*)aod->GetList()->FindObject(AliAODMCHeader::StdBranchName());
511 AliError(
"AliAnalysisTaskSESignificance::UserExec:MC header branch not found!\n");
523 Int_t nProng = arrayProng->GetEntriesFast();
524 if(fDebug>1) printf(
"Number of D2H: %d\n",nProng);
527 TString trigclass=aod->GetFiredTriggerClasses();
528 if(trigclass.Contains(
"C0SMH-B-NOPF-ALLNOTRD") || trigclass.Contains(
"C0SMH-B-NOPF-ALL"))
fHistNEvents->Fill(5);
538 for (
Int_t iProng = 0; iProng < nProng; iProng++) {
567 if(!isSelBit)
continue;
571 if (!DStarToD0pi->GetSecondaryVtx())
continue;
573 if (!D0Particle)
continue;
582 AliAODMCParticle *partD = (AliAODMCParticle*)arrayMC->At(labD);
584 Int_t abspdgGranma = TMath::Abs(pdgGranma);
585 if ((abspdgGranma > 500 && abspdgGranma < 600) || (abspdgGranma > 5000 && abspdgGranma < 6000)) {
587 AliDebug(2,Form(
"Particle has a b-meson, or b-baryon mother (pdg code mother = %d )--> not coming from a c-quark, skipping...", pdgGranma));
599 if(isSelected&&isFidAcc) {
601 if(fDebug>1) printf(
"+++++++Is Selected\n");
607 if(ptbin==-1)
continue;
608 TString mdvname=Form(
"multiDimVectorPtBin%d",ptbin);
612 if(fDebug>1)printf(
"nvals = %d\n",nVals);
613 for(
Int_t ivals=0;ivals<nVals;ivals++){
615 if (fDebug>1) printf(
"Overflow!!\n");
625 FillDplus(d,arrayMC,(
Int_t)(ptbin*nHistpermv+addresses[ivals]),isSelected);
628 FillD02p(d,arrayMC,(
Int_t)(ptbin*nHistpermv+addresses[ivals]),isSelected);
631 FillDstar(DStarToD0pi,arrayMC,(
Int_t)(ptbin*nHistpermv+addresses[ivals]),isSelected);
635 FillDs(d,arrayMC,(
Int_t)(ptbin*nHistpermv+addresses[ivals]),isSelected,1);
639 FillD04p(d,arrayMC,(
Int_t)(ptbin*nHistpermv+addresses[ivals]),isSelected);
642 FillLambdac(d,arrayMC,(
Int_t)(ptbin*nHistpermv+addresses[ivals]),isSelected);
656 if(fDebug>1)printf(
"nvals = %d\n",nVals);
657 for(
Int_t ivals=0;ivals<nVals;ivals++){
659 if (fDebug>1) printf(
"Overflow!!\n");
663 FillDs(d,arrayMC,(
Int_t)(ptbin*nHistpermv+addresses[ivals]),isSelected,0);
692 AliError(
"Candidate not selected\n");
697 Int_t pdgdaughters[3] = {211,321,211};
705 lab = d->MatchToMC(411,arrayMC,3,pdgdaughters);
720 Int_t pdgdaughtersD0[2]={211,321};
721 Int_t pdgdaughtersD0bar[2]={321,211};
737 Int_t pdgdaughters[2];
743 Int_t prongPdgPlus=421,prongPdgMinus=(-1)*421;
746 AliAODMCParticle *dMC = (AliAODMCParticle*)arrayMC->At(matchtoMC);
747 Int_t pdgMC = dMC->GetPdgCode();
749 if(pdgMC==prongPdgPlus)
fSigHist[index]->Fill(masses[0]);
750 else fRflHist[index]->Fill(masses[0]);
752 }
else fBkgHist[index]->Fill(masses[0]);
757 AliAODMCParticle *dMC = (AliAODMCParticle*)arrayMC->At(matchtoMC);
758 Int_t pdgMC = dMC->GetPdgCode();
760 if(pdgMC==prongPdgMinus)
fSigHist[index]->Fill(masses[1]);
761 else fRflHist[index]->Fill(masses[1]);
762 }
else fBkgHist[index]->Fill(masses[1]);
770 AliInfo(
"Dstar selected\n");
777 Int_t matchtoMC = -1;
780 Int_t prongPdgDStarPlus=413;
785 AliAODMCParticle *dMC = (AliAODMCParticle*)arrayMC->At(matchtoMC);
786 Int_t pdgMC = dMC->GetPdgCode();
788 if (pdgMC==prongPdgDStarPlus)
fSigHist[index]->Fill(mass);
790 dstarD0pi->SetCharge(-1*dstarD0pi->GetCharge());
793 dstarD0pi->SetCharge(-1*dstarD0pi->GetCharge());
807 Int_t pdgDsKKpi[3]={321,321,211};
808 Int_t pdgDspiKK[3]={211,321,321};
815 labDs = d->MatchToMC(431,arrayMC,3,pdgDsKKpi);
818 Int_t isKKpi=isSel&1;
819 Int_t ispiKK=isSel&2;
820 Int_t isPhiKKpi=isSel&4;
821 Int_t isPhipiKK=isSel&8;
822 Int_t isK0starKKpi=isSel&16;
823 Int_t isK0starpiKK=isSel&32;
838 Int_t labDau0=((AliAODTrack*)d->GetDaughter(0))->GetLabel();
839 AliAODMCParticle* p=(AliAODMCParticle*)arrayMC->UncheckedAt(labDau0);
840 Int_t pdgCode0=TMath::Abs(p->GetPdgCode());
862 Int_t labDau0=((AliAODTrack*)d->GetDaughter(0))->GetLabel();
863 AliAODMCParticle* p=(AliAODMCParticle*)arrayMC->UncheckedAt(labDau0);
864 Int_t pdgCode0=TMath::Abs(p->GetPdgCode());
880 AliInfo(
"D0 in 4 prongs channel not implemented\n");
888 Int_t pdgdaughtersLc[3]={2212,321,211};
890 Int_t pdgdaughtersLc2[3]={211,321,2212};
897 if(isSel==1 || isSel==3)
fMassHist[index]->Fill(masses[0]);
898 if(isSel>=2)
fMassHist[index]->Fill(masses[1]);
907 Int_t matchtoMC = -1;
912 Int_t absPdgMom = 4122;
913 matchtoMC = d->MatchToMC(absPdgMom,arrayMC,
fNProngs,pdgdaughtersLc);
917 AliAODMCParticle *dMC = (AliAODMCParticle*)arrayMC->At(matchtoMC);
918 Int_t pdgMC = dMC->GetPdgCode();
919 if (TMath::Abs(pdgMC)!=absPdgMom) AliInfo(
"What's up, isn't it a lambdac ?!");
920 Int_t labDau0 = ((AliAODTrack*)d->GetDaughter(0))->GetLabel();
921 AliAODMCParticle* p0 = (AliAODMCParticle*)arrayMC->UncheckedAt(labDau0);
922 Int_t pdgCode0 = TMath::Abs(p0->GetPdgCode());
923 Int_t labDau1 = ((AliAODTrack*)d->GetDaughter(1))->GetLabel();
924 AliAODMCParticle* p1 = (AliAODMCParticle*)arrayMC->UncheckedAt(labDau1);
925 Int_t pdgCode1 = TMath::Abs(p1->GetPdgCode());
926 Int_t labDau2 = ((AliAODTrack*)d->GetDaughter(2))->GetLabel();
927 AliAODMCParticle* p2 = (AliAODMCParticle*)arrayMC->UncheckedAt(labDau2);
928 Int_t pdgCode2 = TMath::Abs(p2->GetPdgCode());
932 if(pdgCode0==pPDG && pdgCode1==kPDG && pdgCode2==piPDG){
940 if(pdgCode0==piPDG && pdgCode1==kPDG && pdgCode2==pPDG){
947 if(ispKpi==1)
fBkgHist[index]->Fill(masses[0]);
948 if(ispiKp==2)
fBkgHist[index]->Fill(masses[1]);
962 if(fDebug > 1) printf(
"AnalysisTaskSESignificance: Terminate() \n");
967 printf(
"ERROR: fOutput not available\n");
973 printf(
"ERROR: fCutList not available\n");
979 cout<<
"multidimvec not found in TList"<<endl;
984 TCanvas *c1=
new TCanvas(
"c1",
"Invariant mass distribution - loose cuts",500,500);
986 for(
Int_t i=0;i<nHist;i++){
993 hisname.Form(
"hMass_%d",i);
994 signame.Form(
"hSig_%d",i);
995 bkgname.Form(
"hBkg_%d",i);
996 rflname.Form(
"hRfl_%d",i);
1000 if (!drawn &&
fMassHist[i]->GetEntries() > 0){
1026 Int_t pdgGranma = 0;
1028 mother = mcPart->GetMother();
1032 AliDebug(2,Form(
"mother at step %d = %d", istep, mother));
1033 AliAODMCParticle* mcGranma =
dynamic_cast<AliAODMCParticle*
>(mcArray->At(mother));
1034 if(!mcGranma)
break;
1035 pdgGranma = mcGranma->GetPdgCode();
1036 AliDebug(2,Form(
"Pdg mother at step %d = %d", istep, pdgGranma));
1037 Int_t abspdgGranma = TMath::Abs(pdgGranma);
1038 if ((abspdgGranma > 500 && abspdgGranma < 600) || (abspdgGranma > 5000 && abspdgGranma < 6000)) {
1041 mother = mcGranma->GetMother();
Float_t fLowmasslimit
upper inv mass limit for histos
virtual void GetCutVarsForOpt(AliAODRecoDecayHF *d, Float_t *vars, Int_t nvars, Int_t *pdgdaughters)=0
void SetBFeedDown(FeedDownEnum flagB)
Float_t fVars[kMaxCutVar]
number of selection variables
AliRDHFCuts * fRDCuts
lower inv mass limit for histos
virtual void UserExec(Option_t *option)
Double_t DeltaInvMass() const
AliAnalysisTaskSESignificance()
Bool_t HasSelectionBit(Int_t i) const
Int_t fNBins
array with values of cut variables
Int_t MatchToMC(Int_t pdgabs, Int_t pdgabs2prong, Int_t *pdgDg, Int_t *pdgDg2prong, TClonesArray *mcArray, Bool_t isV0=kFALSE) const
Int_t fPDGD0ToKpi[2]
PDG codes for the particles in the D* -> pi + D0 decay.
Int_t fPDGdaughters[4]
number of prong of the decay channel
static Int_t CheckMatchingAODdeltaAODevents()
Int_t fNPtBins
prong cut values
TH1F * fBkgHist[kMaxNHist]
!hist. for inv mass (bkg from MC truth)
void SetPDGdaughterDstoKKpi()
FeedDownEnum fBFeedDown
flag to use selection bit (speed up candidates selection)
Int_t GetWhyRejection() const
TList * fOutput
! list send on output slot 0
TString * GetVarNames() const
Int_t fPartOrAndAntiPart
number of bins in the mass histograms
void FillDs(AliAODRecoDecayHF *d, TClonesArray *arrayMC, Int_t index, Int_t isSel, Int_t optDecay)
Int_t fSelectionlevel
AOD branch name for channel.
Bool_t fUseSelBit
flag for access to MC
Int_t fNProngs
PDG code of D meson.
Class for cuts on AOD reconstructed D+->Kpipi.
void FillLambdac(AliAODRecoDecayHF *d, TClonesArray *arrayMC, Int_t index, Int_t isSel)
virtual ~AliAnalysisTaskSESignificance()
Bool_t * GetIsUpperCut() const
TH1F * fRflHist[kMaxNHist]
!hist. for inv mass (bkg from MC truth)
Bool_t * GetVarsForOpt() const
Int_t CheckOrigin(const AliAODMCParticle *mcPart, const TClonesArray *mcArray) const
virtual void UserCreateOutputObjects()
Implementation of interface methods.
void SetPDGdaughterDstopiKK()
Int_t GetNVarsForOpt() const
ULong64_t * GetGlobalAddressesAboveCuts(const Float_t *values, Float_t pt, Int_t &nVals) const
Int_t fAODProtection
number of pt bins
Int_t fPDGmother
decay channel identifier
void FillD04p(AliAODRecoDecayHF *d, TClonesArray *arrayMC, Int_t index, Int_t isSel)
Bool_t CheckConsistency()
Int_t fPDGDStarToD0pi[2]
Ds resonant channel selected.
Bool_t Data(TH1F *h, Double_t *rangefit, Bool_t writefit, Double_t &sgn, Double_t &errsgn, Double_t &bkg, Double_t &errbkg, Double_t &sgnf, Double_t &errsgnf, Double_t &sigmafit, Int_t &status)
TString fBranchName
PDG codes of daughters.
void FillDplus(AliAODRecoDecayHF *d, TClonesArray *arrayMC, Int_t index, Int_t isSel)
Bool_t IsEventSelected(AliVEvent *event)
ULong64_t GetNTotCells() const
virtual void PrintAll() const
ClassImp(AliAnalysisTaskCRC) AliAnalysisTaskCRC
void SetDsChannel(Int_t chan)
void FillD02p(AliAODRecoDecayHF *d, TClonesArray *arrayMC, Int_t index, Int_t isSel)
void SetMassLimits(Float_t range, Int_t pdg)
Bool_t IsSelected(TObject *obj)
virtual void Terminate(Option_t *option)
Int_t fNVars
selection level: kALL,kTracks,kCandidate
TH1F * fHistNEvents
! hist of n of aods
AliAODRecoDecayHF2Prong * Get2Prong() const
virtual Bool_t IsInFiducialAcceptance(Double_t, Double_t) const
Int_t PtBin(Double_t pt) const
TH1F * fMassHist[kMaxNHist]
Multidimvector container.
Int_t fDecChannel
flag to search for D from B decays
void FillDstar(AliAODRecoCascadeHF *dstarD0pi, TClonesArray *arrayMC, Int_t index, Int_t isSel)
Int_t fDsChannel
fill histograms with particle only (+1), antiparticle only (-1), both (0)
TH1F * fSigHist[kMaxNHist]
!hist. for inv mass (sig from MC truth)