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"
89 fPartOrAndAntiPart(0),
121 fDecChannel(decaychannel),
125 fSelectionlevel(selectionlevel),
128 fPartOrAndAntiPart(0),
147 DefineOutput(1,TList::Class());
148 DefineOutput(2,TList::Class());
149 DefineOutput(3,AliRDHFCuts::Class());
257 TString mdvname=Form(
"multiDimVectorPtBin%d",i);
260 for(
Int_t ivar=0;ivar<nvars;ivar++){
261 if(varsforopt[ivar]){
265 AliFatal(Form(
"tight and loose cut for optimization variable number %d are the same in ptbin %d\n",ic,i));
269 if(uppervars[ivar]&&lowermdv){
270 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));
273 if(!uppervars[ivar]&&!lowermdv){
274 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));
287 AliInfo(
"B feed down not allowed without MC info\n");
294 Int_t abspdg=TMath::Abs(pdg);
295 mass=TDatabasePDG::Instance()->GetParticle(abspdg)->Mass();
315 if(fDebug > 1) printf(
"AnalysisTaskSESignificance::Init() \n");
378 if(fDebug > 1) printf(
"AnalysisTaskSESignificance::UserCreateOutputObjects() \n");
383 fOutput->SetName(
"OutputHistos");
387 cout<<
"ncells = "<<nHist<<
" n ptbins = "<<
fNPtBins<<endl;
389 cout<<
"Total = "<<nHist<<endl;
390 for(
Int_t i=0;i<nHist;i++){
398 hisname.Form(
"hMass_%d",i);
399 signame.Form(
"hSig_%d",i);
400 bkgname.Form(
"hBkg_%d",i);
401 rflname.Form(
"hRfl_%d",i);
403 title.Form(
"Invariant mass;M[GeV/c^{2}];Entries");
426 fHistNEvents=
new TH1F(
"fHistNEvents",
"Number of AODs scanned",8,-0.5,7.5);
428 fHistNEvents->GetXaxis()->SetBinLabel(2,
"nEvSelected (vtx)");
429 fHistNEvents->GetXaxis()->SetBinLabel(3,
"nCandidatesSelected");
430 fHistNEvents->GetXaxis()->SetBinLabel(4,
"nTotEntries Mass hists");
434 fHistNEvents->GetXaxis()->SetBinLabel(7,
"MC Cand from c");
435 fHistNEvents->GetXaxis()->SetBinLabel(8,
"MC Cand from b");
437 fHistNEvents->GetXaxis()->SetBinLabel(7,
"N candidates");
454 if(fDebug>2) printf(
"Analysing decay %d\n",
fDecChannel);
457 TClonesArray *arrayProng =0;
459 if(!aod && AODEvent() && IsStandardAOD()) {
465 AliAODHandler* aodHandler = (AliAODHandler*)
466 ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
467 if(aodHandler->GetExtensions()) {
469 AliAODExtension *ext = (AliAODExtension*)aodHandler->GetExtensions()->FindObject(
"AliAOD.VertexingHF.root");
471 arrayProng=(TClonesArray*)aodFromExt->GetList()->FindObject(
fBranchName.Data());
475 arrayProng=(TClonesArray*)aod->GetList()->FindObject(
fBranchName.Data());
477 if(!aod || !arrayProng) {
478 AliError(
"AliAnalysisTaskSESignificance::UserExec:Branch not found!\n");
484 if(!aod->GetPrimaryVertex() || TMath::Abs(aod->GetMagneticField())<0.001)
return;
485 TClonesArray *arrayMC=0;
486 AliAODMCHeader *mcHeader=0;
491 arrayMC = (TClonesArray*)aod->GetList()->FindObject(AliAODMCParticle::StdBranchName());
493 AliError(
"AliAnalysisTaskSESignificance::UserExec:MC particles branch not found!\n");
498 mcHeader = (AliAODMCHeader*)aod->GetList()->FindObject(AliAODMCHeader::StdBranchName());
500 AliError(
"AliAnalysisTaskSESignificance::UserExec:MC header branch not found!\n");
512 Int_t nProng = arrayProng->GetEntriesFast();
513 if(fDebug>1) printf(
"Number of D2H: %d\n",nProng);
516 TString trigclass=aod->GetFiredTriggerClasses();
517 if(trigclass.Contains(
"C0SMH-B-NOPF-ALLNOTRD") || trigclass.Contains(
"C0SMH-B-NOPF-ALL"))
fHistNEvents->Fill(5);
527 for (
Int_t iProng = 0; iProng < nProng; iProng++) {
556 if(!isSelBit)
continue;
560 if (!DStarToD0pi->GetSecondaryVtx())
continue;
562 if (!D0Particle)
continue;
571 AliAODMCParticle *partD = (AliAODMCParticle*)arrayMC->At(labD);
573 Int_t abspdgGranma = TMath::Abs(pdgGranma);
574 if ((abspdgGranma > 500 && abspdgGranma < 600) || (abspdgGranma > 5000 && abspdgGranma < 6000)) {
576 AliDebug(2,Form(
"Particle has a b-meson, or b-baryon mother (pdg code mother = %d )--> not coming from a c-quark, skipping...", pdgGranma));
588 if(isSelected&&isFidAcc) {
590 if(fDebug>1) printf(
"+++++++Is Selected\n");
596 if(ptbin==-1)
continue;
597 TString mdvname=Form(
"multiDimVectorPtBin%d",ptbin);
601 if(fDebug>1)printf(
"nvals = %d\n",nVals);
602 for(
Int_t ivals=0;ivals<nVals;ivals++){
604 if (fDebug>1) printf(
"Overflow!!\n");
614 FillDplus(d,arrayMC,(
Int_t)(ptbin*nHistpermv+addresses[ivals]),isSelected);
617 FillD02p(d,arrayMC,(
Int_t)(ptbin*nHistpermv+addresses[ivals]),isSelected);
620 FillDstar(DStarToD0pi,arrayMC,(
Int_t)(ptbin*nHistpermv+addresses[ivals]),isSelected);
624 FillDs(d,arrayMC,(
Int_t)(ptbin*nHistpermv+addresses[ivals]),isSelected,1);
628 FillD04p(d,arrayMC,(
Int_t)(ptbin*nHistpermv+addresses[ivals]),isSelected);
631 FillLambdac(d,arrayMC,(
Int_t)(ptbin*nHistpermv+addresses[ivals]),isSelected);
645 if(fDebug>1)printf(
"nvals = %d\n",nVals);
646 for(
Int_t ivals=0;ivals<nVals;ivals++){
648 if (fDebug>1) printf(
"Overflow!!\n");
652 FillDs(d,arrayMC,(
Int_t)(ptbin*nHistpermv+addresses[ivals]),isSelected,0);
681 AliError(
"Candidate not selected\n");
686 Int_t pdgdaughters[3] = {211,321,211};
694 lab = d->MatchToMC(411,arrayMC,3,pdgdaughters);
709 Int_t pdgdaughtersD0[2]={211,321};
710 Int_t pdgdaughtersD0bar[2]={321,211};
726 Int_t pdgdaughters[2];
732 Int_t prongPdgPlus=421,prongPdgMinus=(-1)*421;
735 AliAODMCParticle *dMC = (AliAODMCParticle*)arrayMC->At(matchtoMC);
736 Int_t pdgMC = dMC->GetPdgCode();
738 if(pdgMC==prongPdgPlus)
fSigHist[index]->Fill(masses[0]);
739 else fRflHist[index]->Fill(masses[0]);
741 }
else fBkgHist[index]->Fill(masses[0]);
746 AliAODMCParticle *dMC = (AliAODMCParticle*)arrayMC->At(matchtoMC);
747 Int_t pdgMC = dMC->GetPdgCode();
749 if(pdgMC==prongPdgMinus)
fSigHist[index]->Fill(masses[1]);
750 else fRflHist[index]->Fill(masses[1]);
751 }
else fBkgHist[index]->Fill(masses[1]);
759 AliInfo(
"Dstar selected\n");
766 Int_t matchtoMC = -1;
769 Int_t prongPdgDStarPlus=413;
774 AliAODMCParticle *dMC = (AliAODMCParticle*)arrayMC->At(matchtoMC);
775 Int_t pdgMC = dMC->GetPdgCode();
777 if (pdgMC==prongPdgDStarPlus)
fSigHist[index]->Fill(mass);
779 dstarD0pi->SetCharge(-1*dstarD0pi->GetCharge());
782 dstarD0pi->SetCharge(-1*dstarD0pi->GetCharge());
796 Int_t pdgDsKKpi[3]={321,321,211};
797 Int_t pdgDspiKK[3]={211,321,321};
804 labDs = d->MatchToMC(431,arrayMC,3,pdgDsKKpi);
807 Int_t isKKpi=isSel&1;
808 Int_t ispiKK=isSel&2;
809 Int_t isPhiKKpi=isSel&4;
810 Int_t isPhipiKK=isSel&8;
811 Int_t isK0starKKpi=isSel&16;
812 Int_t isK0starpiKK=isSel&32;
827 Int_t labDau0=((AliAODTrack*)d->GetDaughter(0))->GetLabel();
828 AliAODMCParticle* p=(AliAODMCParticle*)arrayMC->UncheckedAt(labDau0);
829 Int_t pdgCode0=TMath::Abs(p->GetPdgCode());
851 Int_t labDau0=((AliAODTrack*)d->GetDaughter(0))->GetLabel();
852 AliAODMCParticle* p=(AliAODMCParticle*)arrayMC->UncheckedAt(labDau0);
853 Int_t pdgCode0=TMath::Abs(p->GetPdgCode());
869 AliInfo(
"D0 in 4 prongs channel not implemented\n");
877 Int_t pdgdaughtersLc[3]={2212,321,211};
879 Int_t pdgdaughtersLc2[3]={211,321,2212};
886 if(isSel==1 || isSel==3)
fMassHist[index]->Fill(masses[0]);
887 if(isSel>=2)
fMassHist[index]->Fill(masses[1]);
896 Int_t matchtoMC = -1;
901 Int_t absPdgMom = 4122;
902 matchtoMC = d->MatchToMC(absPdgMom,arrayMC,
fNProngs,pdgdaughtersLc);
906 AliAODMCParticle *dMC = (AliAODMCParticle*)arrayMC->At(matchtoMC);
907 Int_t pdgMC = dMC->GetPdgCode();
908 if (TMath::Abs(pdgMC)!=absPdgMom) AliInfo(
"What's up, isn't it a lambdac ?!");
909 Int_t labDau0 = ((AliAODTrack*)d->GetDaughter(0))->GetLabel();
910 AliAODMCParticle* p0 = (AliAODMCParticle*)arrayMC->UncheckedAt(labDau0);
911 Int_t pdgCode0 = TMath::Abs(p0->GetPdgCode());
912 Int_t labDau1 = ((AliAODTrack*)d->GetDaughter(1))->GetLabel();
913 AliAODMCParticle* p1 = (AliAODMCParticle*)arrayMC->UncheckedAt(labDau1);
914 Int_t pdgCode1 = TMath::Abs(p1->GetPdgCode());
915 Int_t labDau2 = ((AliAODTrack*)d->GetDaughter(2))->GetLabel();
916 AliAODMCParticle* p2 = (AliAODMCParticle*)arrayMC->UncheckedAt(labDau2);
917 Int_t pdgCode2 = TMath::Abs(p2->GetPdgCode());
921 if(pdgCode0==pPDG && pdgCode1==kPDG && pdgCode2==piPDG){
929 if(pdgCode0==piPDG && pdgCode1==kPDG && pdgCode2==pPDG){
936 if(ispKpi==1)
fBkgHist[index]->Fill(masses[0]);
937 if(ispiKp==2)
fBkgHist[index]->Fill(masses[1]);
951 if(fDebug > 1) printf(
"AnalysisTaskSESignificance: Terminate() \n");
956 printf(
"ERROR: fOutput not available\n");
962 printf(
"ERROR: fCutList not available\n");
968 cout<<
"multidimvec not found in TList"<<endl;
973 TCanvas *c1=
new TCanvas(
"c1",
"Invariant mass distribution - loose cuts",500,500);
975 for(
Int_t i=0;i<nHist;i++){
982 hisname.Form(
"hMass_%d",i);
983 signame.Form(
"hSig_%d",i);
984 bkgname.Form(
"hBkg_%d",i);
985 rflname.Form(
"hRfl_%d",i);
989 if (!drawn &&
fMassHist[i]->GetEntries() > 0){
1015 Int_t pdgGranma = 0;
1017 mother = mcPart->GetMother();
1021 AliDebug(2,Form(
"mother at step %d = %d", istep, mother));
1022 AliAODMCParticle* mcGranma =
dynamic_cast<AliAODMCParticle*
>(mcArray->At(mother));
1023 if(!mcGranma)
break;
1024 pdgGranma = mcGranma->GetPdgCode();
1025 AliDebug(2,Form(
"Pdg mother at step %d = %d", istep, pdgGranma));
1026 Int_t abspdgGranma = TMath::Abs(pdgGranma);
1027 if ((abspdgGranma > 500 && abspdgGranma < 600) || (abspdgGranma > 5000 && abspdgGranma < 6000)) {
1030 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
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.
Bool_t fReadMC
number of pt bins
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 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)