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>
29 #include "AliAnalysisManager.h"
30 #include "AliAODHandler.h"
31 #include "AliAODEvent.h"
32 #include "AliAODVertex.h"
33 #include "AliAODTrack.h"
34 #include "AliAODMCHeader.h"
35 #include "AliAODMCParticle.h"
36 #include "AliAODRecoDecayHF3Prong.h"
37 #include "AliAnalysisVertexingHF.h"
38 #include "AliAnalysisTaskSE.h"
39 #include "AliAnalysisTaskSEDplus.h"
41 ClassImp(AliAnalysisTaskSEDplus)
44 //________________________________________________________________________
45 AliAnalysisTaskSEDplus::AliAnalysisTaskSEDplus():
53 // Default constructor
56 //________________________________________________________________________
57 AliAnalysisTaskSEDplus::AliAnalysisTaskSEDplus(const char *name,Bool_t fillNtuple):
58 AliAnalysisTaskSE(name),
62 fFillNtuple(fillNtuple),
65 // Default constructor
67 // Output slot #1 writes into a TList container
68 DefineOutput(1,TList::Class()); //My private output
71 // Output slot #2 writes into a TNtuple container
72 DefineOutput(2,TNtuple::Class()); //My private output
73 // Output slot #3 writes into a TNtuple container
74 DefineOutput(3,TNtuple::Class()); //My private output
78 //________________________________________________________________________
79 AliAnalysisTaskSEDplus::~AliAnalysisTaskSEDplus()
92 //________________________________________________________________________
93 void AliAnalysisTaskSEDplus::Init()
97 if(fDebug > 1) printf("AnalysisTaskSEDplus::Init() \n");
99 gROOT->LoadMacro("ConfigVertexingHF.C");
101 fVHF = (AliAnalysisVertexingHF*)gROOT->ProcessLine("ConfigVertexingHF()");
107 //________________________________________________________________________
108 void AliAnalysisTaskSEDplus::UserCreateOutputObjects()
110 // Create the output container
112 if(fDebug > 1) printf("AnalysisTaskSEDplus::UserCreateOutputObjects() \n");
114 // Several histograms are more conveniently managed in a TList
115 fOutput = new TList();
117 fOutput->SetName("OutputHistos");
121 for(Int_t i=0;i<nPtBins;i++){
122 hisname.Form("hMassPt%d",i);
123 TH1F* hm=new TH1F(hisname.Data(),hisname.Data(),100,1.765,1.965);
125 hisname.Form("hSigPt%d",i);
126 TH1F* hs=new TH1F(hisname.Data(),hisname.Data(),100,1.765,1.965);
128 hisname.Form("hBkgPt%d",i);
129 TH1F* hb=new TH1F(hisname.Data(),hisname.Data(),100,1.765,1.965);
132 hisname.Form("hMassPt%dTC",i);
133 TH1F* hmtc=new TH1F(hisname.Data(),hisname.Data(),100,1.765,1.965);
135 hisname.Form("hSigPt%dTC",i);
136 TH1F* hstc=new TH1F(hisname.Data(),hisname.Data(),100,1.765,1.965);
138 hisname.Form("hBkgPt%dTC",i);
139 TH1F* hbtc=new TH1F(hisname.Data(),hisname.Data(),100,1.765,1.965);
153 OpenFile(2); // 2 is the slot number of the ntuple
154 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");
155 OpenFile(3); // 3 is the slot number of the ntuple
156 fNtupleDplusbackg = new TNtuple("fNtupleDplusbackg","D + backg","Ptpibkg:Ptkbkg:Ptpi2bkg:PtRecbkg:PointingAnglebkg:DLbkg:VxRecbkg:VyRecbkg:VzRecbkg:InvMassbkg:sigvertbkg:d0Pibkg:d0Kbkg:d0Pi2bkg");
162 //________________________________________________________________________
163 void AliAnalysisTaskSEDplus::UserExec(Option_t */*option*/)
165 // Execute analysis for current event:
166 // heavy flavor candidates association to MC truth
170 AliAODEvent *aod = dynamic_cast<AliAODEvent*> (InputEvent());
172 TClonesArray *array3Prong = 0;
174 if(!aod && AODEvent() && IsStandardAOD()) {
175 // In case there is an AOD handler writing a standard AOD, use the AOD
176 // event in memory rather than the input (ESD) event.
177 aod = dynamic_cast<AliAODEvent*> (AODEvent());
178 // in this case the braches in the deltaAOD (AliAOD.VertexingHF.root)
179 // have to taken from the AOD event hold by the AliAODExtension
180 AliAODHandler* aodHandler = (AliAODHandler*)
181 ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
182 if(aodHandler->GetExtensions()) {
183 AliAODExtension *ext = (AliAODExtension*)aodHandler->GetExtensions()->FindObject("AliAOD.VertexingHF.root");
184 AliAODEvent *aodFromExt = ext->GetAOD();
185 array3Prong=(TClonesArray*)aodFromExt->GetList()->FindObject("Charm3Prong");
188 array3Prong=(TClonesArray*)aod->GetList()->FindObject("Charm3Prong");
192 printf("AliAnalysisTaskSEDplus::UserExec: Charm3Prong branch not found!\n");
196 // AOD primary vertex
197 AliAODVertex *vtx1 = (AliAODVertex*)aod->GetPrimaryVertex();
201 TClonesArray *arrayMC =
202 (TClonesArray*)aod->GetList()->FindObject(AliAODMCParticle::StdBranchName());
204 printf("AliAnalysisTaskSEDplus::UserExec: MC particles branch not found!\n");
209 AliAODMCHeader *mcHeader =
210 (AliAODMCHeader*)aod->GetList()->FindObject(AliAODMCHeader::StdBranchName());
212 printf("AliAnalysisTaskSEDplus::UserExec: MC header branch not found!\n");
215 Int_t n3Prong = array3Prong->GetEntriesFast();
216 if(fDebug>1) printf("Number of D+->Kpipi: %d\n",n3Prong);
219 Int_t pdgDgDplustoKpipi[3]={321,211,211};
220 Double_t cutsDplus[12]={0.2,0.4,0.4,0.,0.,0.01,0.06,0.02,0.,0.85,0.,10000000000.};
221 for (Int_t i3Prong = 0; i3Prong < n3Prong; i3Prong++) {
222 AliAODRecoDecayHF3Prong *d = (AliAODRecoDecayHF3Prong*)array3Prong->UncheckedAt(i3Prong);
225 Bool_t unsetvtx=kFALSE;
226 if(!d->GetOwnPrimaryVtx()){
227 d->SetOwnPrimaryVtx(vtx1);
230 if(d->SelectDplus(fVHF->GetDplusCuts())) {
232 Double_t ptCand = d->Pt();
239 else if(ptCand>2. && ptCand<3){
244 }else if(ptCand>3. && ptCand<5){
255 Bool_t passTightCuts=d->SelectDplus(cutsDplus);
256 Int_t labDp = d->MatchToMC(411,arrayMC,3,pdgDgDplustoKpipi);
257 Double_t invMass=d->InvMassDplus();
259 TString hisNameA(Form("hMassPt%d",iPtBin));
260 TString hisNameS(Form("hSigPt%d",iPtBin));
261 TString hisNameB(Form("hBkgPt%d",iPtBin));
262 TString hisNameATC(Form("hMassPt%dTC",iPtBin));
263 TString hisNameSTC(Form("hSigPt%dTC",iPtBin));
264 TString hisNameBTC(Form("hBkgPt%dTC",iPtBin));
266 ((TH1F*)(fOutput->FindObject(hisNameA)))->Fill(invMass);
268 ((TH1F*)(fOutput->FindObject(hisNameATC)))->Fill(invMass);
273 ((TH1F*)(fOutput->FindObject(hisNameS)))->Fill(invMass);
275 ((TH1F*)(fOutput->FindObject(hisNameSTC)))->Fill(invMass);
278 AliAODMCParticle *partDp = (AliAODMCParticle*)arrayMC->At(labDp);
279 AliAODMCParticle *dg0 = (AliAODMCParticle*)arrayMC->At(partDp->GetDaughter(0));
281 tmp[0]=TMath::Abs(partDp->GetPdgCode());
282 tmp[1]=partDp->Px()-d->Px();
283 tmp[2]=partDp->Py()-d->Py();
284 tmp[3]=partDp->Pz()-d->Pz();
285 tmp[4]=d->PtProng(0);
286 tmp[5]=d->PtProng(1);
287 tmp[6]=d->PtProng(2);
290 tmp[9]=d->CosPointingAngle();
291 tmp[10]=d->DecayLength();
296 tmp[15]=d->InvMassDplus();
297 tmp[16]=d->GetSigmaVert();
298 tmp[17]=d->Getd0Prong(0);
299 tmp[18]=d->Getd0Prong(1);
300 tmp[19]=d->Getd0Prong(2);
301 fNtupleDplus->Fill(tmp);
302 PostData(2,fNtupleDplus);
305 ((TH1F*)(fOutput->FindObject(hisNameB)))->Fill(invMass);
307 ((TH1F*)(fOutput->FindObject(hisNameBTC)))->Fill(invMass);
311 tmpbkg[0]=d->PtProng(0);
312 tmpbkg[1]=d->PtProng(1);
313 tmpbkg[2]=d->PtProng(2);
315 tmpbkg[4]=d->CosPointingAngle();
316 tmpbkg[5]=d->DecayLength();
320 tmpbkg[9]=d->InvMassDplus();
321 tmpbkg[10]=d->GetSigmaVert();
322 tmpbkg[11]=d->Getd0Prong(0);
323 tmpbkg[12]=d->Getd0Prong(1);
324 tmpbkg[13]=d->Getd0Prong(2);
325 fNtupleDplusbackg->Fill(tmpbkg);
326 PostData(3,fNtupleDplusbackg);
331 if(unsetvtx) d->UnsetOwnPrimaryVtx();
337 //________________________________________________________________________
338 void AliAnalysisTaskSEDplus::Terminate(Option_t */*option*/)
340 // Terminate analysis
342 if(fDebug > 1) printf("AnalysisTaskSEDplus: Terminate() \n");
344 fOutput = dynamic_cast<TList*> (GetOutputData(1));
346 printf("ERROR: fOutput not available\n");
351 fNtupleDplus = dynamic_cast<TNtuple*>(GetOutputData(2));
352 fNtupleDplusbackg = dynamic_cast<TNtuple*>(GetOutputData(3));