25 #include "AliAnalysisManager.h" 26 #include "AliInputEventHandler.h" 27 #include "AliAODHandler.h" 28 #include "AliAODEvent.h" 29 #include "AliAODMCParticle.h" 30 #include "AliAODMCHeader.h" 31 #include "AliAODVertex.h" 72 DefineOutput(1,TList::Class());
110 if(fDebug > 1) printf(
"AliAnalysisTaskDmesonMCPerform::UserCreateOutputObjects() \n");
113 fOutput->SetName(
"OutputHistos");
115 fHistNEvents =
new TH1F(
"fHistNEvents",
"number of events ",10,-0.5,9.5);
116 fHistNEvents->GetXaxis()->SetBinLabel(1,
"nEvents read");
117 fHistNEvents->GetXaxis()->SetBinLabel(2,
"Rejected due to mismatch in trees");
118 fHistNEvents->GetXaxis()->SetBinLabel(3,
"nEvents with good AOD");
119 fHistNEvents->GetXaxis()->SetBinLabel(4,
"Rejected due to trigger");
120 fHistNEvents->GetXaxis()->SetBinLabel(5,
"Rejected due to vertex reco");
121 fHistNEvents->GetXaxis()->SetBinLabel(6,
"Rejected due to pileup");
122 fHistNEvents->GetXaxis()->SetBinLabel(7,
"Rejected due to centrality");
123 fHistNEvents->GetXaxis()->SetBinLabel(8,
"Rejected due to vtxz");
124 fHistNEvents->GetXaxis()->SetBinLabel(9,
"Rejected due to Physics Sel");
125 fHistNEvents->GetXaxis()->SetBinLabel(10,
"nEvents accepted");
130 fHistNGenD=
new TH1F(
"fHistNGenD",
"number of D mesons",10,-0.5,9.5);
131 TString names[5]={
"Dzero",
"Dplus",
"Dstar",
"Ds",
"Lc"};
132 TString type[2]={
"Prompt",
"Feeddown"};
133 for(
Int_t j=0; j<5; j++){
134 for(
Int_t i=0; i<2; i++){
136 fHistNGenD->GetXaxis()->SetBinLabel(index+1,Form(
"%s %s",type[i].
Data(),names[j].
Data()));
139 fHistNGenD->GetXaxis()->SetNdivisions(1,kFALSE);
143 fHistNCand=
new TH2F(
"fHistNCand",
"number of D meson candidates",5,-0.5,4.5,16,0.,16.);
144 fHistNCand->GetXaxis()->SetBinLabel(1,
"D0#rightarrowK#pi");
145 fHistNCand->GetXaxis()->SetBinLabel(2,
"D+#rightarrowK#pi#pi");
146 fHistNCand->GetXaxis()->SetBinLabel(3,
"D*+#rightarrowD0#pi");
147 fHistNCand->GetXaxis()->SetBinLabel(4,
"D_s#rightarrowKK#pi");
148 fHistNCand->GetXaxis()->SetBinLabel(5,
"Lc#rightarrowpK#pi");
153 for(
Int_t i=0; i<2; i++){
155 fHistPtYMultGen[index]=
new TH3F(Form(
"hPtYMult%sGen%s",type[i].
Data(),
fPartName[j].
Data()),
" ; p_{T} (GeV/c) ; y; multPercentile",16,0.,16.,24,-6.,6.,40,0.,100.);
156 fHistPtYMultGenDauInAcc[index]=
new TH3F(Form(
"hPtYMult%sGenDauInAcc%s",type[i].
Data(),
fPartName[j].
Data()),
" ; p_{T} (GeV/c) ; y; multPercentile",16,0.,16.,24,-6.,6.,40,0.,100.);
157 fHistPtYMultReco[index]=
new TH3F(Form(
"hPtYMult%sReco%s",type[i].
Data(),
fPartName[j].
Data()),
" ; p_{T} (GeV/c) ; y; multPercentile",16,0.,16.,24,-6.,6.,40,0.,100.);
158 fHistPtYMultRecoFilt[index]=
new TH3F(Form(
"hPtYMult%sRecoFilt%s",type[i].
Data(),
fPartName[j].
Data()),
" ; p_{T} (GeV/c) ; y; multPercentile",16,0.,16.,24,-6.,6.,40,0.,100.);
159 fHistPtYMultRecoSel[index]=
new TH3F(Form(
"hPtYMult%sRecoSel%s",type[i].
Data(),
fPartName[j].
Data()),
" ; p_{T} (GeV/c) ; y; multPercentile",16,0.,16.,24,-6.,6.,40,0.,100.);
200 if (matchingAODdeltaAODlevel<0 || (matchingAODdeltaAODlevel==0 &&
fAODProtection==1)) {
208 TClonesArray *arrayD0toKpi =0;
209 TClonesArray *array3Prong =0;
210 TClonesArray *arrayDstar =0;
211 TClonesArray *arrayCascades =0;
212 if(!aod && AODEvent() && IsStandardAOD()) {
218 AliAODHandler* aodHandler = (AliAODHandler*)
219 ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
220 if(aodHandler->GetExtensions()) {
222 AliAODExtension *ext = (AliAODExtension*)aodHandler->GetExtensions()->FindObject(
"AliAOD.VertexingHF.root");
225 array3Prong =(TClonesArray*)aodFromExt->GetList()->FindObject(
"Charm3Prong");
226 arrayD0toKpi =(TClonesArray*)aodFromExt->GetList()->FindObject(
"D0toKpi");
227 arrayDstar =(TClonesArray*)aodFromExt->GetList()->FindObject(
"Dstar");
228 arrayCascades=(TClonesArray*)aodFromExt->GetList()->FindObject(
"CascadesHF");
231 array3Prong =(TClonesArray*)aod->GetList()->FindObject(
"Charm3Prong");
232 arrayD0toKpi =(TClonesArray*)aod->GetList()->FindObject(
"D0toKpi");
233 arrayDstar =(TClonesArray*)aod->GetList()->FindObject(
"Dstar");
234 arrayCascades=(TClonesArray*)aod->GetList()->FindObject(
"CascadesHF");
237 if(!aod || !array3Prong || !arrayD0toKpi) {
238 printf(
"AliAnalysisTaskSEDplus::UserExec: Charm3Prong branch not found!\n");
243 if(!aod->GetPrimaryVertex()||TMath::Abs(aod->GetMagneticField())<0.001)
return;
256 AliAODMCHeader *mcHeader = (AliAODMCHeader*)aod->GetList()->FindObject(AliAODMCHeader::StdBranchName());
258 printf(
"AliAnalysisTaskDmesonMCPerform:UserExec: MC header branch not found!\n");
263 TClonesArray *arrayMC= (TClonesArray*)aod->GetList()->FindObject(AliAODMCParticle::StdBranchName());
265 printf(
"AliAnalysisTaskDmesonMCPerform::UserExec: MC particles branch not found!\n");
269 Int_t runNumber=aod->GetRunNumber();
271 if(aod->GetTriggerMask()==0 &&
272 (runNumber>=195344 && runNumber<=195677)){
297 Double_t zMCVertex = mcHeader->GetVtxZ();
302 for(
Int_t iPart=0; iPart<arrayMC->GetEntriesFast(); iPart++){
303 AliAODMCParticle* mcPart =
dynamic_cast<AliAODMCParticle*
>(arrayMC->At(iPart));
304 Int_t pdgCode=TMath::Abs(mcPart->GetPdgCode());
306 if(pdgCode == 411) iSpec=1;
307 else if(pdgCode == 413) iSpec=2;
308 else if(pdgCode == 421) iSpec=0;
309 else if(pdgCode == 431) iSpec=3;
310 else if(pdgCode == 4122) iSpec=4;
313 if(orig<4 || orig>5)
continue;
314 Int_t indexh=iSpec*2+(orig-4);
317 Bool_t isGoodDecay=kFALSE;
318 Int_t labDau[4]={-1,-1,-1,-1};
322 if(deca>0) isGoodDecay=kTRUE;
323 }
else if(pdgCode == 421){
325 if(mcPart->GetNDaughters()!=2)
continue;
326 if(deca==1) isGoodDecay=kTRUE;
328 }
else if(pdgCode == 431){
330 if(deca==1) isGoodDecay=kTRUE;
331 }
else if(pdgCode==413){
333 if(deca==1) isGoodDecay=kTRUE;
334 }
else if(pdgCode==4122){
336 if(deca>=1) isGoodDecay=kTRUE;
341 if(isGoodDecay && indexh>=0){
368 Int_t pdg0[2]={321,211};
369 Int_t pdgp[3]={321,211,211};
370 Int_t pdgs[3]={321,211,321};
371 Int_t pdgst[2]={421,211};
372 Int_t pdgl[3]={2212,321,211};
378 Int_t nCand=arrayDcand->GetEntriesFast();
379 for (
Int_t iCand = 0; iCand < nCand; iCand++) {
389 labD = d->MatchToMC(421,arrayMC,2,pdg0);
392 AliAODMCParticle *pd0 = (AliAODMCParticle*)arrayMC->At(labD);
402 labD = d->MatchToMC(411,arrayMC,3,pdgp);
407 Int_t labDau0=((AliAODTrack*)d->GetDaughter(0))->GetLabel();
408 AliAODMCParticle* pdau0=(AliAODMCParticle*)arrayMC->UncheckedAt(TMath::Abs(labDau0));
409 Int_t pdgCode0=TMath::Abs(pdau0->GetPdgCode());
410 labD = d->MatchToMC(431,arrayMC,3,pdgs);
416 labD = d->MatchToMC(4122,arrayMC,3,pdgl);
435 if(labD>=0 && iSpec>=0){
436 AliAODMCParticle *partD = (AliAODMCParticle*)arrayMC->At(labD);
443 Double_t dx=(d->Xv()-partD->Xv())*10000.;
444 Double_t dy=(d->Yv()-partD->Yv())*10000.;
445 Double_t dz=(d->Zv()-partD->Zv())*10000.;
447 if(orig<4 || orig>5)
continue;
448 Int_t indexh=iSpec*2+(orig-4);
473 for (
Int_t iProng = 0; iProng<nProng; iProng++){
474 AliAODMCParticle* mcPartDaughter=
dynamic_cast<AliAODMCParticle*
>(arrayMC->At(labDau[iProng]));
475 if(!mcPartDaughter)
return kFALSE;
476 Double_t eta = mcPartDaughter->Eta();
478 if (TMath::Abs(eta) > 0.9 || pt < 0.1)
return kFALSE;
486 Int_t nTracks=aod->GetNumberOfTracks();
488 for(
Int_t it=0; it<nTracks; it++) {
489 AliAODTrack *tr=
dynamic_cast<AliAODTrack*
>(aod->GetTrack(it));
491 if(tr->GetID()<0)
continue;
492 Int_t lab=TMath::Abs(tr->GetLabel());
494 else printf(
"Label %d exceeds upper limit\n",lab);
503 Double_t px[3],py[3],pz[3],d0[3],d0err[3];
505 for(
Int_t jd=0; jd<nProng; jd++){
508 AliAODTrack* tr=
dynamic_cast<AliAODTrack*
>(aod->GetTrack(it));
510 if(TMath::Abs(tr->GetLabel())!=labDau[jd]){
511 printf(
"Mismatched track label\n");
523 if(nFound!=nProng)
return 0x0;
532 if(fDebug > 1) printf(
"AnalysisTaskDmesonMCPerform: Terminate() \n");
536 printf(
"ERROR: fOutput not available\n");
542 printf(
"Number of analyzed events = %d\n",(
Int_t)
fHistNEvents->GetBinContent(10));
544 printf(
"ERROR: fHistNEvents not available\n");
Double_t NormalizedDecayLengthXY() const
static Int_t CheckD0Decay(AliMCEvent *mcEvent, Int_t label, Int_t *arrayDauLab)
static Int_t CheckDplusDecay(AliMCEvent *mcEvent, Int_t label, Int_t *arrayDauLab)
void SetMaxVtxZ(Float_t z=1e6)
Int_t IsEventSelectedInCentrality(AliVEvent *event)
Bool_t HasSelectionBit(Int_t i) const
static Int_t CheckDsDecay(AliMCEvent *mcEvent, Int_t label, Int_t *arrayDauLab)
static Int_t CheckLcpKpiDecay(AliMCEvent *mcEvent, Int_t label, Int_t *arrayDauLab)
void SetUseCentrality(Int_t flag=1)
static Int_t CheckMatchingAODdeltaAODevents()
Int_t GetWhyRejection() const
Bool_t FillRecoCand(AliVEvent *event, AliAODRecoDecayHF3Prong *rd3)
virtual Bool_t IsInFiducialAcceptance(Double_t pt, Double_t y) const
static Int_t CheckOrigin(TClonesArray *arrayMC, AliAODMCParticle *mcPart, Bool_t searchUpToQuark=kTRUE)
Functions to check the decay tree.
Double_t GetMaxVtxZ() const
void SetUsePhysicsSelection(Bool_t use=kTRUE)
Bool_t FillRecoCasc(AliVEvent *event, AliAODRecoCascadeHF *rc, Bool_t isDStar, Bool_t recoSecVtx=kFALSE)
virtual Int_t IsSelected(TObject *obj, Int_t selectionLevel)
Float_t GetCentrality(AliAODEvent *aodEvent)
static Int_t CheckDstarDecay(AliMCEvent *mcEvent, Int_t label, Int_t *arrayDauLab)
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)
Bool_t IsEventSelected(AliVEvent *event)
Double_t CosPointingAngle() const
void SetTriggerClass(TString trclass0, TString trclass1="")
Int_t GetUseCentrality() const
void SetOptPileup(Int_t opt=0)
Double_t DecayLength() const