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 **************************************************************************/
16 /////////////////////////////////////////////////////////////
18 // AliAnalysisTaskSE for the extraction of signal(e.g D+) of heavy flavor
19 // decay candidates with the MC truth.
20 // Author: Renu Bala, bala@to.infn.it
21 /////////////////////////////////////////////////////////////
23 #include <TClonesArray.h>
28 #include "AliAODEvent.h"
29 #include "AliAODVertex.h"
30 #include "AliAODTrack.h"
31 #include "AliAODMCHeader.h"
32 #include "AliAODMCParticle.h"
33 #include "AliAODRecoDecayHF3Prong.h"
34 #include "AliAnalysisVertexingHF.h"
35 #include "AliAnalysisTaskSE.h"
36 #include "AliAnalysisTaskSEDplus.h"
38 ClassImp(AliAnalysisTaskSEDplus)
41 //________________________________________________________________________
42 AliAnalysisTaskSEDplus::AliAnalysisTaskSEDplus():
50 // Default constructor
53 //________________________________________________________________________
54 AliAnalysisTaskSEDplus::AliAnalysisTaskSEDplus(const char *name,Bool_t fillNtuple):
55 AliAnalysisTaskSE(name),
59 fFillNtuple(fillNtuple),
62 // Default constructor
64 // Output slot #1 writes into a TList container
65 DefineOutput(1,TList::Class()); //My private output
68 // Output slot #2 writes into a TNtuple container
69 DefineOutput(2,TNtuple::Class()); //My private output
70 // Output slot #3 writes into a TNtuple container
71 DefineOutput(3,TNtuple::Class()); //My private output
75 //________________________________________________________________________
76 AliAnalysisTaskSEDplus::~AliAnalysisTaskSEDplus()
89 //________________________________________________________________________
90 void AliAnalysisTaskSEDplus::Init()
94 if(fDebug > 1) printf("AnalysisTaskSEDplus::Init() \n");
96 gROOT->LoadMacro("ConfigVertexingHF.C");
98 fVHF = (AliAnalysisVertexingHF*)gROOT->ProcessLine("ConfigVertexingHF()");
104 //________________________________________________________________________
105 void AliAnalysisTaskSEDplus::UserCreateOutputObjects()
107 // Create the output container
109 if(fDebug > 1) printf("AnalysisTaskSEDplus::UserCreateOutputObjects() \n");
111 // Several histograms are more conveniently managed in a TList
112 fOutput = new TList();
114 fOutput->SetName("OutputHistos");
118 for(Int_t i=0;i<nPtBins;i++){
119 hisname.Form("hMassPt%d",i);
120 TH1F* hm=new TH1F(hisname.Data(),hisname.Data(),100,1.765,1.965);
122 hisname.Form("hSigPt%d",i);
123 TH1F* hs=new TH1F(hisname.Data(),hisname.Data(),100,1.765,1.965);
125 hisname.Form("hBkgPt%d",i);
126 TH1F* hb=new TH1F(hisname.Data(),hisname.Data(),100,1.765,1.965);
129 hisname.Form("hMassPt%dTC",i);
130 TH1F* hmtc=new TH1F(hisname.Data(),hisname.Data(),100,1.765,1.965);
132 hisname.Form("hSigPt%dTC",i);
133 TH1F* hstc=new TH1F(hisname.Data(),hisname.Data(),100,1.765,1.965);
135 hisname.Form("hBkgPt%dTC",i);
136 TH1F* hbtc=new TH1F(hisname.Data(),hisname.Data(),100,1.765,1.965);
150 OpenFile(2); // 2 is the slot number of the ntuple
151 fNtupleDplus = new TNtuple("fNtupleDplus","D +","pdg:Px:Py:Pz:Ptpi:PtK:Ptpi2:PtRec:PtTrue:PointingAngle:DecLeng:VxTrue:VxRec:VyRec:VzRec:InvMass:sigvert:d0Pi:d0K:d0Pi2");
152 OpenFile(3); // 3 is the slot number of the ntuple
153 fNtupleDplusbackg = new TNtuple("fNtupleDplusbackg","D + backg","Ptpibkg:Ptkbkg:Ptpi2bkg:PtRecbkg:PointingAnglebkg:DLbkg:VxRecbkg:VyRecbkg:VzRecbkg:InvMassbkg:sigvertbkg:d0Pibkg:d0Kbkg:d0Pi2bkg");
159 //________________________________________________________________________
160 void AliAnalysisTaskSEDplus::UserExec(Option_t */*option*/)
162 // Execute analysis for current event:
163 // heavy flavor candidates association to MC truth
167 AliAODEvent *aod = dynamic_cast<AliAODEvent*> (InputEvent());
169 // load Dplus->Kpipi candidates
170 TClonesArray *array3Prong =
171 (TClonesArray*)aod->GetList()->FindObject("Charm3Prong");
173 printf("AliAnalysisTaskSEDplus::UserExec: Charm3Prong branch not found!\n");
177 // AOD primary vertex
178 AliAODVertex *vtx1 = (AliAODVertex*)aod->GetPrimaryVertex();
182 TClonesArray *arrayMC =
183 (TClonesArray*)aod->GetList()->FindObject(AliAODMCParticle::StdBranchName());
185 printf("AliAnalysisTaskSEDplus::UserExec: MC particles branch not found!\n");
190 AliAODMCHeader *mcHeader =
191 (AliAODMCHeader*)aod->GetList()->FindObject(AliAODMCHeader::StdBranchName());
193 printf("AliAnalysisTaskSEDplus::UserExec: MC header branch not found!\n");
196 Int_t n3Prong = array3Prong->GetEntriesFast();
197 if(fDebug>1) printf("Number of D+->Kpipi: %d\n",n3Prong);
200 Int_t pdgDgDplustoKpipi[3]={321,211,211};
201 Double_t cutsDplus[12]={0.2,0.4,0.4,0.,0.,0.01,0.06,0.02,0.,0.85,0.,10000000000.};
202 for (Int_t i3Prong = 0; i3Prong < n3Prong; i3Prong++) {
203 AliAODRecoDecayHF3Prong *d = (AliAODRecoDecayHF3Prong*)array3Prong->UncheckedAt(i3Prong);
206 Bool_t unsetvtx=kFALSE;
207 if(!d->GetOwnPrimaryVtx()){
208 d->SetOwnPrimaryVtx(vtx1);
211 if(d->SelectDplus(fVHF->GetDplusCuts())) {
213 Double_t ptCand = d->Pt();
220 else if(ptCand>2. && ptCand<3){
225 }else if(ptCand>3. && ptCand<5){
236 Bool_t passTightCuts=d->SelectDplus(cutsDplus);
237 Int_t labDp = d->MatchToMC(411,arrayMC,3,pdgDgDplustoKpipi);
238 Double_t invMass=d->InvMassDplus();
240 TString hisNameA(Form("hMassPt%d",iPtBin));
241 TString hisNameS(Form("hSigPt%d",iPtBin));
242 TString hisNameB(Form("hBkgPt%d",iPtBin));
243 TString hisNameATC(Form("hMassPt%dTC",iPtBin));
244 TString hisNameSTC(Form("hSigPt%dTC",iPtBin));
245 TString hisNameBTC(Form("hBkgPt%dTC",iPtBin));
247 ((TH1F*)(fOutput->FindObject(hisNameA)))->Fill(invMass);
249 ((TH1F*)(fOutput->FindObject(hisNameATC)))->Fill(invMass);
254 ((TH1F*)(fOutput->FindObject(hisNameS)))->Fill(invMass);
256 ((TH1F*)(fOutput->FindObject(hisNameSTC)))->Fill(invMass);
259 AliAODMCParticle *partDp = (AliAODMCParticle*)arrayMC->At(labDp);
260 AliAODMCParticle *dg0 = (AliAODMCParticle*)arrayMC->At(partDp->GetDaughter(0));
262 tmp[0]=TMath::Abs(partDp->GetPdgCode());
263 tmp[1]=partDp->Px()-d->Px();
264 tmp[2]=partDp->Py()-d->Py();
265 tmp[3]=partDp->Pz()-d->Pz();
266 tmp[4]=d->PtProng(0);
267 tmp[5]=d->PtProng(1);
268 tmp[6]=d->PtProng(2);
271 tmp[9]=d->CosPointingAngle();
272 tmp[10]=d->DecayLength();
277 tmp[15]=d->InvMassDplus();
278 tmp[16]=d->GetSigmaVert();
279 tmp[17]=d->Getd0Prong(0);
280 tmp[18]=d->Getd0Prong(1);
281 tmp[19]=d->Getd0Prong(2);
282 fNtupleDplus->Fill(tmp);
283 PostData(2,fNtupleDplus);
286 ((TH1F*)(fOutput->FindObject(hisNameB)))->Fill(invMass);
288 ((TH1F*)(fOutput->FindObject(hisNameBTC)))->Fill(invMass);
292 tmpbkg[0]=d->PtProng(0);
293 tmpbkg[1]=d->PtProng(1);
294 tmpbkg[2]=d->PtProng(2);
296 tmpbkg[4]=d->CosPointingAngle();
297 tmpbkg[5]=d->DecayLength();
301 tmpbkg[9]=d->InvMassDplus();
302 tmpbkg[10]=d->GetSigmaVert();
303 tmpbkg[11]=d->Getd0Prong(0);
304 tmpbkg[12]=d->Getd0Prong(1);
305 tmpbkg[13]=d->Getd0Prong(2);
306 fNtupleDplusbackg->Fill(tmpbkg);
307 PostData(3,fNtupleDplusbackg);
312 if(unsetvtx) d->UnsetOwnPrimaryVtx();
318 //________________________________________________________________________
319 void AliAnalysisTaskSEDplus::Terminate(Option_t */*option*/)
321 // Terminate analysis
323 if(fDebug > 1) printf("AnalysisTaskSEDplus: Terminate() \n");
325 fOutput = dynamic_cast<TList*> (GetOutputData(1));
327 printf("ERROR: fOutput not available\n");
332 fNtupleDplus = dynamic_cast<TNtuple*>(GetOutputData(2));
333 fNtupleDplusbackg = dynamic_cast<TNtuple*>(GetOutputData(3));