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 // In case there is an AOD handler writing a standard AOD, use the AOD
170 // event in memory rather than the input (ESD) event.
171 if (!aod && AODEvent() && IsStandardAOD()) aod = dynamic_cast<AliAODEvent*> (AODEvent());
173 // load Dplus->Kpipi candidates
174 TClonesArray *array3Prong =
175 (TClonesArray*)aod->GetList()->FindObject("Charm3Prong");
177 printf("AliAnalysisTaskSEDplus::UserExec: Charm3Prong branch not found!\n");
181 // AOD primary vertex
182 AliAODVertex *vtx1 = (AliAODVertex*)aod->GetPrimaryVertex();
186 TClonesArray *arrayMC =
187 (TClonesArray*)aod->GetList()->FindObject(AliAODMCParticle::StdBranchName());
189 printf("AliAnalysisTaskSEDplus::UserExec: MC particles branch not found!\n");
194 AliAODMCHeader *mcHeader =
195 (AliAODMCHeader*)aod->GetList()->FindObject(AliAODMCHeader::StdBranchName());
197 printf("AliAnalysisTaskSEDplus::UserExec: MC header branch not found!\n");
200 Int_t n3Prong = array3Prong->GetEntriesFast();
201 if(fDebug>1) printf("Number of D+->Kpipi: %d\n",n3Prong);
204 Int_t pdgDgDplustoKpipi[3]={321,211,211};
205 Double_t cutsDplus[12]={0.2,0.4,0.4,0.,0.,0.01,0.06,0.02,0.,0.85,0.,10000000000.};
206 for (Int_t i3Prong = 0; i3Prong < n3Prong; i3Prong++) {
207 AliAODRecoDecayHF3Prong *d = (AliAODRecoDecayHF3Prong*)array3Prong->UncheckedAt(i3Prong);
210 Bool_t unsetvtx=kFALSE;
211 if(!d->GetOwnPrimaryVtx()){
212 d->SetOwnPrimaryVtx(vtx1);
215 if(d->SelectDplus(fVHF->GetDplusCuts())) {
217 Double_t ptCand = d->Pt();
224 else if(ptCand>2. && ptCand<3){
229 }else if(ptCand>3. && ptCand<5){
240 Bool_t passTightCuts=d->SelectDplus(cutsDplus);
241 Int_t labDp = d->MatchToMC(411,arrayMC,3,pdgDgDplustoKpipi);
242 Double_t invMass=d->InvMassDplus();
244 TString hisNameA(Form("hMassPt%d",iPtBin));
245 TString hisNameS(Form("hSigPt%d",iPtBin));
246 TString hisNameB(Form("hBkgPt%d",iPtBin));
247 TString hisNameATC(Form("hMassPt%dTC",iPtBin));
248 TString hisNameSTC(Form("hSigPt%dTC",iPtBin));
249 TString hisNameBTC(Form("hBkgPt%dTC",iPtBin));
251 ((TH1F*)(fOutput->FindObject(hisNameA)))->Fill(invMass);
253 ((TH1F*)(fOutput->FindObject(hisNameATC)))->Fill(invMass);
258 ((TH1F*)(fOutput->FindObject(hisNameS)))->Fill(invMass);
260 ((TH1F*)(fOutput->FindObject(hisNameSTC)))->Fill(invMass);
263 AliAODMCParticle *partDp = (AliAODMCParticle*)arrayMC->At(labDp);
264 AliAODMCParticle *dg0 = (AliAODMCParticle*)arrayMC->At(partDp->GetDaughter(0));
266 tmp[0]=TMath::Abs(partDp->GetPdgCode());
267 tmp[1]=partDp->Px()-d->Px();
268 tmp[2]=partDp->Py()-d->Py();
269 tmp[3]=partDp->Pz()-d->Pz();
270 tmp[4]=d->PtProng(0);
271 tmp[5]=d->PtProng(1);
272 tmp[6]=d->PtProng(2);
275 tmp[9]=d->CosPointingAngle();
276 tmp[10]=d->DecayLength();
281 tmp[15]=d->InvMassDplus();
282 tmp[16]=d->GetSigmaVert();
283 tmp[17]=d->Getd0Prong(0);
284 tmp[18]=d->Getd0Prong(1);
285 tmp[19]=d->Getd0Prong(2);
286 fNtupleDplus->Fill(tmp);
287 PostData(2,fNtupleDplus);
290 ((TH1F*)(fOutput->FindObject(hisNameB)))->Fill(invMass);
292 ((TH1F*)(fOutput->FindObject(hisNameBTC)))->Fill(invMass);
296 tmpbkg[0]=d->PtProng(0);
297 tmpbkg[1]=d->PtProng(1);
298 tmpbkg[2]=d->PtProng(2);
300 tmpbkg[4]=d->CosPointingAngle();
301 tmpbkg[5]=d->DecayLength();
305 tmpbkg[9]=d->InvMassDplus();
306 tmpbkg[10]=d->GetSigmaVert();
307 tmpbkg[11]=d->Getd0Prong(0);
308 tmpbkg[12]=d->Getd0Prong(1);
309 tmpbkg[13]=d->Getd0Prong(2);
310 fNtupleDplusbackg->Fill(tmpbkg);
311 PostData(3,fNtupleDplusbackg);
316 if(unsetvtx) d->UnsetOwnPrimaryVtx();
322 //________________________________________________________________________
323 void AliAnalysisTaskSEDplus::Terminate(Option_t */*option*/)
325 // Terminate analysis
327 if(fDebug > 1) printf("AnalysisTaskSEDplus: Terminate() \n");
329 fOutput = dynamic_cast<TList*> (GetOutputData(1));
331 printf("ERROR: fOutput not available\n");
336 fNtupleDplus = dynamic_cast<TNtuple*>(GetOutputData(2));
337 fNtupleDplusbackg = dynamic_cast<TNtuple*>(GetOutputData(3));