1 /**************************************************************************
2 * Copyright(c) 1998-2009, 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 **************************************************************************/
16 /////////////////////////////////////////////////////////////
18 // AliAnalysisTaskSE for D0 candidates invariant mass histogram
19 // and comparison with the MC truth and cut variables distributions.
21 // Authors: A.Dainese, andrea.dainese@lnl.infn.it
22 // and Chiara Bianchin, chiara.bianchin@pd.infn.it
23 /////////////////////////////////////////////////////////////
25 #include <Riostream.h>
26 #include <TClonesArray.h>
31 #include <TDatabasePDG.h>
33 #include "AliAODEvent.h"
34 #include "AliAODVertex.h"
35 #include "AliAODTrack.h"
36 #include "AliAODMCHeader.h"
37 #include "AliAODMCParticle.h"
38 #include "AliAODRecoDecayHF2Prong.h"
39 #include "AliAODRecoCascadeHF.h"
40 #include "AliAnalysisVertexingHF.h"
41 #include "AliAnalysisTaskSE.h"
42 #include "AliAnalysisTaskSED0Mass.h"
44 ClassImp(AliAnalysisTaskSED0Mass)
47 //________________________________________________________________________
48 AliAnalysisTaskSED0Mass::AliAnalysisTaskSED0Mass():
57 // Default constructor
60 //________________________________________________________________________
61 AliAnalysisTaskSED0Mass::AliAnalysisTaskSED0Mass(const char *name):
62 AliAnalysisTaskSE(name),
70 // Default constructor
72 // Output slot #1 writes into a TList container
73 DefineOutput(1,TList::Class()); //My private output
74 // Output slot #2 writes into a TList container
75 DefineOutput(2,TList::Class()); //My private output
76 // Output slot #3 writes into a TH1F container
77 DefineOutput(3,TH1F::Class()); //My private output
78 // Output slot #4 writes into a TList container
79 DefineOutput(4,TList::Class()); //My private output
82 //________________________________________________________________________
83 AliAnalysisTaskSED0Mass::~AliAnalysisTaskSED0Mass()
115 //________________________________________________________________________
116 void AliAnalysisTaskSED0Mass::Init()
120 if(fDebug > 1) printf("AnalysisTaskSED0Mass::Init() \n");
122 gROOT->LoadMacro("$ALICE_ROOT/PWG3/vertexingHF/ConfigVertexingHF.C");
124 // 2 sets of dedidcated cuts -- defined in UserExec
125 fVHFtight = (AliAnalysisVertexingHF*)gROOT->ProcessLine("ConfigVertexingHF()");
126 fVHFloose = (AliAnalysisVertexingHF*)gROOT->ProcessLine("ConfigVertexingHF()");
131 //________________________________________________________________________
132 void AliAnalysisTaskSED0Mass::UserCreateOutputObjects()
135 // Create the output container
137 if(fDebug > 1) printf("AnalysisTaskSED0Mass::UserCreateOutputObjects() \n");
139 // Several histograms are more conveniently managed in a TList
140 fOutputtight = new TList();
141 fOutputtight->SetOwner();
142 fOutputtight->SetName("listtight");
144 fOutputloose = new TList();
145 fOutputloose->SetOwner();
146 fOutputloose->SetName("listloose");
148 fDistr = new TList();
150 fDistr->SetName("distributionslist");
154 TString nameMass=" ", nameSgn=" ", nameBkg=" ", nameRfl=" ", namedistr=" ";
156 for(Int_t i=0;i<nhist;i++){
157 nameMass="histMass_";
166 //histograms of invariant mass distributions
168 TH1F* tmpMt = new TH1F(nameMass.Data(),"D^{0} invariant mass; M [GeV]; Entries",200,1.765,1.965);
169 TH1F *tmpMl=(TH1F*)tmpMt->Clone();
173 TH1F* tmpSt = new TH1F(nameSgn.Data(), "D^{0} invariant mass - MC; M [GeV]; Entries",200,1.765,1.965);
174 TH1F *tmpSl=(TH1F*)tmpSt->Clone();
178 TH1F* tmpBt = new TH1F(nameBkg.Data(), "Background invariant mass - MC; M [GeV]; Entries",200,1.765,1.965);
179 TH1F *tmpBl=(TH1F*)tmpBt->Clone();
183 //Reflection: histo filled with D0 which pass the cut (also) as D0bar and with D0bar which pass (also) the cut as D0
184 TH1F* tmpRt = new TH1F(nameRfl.Data(), "Reflected signal invariant mass - MC; M [GeV]; Entries",200,1.765,1.965);
185 TH1F *tmpRl=(TH1F*)tmpRt->Clone();
188 // printf("Created histograms %s\t%s\t%s\t%s\n",tmpM->GetName(),tmpS->GetName(),tmpB->GetName(),tmpR->GetName());
190 fOutputtight->Add(tmpMt);
191 fOutputtight->Add(tmpSt);
192 fOutputtight->Add(tmpBt);
193 fOutputtight->Add(tmpRt);
195 fOutputloose->Add(tmpMl);
196 fOutputloose->Add(tmpSl);
197 fOutputloose->Add(tmpBl);
198 fOutputloose->Add(tmpRl);
202 //histograms of cut variable distributions
205 TH1F *hptpiS = new TH1F(namedistr.Data(), "P_{T} distribution (pions);p_{T} [GeV/c]",200,0.,8.);
206 // namedistr="hptpiR";
207 // TH1F *hptpiR = new TH1F(namedistr.Data(), "P_{T} distribution (pions);p_{T} [GeV/c]",200,0.,8.);
210 TH1F *hptKS = new TH1F(namedistr.Data(), "P_{T} distribution (kaons);p_{T} [GeV/c]",200,0.,8.);
213 TH1F *hptB = new TH1F(namedistr.Data(), "P_{T} distribution;p_{T} [GeV/c]",200,0.,8.);
214 // namedistr="hptKR";
215 // TH1F *hptKR = new TH1F(namedistr.Data(), "P_{T} distribution (kaons);p_{T} [GeV/c]",200,0.,8.);
219 TH1F *hdcaS = new TH1F(namedistr.Data(), "DCA distribution;dca [cm]",200,0.,0.1);
221 TH1F *hdcaB = new TH1F(namedistr.Data(), "DCA distribution;dca [cm]",200,0.,0.1);
222 // namedistr="hdcaR";
223 // TH1F *hdcaR = new TH1F(namedistr.Data(), "DCA distribution;dca [cm]",200,0.,0.1);
226 namedistr="costhetastarS";
227 TH1F *hcosthetastarS = new TH1F(namedistr.Data(), "cos#theta* distribution;cos#theta*",200,-1.,1.);
228 namedistr="costhetastarB";
229 TH1F *hcosthetastarB = new TH1F(namedistr.Data(), "cos#theta* distribution;cos#theta*",200,-1.,1.);
230 // namedistr="costhetastarR";
231 // TH1F *hcosthetastarR = new TH1F(namedistr.Data(), "cos#theta* distribution;cos#theta*",200,-1.,1.);
235 TH1F *hd0piS = new TH1F(namedistr.Data(), "Impact parameter distribution (pions);d0(#pi) [cm]",200,-0.1,0.1);
236 // namedistr="hd0piR";
237 // TH1F *hd0piR = new TH1F(namedistr.Data(), "Impact parameter distribution (pions);d0(#pi) [cm]",200,0.,1.);
240 TH1F *hd0KS = new TH1F(namedistr.Data(), "Impact parameter distribution (kaons);d0(K) [cm]",200,-0.1,0.1);
242 TH1F *hd0B = new TH1F(namedistr.Data(), "Impact parameter distribution;d0 [cm]",200,-0.1,0.1);
243 // namedistr="hd0KR";
244 // TH1F *hd0KR = new TH1F(namedistr.Data(), "Impact parameter distribution (kaons);d0(K) [cm]",200,0.,0.1);
247 TH1F *hd0d0S = new TH1F(namedistr.Data(), "d_{0}#timesd_{0} distribution;d_{0}#timesd_{0} [cm^{2}]",200,-0.001,0.001);
249 TH1F *hd0d0B = new TH1F(namedistr.Data(), "d_{0}#timesd_{0} distribution;d_{0}#timesd_{0} [cm^{2}]",200,-0.001,0.001);
250 // namedistr="hd0d0R";
251 // TH1F *hd0d0R = new TH1F(namedistr.Data(), "d_{0}#timesd_{0} distribution (pions);d_{0}#timesd_{0} [cm^{2}]",200,-0.001,0.001);
254 namedistr="hcosthetapointS";
255 TH1F *hcosthetapointS = new TH1F(namedistr.Data(), "cos#theta_{Point} distribution;cos#theta_{Point}",200,0,1.);
256 namedistr="hcosthetapointB";
257 TH1F *hcosthetapointB = new TH1F(namedistr.Data(), "cos#theta_{Point} distribution;cos#theta_{Point}",200,0,1.);
258 // namedistr="costhetapointR";
259 // TH1F *hcosthetapointR = new TH1F(namedistr.Data(), "cos#theta_{Point} distribution;cos#theta_{Point}",200,-1,1.);
261 namedistr="hcosthpointd0d0S";
262 TH2F *hcosthpointd0d0S= new TH2F(namedistr.Data(),"Correlation cos#theta_{Point}-d_{0}#timesd_{0};cos#theta_{Point};d_{0}#timesd_{0} [cm^{2}]",200,0,1.,200,-0.001,0.001);
263 namedistr="hcosthpointd0d0B";
264 TH2F *hcosthpointd0d0B= new TH2F(namedistr.Data(),"Correlation cos#theta_{Point}-d_{0}#timesd_{0};cos#theta_{Point};d_{0}#timesd_{0} [cm^{2}]",200,0,1.,200,-0.001,0.001);
267 //fDistr->Add(hptpiR);
270 //fDistr->Add(hptKR);
274 //fDistr->Add(hdcaR);
277 //fDistr->Add(hd0piR);
280 //fDistr->Add(hd0KR);
284 //fDistr->Add(hd0d0R);
286 fDistr->Add(hcosthetastarS);
287 fDistr->Add(hcosthetastarB);
288 //fDistr->Add(hcosthetastarR);
290 fDistr->Add(hcosthetapointS);
291 fDistr->Add(hcosthetapointB);
292 //fDistr->Add(hcosthetapointR);
294 fDistr->Add(hcosthpointd0d0S);
295 fDistr->Add(hcosthpointd0d0B);
297 fNentries=new TH1F("nentriesD0", "Look at the number of entries! it is = to the number of AODs", 2,1.,2.);
302 //________________________________________________________________________
303 void AliAnalysisTaskSED0Mass::UserExec(Option_t */*option*/)
305 // Execute analysis for current event:
306 // heavy flavor candidates association to MC truth
307 //cout<<"I'm in UserExec"<<endl;
308 AliAODEvent *aod = dynamic_cast<AliAODEvent*> (InputEvent());
310 // load D0->Kpi candidates
311 TClonesArray *inputArrayD0toKpi =
312 (TClonesArray*)aod->GetList()->FindObject("D0toKpi");
313 if(!inputArrayD0toKpi) {
314 printf("AliAnalysisTaskSECompareHFpt::UserExec: D0toKpi branch not found!\n");
318 // AOD primary vertex
319 AliAODVertex *vtx1 = (AliAODVertex*)aod->GetPrimaryVertex();
323 TClonesArray *mcArray =
324 (TClonesArray*)aod->GetList()->FindObject(AliAODMCParticle::StdBranchName());
326 printf("AliAnalysisTaskSED0Mass::UserExec: MC particles branch not found!\n");
331 AliAODMCHeader *mcHeader =
332 (AliAODMCHeader*)aod->GetList()->FindObject(AliAODMCHeader::StdBranchName());
334 printf("AliAnalysisTaskSED0Mass::UserExec: MC header branch not found!\n");
339 //histogram filled with 1 for every AOD
341 PostData(3,fNentries);
342 // loop over D0->Kpi candidates
343 Int_t nInD0toKpi = inputArrayD0toKpi->GetEntriesFast();
344 AliDebug(2,Form("Number of D0->Kpi: %d",nInD0toKpi));
346 for (Int_t iD0toKpi = 0; iD0toKpi < nInD0toKpi; iD0toKpi++) {
347 //cout<<"inside the loop"<<endl;
348 AliAODRecoDecayHF2Prong *d = (AliAODRecoDecayHF2Prong*)inputArrayD0toKpi->UncheckedAt(iD0toKpi);
349 Bool_t unsetvtx=kFALSE;
350 if(!d->GetOwnPrimaryVtx()) {
351 d->SetOwnPrimaryVtx(vtx1); // needed to compute all variables
356 // printf(" |M-MD0| [GeV] < %f\n",fD0toKpiCuts[0]);
357 // printf(" dca [cm] < %f\n",fD0toKpiCuts[1]);
358 // printf(" cosThetaStar < %f\n",fD0toKpiCuts[2]);
359 // printf(" pTK [GeV/c] > %f\n",fD0toKpiCuts[3]);
360 // printf(" pTpi [GeV/c] > %f\n",fD0toKpiCuts[4]);
361 // printf(" |d0K| [cm] < %f\n",fD0toKpiCuts[5]);
362 // printf(" |d0pi| [cm] < %f\n",fD0toKpiCuts[6]);
363 // printf(" d0d0 [cm^2] < %f\n",fD0toKpiCuts[7]);
364 // printf(" cosThetaPoint > %f\n",fD0toKpiCuts[8]);
369 Double_t mPDG=TDatabasePDG::Instance()->GetParticle(421)->Mass();
372 Double_t minvD0 = d->InvMassD0();
375 Double_t minvD0bar = d->InvMassD0bar();
376 //apply cut on invariant mass on the pair
377 if(TMath::Abs(minvD0-mPDG)<0.03 || TMath::Abs(minvD0bar-mPDG)<0.03){
378 Int_t pdgDgD0toKpi[2]={321,211};
379 Int_t lab=d->MatchToMC(421,mcArray,2,pdgDgD0toKpi); //return MC particle label if the array corresponds to a D0, -1 if not (cf. AliAODRecoDecay.cxx)
381 // Int_t lab=d->MatchToMC(421,mcArray); //|pdg| requested
382 // AliAODMCParticle *mcmother = (AliAODMCParticle*)mcArray->At(lab);
383 // cout<<"mcmother name = "<<mcmother->GetName()<<" label = "<<mcmother->GetLabel()<<endl;
385 //cout<<"is signal"<<endl;
386 for (Int_t iprong=0; iprong<2; iprong++){
387 AliAODTrack *prong=(AliAODTrack*)d->GetDaughter(iprong);
388 Int_t labprong=prong->GetLabel();
390 //cout<<"prong name = "<<prong->GetName()<<" label = "<<prong->GetLabel()<<endl;
391 AliAODMCParticle *mcprong=0;
392 if(labprong>=0) mcprong= (AliAODMCParticle*)mcArray->At(labprong);
393 Int_t pdgprong=mcprong->GetPdgCode();
394 if(TMath::Abs(pdgprong)==211) {
396 ((TH1F*)fDistr->FindObject("hptpiS"))->Fill(d->PtProng(iprong));
397 ((TH1F*)fDistr->FindObject("hd0piS"))->Fill(d->Getd0Prong(iprong));
400 if(TMath::Abs(pdgprong)==321) {
401 //cout<<"kappa"<<endl;
402 ((TH1F*)fDistr->FindObject("hptKS"))->Fill(d->PtProng(iprong));
403 ((TH1F*)fDistr->FindObject("hd0KS"))->Fill(d->Getd0Prong(iprong));
405 ((TH1F*)fDistr->FindObject("hdcaS"))->Fill(d->GetDCA());
409 if (((AliAODMCParticle*)mcArray->At(lab))->GetPdgCode() == 421)
410 ((TH1F*)fDistr->FindObject("costhetastarS"))->Fill(d->CosThetaStarD0());
411 else ((TH1F*)fDistr->FindObject("costhetastarS"))->Fill(d->CosThetaStarD0bar());
413 ((TH1F*)fDistr->FindObject("hd0d0S"))->Fill(d->Prodd0d0());
415 ((TH1F*)fDistr->FindObject("hcosthetapointS"))->Fill(d->CosPointingAngle());
416 ((TH1F*)fDistr->FindObject("hcosthpointd0d0S"))->Fill(d->CosPointingAngle(),d->Prodd0d0());
418 //cout<<"ok point"<<endl;
421 //cout<<"is background"<<endl;
422 // AliAODTrack *prong=(AliAODTrack*)d->GetDaughter(0);
423 ((TH1F*)fDistr->FindObject("hptB"))->Fill(d->PtProng(0));
424 //cout<<"ptok"<<endl;
425 ((TH1F*)fDistr->FindObject("hd0B"))->Fill(d->Getd0Prong(0));
426 //cout<<"d0ok"<<endl;
427 ((TH1F*)fDistr->FindObject("hdcaB"))->Fill(d->GetDCA());
428 //cout<<"dcaok"<<endl;
429 ((TH1F*)fDistr->FindObject("costhetastarB"))->Fill(d->CosThetaStarD0());
430 ((TH1F*)fDistr->FindObject("costhetastarB"))->Fill(d->CosThetaStarD0bar());
431 ((TH1F*)fDistr->FindObject("hd0d0B"))->Fill(d->Prodd0d0());
432 //cout<<"d0d0ok"<<endl;
433 ((TH1F*)fDistr->FindObject("hcosthetapointB"))->Fill(d->CosPointingAngle());
434 ((TH1F*)fDistr->FindObject("hcosthpointd0d0B"))->Fill(d->CosPointingAngle(),d->Prodd0d0());
436 //cout<<"pointok"<<endl;
443 Double_t pt = d->Pt();
447 //cout<<"P_t = "<<pt<<endl;
448 if (pt>0. && pt<=1.) {
450 fVHFtight->SetD0toKpiCuts(0.7,0.04,0.8,0.5,0.5,0.05,0.05,-0.0003,0.7);
451 fVHFloose->SetD0toKpiCuts(0.7,0.04,0.8,0.5,0.5,0.05,0.05,-0.00025,0.7);
452 // fVHFtight->SetD0toKpiCuts(0.7,0.04,0.8,0.5,0.5,0.05,0.05,-0.0002,0.7);
453 // fVHFloose->SetD0toKpiCuts(0.7,0.04,0.8,0.5,0.5,1,1,-0.00015,0.5);
454 //printf("I'm in the bin %d\n",ptbin);
458 if(pt>1. && pt<=3.) {
460 fVHFtight->SetD0toKpiCuts(0.7,0.02,0.8,0.7,0.7,0.05,0.05,-0.0003,0.9);
461 fVHFloose->SetD0toKpiCuts(0.7,0.02,0.8,0.7,0.7,1,1,-0.00025,0.8);
462 //printf("I'm in the bin %d\n",ptbin);
467 fVHFtight->SetD0toKpiCuts(0.7,0.015,0.8,0.7,0.7,0.05,0.05,-0.0002,0.9);
468 fVHFloose->SetD0toKpiCuts(0.7,0.02,0.8,0.7,0.7,0.05,0.05,-0.00015,0.8);
469 //printf("I'm in the bin %d\n",ptbin);
473 fVHFtight->SetD0toKpiCuts(0.7,0.015,0.8,0.7,0.7,0.05,0.05,-0.0002,0.95);
474 fVHFloose->SetD0toKpiCuts(0.7,0.02,0.8,0.7,0.7,0.05,0.05,-0.00015,0.9);
477 //printf("I'm in the bin %d\n",ptbin);
479 //fVHF->SetD0toKpiCuts(0.7,0.03,0.8,0.06,0.06,0.05,0.05,-0.0002,0.6); //2.p-p vertex reconstructed
481 FillHists(ptbin,d,mcArray,fVHFtight,fOutputtight);
482 FillHists(ptbin,d,mcArray,fVHFloose,fOutputloose);
483 if(unsetvtx) d->UnsetOwnPrimaryVtx();
490 PostData(1,fOutputtight);
491 PostData(2,fOutputloose);
495 //____________________________________________________________________________*
496 void AliAnalysisTaskSED0Mass::FillHists(Int_t ptbin, AliAODRecoDecayHF2Prong *part, TClonesArray *arrMC, AliAnalysisVertexingHF *vhf, TList *listout){
498 // function used in UserExec:
500 Int_t okD0=0,okD0bar=0;
502 if(part->SelectD0(vhf->GetD0toKpiCuts(),okD0,okD0bar)) {//selected
503 Double_t invmassD0 = part->InvMassD0(), invmassD0bar = part->InvMassD0bar();
504 //printf("SELECTED\n");
505 Int_t pdgDgD0toKpi[2]={321,211};
506 Int_t labD0 = part->MatchToMC(421,arrMC,2,pdgDgD0toKpi); //return MC particle label if the array corresponds to a D0, -1 if not (cf. AliAODRecoDecay.cxx)
508 //Int_t labD0 = part->MatchToMC(421,arrMC); //return MC particle label if the array corresponds to a D0, -1 if not (cf. AliAODRecoDecay.cxx)
509 //printf("labD0 %d",labD0);
514 fillthis="histMass_";
516 //cout<<"Filling "<<fillthis<<endl;
518 //printf("Fill mass with D0");
519 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0);
521 AliAODMCParticle *partD0 = (AliAODMCParticle*)arrMC->At(labD0);
522 Int_t pdgD0 = partD0->GetPdgCode();
523 //cout<<"pdg = "<<pdgD0<<endl;
524 if (pdgD0==421){ //D0
525 //cout<<"Fill S with D0"<<endl;
528 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0);
530 } else{ //it was a D0bar
533 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0);
538 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0);
542 fillthis="histMass_";
544 //printf("Fill mass with D0bar");
545 ((TH1F*)listout->FindObject(fillthis))->Fill(invmassD0bar);
548 AliAODMCParticle *partD0 = (AliAODMCParticle*)arrMC->At(labD0);
549 Int_t pdgD0 = partD0->GetPdgCode();
550 //cout<<" pdg = "<<pdgD0<<endl;
551 if (pdgD0==-421){ //D0bar
554 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0bar);
559 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0bar);
564 ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0bar);
569 } //else cout<<"NOT SELECTED"<<endl;
572 //________________________________________________________________________
573 void AliAnalysisTaskSED0Mass::Terminate(Option_t */*option*/)
575 // Terminate analysis
577 if(fDebug > 1) printf("AnalysisTaskSED0Mass: Terminate() \n");
579 fOutputtight = dynamic_cast<TList*> (GetOutputData(1));
581 printf("ERROR: fOutputthight not available\n");
584 fOutputloose = dynamic_cast<TList*> (GetOutputData(2));
586 printf("ERROR: fOutputloose not available\n");
589 fDistr = dynamic_cast<TList*> (GetOutputData(3));
591 printf("ERROR: fDistr not available\n");